diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-10-22 12:48:46 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-22 13:11:35 +0100 |
commit | deb9dd0648abe81cb8c9b0696c71ebd823c0a549 (patch) | |
tree | c10044fe81f24e9f542d5d79aa453994fc3a6993 /sw | |
parent | e8204fe4cb382176bd9a803f4e7a21e5f69ce2db (diff) |
remove original and unused word for windows 1 filter
move fltshell.cxx into basflt and fire up the chainsaw for the rest
This filter has never, as far as I know, had a route to actually execute it
since day 0 of OpenOffice.org.
Change-Id: I35a92e2dee60bdc5d2d4e7181074bc4a3635b54c
Diffstat (limited to 'sw')
-rw-r--r-- | sw/Library_sw.mk | 6 | ||||
-rw-r--r-- | sw/inc/iodetect.hxx | 2 | ||||
-rw-r--r-- | sw/source/filter/basflt/fltini.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/basflt/fltshell.cxx (renamed from sw/source/filter/ww1/fltshell.cxx) | 0 | ||||
-rw-r--r-- | sw/source/filter/basflt/iodetect.cxx | 1 | ||||
-rw-r--r-- | sw/source/filter/inc/fltini.hxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww1/w1class.cxx | 1214 | ||||
-rw-r--r-- | sw/source/filter/ww1/w1class.hxx | 1491 | ||||
-rw-r--r-- | sw/source/filter/ww1/w1filter.cxx | 1988 | ||||
-rw-r--r-- | sw/source/filter/ww1/w1par.cxx | 105 | ||||
-rw-r--r-- | sw/source/filter/ww1/w1par.hxx | 34 | ||||
-rw-r--r-- | sw/source/filter/ww1/w1sprm.cxx | 632 | ||||
-rw-r--r-- | sw/source/filter/ww1/w1struct.hxx | 837 | ||||
-rw-r--r-- | sw/source/uibase/app/docsh.cxx | 3 |
14 files changed, 2 insertions, 6318 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index acf947acc6ed..4bdae0b4b872 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -497,6 +497,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/filter/ascii/wrtasc \ sw/source/filter/basflt/docfact \ sw/source/filter/basflt/fltini \ + sw/source/filter/basflt/fltshell \ sw/source/filter/basflt/iodetect \ sw/source/filter/basflt/shellio \ sw/source/filter/html/SwAppletImpl \ @@ -531,11 +532,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/filter/writer/writer \ sw/source/filter/writer/wrt_fn \ sw/source/filter/writer/wrtswtbl \ - sw/source/filter/ww1/fltshell \ - sw/source/filter/ww1/w1class \ - sw/source/filter/ww1/w1filter \ - sw/source/filter/ww1/w1par \ - sw/source/filter/ww1/w1sprm \ sw/source/filter/xml/XMLRedlineImportHelper \ sw/source/filter/xml/swxml \ sw/source/filter/xml/wrtxml \ diff --git a/sw/inc/iodetect.hxx b/sw/inc/iodetect.hxx index 119713902973..ea1faf96d3d0 100644 --- a/sw/inc/iodetect.hxx +++ b/sw/inc/iodetect.hxx @@ -37,7 +37,6 @@ #define FILTER_XMLV "CXMLV" ///< XML filter #define FILTER_XMLVW "CXMLVWEB" ///< XML filter #define sHTML "HTML" -#define sWW1 "WW1" #define sWW5 "WW6" #define sWW6 "CWW6" @@ -66,7 +65,6 @@ enum ReaderWriterEnum { READER_WRITER_WW8, READER_WRITER_RTF_WH, READER_WRITER_HTML, - READER_WRITER_WW1, READER_WRITER_WW5, READER_WRITER_XML, READER_WRITER_TEXT_DLG, diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx index 3433bdad2875..fca755582b37 100644 --- a/sw/source/filter/basflt/fltini.cxx +++ b/sw/source/filter/basflt/fltini.cxx @@ -77,7 +77,6 @@ SwReaderWriterEntry aReaderWriter[] = SwReaderWriterEntry( &::GetWW8Reader, &::GetWW8Writer, true ), SwReaderWriterEntry( &::GetRTFReader, &::GetRTFWriter, true ), SwReaderWriterEntry( 0, &::GetHTMLWriter, true ), - SwReaderWriterEntry( 0, 0, true ), SwReaderWriterEntry( &::GetWW8Reader, 0, true ), SwReaderWriterEntry( 0, &::GetXMLWriter, true ), SwReaderWriterEntry( 0, &::GetASCWriter, false ), @@ -130,7 +129,6 @@ Filters::Filters() { _SetFltPtr( READER_WRITER_BAS, (ReadAscii = new AsciiReader) ); _SetFltPtr( READER_WRITER_HTML, (ReadHTML = new HTMLReader) ); - _SetFltPtr( READER_WRITER_WW1, new WW1Reader ); _SetFltPtr( READER_WRITER_XML, (ReadXML = new XMLReader) ); _SetFltPtr( READER_WRITER_TEXT_DLG, ReadAscii ); _SetFltPtr( READER_WRITER_TEXT, ReadAscii ); diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx index 6e97e7c19911..6e97e7c19911 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/basflt/fltshell.cxx diff --git a/sw/source/filter/basflt/iodetect.cxx b/sw/source/filter/basflt/iodetect.cxx index bd3876f81466..9fdfe131a295 100644 --- a/sw/source/filter/basflt/iodetect.cxx +++ b/sw/source/filter/basflt/iodetect.cxx @@ -41,7 +41,6 @@ SwIoDetect aFilterDetect[] = SwIoDetect( FILTER_WW8 ), SwIoDetect( sRtfWH ), SwIoDetect( sHTML ), - SwIoDetect( sWW1 ), SwIoDetect( sWW5 ), SwIoDetect( FILTER_XML ), SwIoDetect( FILTER_TEXT_DLG ), diff --git a/sw/source/filter/inc/fltini.hxx b/sw/source/filter/inc/fltini.hxx index bc9b3cba693e..480794b891bd 100644 --- a/sw/source/filter/inc/fltini.hxx +++ b/sw/source/filter/inc/fltini.hxx @@ -39,11 +39,6 @@ public: HTMLReader(); }; -class WW1Reader : public Reader -{ - virtual sal_uLong Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const OUString &) SAL_OVERRIDE; -}; - class XMLReader : public Reader { virtual sal_uLong Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const OUString &) SAL_OVERRIDE; diff --git a/sw/source/filter/ww1/w1class.cxx b/sw/source/filter/ww1/w1class.cxx deleted file mode 100644 index 67629b4f31c7..000000000000 --- a/sw/source/filter/ww1/w1class.cxx +++ /dev/null @@ -1,1214 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <string.h> -#include <rtl/strbuf.hxx> -#include <rtl/ustring.hxx> -#include <tools/stream.hxx> -#include <w1class.hxx> - -#ifdef DUMP -static const sal_Char* pUnknown = "?"; -#define DUMPNAME(s) s -#else -#define DUMPNAME(s) 0 -#endif - -Ww1SingleSprm* Ww1Sprm::aTab[ 256 ]; -Ww1SingleSprm* Ww1Sprm::pSingleSprm = 0; - -// Fib -Ww1Fib::Ww1Fib( SvStream& _rStream ) - : rStream(_rStream) -{ - bOK = 0 == rStream.Seek(0) && - rStream.Read( &aFib, sizeof( aFib )) == sizeof( aFib ); -} - -// PlainText -Ww1PlainText::Ww1PlainText(Ww1Fib& rWwFib, sal_uLong nFilePos, sal_uLong nCountBytes) - : rFib(rWwFib), ulFilePos(nFilePos), ulCountBytes(nCountBytes), - ulSeek(0), bOK(true) -{ -} - -sal_Unicode Ww1PlainText::operator [] ( sal_uLong ulOffset ) -{ - OSL_ENSURE( ulOffset<Count(), "Ww1PlainText" ); - sal_Unicode cRet; - sal_Char cRead; - if( rFib.GetStream().Seek( ulFilePos + ulOffset ) == ulFilePos+ulOffset && - rFib.GetStream().Read( &cRead, sizeof( cRead ) ) == sizeof( cRead ) ) - { - cRet = OUString(&cRead, 1, RTL_TEXTENCODING_MS_1252).toChar(); - } - else - cRet = ' '; - return cRet; -} - -OUString Ww1PlainText::GetText( sal_uLong ulOffset, sal_uLong nLen ) const -{ - OSL_ENSURE(ulOffset+nLen<Count(), "Ww1PlainText"); - - sal_Size nPos = ulFilePos+ulOffset; - - bool bSeekOk = rFib.GetStream().Seek(nPos) == nPos; - return bSeekOk ? - read_uInt8s_ToOUString(rFib.GetStream(), nLen, RTL_TEXTENCODING_MS_1252) : - OUString(); -} - -// Style -Ww1Style::Ww1Style() - : pPapx(0), pParent(0), stcBase(0), stcNext(0), bUsed(false) -{ -} - -Ww1Style::~Ww1Style() -{ - delete pPapx; -} - -void Ww1Style::SetDefaults(sal_uInt8 stc) -{ - if( 222 == stc ) - { - stcBase = 222; - stcNext = 222; - aChpx.hpsSet(20); - } -} - -sal_uInt16 Ww1Style::ReadName( sal_uInt8*&p, sal_uInt16& rnCountBytes, sal_uInt16 stc ) -{ - sal_uInt8 nCountBytes = *p; - p++; - rnCountBytes--; - if( !nCountBytes ) // default - { - static const sal_Char* const names[] = - { - "W1 Null", //222 - "W1 Annotation reference", //223 - "W1 Annotation text", //224 - "W1 Table of contents 8", //225 - "W1 Table of contents 7", //226 - "W1 Table of contents 6", //227 - "W1 Table of contents 5", //228 - "W1 Table of contents 4", //229 - "W1 Table of contents 3", //230 - "W1 Table of contents 2", //231 - "W1 Table of contents 1", //232 - "W1 Index 7", //233 - "W1 Index 6", //234 - "W1 Index 5", //235 - "W1 Index 4", //236 - "W1 Index 3", //237 - "W1 Index 2", //238 - "W1 Index 1", //239 - "W1 Line number", //240 - "W1 Index heading", //241 - "W1 Footer", //242 - "W1 Header", //243 - "W1 Footnote reference", //244 - "W1 Footnote text", //245 - "W1 Heading 9", //246 - "W1 Heading 8", //247 - "W1 Heading 7", //248 - "W1 Heading 6", //249 - "W1 Heading 5", //250 - "W1 Heading 4", //251 - "W1 Heading 3", //252 - "W1 Heading 2", //253 - "W1 Heading 1", //254 - "W1 Normal indent" //255 - };//256 - - const sal_Char* pStr; - size_t nSize(stc); - if (!nSize) - pStr = "W1 Normal"; - else if (nSize - 222 >= SAL_N_ELEMENTS(names)) - pStr = "?"; - else - pStr = names[nSize-222]; - SetName(OUString(pStr, strlen(pStr), RTL_TEXTENCODING_MS_1252)); - } - else if( 255 > nCountBytes ) // unused - { - SetName( OUString( (sal_Char*)p, nCountBytes, RTL_TEXTENCODING_MS_1252 )); - p += nCountBytes; - OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1Style"); - rnCountBytes = rnCountBytes - nCountBytes; - } - return 0; -} - -sal_uInt16 Ww1Style::ReadChpx( sal_uInt8*&p, sal_uInt16& rnCountBytes ) -{ - sal_uInt16 nCountBytes = *p; - p++; - rnCountBytes--; - if (nCountBytes != 255 // unused - && nCountBytes != 0) // default - { - if (nCountBytes > sizeof(aChpx)) - nCountBytes = sizeof(aChpx); - memcpy( &aChpx, p, nCountBytes ); - p += nCountBytes; - OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1Style"); - rnCountBytes = rnCountBytes - nCountBytes; - } - return 0; -} - -sal_uInt16 Ww1Style::ReadPapx(sal_uInt8*&p, sal_uInt16& rnCountBytes) -{ - sal_uInt16 nCountBytes = *p; - p++; - rnCountBytes--; - if (nCountBytes != 255) - { - pPapx = new Ww1SprmPapx(p, nCountBytes); - p += nCountBytes; - OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1Style"); - rnCountBytes = rnCountBytes - nCountBytes; - } - else - pPapx = new Ww1SprmPapx(p, 0); - return 0; -} - -sal_uInt16 Ww1Style::ReadEstcp(sal_uInt8*&p, sal_uInt16& rnCountBytes) -{ - stcNext = *p; - p++; - rnCountBytes--; - stcBase = *p; - p++; - OSL_ENSURE(rnCountBytes>0, "Ww1Style"); - rnCountBytes--; - return 0; -} - -// StyleSheet -Ww1StyleSheet::Ww1StyleSheet(Ww1Fib& _rFib) - : cstcStd(0), - rFib(_rFib), - bOK(false) -{ - sal_uInt16 cbStshf = rFib.GetFIB().cbStshfGet(); - OSL_ENSURE(cbStshf>=17, "Ww1StyleSheet"); - for (sal_uInt16 stc=0;stc<Count();stc++) - { - aStyles[stc].SetParent(this); - aStyles[stc].SetDefaults((sal_uInt8)stc); - } - sal_uInt8* del = NULL; - if (rFib.GetStream().Seek(rFib.GetFIB().fcStshfGet()) - == (sal_uLong)rFib.GetFIB().fcStshfGet() - && (del = new sal_uInt8[cbStshf]) != NULL - && rFib.GetStream().Read(del, cbStshf) == (sal_uLong)cbStshf) - { - sal_uInt8* p = del; - cstcStd = SVBT16ToShort(p); - p += sizeof(SVBT16); - cbStshf -= sizeof(SVBT16); - ReadNames(p, cbStshf); - ReadChpx(p, cbStshf); - ReadPapx(p, cbStshf); - ReadEstcp(p, cbStshf); - OSL_ENSURE(cbStshf==0, "Ww1StyleSheet"); - bOK = cbStshf == 0; - } - delete [] del; -} - -sal_uInt16 Ww1StyleSheet::ReadNames( sal_uInt8*& p, sal_uInt16& rnCountBytes ) -{ - sal_uInt16 nCountBytes = SVBT16ToShort(p); - p += sizeof(SVBT16); - OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1StyleSheet"); - rnCountBytes = rnCountBytes - nCountBytes; - nCountBytes = nCountBytes - sizeof(SVBT16); - sal_uInt16 stcp = 0; - while (nCountBytes > 0) - { - sal_uInt16 stc = (stcp - cstcStd) & 255; - aStyles[stc].ReadName(p, nCountBytes, stc); - stcp++; - } - OSL_ENSURE(nCountBytes==0, "Ww1StyleSheet"); - return 0; -} - -sal_uInt16 Ww1StyleSheet::ReadChpx(sal_uInt8*& p, sal_uInt16& rnCountBytes) -{ - sal_uInt16 nCountBytes = SVBT16ToShort(p); - p += sizeof(SVBT16); - OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1StyleSheet"); - rnCountBytes = rnCountBytes - nCountBytes; - nCountBytes = nCountBytes - sizeof(SVBT16); - sal_uInt16 stcp = 0; - while (nCountBytes > 0) - { - sal_uInt16 stc = (stcp - cstcStd) & 255; - aStyles[stc].ReadChpx(p, nCountBytes); - stcp++; - } - OSL_ENSURE(nCountBytes == 0, "Ww1StyleSheet"); - return 0; -} - -sal_uInt16 Ww1StyleSheet::ReadPapx(sal_uInt8*& p, sal_uInt16& rnCountBytes) -{ - sal_uInt16 nCountBytes = SVBT16ToShort(p); - p += sizeof(SVBT16); - OSL_ENSURE(rnCountBytes>=nCountBytes, "Ww1StyleSheet"); - rnCountBytes = rnCountBytes - nCountBytes; - nCountBytes = nCountBytes - sizeof(SVBT16); - sal_uInt16 stcp = 0; - while (nCountBytes > 0) - { - sal_uInt16 stc = (stcp - cstcStd) & 255; - aStyles[stc].ReadPapx(p, nCountBytes); - stcp++; - } - OSL_ENSURE(nCountBytes == 0, "Ww1StyleSheet"); - return 0; -} - -sal_uInt16 Ww1StyleSheet::ReadEstcp(sal_uInt8*& p, sal_uInt16& rnCountBytes) -{ - sal_uInt16 iMac = SVBT16ToShort(p); - p += sizeof(SVBT16); - OSL_ENSURE(rnCountBytes>=sizeof(SVBT16), "Ww1StyleSheet"); - rnCountBytes -= sizeof(SVBT16); - for (sal_uInt16 stcp=0;stcp<iMac;stcp++) - { - sal_uInt16 stc = (stcp - cstcStd) & 255; - aStyles[stc].ReadEstcp(p, rnCountBytes); - } - OSL_ENSURE(rnCountBytes==0, "Ww1StyleSheet"); - return 0; -} - -// Fonts -Ww1Fonts::Ww1Fonts(Ww1Fib& rInFib, sal_uLong nFieldFlgs) - : pFontA(0), rFib(rInFib), nFieldFlags(nFieldFlgs), nMax(0), bOK(false) -{ - if(rFib.GetFIB().cbSttbfffnGet() > 2 ) // any fonts at all? - { - SVBT16 nCountBytes; - OSL_ENSURE(rFib.GetFIB().cbSttbfffnGet() > sizeof(nCountBytes), "Ww1Fonts"); - if (rFib.GetStream().Seek(rFib.GetFIB().fcSttbfffnGet()) - == (sal_uLong)rFib.GetFIB().fcSttbfffnGet()) - if (rFib.GetStream().Read(nCountBytes, sizeof(nCountBytes)) - == sizeof(nCountBytes)) // length is repeated here - { - OSL_ENSURE(SVBT16ToShort(nCountBytes) - == rFib.GetFIB().cbSttbfffnGet(), "redundant-size missmatch"); - // hopefully they're always equal - W1_FFN* pA = (W1_FFN*)new char[rFib.GetFIB().cbSttbfffnGet() - - sizeof(nCountBytes)]; // allocate Font-Array - //~ Ww1: new-NULL - if (rFib.GetStream().Read(pA, rFib.GetFIB().cbSttbfffnGet() - - sizeof(nCountBytes)) == (sal_uLong)rFib.GetFIB().cbSttbfffnGet() - - sizeof(nCountBytes)) // read all Fonts - {} // nothing - - long nLeft = rFib.GetFIB().cbSttbfffnGet() - - sizeof(nCountBytes); // count how many contain fonts - W1_FFN* p = pA; - while (true) - { - sal_uInt16 nNextSiz; - nNextSiz = p->cbFfnM1Get() + 1; - if(nNextSiz > nLeft) - break; - nMax++; - nLeft -= nNextSiz; - if(nLeft < 1) // need to be able to read next length - break; - p = (W1_FFN *)(((char*)p) + nNextSiz); - } - if (nMax) - { - pFontA = new W1_FFN*[nMax]; // allocate Index-Array - //~ Ww1: new-NULL - pFontA[0] = pA; // fill Index-Array - sal_uInt16 i; - for(i=1, p=pA; i<nMax; i++) - { - p = (W1_FFN*)(((char*)p) + p->cbFfnM1Get() + 1); - pFontA[i] = p; - } - } - else - pFontA = 0; // no entries -> no Array - } - } - bOK = true; -} - -W1_FFN* Ww1Fonts::GetFFN(sal_uInt16 nNum) -{ - W1_FFN* pRet = NULL; - if (pFontA) - if (nNum < nMax) - pRet = pFontA[nNum]; - return pRet; -} - -// DOP -Ww1Dop::Ww1Dop(Ww1Fib& _rFib) - : rFib(_rFib) -{ - long nRead; - memset(&aDop, 0, sizeof(aDop)); // set defaults - if(rFib.GetFIB().cbDopGet() >= sizeof(aDop)) - nRead = sizeof(aDop); - else - nRead = rFib.GetFIB().cbDopGet(); - bOK = rFib.GetStream().Seek(rFib.GetFIB().fcDopGet()) == - (sal_uLong)rFib.GetFIB().fcDopGet() && - rFib.GetStream().Read(&aDop, nRead) == (sal_uLong)nRead; -} - -// Picture -Ww1Picture::Ww1Picture(SvStream& rStream, sal_uLong ulFilePos) - : bOK(false), pPic(0) -{ - ulFilePos &= 0xffffff; //~ ww1: for some reason the high byte contains 5?!?! - SVBT32 lcb; - if (rStream.Seek(ulFilePos) == (sal_uLong)ulFilePos) - if (rStream.Read(&lcb, sizeof(lcb)) == (sal_uLong)sizeof(lcb)) - if (sizeof(int)>=4 || SVBT32ToUInt32(lcb) < 0x8000) //~ mdt: 64K & 16bit - if ((pPic = (W1_PIC*)(new sal_uInt8[SVBT32ToUInt32(lcb)])) != NULL) - if (rStream.Seek(ulFilePos) == (sal_uLong)ulFilePos) - if (rStream.Read(pPic, SVBT32ToUInt32(lcb)) == (sal_uLong)SVBT32ToUInt32(lcb)) - { - OSL_ENSURE(pPic->cbHeaderGet()==sizeof(*pPic)-sizeof(pPic->rgb), "Ww1Picture"); - bOK = true; - } -} - -// Sprm -Ww1Sprm::Ww1Sprm(sal_uInt8* x, sal_uInt16 _nCountBytes) - : p(NULL), - nCountBytes(_nCountBytes), - bOK(false), - pArr(NULL), - count(0) -{ - if (nCountBytes == 0) - bOK = true; - else - if ((p = new sal_uInt8[nCountBytes]) != NULL) - { - memcpy(p, x, nCountBytes); - if (ReCalc()) - bOK = true; - } -} - -Ww1Sprm::Ww1Sprm(SvStream& rStream, sal_uLong ulFilePos) - : p(NULL), - nCountBytes(0), - bOK(false), - pArr(NULL), - count(0) -{ - sal_uInt8 x = 0; - if (rStream.Seek(ulFilePos) == (sal_uLong)ulFilePos) - if (rStream.Read(&x, sizeof(x)) == (sal_uLong)sizeof(x)) - if ((nCountBytes = x) == 255 - || !nCountBytes - || (p = new sal_uInt8[nCountBytes]) != NULL) - if (nCountBytes == 255 - || !nCountBytes - || rStream.Read(p, nCountBytes) == (sal_uLong)nCountBytes) - if (ReCalc()) - bOK = true; -} - -Ww1Sprm::~Ww1Sprm() -{ - delete[] pArr; - delete[] p; -} - -sal_uInt16 Ww1SingleSprm::Size(sal_uInt8* /*pSprm*/) -{ - return nCountBytes; -} - -Ww1SingleSprm::~Ww1SingleSprm() -{ -} - -sal_uInt16 Ww1SingleSprmTab::Size(sal_uInt8* pSprm) // Doc 24/25, Fastsave-Sprm -{ - OSL_ENSURE(nCountBytes==0, "Ww1SingleSprmTab"); - sal_uInt16 nRet = sizeof(sal_uInt8); - sal_uInt16 nSize = *pSprm; - if (nSize != 255) - nRet = nRet + nSize; - else - { - sal_uInt16 nDel = (*(pSprm + 1)) * 4; - sal_uInt16 nIns = (*(pSprm + 3 + nDel)) * 3; - nRet += nDel + nIns; - } - OSL_ENSURE(nRet <= 354, "Ww1SingleSprmTab"); - if (nRet > 354) - nRet = 0; - return nRet; -} - -sal_uInt16 Ww1SingleSprmByteSized::Size(sal_uInt8* pSprm) -{ - sal_uInt16 nRet = *pSprm + sizeof(sal_uInt8) + nCountBytes; - return nRet; -} - -sal_uInt16 Ww1SingleSprmWordSized::Size(sal_uInt8* pSprm) -{ - sal_uInt16 nRet; - nRet = SVBT16ToShort(pSprm); - nRet += sizeof(SVBT16); // var. l. word-size - nRet = nRet + nCountBytes; - return nRet; -} - -static sal_uInt8 nLast = 0; -static sal_uInt8 nCurrent = 0; -sal_uInt16 Ww1Sprm::GetSize(sal_uInt8 nId, sal_uInt8* pSprm) -{ - sal_uInt16 nL = 0; - nL = GetTab(nId).Size(pSprm); - nLast = nCurrent; - nCurrent = nId; - return nL; -} - -bool Ww1Sprm::Fill(sal_uInt16 index, sal_uInt8& nId, sal_uInt16& nL, sal_uInt8*& pSprm) -{ - OSL_ENSURE(index < Count(), "Ww1Sprm"); - pSprm = p + pArr[index]; - nId = *pSprm; - pSprm++; - nL = GetTab(nId).Size(pSprm); - return true; -} - -bool Ww1Sprm::ReCalc() -{ - bool bRet = true; - delete[] pArr; - pArr = NULL; - count = 0; - if (nCountBytes != 255) // not unused? - { - sal_uInt16 cbsik = nCountBytes; - sal_uInt8* psik = p; - while (cbsik > 0) - { - sal_uInt16 iLen = GetSizeBrutto(psik); - OSL_ENSURE(iLen<=cbsik, "Ww1Sprm"); - if (iLen > cbsik) - cbsik = 0; // ignore the rest: we are wrong... - else - { - psik += iLen; - cbsik = cbsik - iLen; - count++; - } - } - if (bRet - && (pArr = new sal_uInt16[count]) != NULL) - { - cbsik = nCountBytes; - sal_uInt16 offset = 0; - sal_uInt16 current = 0; - psik = p; - while (current<count) - { - pArr[current++] = offset; - sal_uInt16 iLen = GetSizeBrutto(psik); - psik += iLen; - if (iLen > cbsik) - cbsik = 0; - else - cbsik = cbsik - iLen; - offset = offset + iLen; - } - - } - else - count = 0; - } - return bRet; -} - -void Ww1Sprm::DeinitTab() -{ - for (size_t i=0; i < SAL_N_ELEMENTS(aTab); ++i) - delete aTab[i]; - memset(aTab, 0, SAL_N_ELEMENTS(aTab)); - delete pSingleSprm; -} - -void Ww1Sprm::InitTab() -{ - memset(aTab, 0, SAL_N_ELEMENTS(aTab)); - pSingleSprm = new Ww1SingleSprm( 0, DUMPNAME(pUnknown)); - - aTab[ 2] = new Ww1SingleSprmByte(DUMPNAME("sprmPStc")); // 2 pap.istd (style code) - aTab[ 3] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmPIstdPermute")); // 3 pap.istd permutation - aTab[ 4] = new Ww1SingleSprmByte(DUMPNAME("sprmPIncLevel")); // 4 pap.istddifference - aTab[ 5] = new Ww1SingleSprmPJc(DUMPNAME("sprmPJc")); // 5 pap.jc (justification) - aTab[ 6] = new Ww1SingleSprmBool(DUMPNAME("sprmPFSideBySide")); // 6 pap.fSideBySide - aTab[ 7] = new Ww1SingleSprmPFKeep(DUMPNAME("sprmPFKeep")); // 7 pap.fKeep - aTab[ 8] = new Ww1SingleSprmPFKeepFollow(DUMPNAME("sprmPFKeepFollow")); // 8 pap.fKeepFollow - aTab[ 9] = new Ww1SingleSprmPPageBreakBefore(DUMPNAME("sprmPPageBreakBefore")); // 9 pap.fPageBreakBefore - aTab[ 10] = new Ww1SingleSprmByte(DUMPNAME("sprmPBrcl")); // 10 pap.brcl - aTab[ 11] = new Ww1SingleSprmByte(DUMPNAME("sprmPBrcp")); // 11 pap.brcp - aTab[ 12] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmPAnld")); // 12 pap.anld (ANLD structure) - aTab[ 13] = new Ww1SingleSprmByte(DUMPNAME("sprmPNLvlAnm")); // 13 pap.nLvlAnm nn - aTab[ 14] = new Ww1SingleSprmBool(DUMPNAME("sprmPFNoLineNumb")); // 14 ap.fNoLnn - aTab[ 15] = new Ww1SingleSprmPChgTabsPapx(DUMPNAME("sprmPChgTabsPapx")); // 15 pap.itbdMac, ... - aTab[ 16] = new Ww1SingleSprmPDxaRight(DUMPNAME("sprmPDxaRight")); // 16 pap.dxaRight - aTab[ 17] = new Ww1SingleSprmPDxaLeft(DUMPNAME("sprmPDxaLeft")); // 17 pap.dxaLeft - aTab[ 18] = new Ww1SingleSprmWord(DUMPNAME("sprmPNest")); // 18 pap.dxaNest - aTab[ 19] = new Ww1SingleSprmPDxaLeft1(DUMPNAME("sprmPDxaLeft1")); // 19 pap.dxaLeft1 - aTab[ 20] = new Ww1SingleSprmPDyaLine(DUMPNAME("sprmPDyaLine")); // 20 pap.lspd an LSPD - aTab[ 21] = new Ww1SingleSprmPDyaBefore(DUMPNAME("sprmPDyaBefore")); // 21 pap.dyaBefore - aTab[ 22] = new Ww1SingleSprmPDyaAfter(DUMPNAME("sprmPDyaAfter")); // 22 pap.dyaAfter - aTab[ 23] = new Ww1SingleSprmTab(0, DUMPNAME(pUnknown)); // 23 pap.itbdMac, pap.rgdxaTab - aTab[ 24] = new Ww1SingleSprmPFInTable(DUMPNAME("sprmPFInTable")); // 24 pap.fInTable - aTab[ 25] = new Ww1SingleSprmPTtp(DUMPNAME("sprmPTtp")); // 25 pap.fTtp - aTab[ 26] = new Ww1SingleSprmPDxaAbs(DUMPNAME("sprmPDxaAbs")); // 26 pap.dxaAbs - aTab[ 27] = new Ww1SingleSprmPDyaAbs(DUMPNAME("sprmPDyaAbs")); // 27 pap.dyaAbs - aTab[ 28] = new Ww1SingleSprmPDxaWidth(DUMPNAME("sprmPDxaWidth")); // 28 pap.dxaWidth - aTab[ 29] = new Ww1SingleSprmPpc(DUMPNAME("sprmPPc")); // 29 pap.pcHorz, pap.pcVert - aTab[ 30] = new Ww1SingleSprmPBrc10(BRC_TOP, DUMPNAME("sprmPBrcTop10")); // 30 pap.brcTop BRC10 - aTab[ 31] = new Ww1SingleSprmPBrc10(BRC_LEFT, DUMPNAME("sprmPBrcLeft10")); // 31 pap.brcLeft BRC10 - aTab[ 32] = new Ww1SingleSprmPBrc10(BRC_BOTTOM, DUMPNAME("sprmPBrcBottom10")); // 32 pap.brcBottom BRC10 - aTab[ 33] = new Ww1SingleSprmPBrc10(BRC_RIGHT, DUMPNAME("sprmPBrcRight10")); // 33 pap.brcRight BRC10 - aTab[ 34] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBetween10")); // 34 pap.brcBetween BRC10 - aTab[ 35] = new Ww1SingleSprmPBrc10(BRC_LEFT, DUMPNAME("sprmPBrcBar10")); // 35 pap.brcBar BRC10 - aTab[ 36] = new Ww1SingleSprmPFromText(DUMPNAME("sprmPFromText10")); // 36 pap.dxaFromText dxa - aTab[ 37] = new Ww1SingleSprmByte(DUMPNAME("sprmPWr")); // 37 pap.wr wr - aTab[ 38] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcTop")); // 38 pap.brcTop BRC - aTab[ 39] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcLeft")); // 39 pap.brcLeft BRC - aTab[ 40] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBottom")); // 40 pap.brcBottom BRC - aTab[ 41] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcRight")); // 41 pap.brcRight BRC - aTab[ 42] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBetween")); // 42 pap.brcBetween BRC - aTab[ 43] = new Ww1SingleSprmWord(DUMPNAME("sprmPBrcBar")); // 43 pap.brcBar BRC word - aTab[ 44] = new Ww1SingleSprmBool(DUMPNAME("sprmPFNoAutoHyph")); // 44 pap.fNoAutoHyph - aTab[ 45] = new Ww1SingleSprmWord(DUMPNAME("sprmPWHeightAbs")); // 45 pap.wHeightAbs w - aTab[ 46] = new Ww1SingleSprmWord(DUMPNAME("sprmPDcs")); // 46 pap.dcs DCS - aTab[ 47] = new Ww1SingleSprmWord(DUMPNAME("sprmPShd")); // 47 pap.shd SHD - aTab[ 48] = new Ww1SingleSprmWord(DUMPNAME("sprmPDyaFromText")); // 48 pap.dyaFromText dya - aTab[ 49] = new Ww1SingleSprmWord(DUMPNAME("sprmPDxaFromText")); // 49 pap.dxaFromText dxa - aTab[ 50] = new Ww1SingleSprmBool(DUMPNAME("sprmPFLocked")); // 50 pap.fLocked 0 or 1 byte - aTab[ 51] = new Ww1SingleSprmBool(DUMPNAME("sprmPFWidowControl")); // 51 pap.fWidowControl 0 or 1 byte - - aTab[ 57] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmCDefault")); // 57 whole CHP (see below) none variable length - aTab[ 58] = new Ww1SingleSprm(0, DUMPNAME("sprmCPlain")); // 58 whole CHP (see below) none 0 - - aTab[ 60] = new Ww1SingleSprm4State(DUMPNAME("sprmCFBold")); // 60 chp.fBold 0,1, 128, or 129 (see below) byte - aTab[ 61] = new Ww1SingleSprm4State(DUMPNAME("sprmCFItalic")); // 61 chp.fItalic 0,1, 128, or 129 (see below) byte - aTab[ 62] = new Ww1SingleSprm4State(DUMPNAME("sprmCFStrike")); // 62 chp.fStrike 0,1, 128, or 129 (see below) byte - aTab[ 63] = new Ww1SingleSprm4State(DUMPNAME("sprmCFOutline")); // 63 chp.fOutline 0,1, 128, or 129 (see below) byte - aTab[ 64] = new Ww1SingleSprm4State(DUMPNAME("sprmCFShadow")); // 64 chp.fShadow 0,1, 128, or 129 (see below) byte - aTab[ 65] = new Ww1SingleSprm4State(DUMPNAME("sprmCFSmallCaps")); // 65 chp.fSmallCaps 0,1, 128, or 129 (see below) byte - aTab[ 66] = new Ww1SingleSprm4State(DUMPNAME("sprmCFCaps")); // 66 chp.fCaps 0,1, 128, or 129 (see below) byte - aTab[ 67] = new Ww1SingleSprm4State(DUMPNAME("sprmCFVanish")); // 67 chp.fVanish 0,1, 128, or 129 (see below) byte - aTab[ 68] = new Ww1SingleSprmWord(DUMPNAME("sprmCFtc")); // 68 chp.ftc ftc word - aTab[ 69] = new Ww1SingleSprmByte(DUMPNAME("sprmCKul")); // 69 chp.kul kul byte - aTab[ 70] = new Ww1SingleSprm(3, DUMPNAME("sprmCSizePos")); // 70 chp.hps, chp.hpsPos (see below) 3 bytes - aTab[ 71] = new Ww1SingleSprmWord(DUMPNAME("sprmCDxaSpace")); // 71 chp.dxaSpace dxa word - aTab[ 72] = new Ww1SingleSprmWord(DUMPNAME("//")); // 72 - aTab[ 73] = new Ww1SingleSprmByte(DUMPNAME("sprmCIco")); // 73 chp.ico ico byte - aTab[ 74] = new Ww1SingleSprmByte(DUMPNAME("sprmCHps")); // 74 chp.hps hps !byte! - aTab[ 75] = new Ww1SingleSprmByte(DUMPNAME("sprmCHpsInc")); // 75 chp.hps (see below) byte - aTab[ 76] = new Ww1SingleSprmWord(DUMPNAME("sprmCHpsPos")); // 76 chp.hpsPos hps !word! - aTab[ 77] = new Ww1SingleSprmByte(DUMPNAME("sprmCHpsPosAdj")); // 77 chp.hpsPos hps (see below) byte - aTab[ 78] = new Ww1SingleSprmByteSized(0, DUMPNAME(pUnknown)); // 78 ?chp.fBold, chp.fItalic, chp.fSmallCaps, ... - - aTab[ 94] = new Ww1SingleSprmByte(DUMPNAME("sprmPicBrcl")); // 94 pic.brcl brcl (see PIC structure definition) byte - aTab[ 95] = new Ww1SingleSprmByteSized(0, DUMPNAME("sprmPicScale")); // 95 pic.mx, pic.my, pic.dxaCropleft, - - aTab[117] = new Ww1SingleSprmByte(DUMPNAME("sprmSBkc")); // 117 sep.bkc bkc byte - aTab[118] = new Ww1SingleSprmBool(DUMPNAME("sprmSFTitlePage")); // 118 sep.fTitlePage 0 or 1 byte - aTab[119] = new Ww1SingleSprmSColumns(DUMPNAME("sprmSCcolumns")); // 119 sep.ccolM1 # of cols - 1 word - aTab[120] = new Ww1SingleSprmWord(DUMPNAME("sprmSDxaColumns")); // 120 sep.dxaColumns dxa word - - aTab[122] = new Ww1SingleSprmByte(DUMPNAME("sprmSNfcPgn")); // 122 sep.nfcPgn nfc byte - - aTab[125] = new Ww1SingleSprmBool(DUMPNAME("sprmSFPgnRestart")); // 125 sep.fPgnRestart 0 or 1 byte - aTab[126] = new Ww1SingleSprmBool(DUMPNAME("sprmSFEndnote")); // 126 sep.fEndnote 0 or 1 byte - aTab[127] = new Ww1SingleSprmByte(DUMPNAME("sprmSLnc")); // 127 sep.lnc lnc byte - aTab[128] = new Ww1SingleSprmSGprfIhdt(DUMPNAME("sprmSGprfIhdt")); // 128 sep.grpfIhdt grpfihdt (see Headers and Footers topic) byte - aTab[129] = new Ww1SingleSprmWord(DUMPNAME("sprmSNLnnMod")); // 129 sep.nLnnMod non-neg int. word - aTab[130] = new Ww1SingleSprmWord(DUMPNAME("sprmSDxaLnn")); // 130 sep.dxaLnn dxa word - aTab[131] = new Ww1SingleSprmWord(DUMPNAME("sprmSDyaHdrTop")); // 131 sep.dyaHdrTop dya word - aTab[132] = new Ww1SingleSprmWord(DUMPNAME("sprmSDyaHdrBottom")); // 132 sep.dyaHdrBottom dya word - aTab[133] = new Ww1SingleSprmBool(DUMPNAME("sprmSLBetween")); // 133 sep.fLBetween 0 or 1 byte - aTab[134] = new Ww1SingleSprmByte(DUMPNAME("sprmSVjc")); // 134 sep.vjc vjc byte - aTab[135] = new Ww1SingleSprmWord(DUMPNAME("sprmSLnnMin")); // 135 sep.lnnMin lnn word - aTab[136] = new Ww1SingleSprmWord(DUMPNAME("sprmSPgnStart")); // 136 sep.pgnStart pgn word - - aTab[146] = new Ww1SingleSprmWord(DUMPNAME("sprmTJc")); // 146 tap.jc jc word (low order byte is significant) - aTab[147] = new Ww1SingleSprmWord(DUMPNAME("sprmTDxaLeft")); // 147 tap.rgdxaCenter (see below) dxa word - aTab[148] = new Ww1SingleSprmWord(DUMPNAME("sprmTDxaGapHalf")); // 148 tap.dxaGapHalf, tap.rgdxaCenter (see below) dxa word - - aTab[152] = new Ww1SingleSprmTDefTable10(DUMPNAME("sprmTDefTable10")); // 152 tap.rgdxaCenter, tap.rgtc complex (see below) variable length - aTab[153] = new Ww1SingleSprmWord(DUMPNAME("sprmTDyaRowHeight")); // 153 tap.dyaRowHeight dya word - - aTab[158] = new Ww1SingleSprm(4, DUMPNAME("sprmTInsert")); // 158 tap.rgdxaCenter,tap.rgtc complex (see below) 4 bytes - aTab[159] = new Ww1SingleSprmWord(DUMPNAME("sprmTDelete")); // 159 tap.rgdxaCenter, tap.rgtc complex (see below) word - aTab[160] = new Ww1SingleSprm(4, DUMPNAME("sprmTDxaCol")); // 160 tap.rgdxaCenter complex (see below) 4 bytes - aTab[161] = new Ww1SingleSprmWord(DUMPNAME("sprmTMerge")); // 161 tap.fFirstMerged, tap.fMerged complex (see below) word - aTab[162] = new Ww1SingleSprmWord(DUMPNAME("sprmTSplit")); // 162 tap.fFirstMerged, tap.fMerged complex (see below) word - aTab[163] = new Ww1SingleSprm(5, DUMPNAME("sprmTSetBrc10")); // 163 tap.rgtc[].rgbrc complex (see below) 5 bytes -} - -// SprmPapx -Ww1SprmPapx::Ww1SprmPapx(sal_uInt8* pByte, sal_uInt16 nSize) : - Ww1Sprm(Sprm(pByte, nSize), SprmSize(pByte, nSize)) -{ - memset(&aPapx, 0, sizeof(aPapx)); - memcpy(&aPapx, pByte, nSize<sizeof(aPapx)?nSize:sizeof(aPapx)); -} - -sal_uInt16 Ww1SprmPapx::SprmSize(sal_uInt8*, sal_uInt16 nSize) -{ - sal_uInt16 nRet = 0; - if (nSize >= sizeof(W1_PAPX)) - nRet = nSize - ( sizeof(W1_PAPX) - 1 ); // the 1st SprmByte is contained - // in the W1_PAPX - return nRet; -} - -sal_uInt8* Ww1SprmPapx::Sprm(sal_uInt8* pByte, sal_uInt16 nSize) -{ - sal_uInt8* pRet = NULL; - if (nSize >= sizeof(W1_PAPX)) - pRet = ((W1_PAPX*)(pByte))->grpprlGet(); - return pRet; -} - -// Plc -Ww1Plc::Ww1Plc(Ww1Fib& rInFib, sal_uLong ulFilePos, sal_uInt16 nInCountBytes, - sal_uInt16 nInItemSize) - : p(0), nCountBytes(nInCountBytes), iMac(0), nItemSize(nInItemSize), - bOK(false), rFib(rInFib) -{ - if (!nCountBytes) - bOK = true; - else - { - if (rFib.GetStream().Seek(ulFilePos) == (sal_uLong)ulFilePos) - { - if ((p = new sal_uInt8[nCountBytes]) != NULL) - { - if (rFib.GetStream().Read(p, nCountBytes) == (sal_uLong)nCountBytes) - { - bOK = true; - iMac = (nCountBytes - - sizeof(SVBT32)) / (sizeof(SVBT32) + nItemSize); - OSL_ENSURE(iMac * ((sal_uInt16)sizeof(sal_uLong) + nItemSize) + - (sal_uInt16)sizeof(SVBT32) == nCountBytes, "Ww1Plc"); - } - } - } - } -} - -Ww1Plc::~Ww1Plc() -{ - delete p; -} - -void Ww1Plc::Seek(sal_uLong ulSeek, sal_uInt16& nIndex) -{ - if (iMac) - for (;nIndex <= iMac && Where(nIndex) < ulSeek;nIndex++) - ; -} - -sal_uLong Ww1Plc::Where(sal_uInt16 nIndex) -{ - sal_uLong ulRet = 0xffffffff; - OSL_ENSURE(nIndex <= iMac, "index out of bounds"); - if (iMac && nIndex <= iMac) - ulRet = SVBT32ToUInt32(p + sizeof(SVBT32) * nIndex); - return ulRet; -} - -sal_uInt8* Ww1Plc::GetData(sal_uInt16 nIndex) -{ - sal_uInt8* pRet = NULL; - OSL_ENSURE(nIndex < iMac, "index out of bounds"); - if (nIndex < iMac) - pRet = p + (iMac + 1) * sizeof(SVBT32) + - nIndex * nItemSize; // Pointer to content array - return pRet; -} - -// PlcBookmarks -// class Ww1StringList reads a number of P strings from the stream into memory -// and patches them into C strings -// nMax returns the count -// Index 0 references all strings; index 1 and higher reference individual strings -Ww1StringList::Ww1StringList( SvStream& rSt, sal_uLong nFc, sal_uInt16 nCb ) - : pIdxA(0), nMax(0) -{ - if( nCb > 2 ) // any entries at all? - { - SVBT16 nCountBytes; - OSL_ENSURE(nCb > sizeof(nCountBytes), "Ww1StringList"); - if (rSt.Seek(nFc) == (sal_uLong)nFc) - if (rSt.Read(nCountBytes, sizeof(nCountBytes)) - == sizeof(nCountBytes)) // length again - { - OSL_ENSURE(SVBT16ToShort(nCountBytes) - == nCb, "redundant-size missmatch"); - // let's hope that they are always equal - sal_Char* pA = new sal_Char[nCb - sizeof(nCountBytes) + 1]; - // allocating PString array - //~ Ww1: new-NULL - if (rSt.Read(pA, nCb - sizeof(nCountBytes)) - == (sal_uLong)nCb - sizeof(nCountBytes)) // read all - {}// do nothing - // Count number of fonts - long nLeft = nCb - sizeof(nCountBytes); - sal_Char* p = pA; - while (true) - { - sal_uInt16 nNextSiz; - nNextSiz = *p + 1; - if(nNextSiz > nLeft) - break; - nMax++; - nLeft -= nNextSiz; - if(nLeft < 1) // need to be able to read next length - break; - p = p + nNextSiz; - } - if (nMax) - { - pIdxA = new sal_Char*[nMax+1]; // allocate index array - pIdxA[0] = pA; // Index 0 : everything - // from index 1 C strings - pIdxA[1] = pA + 1; // fill index array - sal_uInt16 i = 2; - p = pA; - sal_uInt8 nL = *p; - while(true) - { - p += nL + 1; // new length byte - nL = *p; // remember length - *p = '\0'; // make C string - if( i > nMax ) - break; - pIdxA[i] = p + 1; // Ptr to C string - i++; - } - } - else - pIdxA = 0; // No entries -> no array - } - } -} - -const OUString Ww1StringList::GetStr( sal_uInt16 nNum ) const -{ - OUString sRet; - if( nNum <= nMax ) - sRet = OUString( pIdxA[ nNum+1 ], strlen(pIdxA[ nNum+1 ]), RTL_TEXTENCODING_MS_1252 ); - return sRet; -} - -Ww1Bookmarks::Ww1Bookmarks(Ww1Fib& rInFib) - : aNames(rInFib), rFib(rInFib), nIsEnd(0) -{ - pPos[0] = new Ww1PlcBookmarkPos(rFib, rFib.GetFIB().fcPlcfbkfGet(), - rFib.GetFIB().cbPlcfbkfGet(), false); - nPlcIdx[0] = 0; - pPos[1] = new Ww1PlcBookmarkPos(rFib, rFib.GetFIB().fcPlcfbklGet(), - rFib.GetFIB().cbPlcfbklGet(), true); - nPlcIdx[1] = 0; - bOK = !aNames.GetError() && !pPos[0]->GetError() && !pPos[1]->GetError(); -} - -// There's one twist to this operator++: in the case of 2 adjacent bookmarks, -// the end of the first one should be reached first, and then the start of the -// second one. However, if there are 2 bookmarks of length 0 on top of each -// other, each bookmarks' respective start *must* be found before its end. -// The case: ][ -// [...] -// ][ -// is not solved yet. I'd need to jump back and forth in the start and end -// indices, using another index or a bitfield or something similar for keeping -// track of already processed bookmarks. -void Ww1Bookmarks::operator++() -{ - if( bOK ) - { - nPlcIdx[nIsEnd]++; - - sal_uLong l0 = pPos[0]->Where(nPlcIdx[0]); - sal_uLong l1 = pPos[1]->Where(nPlcIdx[1]); - if( l0 < l1 ) - nIsEnd = 0; - else if( l1 < l0 ) - nIsEnd = 1; - else - nIsEnd = ( nIsEnd ) ? 0 : 1; - } -} - -long Ww1Bookmarks::GetHandle() const -{ - if( bOK ) - { - if( nIsEnd ) - return nPlcIdx[1]; - - const sal_uInt8* p = pPos[0]->GetData( nPlcIdx[0] ); - if( p ) - return SVBT16ToShort( p ); - } - return LONG_MAX; -} - -long Ww1Bookmarks::Len() const -{ - if( nIsEnd ) - { - OSL_ENSURE( false, "Invalid usage (1) of Ww1Bookmarks::Len()" ); - return 0; - } - sal_uInt16 nEndIdx = SVBT16ToShort(pPos[0]->GetData(nPlcIdx[0])); - return pPos[1]->Where(nEndIdx) - pPos[0]->Where(nPlcIdx[0]); -} - -const OUString Ww1Bookmarks::GetName() const -{ - if( nIsEnd ) - return OUString("???"); - return aNames.GetStr( nPlcIdx[0] ); -} - -// Fkp -Ww1Fkp::Ww1Fkp(SvStream& rStream, sal_uLong ulFilePos, sal_uInt16 _nItemSize) : - nItemSize(_nItemSize), - bOK(false) -{ - if (rStream.Seek(ulFilePos) == (sal_uLong)ulFilePos) - if (rStream.Read(aFkp, sizeof(aFkp)) == sizeof(aFkp)) - bOK = true; -} - -sal_uLong Ww1Fkp::Where(sal_uInt16 nIndex) -{ - sal_uLong lRet = 0xffffffff; - OSL_ENSURE(nIndex<=Count(), "index out of bounds"); - if (nIndex<=Count()) - lRet = SVBT32ToUInt32(aFkp+nIndex*sizeof(SVBT32)); - return lRet; -} - -sal_uInt8* Ww1Fkp::GetData(sal_uInt16 nIndex) -{ - sal_uInt8* pRet = NULL; - OSL_ENSURE(nIndex<=Count(), "index out of bounds"); - if (nIndex<=Count()) - pRet = aFkp + (Count()+1) * sizeof(SVBT32) + - nIndex * nItemSize; // start of the structures - return pRet; -} - -// FkpPap -bool Ww1FkpPap::Fill(sal_uInt16 nIndex, sal_uInt8*& p, sal_uInt16& rnCountBytes) -{ - OSL_ENSURE( nIndex < Count(), "Ww1FkpPap::Fill() Index out of Range" ); - sal_uInt16 nOffset = *GetData(nIndex) * 2; - if (nOffset) - { - OSL_ENSURE(nOffset>(sal_uInt16)(Count()*sizeof(SVBT32)), "calc error"); - rnCountBytes = *(aFkp+nOffset) * 2; - nOffset += sizeof(sal_uInt8); - if( nOffset + rnCountBytes < 511 ) // SH: Assert triggered 1 too early - rnCountBytes++; // SH: I'm not entirely sure if the last - // byte of the PAPX is used, but this way - // we don't forget any and are on the - // safe side either way - OSL_ENSURE(nOffset+rnCountBytes <= 511, "calc error"); - p = aFkp + nOffset; - } - else - { - p = NULL; - rnCountBytes = 0; - } - return true; -} - -// FkpChp -bool Ww1FkpChp::Fill(sal_uInt16 nIndex, W1_CHP& aChp) -{ - OSL_ENSURE( nIndex < Count(), "Ww1FkpChp::Fill() Index out of Range" ); - memset(&aChp, 0, sizeof(aChp)); - sal_uInt16 nOffset = GetData(nIndex)[0] * 2; - if (nOffset) - { - OSL_ENSURE(nOffset>(sal_uInt16)(Count()*sizeof(SVBT32)), "calc error"); - sal_uInt16 nCountBytes = aFkp[nOffset]; - nOffset += sizeof(sal_uInt8); - OSL_ENSURE(nCountBytes <= 511-nOffset, "calc error"); - OSL_ENSURE(nCountBytes <= sizeof(aChp), "calc error"); - memcpy(&aChp, aFkp+nOffset, nCountBytes); - } - return true; -} - -// Assoc -Ww1Assoc::Ww1Assoc(Ww1Fib& _rFib) - : rFib(_rFib), pBuffer(NULL), bOK(false) -{ - sal_uInt16 cb = rFib.GetFIB().cbSttbfAssocGet(); - sal_uInt16 i; - - for ( i = 0; i < MaxFields; i++ ) - pStrTbl[i] = NULL; - if ((pBuffer = new sal_Char[cb]) != NULL - && rFib.GetStream().Seek(rFib.GetFIB().fcSttbfAssocGet()) == - rFib.GetFIB().fcSttbfAssocGet() - && rFib.GetStream().Read(pBuffer, cb) == cb) - { - sal_uInt16 j; - OSL_ENSURE( cb == SVBT16ToShort( *(SVBT16*)pBuffer ), "size mismatch"); - for (i=0,j=sizeof(SVBT16);j<cb && i<Criteria1;i++) - { - pStrTbl[i] = pBuffer+j; - j += (*pBuffer + j) + 1; - } - bOK = true; - } -} - -OUString Ww1Assoc::GetStr(sal_uInt16 code) -{ - OStringBuffer sRet; - OSL_ENSURE(code<MaxFields, "out of range"); - if (pStrTbl[code] != NULL) - for( sal_uInt16 i=0;i<pStrTbl[code][0];i++ ) - sRet.append(pStrTbl[code][i+1]); - return OStringToOUString(sRet.makeStringAndClear(), - RTL_TEXTENCODING_MS_1252); -} - -// Pap -Ww1Pap::Ww1Pap(Ww1Fib& _rFib) - : Ww1PlcPap(_rFib), nPlcIndex(0), nPushedPlcIndex(0xffff), nFkpIndex(0), - nPushedFkpIndex(0xffff), ulOffset(0), pPap(0) -{ -} - -void Ww1Pap::Seek(sal_uLong ulSeek) -{ - while (ulSeek > Where()) - ++(*this); -} - -// SH: Where has been passed a parameter which determines if the index should be set -// to 0 upon constructing a new Fkp (must not happen for Push/Pop) -// Can't think of an elegant way for now -sal_uLong Ww1Pap::Where( bool bSetIndex ) -{ - sal_uLong ulRet = 0xffffffff; - if (pPap == NULL) - if (nPlcIndex < Count()) - { - pPap = new Ww1FkpPap(rFib.GetStream(), - SVBT16ToShort(GetData(nPlcIndex)) << 9); - if( bSetIndex ) - nFkpIndex = 0; - } - if (pPap != NULL) - if (nFkpIndex <= pPap->Count()) - ulRet = pPap->Where(nFkpIndex) - rFib.GetFIB().fcMinGet(); - return ulRet; -} - -void Ww1Pap::operator++() -{ - if (pPap != NULL) - if (++nFkpIndex > pPap->Count()) - { - delete pPap; - pPap = NULL; - nPlcIndex++; - } -} - -// SH: FindSprm looks for Sprm nId in grpprl -// Return value: pointer or 0 -bool Ww1Pap::FindSprm(sal_uInt16 nId, sal_uInt8* pStart, sal_uInt8* pEnd) -{ - Ww1Sprm aSprm( pStart, static_cast< sal_uInt16 >(pEnd-pStart) ); - sal_uInt16 nC = aSprm.Count(); - sal_uInt16 i; - sal_uInt8 nI; - sal_uInt16 nLen; - sal_uInt8 *pData; - for( i = 0; i < nC; i++ ){ - aSprm.Fill( i, nI, nLen, pData ); - if( nI == nId ) - return true; - } - return false; -} - -bool Ww1Pap::HasId0(sal_uInt16 nId) -{ - bool bRet = false; - UpdateIdx(); - - if( !pPap ){ - OSL_ENSURE( false, "Ww1Pap::HasId():: cannot create a pPap" ); - return false; - } - - sal_uInt8* pByte; - sal_uInt16 n; - if( pPap->Fill(nFkpIndex, pByte, n) ){ - sal_uInt8* p2 = ((W1_PAPX*)(pByte))->grpprlGet(); // SH: Offset was missing - bRet = FindSprm( nId, p2, pByte + n ); - } - return bRet; -} - -bool Ww1Pap::HasId(sal_uInt16 nId) -{ - sal_uInt16 nPushedPlcIndex2 = nPlcIndex; - sal_uInt16 nPushedFkpIndex2 = nFkpIndex; - bool bRet = HasId0( nId ); - if (nPlcIndex != nPushedPlcIndex2) - { - delete pPap; - pPap = NULL; - } - nPlcIndex = nPushedPlcIndex2; - nFkpIndex = nPushedFkpIndex2; - Where( false ); - return bRet; -} - -// Chp -Ww1Chp::Ww1Chp(Ww1Fib& _rFib) - : Ww1PlcChp(_rFib), nPlcIndex(0), nPushedPlcIndex(0xffff), nFkpIndex(0), - nPushedFkpIndex(0xffff), ulOffset(0), pChp(0) -{ -} - -void Ww1Chp::Seek(sal_uLong ulSeek) -{ - while (ulSeek > Where()) - ++(*this); -} - -// SH: Where has been passed a parameter which determines if the index should be set -// to 0 upon constructing a new Fkp (must not happen for Push/Pop) -// Can't think of an elegant way for now -sal_uLong Ww1Chp::Where( bool bSetIndex ) -{ - sal_uLong ulRet = 0xffffffff; - if (pChp == NULL) - if (nPlcIndex < Count()) - { - pChp = new Ww1FkpChp(rFib.GetStream(), - SVBT16ToShort(GetData(nPlcIndex)) << 9); - if( bSetIndex ) - nFkpIndex = 0; - } - if (pChp != NULL) - if (nFkpIndex <= pChp->Count()) - ulRet = pChp->Where(nFkpIndex) - - rFib.GetFIB().fcMinGet() - ulOffset; - return ulRet; -} - -void Ww1Chp::operator++() -{ - if (pChp != NULL) - if (++nFkpIndex > pChp->Count()) - { - delete pChp; - pChp = NULL; - nPlcIndex++; - } -} - -// Manager -Ww1Manager::Ww1Manager(SvStream& rStrm, sal_uLong nFieldFlgs) - : bOK(false), bInTtp(false), bInStyle(false), bStopAll(false), aFib(rStrm), - aDop(aFib), aFonts(aFib, nFieldFlgs), aDoc(aFib), pDoc(&aDoc), - ulDocSeek(0), pSeek(&ulDocSeek), aFld(aFib), pFld(&aFld), aChp(aFib), - aPap(aFib), aFtn(aFib), aBooks(aFib), - aSep(aFib, aDop.GetDOP().grpfIhdtGet()) -{ - bOK = !aFib.GetError() - && !aFib.GetFIB().fComplexGet() - && !aDoc.GetError() - && !aSep.GetError() - && !aPap.GetError() - && !aChp.GetError() - && !aFld.GetError() - && !aFtn.GetError() - && !aBooks.GetError(); -} - -bool Ww1Manager::HasInTable() -{ - return aPap.HasId(24); // Ww1SingleSprmPFInTable -} - -bool Ww1Manager::HasTtp() -{ - return aPap.HasId(25); // Ww1SingleSprmPTtp -} - -bool Ww1Manager::HasPPc() -{ - return aPap.HasId(29); // Ww1SingleSprmPPc -} - -bool Ww1Manager::HasPDxaAbs() -{ - return aPap.HasId(26); // Ww1SingleSprmPDxaAbs -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww1/w1class.hxx b/sw/source/filter/ww1/w1class.hxx deleted file mode 100644 index 5c974104c8c3..000000000000 --- a/sw/source/filter/ww1/w1class.hxx +++ /dev/null @@ -1,1491 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SW_SOURCE_FILTER_WW1_W1CLASS_HXX -#define INCLUDED_SW_SOURCE_FILTER_WW1_W1CLASS_HXX - -#include <rtl/ustring.hxx> - -// local -#include <w1struct.hxx> - -#ifdef DUMP -#include <fstream.h> -#endif - -#include <ostream> - -namespace editeng { class SvxBorderLine; } - -class SvxFontItem; -class SvxBoxItem; -class SvStream; -class SwField; -class Ww1Annotation; -class Ww1AtnText; -class Ww1Chp; -class Ww1DocText; -class Ww1Dop; -class Ww1Fib; -class Ww1Fkp; -class Ww1FkpChp; -class Ww1FkpPap; -class Ww1Fonts; -class Ww1Manager; -class Ww1McrText; -class Ww1Pap; -class Ww1PlainText; -class Ww1Plc; -class Ww1PlcAnnotationRef; -class Ww1PlcAnnotationTxt; -class Ww1PlcChp; -class Ww1PlcFields; -class Ww1PlcFootnoteRef; -class Ww1PlcFootnoteTxt; -class Ww1PlcGlossary; -class Ww1PlcHdd; -class Ww1PlcPap; -class Ww1PlcSep; -class Ww1Shell; -class Ww1Sprm; -class Ww1SprmPapx; -class Ww1SprmSep; -class Ww1Style; -class Ww1StyleSheet; - -// If possible, methods with similar functionality were given similar -// names in this module. The names were taken from ww filter, if -// possible. -// Where() returns an element's position. This can be either a seek -// position in the stream or a relative offset inside the text, since -// these are mixed up in Word. The methods' comments indicate which of -// these options they apply to. -// Count() returns the number of elements. Be careful with n/n-1 -// fields (Word likes to store structures in double arrays, with the -// first one containing n elements, and the second one n-1. -// Fill() fills passed references with data from Word structures. -// GetData() returns pointers to the data range -// Start(), Stop(), Out(), op<< see module w1filter -// Dump() see module w1dump - -// file information block: root of the evil: it's at the start of the -// file (seek(0)) and contains all positions of the structures of the -// file. -class Ww1Fib -{ - W1_FIB aFib; - bool bOK; - SvStream& rStream; -public: - Ww1Fib(SvStream&); - friend std::ostream& operator <<(std::ostream&, Ww1Fib&); - W1_FIB& GetFIB() { return aFib; } - bool GetError() { return !bOK; } - SvStream& GetStream() { return rStream; } -}; - -// document property: properties of the entire document -class Ww1Dop -{ - W1_DOP aDop; - Ww1Fib& rFib; - bool bOK; -public: - Ww1Dop(Ww1Fib&); - bool GetError() { - return !bOK; } - W1_DOP& GetDOP() { - return aDop; } - friend std::ostream& operator <<(std::ostream&, Ww1Dop&); - void Out(Ww1Shell&); -}; - -// ww-files can contain several blocks of text (main-text, -// footnotes etc). PlainText unifies the overlaps -class Ww1PlainText -{ -protected: - Ww1Fib& rFib; - sal_uLong ulFilePos; - sal_uLong ulCountBytes; - sal_uLong ulSeek; - bool bOK; -public: - Ww1PlainText(Ww1Fib& rWwFib, sal_uLong nFilePos, sal_uLong nCountBytes); - // within the text - sal_uLong Where() const { return ulSeek; } - void Seek( sal_uLong ulNew ) - { - OSL_ENSURE(ulNew < ulCountBytes, "Ww1PlainText"); - if (ulNew < ulCountBytes) - ulSeek = ulNew; - } - - sal_uLong Count() const { return ulCountBytes; } - void SetCount(sal_uLong ulNew) - { - ulNew += ulSeek; - if (ulCountBytes > ulNew) - ulCountBytes = ulNew; - } - void operator++() - { - OSL_ENSURE(ulSeek+1<ulCountBytes, "Ww1PlainText"); - ulSeek++; - } - bool GetError() { return !bOK; } - sal_Unicode Out( Ww1Shell&, sal_uLong& ); - sal_Unicode Out( OUString&, sal_uLong=0xffffffff); - sal_Unicode Out( sal_Unicode& ); - friend std::ostream& operator <<(std::ostream&, Ww1PlainText&); - OUString& Fill( OUString&, sal_uLong=0, sal_uLong=0xffffffff ); - sal_Unicode operator []( sal_uLong ); - OUString GetText( sal_uLong ulOffset, sal_uLong nLen ) const; - - enum Consts { MinChar = 32 }; - static bool IsChar( sal_Unicode c ) { return c >= MinChar; } -}; - -class Ww1DocText : public Ww1PlainText -{ -public: - Ww1DocText(Ww1Fib& rFibL) : - Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet(), - rFibL.GetFIB().ccpTextGet()) { - } -}; - -class Ww1FtnText : public Ww1PlainText -{ -public: - sal_uLong Offset(Ww1Fib& rFibL) { - return rFibL.GetFIB().ccpTextGet(); } - Ww1FtnText(Ww1Fib& rFibL) : - Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() + - Offset(rFibL), rFibL.GetFIB().ccpFtnGet()) { - } -}; - -class Ww1HddText : public Ww1PlainText -{ -public: - sal_uLong Offset(Ww1Fib& rFibL) { - return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet(); } - Ww1HddText(Ww1Fib& rFibL) : - Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() + - Offset(rFibL), rFibL.GetFIB().ccpHddGet()) { - } -}; - -class Ww1McrText : public Ww1PlainText -{ -public: - sal_uLong Offset(Ww1Fib& rFibL) { - return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet() - + rFibL.GetFIB().ccpHddGet(); } - Ww1McrText(Ww1Fib& rFibL) : - Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() + - Offset(rFibL), rFibL.GetFIB().ccpMcrGet()) { - } -}; - -class Ww1AtnText : public Ww1PlainText -{ -public: - sal_uLong Offset(Ww1Fib& rFibL) { - return rFibL.GetFIB().ccpTextGet() + rFibL.GetFIB().ccpFtnGet() - + rFibL.GetFIB().ccpHddGet() + rFibL.GetFIB().ccpMcrGet(); } - Ww1AtnText(Ww1Fib& rFibL) : - Ww1PlainText(rFibL, rFibL.GetFIB().fcMinGet() + - Offset(rFibL), rFibL.GetFIB().ccpAtnGet()) { - } -}; - -// a single style or template -class Ww1Style -{ - OUString aName; - W1_CHP aChpx; - Ww1SprmPapx* pPapx; - Ww1StyleSheet* pParent; - sal_uInt8 stcBase; - sal_uInt8 stcNext; - bool bUsed; -public: - Ww1Style(); - ~Ww1Style(); - bool IsUsed() const { return bUsed; } - void SetDefaults(sal_uInt8); - void SetParent(Ww1StyleSheet* newParent) { pParent = newParent; } - void SetName(const OUString& rName) { bUsed = true; aName = rName; } - const OUString& GetName() const { return aName; } - Ww1Style& GetBase(); - sal_uInt16 GetnBase() const { return stcBase; } - sal_uInt16 GetnNext() const { return stcNext; } - sal_uInt16 ReadName(sal_uInt8*&, sal_uInt16&, sal_uInt16 stc); - sal_uInt16 ReadChpx(sal_uInt8*&, sal_uInt16&); - sal_uInt16 ReadPapx(sal_uInt8*&, sal_uInt16&); - sal_uInt16 ReadEstcp(sal_uInt8*&, sal_uInt16&); - friend std::ostream& operator <<(std::ostream&, Ww1Style&); - void Out(Ww1Shell&, Ww1Manager&); -}; - -// collection of all templates (max. 256) -class Ww1StyleSheet -{ - Ww1Style aStyles[256]; - sal_uInt16 cstcStd; // count style code standard - Ww1Fib& rFib; - bool bOK; - sal_uInt16 ReadNames(sal_uInt8*&, sal_uInt16&); - sal_uInt16 ReadChpx(sal_uInt8*&, sal_uInt16&); - sal_uInt16 ReadPapx(sal_uInt8*&, sal_uInt16&); - sal_uInt16 ReadEstcp(sal_uInt8*&, sal_uInt16&); - - void OutDefaults(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc); - void OutOne(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc); - void OutOneWithBase(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc, - sal_uInt8* pbStopRecur ); -public: - Ww1StyleSheet(Ww1Fib& rFib); - Ww1Style& GetStyle(sal_uInt16 stc) { - return aStyles[stc]; } - sal_uInt16 Count() { - return 256; } - friend std::ostream& operator <<(std::ostream&, Ww1StyleSheet&); - void Out(Ww1Shell&, Ww1Manager&); - friend class Ww1Style; - bool GetError() { - return !bOK; } -}; - -// ww only knows font numbers during formatting. Independently, there -// is an array of fonts, so that the number can be converted to a -// specific font. -class Ww1Fonts -{ -protected: - W1_FFN** pFontA; // Array of Pointers to Font Description - Ww1Fib& rFib; - sal_uLong nFieldFlags; - sal_uInt16 nMax; // Array size - bool bOK; -public: - Ww1Fonts(Ww1Fib&, sal_uLong nFieldFlgs); - ~Ww1Fonts() { - if (pFontA) - DELETEZ(pFontA[0]); - DELETEZ(pFontA); } - W1_FFN* GetFFN(sal_uInt16 nNum); - sal_uInt16 Count() { - return nMax; } - friend std::ostream& operator <<(std::ostream&, Ww1Fonts&); - bool GetError() { - return !bOK; } - SvxFontItem GetFont(sal_uInt16); -}; - -// SingleSprm -// These classes replace aSprmTab etc. from ww6 filter. The function -// pointers are virtual methods. There exist derived classes for -// specific types (byte, word, var-sized etc.). They have methods for -// determining their sizes, for dumping and outputting the Sprms to -// the shell. -// The classes get created with new (in InitTab()) and added to the -// table according to their code. For activating them the respective -// method has to be called on an object in the table. -// Take note: SingleSprms only describe Sprms, they don't carry their -// content, which must be passed to the individual methods such as -// Size, Dump and Start/Stop. -class Ww1SingleSprm -{ -public: -#ifdef DUMP - // The vtab only contains the virtual methods; we hide them - // depending on what we compile for (dumper or filter). This saves - // space. Furthermore, these method's implementations live in - // different modules which only get compiled and linked when - // required by the respective project. The name string is only - // required by the dumper -- let's not include it in the filter. - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&); - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&); - virtual std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16); - const sal_Char* sName; -#else - virtual void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&); - virtual void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&); - std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16); -#endif - virtual sal_uInt16 Size(sal_uInt8*); - sal_uInt16 nCountBytes; - - Ww1SingleSprm(sal_uInt16 nBytes, const sal_Char* /*pName*/ = 0 ) - : nCountBytes(nBytes) -#ifdef DUMP - , sName( pName) -#endif - { - } - virtual ~Ww1SingleSprm(); -}; - -class Ww1SingleSprmByteSized : public Ww1SingleSprm { -public: - sal_uInt16 Size(sal_uInt8*) SAL_OVERRIDE; - Ww1SingleSprmByteSized(sal_uInt16 nBytes, sal_Char* sName = 0) : - Ww1SingleSprm(nBytes, sName) { - } -}; - -class Ww1SingleSprmWordSized : public Ww1SingleSprm { -public: - sal_uInt16 Size(sal_uInt8*) SAL_OVERRIDE; - Ww1SingleSprmWordSized(sal_uInt16 nBytes, sal_Char* sName = 0) : - Ww1SingleSprm(nBytes, sName) { - } -}; - -class Ww1SingleSprmByte : public Ww1SingleSprm { -public: - std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16); - Ww1SingleSprmByte(sal_Char* sName = 0) : - Ww1SingleSprm(1, sName) { - } -}; - -class Ww1SingleSprmBool : public Ww1SingleSprmByte { -public: - std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16); - Ww1SingleSprmBool(sal_Char* sName = 0) : - Ww1SingleSprmByte(sName) { - } -}; - -class Ww1SingleSprm4State : public Ww1SingleSprmByte { -public: - std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16); - Ww1SingleSprm4State(sal_Char* sName = 0) : - Ww1SingleSprmByte(sName) { - } -}; - -class Ww1SingleSprmWord : public Ww1SingleSprm { -public: - std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16); - Ww1SingleSprmWord(sal_Char* sName = 0) - : Ww1SingleSprm(2, sName) {} -}; - -class Ww1SingleSprmLong : public Ww1SingleSprm { -public: - std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16); - Ww1SingleSprmLong(sal_Char* sName = 0) : - Ww1SingleSprm(4, sName) { - } -}; - -class Ww1SingleSprmTab : public Ww1SingleSprm { -public: - std::ostream& Dump(std::ostream&, sal_uInt8*, sal_uInt16); - sal_uInt16 Size(sal_uInt8*) SAL_OVERRIDE; - Ww1SingleSprmTab(sal_uInt16 nBytes, sal_Char* sName = 0) : - Ww1SingleSprm(nBytes, sName) { - } -}; - -class Ww1SingleSprmPJc : public Ww1SingleSprmByte { -public: - Ww1SingleSprmPJc(sal_Char* sName) : - Ww1SingleSprmByte(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPDxa : public Ww1SingleSprmWord { -public: - Ww1SingleSprmPDxa(sal_Char* sName) : - Ww1SingleSprmWord(sName) { - } - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPDxaRight : public Ww1SingleSprmPDxa { -public: - Ww1SingleSprmPDxaRight(sal_Char* sName) : - Ww1SingleSprmPDxa(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPDxaLeft : public Ww1SingleSprmPDxa { -public: - Ww1SingleSprmPDxaLeft(sal_Char* sName) : - Ww1SingleSprmPDxa(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPDxaLeft1 : public Ww1SingleSprmPDxa { -public: - Ww1SingleSprmPDxaLeft1(sal_Char* sName) : - Ww1SingleSprmPDxa(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPFKeep : public Ww1SingleSprmBool { -public: - Ww1SingleSprmPFKeep(sal_Char* sName) : - Ww1SingleSprmBool(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPFKeepFollow : public Ww1SingleSprmBool { -public: - Ww1SingleSprmPFKeepFollow(sal_Char* sName) : - Ww1SingleSprmBool(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPPageBreakBefore : public Ww1SingleSprmBool { -public: - Ww1SingleSprmPPageBreakBefore(sal_Char* sName) : - Ww1SingleSprmBool(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPBrc : public Ww1SingleSprmWord { -protected: - // specific start routines, supplied with different BoxItems - // depending on sprm - void Start(Ww1Shell&, sal_uInt8, W1_BRC10*, sal_uInt16, Ww1Manager&, SvxBoxItem&); - void Start(Ww1Shell&, sal_uInt8, W1_BRC*, sal_uInt16, Ww1Manager&, SvxBoxItem&); - - using Ww1SingleSprm::Start; - -public: - Ww1SingleSprmPBrc(sal_Char* sName) : - Ww1SingleSprmWord(sName) { - } - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; - // SetBorder() is needed for tables, too. That's why it's public - static editeng::SvxBorderLine* SetBorder(editeng::SvxBorderLine*, W1_BRC10*); -}; - -#define BRC_TOP ((sal_uInt16)0) -#define BRC_LEFT ((sal_uInt16)1) -#define BRC_BOTTOM ((sal_uInt16)2) -#define BRC_RIGHT ((sal_uInt16)3) -#define BRC_ANZ ((sal_uInt16)BRC_RIGHT-BRC_TOP+1) - -// The BRC structure for 1.0 versions of Word differ from the ones in -// later versions. Luckily, they will be queried by other sprms. -// SH: From now on, all 4 borders handled by a single class. -class Ww1SingleSprmPBrc10 : public Ww1SingleSprmPBrc -{ - sal_uInt16 nLine; // BRC_TOP, BRC_LEFT, ... - - using Ww1SingleSprmPBrc::Start; - -public: - Ww1SingleSprmPBrc10(sal_uInt16 nL, sal_Char* sName) - : Ww1SingleSprmPBrc(sName), nLine(nL) {} - - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmParaSpace : public Ww1SingleSprmWord { -public: - Ww1SingleSprmParaSpace(sal_Char* sName) - : Ww1SingleSprmWord(sName) {} - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPDyaBefore : public Ww1SingleSprmParaSpace { -public: - Ww1SingleSprmPDyaBefore(sal_Char* sName) - : Ww1SingleSprmParaSpace(sName) {} - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPDyaAfter : public Ww1SingleSprmParaSpace { -public: - Ww1SingleSprmPDyaAfter(sal_Char* sName) : - Ww1SingleSprmParaSpace(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPDyaLine : public Ww1SingleSprmWord { -public: - Ww1SingleSprmPDyaLine(sal_Char* sName) : - Ww1SingleSprmWord(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPChgTabsPapx : public Ww1SingleSprmByteSized { -public: - Ww1SingleSprmPChgTabsPapx(sal_Char* sName) : - Ww1SingleSprmByteSized(0, sName) { - } - // Size() is not yet activated! - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmSGprfIhdt : public Ww1SingleSprmByte { -public: - Ww1SingleSprmSGprfIhdt(sal_Char* sName) : - Ww1SingleSprmByte(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmSColumns : public Ww1SingleSprmWord { -public: - Ww1SingleSprmSColumns(sal_Char* sName) : - Ww1SingleSprmWord(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPFInTable : public Ww1SingleSprmBool { -public: - Ww1SingleSprmPFInTable(sal_Char* sName) : - Ww1SingleSprmBool(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPTtp : public Ww1SingleSprmBool { -public: - Ww1SingleSprmPTtp(sal_Char* sName) : - Ww1SingleSprmBool(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; - void Stop(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmTJc : public Ww1SingleSprmWord { -public: - Ww1SingleSprmTJc(sal_Char* sName) - : Ww1SingleSprmWord(sName) {} -}; - -class Ww1SingleSprmTDxaGapHalf : public Ww1SingleSprmWord { -public: - Ww1SingleSprmTDxaGapHalf(sal_Char* sName) : - Ww1SingleSprmWord(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmTDefTable10 : public Ww1SingleSprmWordSized { -public: - Ww1SingleSprmTDefTable10(sal_Char* sName) : - Ww1SingleSprmWordSized(0, sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmTDyaRowHeight : public Ww1SingleSprmWord { -public: - Ww1SingleSprmTDyaRowHeight(sal_Char* sName) : - Ww1SingleSprmWord(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -// Class definitions for table fastsave attributes -// Because we don't support fastsave, we don't need it - -// Class definitions for Apos ( == Flys ) - -class Ww1SingleSprmPpc : public Ww1SingleSprmByte { -public: - Ww1SingleSprmPpc(sal_Char* sName) : - Ww1SingleSprmByte(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPDxaAbs : public Ww1SingleSprmWord { -public: - Ww1SingleSprmPDxaAbs(sal_Char* sName) : - Ww1SingleSprmWord(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPDyaAbs : public Ww1SingleSprmWord { -public: - Ww1SingleSprmPDyaAbs(sal_Char* sName) : - Ww1SingleSprmWord(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPDxaWidth : public Ww1SingleSprmWord { -public: - Ww1SingleSprmPDxaWidth(sal_Char* sName) : - Ww1SingleSprmWord(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -class Ww1SingleSprmPFromText : public Ww1SingleSprmWord { -public: - Ww1SingleSprmPFromText(sal_Char* sName) : - Ww1SingleSprmWord(sName) { - } - void Start(Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) SAL_OVERRIDE; -}; - -// The data type Sprm actually appearing in the file -class Ww1Sprm -{ - bool ReCalc(); - static Ww1SingleSprm* aTab[256]; - static Ww1SingleSprm* pSingleSprm; -protected: - static void InitTab(); - Ww1SingleSprm& GetTab(sal_uInt16 nId) - { - if( !pSingleSprm ) - InitTab(); - return aTab[ nId ] ? *aTab[nId] : *pSingleSprm; - } - - sal_uInt8* p; - sal_uInt16 nCountBytes; - bool bOK; - sal_uInt16* pArr; - sal_uInt16 count; - // without token, with length byte/word - sal_uInt16 GetSize(sal_uInt8 nId, sal_uInt8* pSprm); - // with token and length byte - sal_uInt16 GetSizeBrutto(sal_uInt8* pSprm) { - sal_uInt8 nId = *pSprm++; - return GetSize(nId, pSprm) + 1; } - // returns for the n-th element id, size & pointer to data: - // sal_Bool Fill(sal_uInt16, sal_uInt8&, sal_uInt16&, sal_uInt8*&); -public: - // SH: I need it to be public - // returns for the n-th element id, size & pointer to data: - bool Fill(sal_uInt16, sal_uInt8&, sal_uInt16&, sal_uInt8*&); - - Ww1Sprm(sal_uInt8*, sal_uInt16); - Ww1Sprm(SvStream&, sal_uLong); - ~Ww1Sprm(); - friend std::ostream& operator <<(std::ostream&, Ww1Sprm&); - void Start(Ww1Shell&, Ww1Manager&); - void Start(Ww1Shell&, Ww1Manager&, sal_uInt16); - void Stop(Ww1Shell&, Ww1Manager&); - bool IsUsed() { - return nCountBytes != 255; } - sal_uInt16 Count() { - return count; } - bool GetError() { - return !bOK; } - static void DeinitTab(); -}; - -// the wrapper around the type PIC, a structure, which stands at the beginning -// of a picture filename or an embedded picture -class Ww1Picture -{ - bool bOK; - W1_PIC* pPic; -public: - Ww1Picture(SvStream&, sal_uLong); - ~Ww1Picture() { - } - bool GetError() { - return !bOK; } - friend std::ostream& operator <<(std::ostream&, Ww1Picture&); - void Out(Ww1Shell&, Ww1Manager&); - void WriteBmp(SvStream&); -}; - -// One of the important array structures in ww files. They contain n+1 -// file positions and n attributes applying in between them. -class Ww1Plc -{ - sal_uInt8* p; - sal_uInt16 nCountBytes; - sal_uInt16 iMac; - sal_uInt16 nItemSize; - bool bOK; -protected: - Ww1Fib& rFib; - sal_uInt8* GetData(sal_uInt16); -public: - Ww1Plc(Ww1Fib&, sal_uLong, sal_uInt16, sal_uInt16); - ~Ww1Plc(); - friend std::ostream& operator <<(std::ostream&, Ww1Plc&); - sal_uLong Where(sal_uInt16); // like in each plc - void Seek(sal_uLong, sal_uInt16&); - void Fill(sal_uInt16 nIndex, sal_uLong& begin, sal_uLong& end) { - begin = Where(nIndex); - end = Where(nIndex+1); } - sal_uInt16 Count() { - return iMac; } - bool GetError() { - return !bOK; } -}; - -// Size Tabs from Sven: -// CHP, PAP, SEP, HED, FNR, FNT -//Plc 2, 2, 6, 0, 2, 0 -//Fkp 1, 1, 0, 0, 0, 0 - -class Ww1PlcGlossary : public Ww1Plc -{ -public: - Ww1PlcGlossary(Ww1Fib& rFibL) : - Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfglsyGet(), - rFibL.GetFIB().cbPlcfglsyGet(), 0) { - } -}; - -class Ww1PlcAnnotationRef : public Ww1Plc -{ -public: - Ww1PlcAnnotationRef(Ww1Fib& rFibL) : - Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfandRefGet(), - rFibL.GetFIB().cbPlcfandRefGet(), 0) { - } -}; - -class Ww1PlcAnnotationTxt : public Ww1Plc -{ -public: - Ww1PlcAnnotationTxt(Ww1Fib& rFibL) : - Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfandTxtGet(), - rFibL.GetFIB().cbPlcfandTxtGet(), 0) { - } -}; - -// PlcAnnotation -class Ww1Annotation { - Ww1PlcAnnotationRef aRef; - Ww1PlcAnnotationTxt aTxt; -public: - Ww1Annotation(Ww1Fib& rFib) : - aRef(rFib), - aTxt(rFib) { - } - friend std::ostream& operator <<(std::ostream&, Ww1Annotation&); -}; - -class Ww1PlcSep : public Ww1Plc -{ -public: - Ww1PlcSep(Ww1Fib& rFibL): - Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfsedGet(), - rFibL.GetFIB().cbPlcfsedGet(), 6) { - } - friend std::ostream& operator <<(std::ostream&, Ww1PlcSep&); -}; - -class Ww1PlcChp : public Ww1Plc -{ -public: - Ww1PlcChp(Ww1Fib& rFibL) : - Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfbteChpxGet(), - rFibL.GetFIB().cbPlcfbteChpxGet(), 2) { - } - friend std::ostream& operator <<(std::ostream&, Ww1PlcChp&); -}; - -class Ww1PlcPap : public Ww1Plc -{ -public: - Ww1PlcPap(Ww1Fib& rFibL) : - Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfbtePapxGet(), - rFibL.GetFIB().cbPlcfbtePapxGet(), 2) { - } - friend std::ostream& operator <<(std::ostream&, Ww1PlcPap&); -}; - -class Ww1PlcFootnoteRef : public Ww1Plc -{ -public: - Ww1PlcFootnoteRef(Ww1Fib& rFibL) : - Ww1Plc(rFibL, rFibL.GetFIB().fcPlcffndRefGet(), - rFibL.GetFIB().cbPlcffndRefGet(), 2) { - } - friend std::ostream& operator <<(std::ostream&, Ww1PlcFootnoteRef&); -}; - -class Ww1PlcFootnoteTxt : public Ww1Plc -{ -public: - Ww1PlcFootnoteTxt(Ww1Fib& rFibL) : - Ww1Plc(rFibL, rFibL.GetFIB().fcPlcffndTxtGet(), - rFibL.GetFIB().cbPlcffndTxtGet(), 0) { - } - friend std::ostream& operator <<(std::ostream&, Ww1PlcFootnoteTxt&); -}; - -class Ww1PlcFields : public Ww1Plc -{ -public: - Ww1PlcFields(Ww1Fib& rFibL, sal_uLong start, sal_uInt16 nBytes) - : Ww1Plc(rFibL, start, nBytes, 2) - {} - W1_FLD* GetData(sal_uInt16 nIndex) - { return (W1_FLD*)Ww1Plc::GetData(nIndex); } - sal_uLong Where(sal_uInt16 nIndex) // absolute within the file - { return Ww1Plc::Where(nIndex) + rFib.GetFIB().fcMinGet(); } - friend std::ostream& operator <<(std::ostream&, Ww1PlcFields&); -}; - -// PlcBookmarks -class Ww1StringList -{ - sal_Char** pIdxA; - sal_uInt16 nMax; -public: - Ww1StringList( SvStream& rSt, sal_uLong nFc, sal_uInt16 nCb ); - ~Ww1StringList() - { if( pIdxA ) { delete pIdxA[0]; delete pIdxA; } } - const OUString GetStr( sal_uInt16 nNum ) const; - sal_uInt16 Count() const { return nMax; } - bool GetError() const { return (nMax != 0) && !pIdxA; } -}; - -class Ww1PlcBookmarkTxt: public Ww1StringList -{ -public: - Ww1PlcBookmarkTxt(Ww1Fib& rFib) : - Ww1StringList( rFib.GetStream(), rFib.GetFIB().fcSttbfbkmkGet(), - rFib.GetFIB().cbSttbfbkmkGet() ) - {} -}; - -class Ww1PlcBookmarkPos : public Ww1Plc -{ -public: - Ww1PlcBookmarkPos(Ww1Fib& _rFib, sal_uLong start, sal_uInt16 nBytes, bool bEnd) - : Ww1Plc(_rFib, start, nBytes, (bEnd) ? 0 : 2) - {} - - sal_uInt8* GetData(sal_uInt16 nIndex) { return Ww1Plc::GetData(nIndex); } - // Position as CP - sal_uLong WhereCP(sal_uInt16 nIndex) { return Ww1Plc::Where(nIndex); } - // absolute within the file - sal_uLong Where(sal_uInt16 nIndex) - { - return ( nIndex < Count() ) - ? Ww1Plc::Where(nIndex) + rFib.GetFIB().fcMinGet() - : 0xffffffff; - } -}; - -class Ww1PlcHdd : public Ww1Plc -{ -public: - Ww1PlcHdd(Ww1Fib& rFibL) - : Ww1Plc(rFibL, rFibL.GetFIB().fcPlcfhddGet(), - rFibL.GetFIB().cbPlcfhddGet(), 0) - {} -}; - -// Arrays very similar to the plcs; limited to a size of 512 bytes -class Ww1Fkp -{ -protected: - sal_uInt8 aFkp[512]; - sal_uInt16 nItemSize; - bool bOK; - sal_uInt8* GetData(sal_uInt16); -public: - Ww1Fkp(SvStream&, sal_uLong, sal_uInt16); - friend std::ostream& operator <<(std::ostream&, Ww1Fkp&); - sal_uInt16 Count() const { return *(aFkp+511); } - sal_uLong Where(sal_uInt16); // like in the corresponding fkp -}; - -class Ww1FkpPap : public Ww1Fkp -{ -public: - Ww1FkpPap(SvStream& rStream, sal_uLong ulFilePos) - : Ww1Fkp(rStream, ulFilePos, 1) - {} - friend std::ostream& operator <<(std::ostream&, Ww1FkpPap&); - bool Fill(sal_uInt16, sal_uInt8*&, sal_uInt16&); -}; - -class Ww1FkpChp : public Ww1Fkp -{ -#ifdef DUMP - SvStream& rStream; - SvStream& GetStream() { return rStream; } -#endif -public: - Ww1FkpChp(SvStream& rStream, sal_uLong ulFilePos) - : Ww1Fkp(rStream, ulFilePos, 1) -#ifdef DUMP - , rStream(rStream) -#endif - {} - - friend std::ostream& operator <<(std::ostream&, Ww1FkpChp&); - bool Fill(sal_uInt16, W1_CHP&); -}; - -class Ww1SprmPapx : public Ww1Sprm -{ - W1_PAPX aPapx; - sal_uInt8* Sprm(sal_uInt8* p, sal_uInt16 nSize); - sal_uInt16 SprmSize(sal_uInt8* p, sal_uInt16 nSize); -public: - Ww1SprmPapx(sal_uInt8* p, sal_uInt16 nSize); - friend std::ostream& operator <<(std::ostream&, Ww1SprmPapx&); - void Start(Ww1Shell&, Ww1Manager&); - void Stop(Ww1Shell&, Ww1Manager&); -}; - -class Ww1SprmSep : public Ww1Sprm -{ -public: - Ww1SprmSep(Ww1Fib& rFib, sal_uLong ulFilePos) - : Ww1Sprm(rFib.GetStream(), ulFilePos) - {} - friend std::ostream& operator <<(std::ostream&, Ww1SprmSep&); -}; - -class Ww1Assoc -{ - enum fields { FileNext, Dot, Title, Subject, KeyWords, Comments, - Author, LastRevBy, DataDoc, HeaderDoc, Criteria1, Criteria2, - Criteria3, Criteria4, Criteria5, Criteria6, Criteria7, MaxFields }; - - Ww1Fib& rFib; - sal_Char* pBuffer; - sal_Char* pStrTbl[ MaxFields ]; - bool bOK; - - OUString GetStr(sal_uInt16); - -public: - Ww1Assoc(Ww1Fib&); - ~Ww1Assoc() { delete pBuffer; } - bool GetError() const { return !bOK; } - friend std::ostream& operator <<(std::ostream&, Ww1Assoc&); - void Out(Ww1Shell&); -}; - -// Header/footer/footnote separators are stored in a separate text one -// after the other. A plc partitions these texts into several -// parts. They are numbered as ihdd. There are 9 different functions -// for these texts. When one of them is requested, it applies to the -// first ihdd, the next time to the second and so on. Which type a -// given text part will be treated as can only be determined by -// reading the file sequentially. The 9 types are: footnote separator, -// footnote continuation separator, footnote continuation note, even -// page header, odd page header, even page footer, odd page footer, -// header and footer for the first page. HeaderFooter remembers the -// current setting for each of these (but not the previous one) and -// the following ihdd. A part of type 0xffff denotes a non-existing -// part. -class Ww1HeaderFooter : public Ww1PlcHdd -{ - sal_uInt16 nextIhdd; // next text part in HddText - sal_uInt16 nFtnSep; // footnote separator - sal_uInt16 nFtnFollowSep; // footnote continuation separator - sal_uInt16 nFtnNote; // footnote continuation note - sal_uInt16 nEvenHeadL; - sal_uInt16 nOddHeadL; - sal_uInt16 nEvenFootL; - sal_uInt16 nOddFootL; - sal_uInt16 nFirstHeadL; - sal_uInt16 nFirstFootL; - enum HeaderFooterMode { - None, FtnSep, FtnFollowSep, FtnNote, EvenHeadL, OddHeadL, - EvenFootL, OddFootL, FirstHeadL, MaxHeaderFooterMode - } eHeaderFooterMode; - -public: - Ww1HeaderFooter(Ww1Fib& rFibL, sal_uInt16 grpfIhdt) - : Ww1PlcHdd(rFibL), - nextIhdd(0), - nFtnSep(0xffff), - nFtnFollowSep(0xffff), - nFtnNote(0xffff), - nEvenHeadL(0xffff), - nOddHeadL(0xffff), - nEvenFootL(0xffff), - nOddFootL(0xffff), - nFirstHeadL(0xffff), - nFirstFootL(0xffff), - eHeaderFooterMode(None) - { - if (grpfIhdt & 0x0001) nFtnSep = nextIhdd++; - if (grpfIhdt & 0x0002) nFtnFollowSep = nextIhdd++; - if (grpfIhdt & 0x0004) nFtnNote = nextIhdd++; - } - void SetGrpfIhdt(sal_uInt16 grpfIhdt) - { - if (grpfIhdt & 0x0001) nEvenHeadL = nextIhdd++; - if (grpfIhdt & 0x0002) nOddHeadL = nextIhdd++; - if (grpfIhdt & 0x0004) nEvenFootL = nextIhdd++; - if (grpfIhdt & 0x0008) nOddFootL = nextIhdd++; - if (grpfIhdt & 0x0010) nFirstHeadL = nextIhdd++; - if (grpfIhdt & 0x0020) nFirstFootL = nextIhdd++; - OSL_ENSURE(nextIhdd<=Count(), "Ww1HeaderFooter"); - } - bool operator++() - { - bool bRet = true; - eHeaderFooterMode = (HeaderFooterMode)((short)eHeaderFooterMode + 1); - if( eHeaderFooterMode == MaxHeaderFooterMode) - { - eHeaderFooterMode = None; - bRet = false; - } - return bRet; - } - bool FillFtnSep(sal_uLong& begin, sal_uLong& end) - { - if (nFtnSep == 0xffff) - return false; - Fill(nFtnSep, begin, end); - return true; - } - bool FillFtnFollowSep(sal_uLong& begin, sal_uLong& end) - { - if (nFtnFollowSep == 0xffff) - return false; - Fill(nFtnFollowSep, begin, end); - return true; - } - bool FillFtnNote(sal_uLong& begin, sal_uLong& end) - { - if (nFtnNote == 0xffff) - return false; - Fill(nFtnNote, begin, end); - return true; - } - bool FillEvenHeadL(sal_uLong& begin, sal_uLong& end) - { - if (nEvenHeadL == 0xffff) - return false; - Fill(nEvenHeadL, begin, end); - return true; - } - bool FillOddHeadL(sal_uLong& begin, sal_uLong& end) - { - if (nOddHeadL == 0xffff) - return false; - Fill(nOddHeadL, begin, end); - return true; - } - bool FillEvenFootL(sal_uLong& begin, sal_uLong& end) - { - if (nEvenFootL == 0xffff) - return false; - Fill(nEvenFootL, begin, end); - return true; - } - bool FillOddFootL(sal_uLong& begin, sal_uLong& end) - { - if (nOddFootL == 0xffff) - return false; - Fill(nOddFootL, begin, end); - return true; - } - bool FillFirstHeadL(sal_uLong& begin, sal_uLong& end) - { - if (nFirstHeadL == 0xffff) - return false; - Fill(nFirstHeadL, begin, end); - return true; - } - bool FillFirstFootL(sal_uLong& begin, sal_uLong& end) - { - if (nFirstFootL == 0xffff) - return false; - Fill(nFirstFootL, begin, end); - return true; - } - void Start(Ww1Shell&, Ww1Manager&); - void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&); -}; - -class Ww1Fields : public Ww1PlcFields -{ - sal_uInt16 nPlcIndex; - OUString sResult; // Calculated by Word - SwField* pField; - sal_uLong Where(sal_uInt16 nIndex) // within the text - { return Ww1PlcFields::Where(nIndex) - rFib.GetFIB().fcMinGet(); } - -public: - Ww1Fields(Ww1Fib& rFibL, sal_uLong ulFilePos, sal_uInt16 nBytes) - : Ww1PlcFields(rFibL, ulFilePos, nBytes), nPlcIndex(0), pField(0) - {} - // within the text - sal_uLong Where() { return Where(nPlcIndex); } - void operator++() - { - OSL_ENSURE(nPlcIndex+1 <= Count(), "Ww1Fields"); - nPlcIndex++; - } - void Seek(sal_uLong ulNew) { Ww1PlcFields::Seek(ulNew, nPlcIndex); } - W1_FLD* GetData() - { - OSL_ENSURE(nPlcIndex < Count(), "Ww1Fields"); - return Ww1PlcFields::GetData(nPlcIndex); - } - sal_uLong GetLength(); - friend std::ostream& operator <<(std::ostream&, Ww1Manager&); - void Start(Ww1Shell&, Ww1Manager&); - void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&); - void Out(Ww1Shell&, Ww1Manager&, sal_uInt16=0); -}; - -class Ww1TextFields : public Ww1Fields -{ -public: - Ww1TextFields(Ww1Fib& rFibL) - : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldMomGet(), - rFibL.GetFIB().cbPlcffldMomGet()) - {} -}; - -class Ww1FootnoteFields : public Ww1Fields -{ -public: - Ww1FootnoteFields(Ww1Fib& rFibL) - : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldFtnGet(), - rFibL.GetFIB().cbPlcffldFtnGet()) - {} -}; - -class Ww1HeaderFooterFields : public Ww1Fields -{ -public: - Ww1HeaderFooterFields(Ww1Fib& rFibL) - : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldHdrGet(), - rFibL.GetFIB().cbPlcffldHdrGet()) - {} -}; - -class Ww1MacroFields : public Ww1Fields -{ -public: - Ww1MacroFields(Ww1Fib& rFibL) - : Ww1Fields(rFibL, rFibL.GetFIB().fcPlcffldMcrGet(), - rFibL.GetFIB().cbPlcffldMcrGet()) - {} -}; - -class Ww1Bookmarks -{ - Ww1PlcBookmarkTxt aNames; - Ww1PlcBookmarkPos* pPos[2]; - Ww1Fib& rFib; - - sal_uInt16 nPlcIdx[2]; - sal_uInt16 nIsEnd; - bool bOK; -public: - Ww1Bookmarks(Ww1Fib& rFib); - ~Ww1Bookmarks() - { - delete pPos[1]; - delete pPos[0]; - } - sal_uLong Where() const { return pPos[nIsEnd]->WhereCP(nPlcIdx[nIsEnd]); } - void operator++(); - bool GetError() const { return !bOK; } - long GetHandle() const; - bool GetIsEnd() const { return ( nIsEnd ) ? sal_True : sal_False; } - const OUString GetName() const; - long Len() const; - friend std::ostream& operator <<(std::ostream&, Ww1Bookmarks&); - void Start(Ww1Shell&, Ww1Manager&); - void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&); - void Out(Ww1Shell&, Ww1Manager&, sal_uInt16=0); -}; - -class Ww1Footnotes : public Ww1PlcFootnoteRef -{ - sal_uInt16 nPlcIndex; - Ww1PlcFootnoteTxt aText; - bool bStarted; -public: - Ww1Footnotes(Ww1Fib& rFibL) - : Ww1PlcFootnoteRef(rFibL), nPlcIndex(0), aText(rFibL), bStarted(false) - {} - // within the text - sal_uLong Where() - { - sal_uLong ulRet = 0xffffffff; - if (Count()) - ulRet = Ww1PlcFootnoteRef::Where(nPlcIndex); - return ulRet; - } - void operator++() - { - OSL_ENSURE(nPlcIndex+1 <= Count(), "Ww1Footnotes"); - nPlcIndex++; - } - void Start(Ww1Shell&, Ww1Manager&); - void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&); -}; - -class Ww1Sep : public Ww1PlcSep -{ - Ww1HeaderFooter aHdd; - sal_uInt16 nPlcIndex; -public: - Ww1Sep(Ww1Fib& rFibL, sal_uInt16 grpfIhdt) - : Ww1PlcSep(rFibL), aHdd(rFibL, grpfIhdt), nPlcIndex(0) {} - - Ww1HeaderFooter& GetHdd() { return aHdd; } - void operator++() { nPlcIndex++; } - sal_uInt8* GetData() { return Ww1PlcSep::GetData(nPlcIndex); } - // within the text - sal_uLong Where() { return Ww1PlcSep::Where(nPlcIndex); } - void SetGrpfIhdt(sal_uInt8 grpfIhdt) - { - GetHdd().SetGrpfIhdt(grpfIhdt); - } - void Start(Ww1Shell&, Ww1Manager&); - void Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode& c) - { aHdd.Stop(rOut, rMan, c); } -}; - -class Ww1Pap : public Ww1PlcPap -{ - sal_uInt16 nPlcIndex; - sal_uInt16 nPushedPlcIndex; - sal_uInt16 nFkpIndex; - sal_uInt16 nPushedFkpIndex; - sal_uLong ulOffset; - Ww1FkpPap* pPap; - - bool FindSprm(sal_uInt16 nId, sal_uInt8* pStart, sal_uInt8* pEnd); - void UpdateIdx() - { - if (pPap && nFkpIndex >= pPap->Count() ) - { - delete pPap; - pPap = NULL; - nPlcIndex++; - } - if( !pPap ) - Where(); - } - bool HasId0(sal_uInt16 nId); - -public: - Ww1Pap(Ww1Fib& rFib); - ~Ww1Pap() { delete pPap; } - sal_uLong Where( bool bSetIndex = true ); // within the text - void operator++(); - bool FillStart(sal_uInt8*& pB, sal_uInt16& nSize) - { - UpdateIdx(); - return pPap->Fill(nFkpIndex, pB, nSize); - } - bool FillStop(sal_uInt8*& pB, sal_uInt16& nSize) - { - return nFkpIndex ? pPap->Fill(nFkpIndex-1, pB, nSize) : sal_False; - } - void Start(Ww1Shell&, Ww1Manager&); - void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&); - void Seek(sal_uLong); - void Push(sal_uLong ulOffsetTmp = 0) - { - OSL_ENSURE(!Pushed(), "Ww1Pap"); - nPushedPlcIndex = nPlcIndex; - nPushedFkpIndex = nFkpIndex; - Seek(ulOffsetTmp); - ulOffset = ulOffsetTmp; - delete pPap; - pPap = NULL; - } - bool Pushed() - { - return nPushedPlcIndex != 0xffff; - } - void Pop() - { - OSL_ENSURE(Pushed(), "Ww1Pap"); - ulOffset = 0; - nPlcIndex = nPushedPlcIndex; - nFkpIndex = nPushedFkpIndex; - nPushedPlcIndex = 0xffff; - nPushedFkpIndex = 0xffff; - delete pPap; - pPap = NULL; - Where( false ); - } - bool HasId(sal_uInt16 nId); -}; - -class Ww1Chp : public Ww1PlcChp -{ - sal_uInt16 nPlcIndex; - sal_uInt16 nPushedPlcIndex; - sal_uInt16 nFkpIndex; - sal_uInt16 nPushedFkpIndex; - sal_uLong ulOffset; - Ww1FkpChp* pChp; - void UpdateIdx() - { - if (pChp && nFkpIndex >= pChp->Count() ) - { - delete pChp; - pChp = NULL; - nPlcIndex++; - } - if( !pChp ) - Where(); - } - -public: - Ww1Chp( Ww1Fib& rFib ); - ~Ww1Chp() { delete pChp; } - sal_uLong Where( bool bSetIndex = true ); // within the text - void operator++(); - bool FillStart(W1_CHP& rChp) - { - UpdateIdx(); - return pChp->Fill(nFkpIndex, rChp); - } - bool FillStop(W1_CHP& rChp) - { return nFkpIndex ? pChp->Fill(nFkpIndex-1, rChp) : sal_False; } - void Start(Ww1Shell&, Ww1Manager&); - void Stop(Ww1Shell&, Ww1Manager&, sal_Unicode&); - void Seek(sal_uLong); - void Push(sal_uLong ulOffsetTmp = 0) - { - OSL_ENSURE(!Pushed(), "Ww1Chp"); - nPushedPlcIndex = nPlcIndex; - nPushedFkpIndex = nFkpIndex; - Seek(ulOffsetTmp); - ulOffset = ulOffsetTmp; - delete pChp; - pChp = NULL; - } - bool Pushed() { return nPushedPlcIndex != 0xffff; } - void Pop() - { - OSL_ENSURE(Pushed(), "Ww1Chp"); - ulOffset = 0; - nPlcIndex = nPushedPlcIndex; - nFkpIndex = nPushedFkpIndex; - nPushedPlcIndex = 0xffff; - nPushedFkpIndex = 0xffff; - delete pChp; - pChp = NULL; - Where( false ); - } -}; - -// Central point of access for the ww side of the filter, constructed -// from the input stream (ww file). It contains everything necessary -// for being piped into the shell (pm side). -class Ww1Manager -{ - bool bOK; - bool bInTtp; - bool bInStyle; - bool bStopAll; - Ww1Fib aFib; - Ww1Dop aDop; - Ww1Fonts aFonts; - // from now on, everything in pairs, for 'pushed': - Ww1DocText aDoc; - Ww1PlainText* pDoc; - sal_uLong ulDocSeek; - sal_uLong* pSeek; - Ww1TextFields aFld; - Ww1Fields* pFld; - // 'push'able itself: - Ww1Chp aChp; - Ww1Pap aPap; - // not present in text ranges if 'pushed' - Ww1Footnotes aFtn; - Ww1Bookmarks aBooks; - Ww1Sep aSep; - - void OutStop( Ww1Shell&, sal_Unicode ); - void OutStart( Ww1Shell& ); - void Out(Ww1Shell&, sal_Unicode ); - -public: - Ww1Manager(SvStream& rStrm, sal_uLong nFieldFlgs); - bool GetError() const { return !bOK; } - - // for tables - void SetInTtp(bool bSet = true) { bInTtp = bSet; } - bool IsInTtp() const { return bInTtp; } - void SetInStyle(bool bSet = true) { bInStyle = bSet; } - bool IsInStyle() const { return bInStyle; } - void SetStopAll(bool bSet = true) { bStopAll = bSet; } - bool IsStopAll() const { return bStopAll; } - bool HasInTable(); - bool HasTtp(); - bool LastHasTtp(); - - // for flys - bool HasPPc(); - bool HasPDxaAbs(); - - Ww1Fib& GetFib() { return aFib; } - Ww1PlainText& GetText() { return *pDoc; } - Ww1Dop& GetDop() { return aDop; } - Ww1Sep& GetSep() { return aSep; } - // within the text - sal_uLong Where() { return pDoc->Where(); } - void Fill( sal_Unicode& rChr ) { pDoc->Out( rChr ); } - sal_uInt8 Fill( OUString& rStr, sal_uLong ulLen) - { - ulLen += pDoc->Where(); - return sal::static_int_cast< sal_uInt8 >(pDoc->Out(rStr, ulLen)); - } - SvxFontItem GetFont(sal_uInt16 nFCode); - friend Ww1Shell& operator <<(Ww1Shell&, Ww1Manager&); - friend std::ostream& operator <<(std::ostream&, Ww1Manager&); - bool Pushed() { return pDoc != &aDoc; } - void Pop(); - void Push0(Ww1PlainText* pDoc, sal_uLong, Ww1Fields* = 0); - void Push1(Ww1PlainText* pDoc, sal_uLong ulSeek, sal_uLong ulSeek2 = 0, - Ww1Fields* = 0); -}; - -#endif // INCLUDED_SW_SOURCE_FILTER_WW1_W1CLASS_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww1/w1filter.cxx b/sw/source/filter/ww1/w1filter.cxx deleted file mode 100644 index 1e2e28998d50..000000000000 --- a/sw/source/filter/ww1/w1filter.cxx +++ /dev/null @@ -1,1988 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <hintids.hxx> -#include <sw3convert.hxx> -#include <tools/solar.h> -#include <comphelper/string.hxx> -#include <editeng/paperinf.hxx> -#include <vcl/graphicfilter.hxx> -#include <vcl/graph.hxx> -#include <vcl/wmf.hxx> -#include <editeng/fontitem.hxx> -#include <editeng/lrspitem.hxx> -#include <editeng/ulspitem.hxx> -#include <editeng/wghtitem.hxx> -#include <editeng/postitem.hxx> -#include <editeng/crossedoutitem.hxx> -#include <editeng/contouritem.hxx> -#include <editeng/cmapitem.hxx> -#include <editeng/fhgtitem.hxx> -#include <editeng/udlnitem.hxx> -#include <editeng/wrlmitem.hxx> -#include <editeng/colritem.hxx> -#include <editeng/kernitem.hxx> -#include <editeng/escapementitem.hxx> -#include <editeng/tstpitem.hxx> -#include <svl/urihelper.hxx> -#include <fmtfsize.hxx> -#include <doc.hxx> -#include <IDocumentFieldsAccess.hxx> -#include <pam.hxx> -#include <ndtxt.hxx> -#include <pagedesc.hxx> -#include <flddat.hxx> -#include <reffld.hxx> -#include <expfld.hxx> -#include <docufld.hxx> -#include <ftninfo.hxx> -#include <section.hxx> -#include <fltini.hxx> -#include <w1par.hxx> -#include <docsh.hxx> -#include <swerror.h> -#include <mdiexp.hxx> -#include <statstr.hrc> -#include <stdio.h> -#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> -#include <com/sun/star/document/XDocumentProperties.hpp> -#include <vcl/dibtools.hxx> - -#define MAX_FIELDLEN 64000 - -using namespace css; -using namespace nsSwDocInfoSubType; - -// The methods operator<<, Out, Start and Stop are to be used like -// this: If possible, information from the document is transferred to -// the shell with -// operator<<() -// If additional parameters are required, the method -// Out() -// needs to be used. The methods for marking a range (attribute range, -// for example), are -// Start(), Stop() -// This module contains all of these methods. It is necessary for the -// filter, but not for the dumper, with one exception though: the -// module also contains methods, which are useless for the dumper, for -// example because they operate on sv structures like GetFont() does on -// SvxFontItem. - -// Manager -Ww1Shell& operator <<(Ww1Shell& rOut, Ww1Manager& This) -{ - // prohibit action in case of recursive call - if (!This.Pushed()) - { - { - // is only needed temporarily - This.SetInStyle( true ); - Ww1StyleSheet(This.aFib).Out(rOut, This); - This.SetInStyle( false ); - } - { - // this one, too - Ww1Assoc(This.aFib).Out(rOut); - } - This.aDop.Out(rOut); - // Decide now how page templates will be created - if (This.GetSep().Count() <= 1) - rOut.SetUseStdPageDesc(); - } - // and now the actual dok - sal_Unicode cUnknown = ' '; - while (*This.pSeek < This.pDoc->Count()) - { - // output the ProgressState only for main text, because we - // cannot determine the correct value otherwise - if (!This.Pushed()) - ::SetProgressState(This.Where() * 100 / This.pDoc->Count(), - rOut.GetDoc().GetDocShell()); - // Here, attributes and characters get pumped into the shell - // alternatingly. The positions get incremented by reading - // chars from the manager. First, the attributes: - This.Out(rOut, cUnknown); - // The text document pDoc is a Ww1PlainText, whose Out() - // method outputs until the next special character or the - // requested number of characters has been reached. - cUnknown = This.pDoc->Out(rOut, *This.pSeek); - } - This.SetStopAll(true); - This.OutStop(rOut, cUnknown); // So that attributes get closed at the end - This.SetStopAll(false); - return rOut; -} - -void Ww1Manager::OutStop(Ww1Shell& rOut, sal_Unicode cUnknown) -{ - // bookmarks don't need to be ended? - if (pFld) - pFld->Stop(rOut, *this, cUnknown); - if (!Pushed()) - aFtn.Stop(rOut, *this, cUnknown); - if (true) - aChp.Stop(rOut, *this, cUnknown); - if (true) - aPap.Stop(rOut, *this, cUnknown); - if (!Pushed()) - aSep.Stop(rOut, *this, cUnknown); -} - -void Ww1Manager::OutStart( Ww1Shell& rOut ) -{ - // start all attributes which need it - if (!Pushed()) - aSep.Start(rOut, *this); - if (true) - aPap.Start(rOut, *this); - if (true) - aChp.Start(rOut, *this); - if (!Pushed()) - aFtn.Start(rOut, *this); - if (pFld) - pFld->Start(rOut, *this); - if (!Pushed()) - aBooks.Start(rOut, *this); - // determine next event - sal_uLong ulEnd = pDoc->Count(); // at the latest at the end of the text - if (!Pushed()) - if (ulEnd > aSep.Where()) // next Sep prior? - ulEnd = aSep.Where(); - if (true) - if (ulEnd > aPap.Where()) // next Pap prior? - ulEnd = aPap.Where(); - if (true) - if (ulEnd > aChp.Where()) // next Chp prior? - ulEnd = aChp.Where(); - if (!Pushed()) - if (ulEnd > aFtn.Where()) // next Ftn prior? - ulEnd = aFtn.Where(); - if (pFld) - if (ulEnd > pFld->Where()) // next Fld prior? - ulEnd = pFld->Where(); - if (!Pushed()) - if (ulEnd > aBooks.Where()) // next Bookmark prior? - ulEnd = aBooks.Where(); - *pSeek = Where(); // current position - if (*pSeek < ulEnd) - *pSeek = ulEnd; -} - -void Ww1Manager::Out(Ww1Shell& rOut, sal_Unicode cUnknown) -{ -// Depending on the mode, fields, footnotes, character attributes, -// paragraph attributes and sections are handled like this: First, the -// Stop() method is called. If the object determines that there is -// something to end (obviously not during the first pass), it will be -// ended, otherwise the call is without effect. Next, unhandled -// special characters get output. Then, all Start() methods get -// called, and then Where() is used to find the next interesting -// position. - -// With the manager in 'push'ed mode, some elements will be -// skipped. Fields are only skipped under special circumstances, more -// precisely only during output of ranges which cannot contain -// fields. Character and paragraph attributes are never skipped. The -// if (1) instructions were added for uniformity. - -// First, some special-casing for tables: -// the important attributes are best queried before they end -// Optimization: they only get set to meaningful values when the 0x07 -// character is pending. - - bool bLIsTtp = false; - bool bLHasTtp = false; - if( cUnknown == 0x07 ) - { - bLIsTtp = IsInTtp(); - bLHasTtp = HasTtp(); - } - - OutStop( rOut, cUnknown ); // End attrs if necessary - - // interpret meta characters: - if (!Ww1PlainText::IsChar(cUnknown)) - switch (cUnknown) - { - case 0x02: - // dontknow - break; - case 0x07: // table - if (rOut.IsInTable() && HasInTable() && !bLIsTtp && !bLHasTtp) - rOut.NextTableCell(); - break; - case 0x09: // tab - rOut.NextTab(); - break; - case 0x0a: // linefeed - rOut.NextParagraph(); - break; - case 0x0b: // linebreak - if (rOut.IsInTable()) - ; - else - rOut.NextLine(); - break; - case 0x0d: // carriage return - // ignore - break; - case 0x0c: // pagebreak - rOut.NextPage(); - break; - case 0x14: // sectionendchar - // ignore here - break; - default: - break; - } - - OutStart( rOut ); // End attrs if necessary and calculate next pos -} - -SvxFontItem Ww1Manager::GetFont(sal_uInt16 nFCode) -{ - return aFonts.GetFont(nFCode); -} - -void Ww1Manager::Push0(Ww1PlainText* _pDoc, sal_uLong ulSeek, Ww1Fields* _pFld) -{ - OSL_ENSURE(!Pushed(), "Ww1Manager"); - this->pDoc = _pDoc; - pSeek = new sal_uLong; - *pSeek = pDoc->Where(); - aPap.Push(ulSeek); - aChp.Push(ulSeek); - this->pFld = _pFld; -} - -// ulSeek is the FC distance between start of main text and start of special text -// ulSeek2 is this special text's offset in the special case range -void Ww1Manager::Push1(Ww1PlainText* _pDoc, sal_uLong ulSeek, sal_uLong ulSeek2, - Ww1Fields* _pFld) -{ - OSL_ENSURE(!Pushed(), "Ww1Manager"); - this->pDoc = _pDoc; - pSeek = new sal_uLong; - *pSeek = pDoc->Where(); - aPap.Push(ulSeek + ulSeek2); - aChp.Push(ulSeek + ulSeek2); - if( _pFld ) - _pFld->Seek( ulSeek2 ); - this->pFld = _pFld; -} - -void Ww1Manager::Pop() -{ - OSL_ENSURE(Pushed(), "Ww1Manager"); - delete pDoc; - pDoc = &aDoc; - delete pSeek; - pSeek = &ulDocSeek; - aChp.Pop(); - aPap.Pop(); - delete pFld; - pFld = &aFld; -} - -void Ww1Bookmarks::Out(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16) -{ - if (GetIsEnd()) - { - rOut.SetBookEnd(GetHandle()); - return; - } - - const OUString & rName = GetName(); - if( rName.startsWith( "_Toc" ) ) // "_Toc*" is superfluous - return; - - if( rOut.IsFlagSet( SwFltControlStack::HYPO ) - && rName.equalsIgnoreAsciiCase( "FORMULAR" ) ) - rOut.SetProtect(); - - // Set for transformation bookmark -> variable - long nLen = Len(); - if( nLen > MAX_FIELDLEN ) - nLen = MAX_FIELDLEN; - - // read content of the bookmark - // Would supposedly also work via Ww1PlainText - OUString aVal( rMan.GetText().GetText( Where(), nLen ) ); - - // in 2 steps, since OS/2 is too stupid - SwFltBookmark aBook( rName, aVal, GetHandle() ); - rOut << aBook; -} - -void Ww1Bookmarks::Start(Ww1Shell& rOut, Ww1Manager& rMan) -{ - if (rMan.Where() >= Where()) - { - Out(rOut, rMan); - ++(*this); - } -} - -void Ww1Footnotes::Start(Ww1Shell& rOut, Ww1Manager& rMan) -{ - if (rMan.Where() >= Where()) - { - OSL_ENSURE(nPlcIndex < Count(), "WwFootnotes"); - sal_Unicode c; - rMan.Fill(c); - OSL_ENSURE(c==0x02, "Ww1Footnotes"); - if (c==0x02) - { - Ww1FtnText* pText = new Ww1FtnText(rMan.GetFib()); - sal_uLong start = aText.Where(nPlcIndex); - pText->Seek(start); - sal_uLong count = aText.Where(nPlcIndex+1) - start; - pText->SetCount(count); - // first byte should be foot note marker - pText->Out(c); - OSL_ENSURE(c==0x02, "Ww1Footnotes"); - count--; // for the just read marker byte - rOut.BeginFootnote(); - bStarted = true; - rMan.Push0(pText, pText->Offset(rMan.GetFib()), - new Ww1FootnoteFields(rMan.GetFib())); - rOut << rMan; - rMan.Pop(); - rOut.EndFootnote(); - } - else - ++(*this); - } -} - -void Ww1Footnotes::Stop(Ww1Shell& /*rOut*/, Ww1Manager& rMan, sal_Unicode& c) -{ - if (bStarted && rMan.Where() > Where()) - { - OSL_ENSURE(nPlcIndex < Count(), "Ww1Footnotes"); - c = ' '; - ++(*this); - } -} - -void Ww1Fields::Start(Ww1Shell& rOut, Ww1Manager& rMan) -{ - if (rMan.Where() >= Where()){ - OSL_ENSURE(nPlcIndex < Count(), "Ww1Fields"); - if (GetData()->chGet() == 19) - Out(rOut, rMan); - else - ++(*this); // ignore - } -} - -void Ww1Fields::Stop( Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode& c) -{ - if (rMan.Where() >= Where()) - { - OSL_ENSURE(nPlcIndex < Count(), "Ww1Fields"); - if (GetData()->chGet() != 19) - { - rMan.Fill( c ); - OSL_ENSURE(c==21, "Ww1Fields"); - ++(*this); - c = ' '; - if (pField) - // Do we have a complete field for insertion? - { - rOut << *pField; - delete pField; - pField = 0; - // The filter does it like this so that attributes - // applying to this field actually get read and applied - } - if (!sResult.isEmpty()) - rOut << sResult; - } - } -} - -enum WWDateTime{ WW_DONTKNOW = 0x0, WW_DATE = 0x1, WW_TIME = 0x2, WW_BOTH = 0x3 }; - -static WWDateTime GetTimeDatePara( const OUString& rForm, - SwTimeFormat* pTime = 0, - SwDateFormat* pDate = 0 ) -{ - WWDateTime eDT = WW_BOTH; - if (rForm.indexOf('H') != -1) // H -> 24h - { - if( pTime ) - *pTime = TF_SSMM_24; - } - else if (rForm.indexOf('h') != -1) // h -> 24h - { - if( pTime ) - *pTime = TF_SSMM_12; - } - else // no time - { - eDT = (WWDateTime)( eDT & ~(sal_uInt16)WW_TIME ); - } - - sal_Int32 nDPos = 0; - while (true) - { - nDPos = rForm.indexOf('M', nDPos); // M -> date - if (nDPos == 0 || nDPos == -1) - break; - sal_Unicode cPrev = rForm[nDPos - 1]; - // Ignore "AM", "aM", "PM", "pM" here - if( 'a' != cPrev && 'A' != cPrev && 'p' != cPrev && 'P' != cPrev ) - break; - // else search again - ++nDPos; - } - - if (nDPos != -1) // month -> date ? - { - static SwDateFormat const aDateA[32] = - { - DFF_DMY, DFF_DMMY, DFF_DMYY, DFF_DMMYY, - DFF_DMMMY, DFF_DMMMY, DFF_DMMMYY, DFF_DMMMYY, - DFF_DDMMY, DFF_DDMMY, DFF_DDMMMYY, DFF_DDMMMYY, - DFF_DDMMMY, DFF_DDMMMY, DFF_DDMMMYY, DFF_DDMMMYY, - DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY, - DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY, - DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY, - DFF_DDDMMMY, DFF_DDDMMMY, DFF_DDDMMMYY, DFF_DDDMMMYY - }; - - bool bHasDay = rForm.indexOf('t') != -1 || - rForm.indexOf('T') != -1 || - rForm.indexOf('d') != -1 || - rForm.indexOf('D') != -1; - - bool bLongDayOfWeek = rForm.indexOf("tttt") != -1 || - rForm.indexOf("TTTT") != -1 || - rForm.indexOf("dddd") != -1 || - rForm.indexOf("DDDD") != -1; - - bool bDayOfWeek = rForm.indexOf("ttt") != -1 || - rForm.indexOf("TTT") != -1 || - rForm.indexOf("ddd") != -1 || - rForm.indexOf("DDD") != -1; - - // M, MM -> numeric month - // MMM, MMMM -> text. month - bool bLitMonth = rForm.indexOf("MMM") != -1; - // MMMM -> full month - bool bFullMonth = rForm.indexOf("MMMM") != -1; - // jj, JJ -> 2-col-year - // jjjj, JJJJ -> 4-col-year - bool bFullYear = rForm.indexOf("jjj") != -1 || - rForm.indexOf("JJJ") != -1 || - rForm.indexOf("yyy") != -1 || - rForm.indexOf("YYY") != -1; - - sal_uInt16 i = (sal_uInt16) bLitMonth - | ( (sal_uInt16)bFullYear << 1 ) - | ( (sal_uInt16)bFullMonth << 2 ) - | ( (sal_uInt16)bDayOfWeek << 3 ) - | ( (sal_uInt16)bLongDayOfWeek << 4 ); - if( pDate ) - { - if( !bHasDay && !bFullMonth ) - *pDate = DFF_MY; - else - *pDate = aDateA[i]; - } - } - else - { - eDT = (WWDateTime)( eDT & ~(sal_uInt16)WW_DATE ); - } - return eDT; -} - -void Ww1Fields::Out(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 nDepth) -{ - OUString sType; // the type as string - OUString sFormula; - OUString sFormat; - OUString sDTFormat; // date/time format - W1_FLD* pData = GetData(); // data bound to plc - OSL_ENSURE(pData->chGet()==19, "Ww1Fields"); // should be begin - - sal_Unicode c; - rMan.Fill( c ); - OSL_ENSURE(c==19, "Ww1Fields"); // should also be begin - if (pData->chGet()==19 && c == 19) - { - OUString aStr; - c = rMan.Fill( aStr, GetLength() ); - OSL_ENSURE(Ww1PlainText::IsChar(c), "Ww1Fields"); - sal_Int32 pos = aStr.indexOf(' '); - // get type out of text - if ( pos != -1 ) - { - sType = aStr.copy(0, pos); - aStr = aStr.copy(pos+1); - } - else - { - sType = aStr; - aStr = ""; - } - sFormula += aStr; - sal_uInt8 rbType = pData->fltGet(); - do { - // Read the formula part until the entire field ends or - // the result part starts. Of course, other fields can - // start during this (Word supports nested fields). - ++(*this); - pData = GetData(); - if (pData->chGet()==19) // nested field - { - Out(rOut, rMan, nDepth+1); - rMan.Fill(c); - OSL_ENSURE(c==21, "Ww1PlainText"); - sFormula += "Ww" + OUString::number(nPlcIndex); - c = rMan.Fill(aStr, GetLength()); - OSL_ENSURE(Ww1PlainText::IsChar(c), "Ww1PlainText"); - sFormula += aStr; - } - } - while (pData->chGet()==19); - - // get format out of text - pos = sFormula.indexOf("\\*"); - if (pos != -1) - { - sFormat = sFormula.copy(pos); - sFormula = sFormula.copy(0, pos); - } - - pos = sFormula.indexOf( "\\@" ); - if (pos != -1) - { - sDTFormat = sFormula.copy(pos); - sFormula = sFormula.copy(0, pos); - } - - // The formula part is done, does a result part follow? - if( pData->chGet() == 20 ) - { - rMan.Fill( c ); - OSL_ENSURE(c==20, "Ww1PlainText"); - c = rMan.Fill(sResult, GetLength()); - if (!Ww1PlainText::IsChar(c)) - sResult += OUString(c); //~ mdt: handle special chars - ++(*this); - } - OSL_ENSURE(GetData()->chGet()==21, "Ww1PlainText"); - bool bKnown = true; - OSL_ENSURE(pField==0, "Ww1PlainText"); - if (pField != 0) - { - rOut << *pField; - delete pField; - pField = 0; - } -oncemore: - switch (rbType) - { - case 3: // bookmark reference - sFormula = rOut.ConvertUStr(sFormula); - pField = new SwGetRefField( (SwGetRefFieldType*) - rOut.GetSysFldType( RES_GETREFFLD ), - sFormula, - REF_BOOKMARK, - 0, - REF_CONTENT ); - - break; - case 6: // set command - { - pos = aStr.indexOf(' '); - OUString aName; - if (pos != -1) - { - aName = aStr.copy(0, pos); - aStr = aStr.copy(pos+1); - } - else - { - aName = aStr; - aStr = ""; - } - if (aName.isEmpty()) - break; - aName = rOut.ConvertUStr(aName); - SwFieldType* pFT = rOut.GetDoc().getIDocumentFieldsAccess().InsertFldType( - SwSetExpFieldType( &rOut.GetDoc(), aName, nsSwGetSetExpType::GSE_STRING ) ); - pField = new SwSetExpField((SwSetExpFieldType*)pFT, aStr); - ((SwSetExpField*)pField)->SetSubType( nsSwExtendedSubType::SUB_INVISIBLE ); - // Invisible causes trouble in 378; should work soon - - // Ignoring bookmarks is not implemented - } - break; - case 14: // info variable - { - OUString aSubType; - pos = aStr.indexOf(' '); - if (pos != -1) - { - aSubType = aStr.copy(0, pos); - aStr = aStr.copy(pos+1); - } - else - { - aSubType = aStr; - aStr = ""; - } - - aSubType = rOut.ConvertUStr(aSubType); - - // huge pile of shit: the type 'info' can represent one of - // types 15 to 31. it contains as formula the actual field - // of the doc info. - // Don't use ';' with the following macro -#define IS(sd, se, t) \ - if (aSubType == sd || aSubType == se) \ - rbType = t; \ - else - - // german name english name type-code - IS("titel", "title", 15) - IS("thema", "subject", 16) - IS("autor", "author", 17) - IS("stichw?rter", "keywords", 18) //~ mdt: umlaut - IS("kommentar", "comment", 19) - IS("gespeichertvon", "lastrevisedby", 20) - IS("ertelldat", "creationdate", 21) - IS("speicherdat", "revisiondate", 22) - IS("druckdat", "printdate", 23) - IS("version", "revisionnumber", 24) - IS("zeit", "edittime", 25) - IS("anzseit", "numberofpages", 26) - IS("anzw?rter", "numberofwords", 27) //~ mdt: umlaut - IS("anzzeichen", "numberofchars", 28) - IS("dateiname", "filename", 29) - IS("vorlage", "templatename", 30) - bKnown = false; -#undef IS - if (rbType != 14) - goto oncemore; - } - break; - case 15: // title - pField = new SwDocInfoField((SwDocInfoFieldType*) - rOut.GetSysFldType(RES_DOCINFOFLD), DI_TITEL, OUString(), 0); - break; - case 16: // subject - pField = new SwDocInfoField((SwDocInfoFieldType*) - rOut.GetSysFldType(RES_DOCINFOFLD), DI_THEMA, OUString(), 0); - break; - case 17: // author - pField = new SwAuthorField((SwAuthorFieldType*) - rOut.GetSysFldType(RES_AUTHORFLD), AF_NAME ); - break; - case 18: // keywords - pField = new SwDocInfoField((SwDocInfoFieldType*) - rOut.GetSysFldType(RES_DOCINFOFLD), DI_KEYS, OUString(), 0); - break; - case 19: // comments - pField = new SwDocInfoField((SwDocInfoFieldType*) - rOut.GetSysFldType(RES_DOCINFOFLD), DI_COMMENT, OUString(), 0); - break; - case 20: // last revised by - pField = new SwDocInfoField((SwDocInfoFieldType*) - rOut.GetSysFldType(RES_DOCINFOFLD), DI_CHANGE|DI_SUB_AUTHOR, OUString()); - break; - case 21: // creation date - case 22: // revision date - case 23: // print date - case 25:{// edit time - sal_uInt16 nSub; - sal_uInt16 nReg = 0; // RegInfoFormat, DefaultFormat for DocInfo fields - - switch( rbType ) - { - default: - case 21: nSub = DI_CREATE; nReg = DI_SUB_DATE; break; - case 23: nSub = DI_PRINT; nReg = DI_SUB_DATE; break; - case 22: nSub = DI_CHANGE; nReg = DI_SUB_DATE; break; - case 25: nSub = DI_CHANGE; nReg = DI_SUB_TIME; break; - } - switch( GetTimeDatePara( sDTFormat ) ) - { - case WW_DATE: nReg = DI_SUB_DATE; break; - case WW_TIME: nReg = DI_SUB_TIME; break; - case WW_BOTH: nReg = DI_SUB_DATE; break; - default: - break; - // WW_DONTKNOW -> Default already set - } - pField = new SwDocInfoField((SwDocInfoFieldType*) - rOut.GetSysFldType(RES_DOCINFOFLD), nSub | nReg, OUString()); - } - break; - case 24: // revision number - pField = new SwDocInfoField((SwDocInfoFieldType*) - rOut.GetSysFldType(RES_DOCINFOFLD), DI_DOCNO, OUString(), 0); - break; - case 26: // number of pages - pField = new SwDocStatField((SwDocStatFieldType*) - rOut.GetSysFldType(RES_DOCSTATFLD), DS_PAGE, SVX_NUM_ARABIC); - break; - case 27: // number of words - pField = new SwDocStatField((SwDocStatFieldType*) - rOut.GetSysFldType(RES_DOCSTATFLD), DS_WORD, SVX_NUM_ARABIC); - break; - case 28: // number of chars - pField = new SwDocStatField((SwDocStatFieldType*) - rOut.GetSysFldType(RES_DOCSTATFLD), DS_CHAR, SVX_NUM_ARABIC); - break; - case 29: // file name - pField = new SwFileNameField((SwFileNameFieldType*) - rOut.GetSysFldType(RES_FILENAMEFLD)); - break; - case 30: // doc template name - pField = new SwTemplNameField((SwTemplNameFieldType*) - rOut.GetSysFldType(RES_TEMPLNAMEFLD), FF_NAME); - break; - case 31: - case 32:{ - SwDateFormat aDate = DF_SSYS; - SwTimeFormat aTime = TF_SYSTEM; - - WWDateTime eDT = GetTimeDatePara(sDTFormat, &aTime, &aDate); - if( eDT == WW_DONTKNOW ) // no D/T-format string - eDT = ( rbType == 32 ) ? WW_TIME : WW_DATE; // use ID - - if( eDT & WW_DATE ) - { - sal_uInt16 nWhich = RES_DATEFLD; - sal_uInt16 nSubType = DATEFLD; - sal_uLong nFormat = aDate; - sw3io_ConvertFromOldField( rOut.GetDoc(), - nWhich, nSubType, nFormat, 0x0110 ); - pField = new SwDateTimeField((SwDateTimeFieldType*) - rOut.GetSysFldType(RES_DATETIMEFLD), DATEFLD, nFormat); - - if( eDT == WW_BOTH ) - rOut << * pField << ' '; - // Cheat: insert directly and a space afterwards - } - if( eDT & WW_TIME ) - { - sal_uInt16 nWhich = RES_TIMEFLD; - sal_uInt16 nSubType = TIMEFLD; - sal_uLong nFormat = aTime; - sw3io_ConvertFromOldField( rOut.GetDoc(), - nWhich, nSubType, nFormat, 0x0110 ); - pField = new SwDateTimeField((SwDateTimeFieldType*) - rOut.GetSysFldType(RES_DATETIMEFLD), TIMEFLD, nFormat); - } - - } - break; - case 33: // current page - pField = new SwPageNumberField((SwPageNumberFieldType*) - rOut.GetSysFldType(RES_PAGENUMBERFLD), PG_RANDOM, SVX_NUM_ARABIC); - break; - case 34: // evaluation exp - { - if (nDepth == 0) - { - SwGetExpFieldType* pFieldType = - (SwGetExpFieldType*)rOut.GetSysFldType(RES_GETEXPFLD); - OSL_ENSURE(pFieldType!=0, "Ww1Fields"); - if (pFieldType != 0) - pField = new SwGetExpField(pFieldType, sFormula, - nsSwGetSetExpType::GSE_STRING, VVF_SYS); - } - else // recursion: - { - OUString aName("Ww"); - aName += OUString::number( nPlcIndex ); - SwFieldType* pFT = rOut.GetDoc().getIDocumentFieldsAccess().GetFldType( RES_SETEXPFLD, aName, false); - if (pFT == 0) - { - SwSetExpFieldType aS(&rOut.GetDoc(), aName, nsSwGetSetExpType::GSE_FORMULA); - pFT = rOut.GetDoc().getIDocumentFieldsAccess().InsertFldType(aS); - } - SwSetExpField aFld((SwSetExpFieldType*)pFT, sFormula); - aFld.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE); - rOut << aFld; - } - } - break; - case 36: // print command, insert file - { - OUString aFName; - pos = aStr.indexOf(' '); - if (pos != -1) - { - aFName = aStr.copy(0, pos); - aStr = aStr.copy(pos+1); - } - else - { - aFName = aStr; - aStr = ""; - } - - if(aFName.isEmpty()) - break; - aFName = aFName.replaceFirst("\\\\", "\\"); - - aFName = URIHelper::SmartRel2Abs( - INetURLObject(rOut.GetBaseURL()), aFName ); - - const OUString sStr(aStr); - SwSectionData * pSection = new SwSectionData( FILE_LINK_SECTION, - rOut.GetDoc().GetUniqueSectionName( &sStr ) ); - pSection->SetLinkFileName( aFName ); - pSection->SetProtectFlag( true ); - rOut << SwFltSection( pSection ); - rOut.EndItem( RES_FLTR_SECTION ); - rOut.NextParagraph(); - } - case 37: // page ref - pField = new SwGetRefField( - (SwGetRefFieldType*)rOut.GetSysFldType(RES_GETREFFLD), - sFormula, 0, 0, REF_PAGE); - break; - case 38: // ask command - { - OUString aName; - pos = aStr.indexOf(' '); - if (pos != -1) - { - aName = aStr.copy(0, pos); - aStr = aStr.copy(pos+1); - } - else - { - aName = aStr; - aStr = ""; - } - - if (aName.isEmpty()) - break; - - SwFieldType* pFT = rOut.GetDoc().getIDocumentFieldsAccess().InsertFldType( - SwSetExpFieldType( &rOut.GetDoc(), aName, nsSwGetSetExpType::GSE_STRING ) ); - pField = new SwSetExpField((SwSetExpFieldType*)pFT, aStr ); - ((SwSetExpField*)pField)->SetInputFlag( true ); - ((SwSetExpField*)pField)->SetSubType(nsSwExtendedSubType::SUB_INVISIBLE); - } - case 39: // filling command - pField = new SwInputField( - static_cast<SwInputFieldType*>(rOut.GetSysFldType( RES_INPUTFLD )), - OUString(), sFormula, - INP_TXT, 0, false ); - break; - case 51: // macro button - { - OUString aName; - pos = aStr.indexOf(' '); - if (pos != -1) - { - aName = aStr.copy(0, pos); - aStr = aStr.copy(pos+1); - } - else - { - aName = aStr; - aStr = ""; - } - - if (aName.isEmpty() || aStr.isEmpty()) - break; - - pField = new SwMacroField( (SwMacroFieldType*) - rOut.GetSysFldType( RES_MACROFLD ), - "StarOffice.Standard.Modul1." + aName, aStr ); - } - break; - case 55: // read tiff / or better: import anything - { - const sal_Unicode* pFormula = sFormula.getStr(); - const sal_Unicode* pDot = 0; - OUString sName; - while (*pFormula != '\0' && *pFormula != ' ') - { - // from here on an extension could appear - if (*pFormula == '.') - pDot = pFormula; - else - // so far we were in directories - if (*pFormula == '\\') - { - pDot = 0; - if (pFormula[1] == '\\') - pFormula++; - } - if (*pFormula != '\0') - sName += OUString(*pFormula++); - } - if( pDot ) - { - OUStringBuffer sBuf; - while( *pDot != '\0' && *pDot != ' ') - sBuf.append(*pDot++); - OUString sExt = sBuf.makeStringAndClear(); - - if( sExt.equalsIgnoreAsciiCase( ".tiff" ) - || sExt.equalsIgnoreAsciiCase( ".bmp" ) - || sExt.equalsIgnoreAsciiCase( ".gif" ) - || sExt.equalsIgnoreAsciiCase( ".pcx" ) - || sExt.equalsIgnoreAsciiCase( ".pic" )) - rOut.AddGraphic( sName ); - else - bKnown = false; - } - else - bKnown = false; - } - break; - default: // unknown - OSL_ENSURE(false, "Ww1PlainText"); - // unsupported: - case 1: // unknown - case 2: // possible bookmark - case 4: // index entry - // wwpar5: 1351/1454 - case 5: // footnote ref - case 7: // if command - case 8: // create index - // wwpar5: 1351/1454 - case 9: // table of contents entry - // wwpar5: 1351/1454 - case 10: // style ref - case 11: // doc ref - case 12: // seq ref - case 13: // create table of contents - // wwpar5: 1351/1454 - case 35: // literal text - // print merge: - case 40: // data command - case 41: // next command - case 42: // nextif command - case 43: // skipif command - case 44: // number of record - - case 45: // dde ref - case 46: // dde auto ref - case 47: // glossary entry - case 48: // print char - case 49: // formula def - case 50: // goto button - case 52: // auto number outline - case 53: // auto number legal - case 54: // auto number arabic - bKnown = false; - break; - } - if( bKnown || sResult == "\270" ) - this->sResult = ""; - else - this->sResult = sResult; - } - else // oops: we are terribly wrong: skip this - ++(*this); -} - -sal_uLong Ww1Fields::GetLength() -{ - // Calculates a field part's length, excluding the terminating - // chars in the text (19, 20, 21) meaning begin, separator and - // end, respectively. - sal_uLong ulBeg = Where(); - sal_uLong ulEnd = Where(nPlcIndex+1); - OSL_ENSURE(ulBeg<ulEnd, "Ww1Fields"); - return (ulEnd - ulBeg) - 1; -} - -void Ww1Sep::Start(Ww1Shell& rOut, Ww1Manager& rMan) -{ - if (rMan.Where() >= Where()) - { - rOut.NextSection(); - SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster(); - W1_DOP& rDOP = rMan.GetDop().GetDOP(); - rOut.GetPageDesc().SetLandscape(rDOP.fWideGet()); - SwFmtFrmSize aSz(rFmt.GetFrmSize()); - aSz.SetWidth(rDOP.xaPageGet()); - aSz.SetHeight(rDOP.yaPageGet()); - rFmt.SetFmtAttr(aSz); - SvxLRSpaceItem aLR(rDOP.dxaLeftGet()+rDOP.dxaGutterGet(), - rDOP.dxaRightGet(), 0, 0, RES_LR_SPACE); - rFmt.SetFmtAttr(aLR); - SvxULSpaceItem aUL(rDOP.dyaTopGet(), rDOP.dyaBottomGet(), RES_UL_SPACE); - rFmt.SetFmtAttr(aUL); - - // As soon as we've reached reading the start of the current - // sep's attribute, we insert it. This method is the same for - // most member classes of the manager. - sal_uInt8* pByte = GetData(); - Ww1SprmSep aSprm(rFib, SVBT32ToUInt32(pByte + 2)); - aSprm.Start(rOut, rMan); - aSprm.Stop(rOut, rMan); - ++(*this); - aHdd.Start(rOut, rMan); - } -} - -void Ww1Pap::Start(Ww1Shell& rOut, Ww1Manager& rMan) -{ - if (rMan.Where() >= Where()) - { - sal_uInt8* pByte; - sal_uInt16 cb; - // Supply the attributes to be started - if (FillStart(pByte, cb)) - { - Ww1SprmPapx aSprm(pByte, cb); - // and give the following output - aSprm.Start(rOut, rMan); - } - ++(*this); - } -} - -void Ww1Pap::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&) -{ - if (rMan.Where() >= Where() || rMan.IsStopAll()) - { - sal_uInt8* pByte; - sal_uInt16 cb; - if (FillStop(pByte, cb)){ - Ww1SprmPapx aSprm(pByte, cb); - aSprm.Stop(rOut, rMan); - }else{ - OSL_ENSURE( !nPlcIndex || rMan.IsStopAll(), "Pap-Attribut-Stop verloren" ); - } - } -} - -// Currently, the output of W1CHPxes cannot be solved only by define... -void W1_CHP::Out(Ww1Shell& rOut, Ww1Manager& rMan) -{ - if (fBoldGet()) - rOut << SvxWeightItem( - rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT); - if (fItalicGet()) - rOut << SvxPostureItem( - rOut.GetPostureItalic()?ITALIC_NONE:ITALIC_NORMAL, RES_CHRATR_POSTURE); - if (fStrikeGet()) - rOut << SvxCrossedOutItem( - rOut.GetCrossedOut()?STRIKEOUT_NONE:STRIKEOUT_SINGLE, RES_CHRATR_CROSSEDOUT); - if (fOutlineGet()) - rOut << SvxContourItem(!rOut.GetContour(), RES_CHRATR_CONTOUR); - if (fSmallCapsGet()) - rOut << SvxCaseMapItem( - rOut.GetCaseKapitaelchen()?SVX_CASEMAP_NOT_MAPPED:SVX_CASEMAP_KAPITAELCHEN, RES_CHRATR_CASEMAP); - if (fCapsGet()) - rOut << SvxCaseMapItem( - rOut.GetCaseVersalien()?SVX_CASEMAP_NOT_MAPPED:SVX_CASEMAP_VERSALIEN, RES_CHRATR_CASEMAP); - if (fsHpsGet()) - rOut << SvxFontHeightItem(hpsGet() * 10, 100, RES_CHRATR_FONTSIZE); - if (fsKulGet()) - switch (kulGet()) { - case 0: rOut << SvxUnderlineItem(UNDERLINE_NONE, RES_CHRATR_UNDERLINE) - << SvxWordLineModeItem(false, RES_CHRATR_WORDLINEMODE); - break; - case 1: rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE); - break; - case 2: rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE) - << SvxWordLineModeItem(true, RES_CHRATR_WORDLINEMODE); - break; - case 3: rOut << SvxUnderlineItem(UNDERLINE_DOUBLE, RES_CHRATR_UNDERLINE); - break; - case 4: rOut << SvxUnderlineItem(UNDERLINE_DOTTED, RES_CHRATR_UNDERLINE); - break; - default: OSL_ENSURE(false, "Chpx"); - } - - if (fsIcoGet()) - switch(icoGet()) { - default: OSL_ENSURE(false, "Chpx"); - //fall-through - case 0: { rOut.EndItem(RES_CHRATR_COLOR); } break; - case 1: { rOut << SvxColorItem(Color(COL_BLACK), RES_CHRATR_COLOR); } break; - case 2: { rOut << SvxColorItem(Color(COL_LIGHTBLUE), RES_CHRATR_COLOR); } break; - case 3: { rOut << SvxColorItem(Color(COL_LIGHTCYAN), RES_CHRATR_COLOR); } break; - case 4: { rOut << SvxColorItem(Color(COL_LIGHTGREEN), RES_CHRATR_COLOR); } break; - case 5: { rOut << SvxColorItem(Color(COL_LIGHTMAGENTA), RES_CHRATR_COLOR); } break; - case 6: { rOut << SvxColorItem(Color(COL_LIGHTRED), RES_CHRATR_COLOR); } break; - case 7: { rOut << SvxColorItem(Color(COL_YELLOW), RES_CHRATR_COLOR); } break; - case 8: { rOut << SvxColorItem(Color(COL_WHITE), RES_CHRATR_COLOR); } break; - } - if (fsSpaceGet()) { - short sQps = qpsSpaceGet(); - if (sQps > 56) - sQps = sQps - 64; - rOut << SvxKerningItem(sQps, RES_CHRATR_KERNING); - } - if (fsPosGet()) { - if (hpsPosGet() == 0) - rOut << SvxEscapementItem(SVX_ESCAPEMENT_OFF, 100, RES_CHRATR_ESCAPEMENT); - else { - short sHps = hpsPosGet(); - if (sHps > 128) - sHps = sHps - 256; - sHps *= 100; - sHps /= 24; - rOut << SvxEscapementItem(sHps, 100, RES_CHRATR_ESCAPEMENT); - } - } - if (fsFtcGet()) { - SvxFontItem aFont(rMan.GetFont(ftcGet())); - rOut << aFont; - } -} - -void Ww1Chp::Start(Ww1Shell& rOut, Ww1Manager& rMan) -{ - if (rMan.Where() >= Where()) - { - W1_CHP aChpx; - if (FillStart(aChpx)) - { - aChpx.Out(rOut, rMan); - if (aChpx.fcPicGet()) - { - Ww1Picture aPic(rMan.GetFib().GetStream(), - aChpx.fcPicGet()); - if (!aPic.GetError()) - aPic.Out(rOut, rMan); - } - } - ++(*this); - } -} - -void Ww1Chp::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&) -{ - if (rMan.Where() >= Where()) - { - W1_CHP aChpx; - if (FillStop(aChpx)) - { - // First all toggle flags - if (aChpx.fBoldGet()) - rOut.EndItem(RES_CHRATR_WEIGHT); - if (aChpx.fItalicGet()) - rOut.EndItem(RES_CHRATR_POSTURE); - if (aChpx.fStrikeGet()) - rOut.EndItem(RES_CHRATR_CROSSEDOUT); - if (aChpx.fOutlineGet()) - rOut.EndItem(RES_CHRATR_CONTOUR); - if (aChpx.fSmallCapsGet() || aChpx.fCapsGet()) - rOut.EndItem(RES_CHRATR_CASEMAP); - // then all number values; these have flags when they are set... - if (aChpx.fsHpsGet()) - rOut.EndItem(RES_CHRATR_FONTSIZE); - if (aChpx.fsKulGet()) - rOut.EndItem(RES_CHRATR_UNDERLINE) - .EndItem(RES_CHRATR_WORDLINEMODE); - if (aChpx.fsIcoGet()) - rOut.EndItem(RES_CHRATR_COLOR); - if (aChpx.fsSpaceGet()) - rOut.EndItem(RES_CHRATR_KERNING); - if (aChpx.fsPosGet()) - rOut.EndItem(RES_CHRATR_ESCAPEMENT); - if (aChpx.fsFtcGet()) - rOut.EndItem(RES_CHRATR_FONT); - }else{ - OSL_ENSURE( !nPlcIndex, "Lost Chp-Attribut-Stop" ); - } - } -} - -void Ww1Style::Out(Ww1Shell& rOut, Ww1Manager& rMan) -{ - // Base first, so that base style attributes can be recognized - // first: Base - if(pParent->GetStyle(stcBase).IsUsed() ) // Base valid ? - rOut.BaseStyle(stcBase); - - // next of all: CHP - aChpx.Out(rOut, rMan); - // Last: PAP - if (pPapx) - pPapx->Start(rOut, rMan); -} - -// The Out() methods output a number of characters to the shell, a -// string or a character. The amount of output is determined by ulEnd, -// which specifies the position at which to stop. Control characters -// also end the output. -// They are defined by MinChar. All characters with a value lower than -// that are treated as control characters. This classification is -// handled by IsChar. If a control character is encountered, the -// output method returns immediately and returns it. Pay attention to -// this; ulEnd might not have been reached if !IsChar(Out(...)). In -// this case, the control character has been consumed, but not been -// output. -sal_Unicode Ww1PlainText::Out( Ww1Shell& rOut, sal_uLong& ulEnd ) -{ - if (ulEnd > Count()) - ulEnd = Count(); - while (ulSeek < ulEnd) - { - sal_Unicode c = (*this)[ulSeek]; - ++(*this); - if (Ww1PlainText::IsChar(c)) - rOut << c; - else - return c; - } - return Ww1PlainText::MinChar; -} - -sal_Unicode Ww1PlainText::Out(OUString& rStr, sal_uLong ulEnd) -{ - // Like Out(Shell..., but output into a string - rStr = ""; - if (ulEnd > Count()) - ulEnd = Count(); - while (ulSeek < ulEnd) - { - sal_Unicode c = (*this)[ulSeek]; - ++(*this); - if( Ww1PlainText::IsChar(c) ) - rStr += OUString(c); - else - return c; - } - return Ww1PlainText::MinChar; -} - -// This makes ulEnd unnecessary, right? -sal_Unicode Ww1PlainText::Out( sal_Unicode& rRead ) -{ - rRead = (*this)[ulSeek]; - ++(*this); - return rRead; -} - -void Ww1SprmPapx::Start(Ww1Shell& rOut, Ww1Manager& rMan) -{ - if( !rMan.IsInStyle() ){ // Normal attributes apply within style - if (!rOut.IsInFly() - && !rOut.IsInTable() - && ( rMan.HasPPc() || rMan.HasPDxaAbs())){ // Fly-Start - rOut.BeginFly(); // eAnchor ); - } - if (!rOut.IsInTable() && rMan.HasInTable()) - { - rOut.BeginTable(); - } - rOut.SetStyle(aPapx.stcGet()); - } - Ww1Sprm::Start(rOut, rMan); -} - -void Ww1SprmPapx::Stop(Ww1Shell& rOut, Ww1Manager& rMan) -{ - Ww1Sprm::Stop(rOut, rMan); - - if( !rMan.IsInStyle() ) // Normal attributes apply within style - { - if (rOut.IsInTable() &&( rMan.IsStopAll() || !rMan.HasInTable())) - rOut.EndTable(); - - if( rOut.IsInFly() && - ( rMan.IsStopAll() - || ( !rMan.HasPPc() && !rMan.HasPDxaAbs() // Fly end - && !rOut.IsInTable()))) - rOut.EndFly(); - } -} - -SvxFontItem Ww1Fonts::GetFont(sal_uInt16 nFCode) -{ - // Create a font in sw fashion from existing word structures - FontFamily eFamily = FAMILY_DONTKNOW; - OUString aName; - FontPitch ePitch = PITCH_DONTKNOW; - rtl_TextEncoding eCharSet = RTL_TEXTENCODING_DONTKNOW; - switch (nFCode) - { - // In the Winword 1.x format, the names of the first three fonts were - // omitted from the table and assumed to be "Tms Rmn" (for ftc = 0), - // "Symbol", and "Helv" - case 0: - eFamily = FAMILY_ROMAN; - aName = "Tms Rmn"; - ePitch = PITCH_VARIABLE; - eCharSet = RTL_TEXTENCODING_MS_1252; - break; - case 1: - aName = "Symbol"; - ePitch = PITCH_VARIABLE; - eCharSet = RTL_TEXTENCODING_SYMBOL; - break; - case 2: - eFamily = FAMILY_SWISS; - aName = "Helv"; - ePitch = PITCH_VARIABLE; - eCharSet = RTL_TEXTENCODING_MS_1252; - break; - default: - { - W1_FFN* pF = GetFFN(nFCode - 3); - if (pF != 0) - { - // Fontname - aName = OUString( (sal_Char*)pF->szFfnGet(), strlen( (sal_Char*)pF->szFfnGet() ), - RTL_TEXTENCODING_MS_1252 ); - // Pitch - static const FontPitch ePitchA[] = - { - PITCH_DONTKNOW, PITCH_FIXED, PITCH_VARIABLE, PITCH_DONTKNOW - }; - ePitch = ePitchA[pF->prgGet()]; - // CharSet - eCharSet = RTL_TEXTENCODING_MS_1252; - if (aName.equalsIgnoreAsciiCase("Symbol") - || aName.equalsIgnoreAsciiCase("Symbol Set") - || aName.equalsIgnoreAsciiCase("Wingdings") - || aName.equalsIgnoreAsciiCase("ITC Zapf Dingbats") ) - eCharSet = RTL_TEXTENCODING_SYMBOL; - // FontFamily - sal_uInt16 b = pF->ffGet(); - static const FontFamily eFamilyA[] = - { - FAMILY_DONTKNOW, FAMILY_ROMAN, FAMILY_SWISS, FAMILY_MODERN, - FAMILY_SCRIPT, FAMILY_DECORATIVE - }; - if (b < (sizeof(eFamilyA)/sizeof(eFamilyA[0]))) - eFamily = eFamilyA[b]; - } - else - { - OSL_ENSURE(false, "WW1Fonts::GetFont: Non-existent font !"); - eFamily = FAMILY_SWISS; - aName = "Helv"; - ePitch = PITCH_VARIABLE; - eCharSet = RTL_TEXTENCODING_MS_1252; - } - } - break; - } - if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) - && ( aName.equalsIgnoreAsciiCase("Helv") - || aName.equalsIgnoreAsciiCase("Helvetica") ) ) - { - aName = "Helvetica Neue"; - if (eFamily==FAMILY_DONTKNOW) - eFamily = FAMILY_SWISS; - } - else - { - // VCL matches fonts on its own - // Unfortunately, this breaks for Helv, Tms Rmn and System - // Monospaced, so they need to be replaced. - // According to TH they should be replaced by fixed values, - // not using System::GetStandardFont, so no name lists appear - // (this could confuse the user) - if( aName.equalsIgnoreAsciiCase("Helv")) - { - aName = "Helvetica"; - if (eFamily==FAMILY_DONTKNOW) - eFamily = FAMILY_SWISS; - } - else if (aName.equalsIgnoreAsciiCase("Tms Rmn")) - { - aName = "Times New Roman"; - if (eFamily==FAMILY_DONTKNOW) - eFamily = FAMILY_ROMAN; - } - else if (aName.equalsIgnoreAsciiCase("System Monospaced") ) - { - aName = "Courier"; - ePitch = PITCH_FIXED; - } - } - return SvxFontItem(eFamily, aName, OUString(), ePitch, eCharSet, RES_CHRATR_FONT); -} - -void Ww1Dop::Out(Ww1Shell& rOut) -{ - //~ mdt: missing - long nDefTabSiz = aDop.dxaTabGet(); - if (nDefTabSiz < 56) - nDefTabSiz = 709; - - // we want exactly one DefaultTab - SvxTabStopItem aNewTab(1, sal_uInt16(nDefTabSiz), SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP); - ((SvxTabStop&)aNewTab[0]).GetAdjustment() = SVX_TAB_ADJUST_DEFAULT; - rOut.GetDoc().GetAttrPool().SetPoolDefaultItem( aNewTab); //~ mdt: better (GetDoc) - - SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster(); - W1_DOP& rDOP = GetDOP(); - rOut.GetPageDesc().SetLandscape(rDOP.fWideGet()); - SwFmtFrmSize aSz(rFmt.GetFrmSize()); - aSz.SetWidth(rDOP.xaPageGet()); - aSz.SetHeight(rDOP.yaPageGet()); - rFmt.SetFmtAttr(aSz); - SvxLRSpaceItem aLR(rDOP.dxaLeftGet()+rDOP.dxaGutterGet(), - rDOP.dxaRightGet(), 0, 0, RES_LR_SPACE); - rFmt.SetFmtAttr(aLR); - SvxULSpaceItem aUL(rDOP.dyaTopGet(), rDOP.dyaBottomGet(), RES_UL_SPACE); - rFmt.SetFmtAttr(aUL); - - SwFtnInfo aInfo; - aInfo = rOut.GetDoc().GetFtnInfo(); // Copy-Ctor private - // where positioned ? ( 0 == Section, 1 == Page, - // 2 == next to Text -> Page, 3 == Doc ) - switch( rDOP.fpcGet() ){ - case 1: - case 2: aInfo.ePos = FTNPOS_PAGE; break; - default: aInfo.ePos = FTNPOS_CHAPTER; break; - } - // Always doc, because Sw seems to interpret Chapter differently from PMW - aInfo.eNum = FTNNUM_DOC; - // how to renumber ? - // SW-UI allows number only with FTNNUM_DOC - if( rDOP.nFtnGet() > 0 && aInfo.eNum == FTNNUM_DOC ) - aInfo.nFtnOffset = rDOP.nFtnGet() - 1; - rOut.GetDoc().SetFtnInfo( aInfo ); - -} - -void Ww1Assoc::Out(Ww1Shell& rOut) -{ - //~ mdt: missing: FileNext, Dot, DataDoc, HeaderDoc, Criteria1, - // Criteria2, Criteria3, Criteria4, Criteria5, Criteria6, Criteria7 - SwDocShell *pDocShell(rOut.GetDoc().GetDocShell()); - OSL_ENSURE(pDocShell, "no SwDocShell"); - if (pDocShell) { - uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - pDocShell->GetModel(), uno::UNO_QUERY_THROW); - uno::Reference<document::XDocumentProperties> xDocProps( - xDPS->getDocumentProperties()); - OSL_ENSURE(xDocProps.is(), "DocumentProperties is null"); - if (xDocProps.is()) { - xDocProps->setTitle( GetStr(Title) ); - xDocProps->setSubject( GetStr(Subject) ); - xDocProps->setDescription( GetStr(Comments) ); - xDocProps->setKeywords( - ::comphelper::string::convertCommaSeparated( GetStr(KeyWords) ) ); - xDocProps->setAuthor( GetStr(Author) ); - xDocProps->setModifiedBy( GetStr(LastRevBy) ); - } - } -} - -void Ww1StyleSheet::OutDefaults(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc) -{ - switch (stc){ - case 222: // Null - rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE); - rOut << SvxFontItem(rMan.GetFont(2)); - break; - case 223: // annotation reference - rOut << SvxFontHeightItem(160, 100, RES_CHRATR_FONTSIZE); - break; - case 224: // annotation text - rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE); - break; - case 225: // table of contents 8 - case 226: // table of contents 7 - case 227: // table of contents 6 - case 228: // table of contents 5 - case 229: // table of contents 4 - case 230: // table of contents 3 - case 231: // table of contents 2 - case 232: // table of contents 1 - rOut << SvxLRSpaceItem(( 232 - stc ) * 720, 720, 0, 0, RES_LR_SPACE); - // tabs still missing ! - break; - case 233: // index 7 - case 234: // and index 6 - case 235: // and index 5 - case 236: // and index 4 - case 237: // and index 3 - case 238: // and index 2 - rOut << SvxLRSpaceItem(( 239 - stc ) * 360, 0, 0, 0, RES_LR_SPACE); - break; - case 239: // index 1 - break; - case 240: // line number - break; - case 241: // index heading - break; - case 242: // footer - case 243:{ // ... and header - SvxTabStopItem aAttr(RES_PARATR_TABSTOP); - SvxTabStop aTabStop; - aTabStop.GetTabPos() = 4535; // 8 cm - aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER; - aAttr.Insert( aTabStop ); - aTabStop.GetTabPos() = 9071; // 16 cm - aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT; - aAttr.Insert( aTabStop ); - rOut << aAttr; - } - break; - case 244: // footnote reference - rOut << SvxFontHeightItem(160, 100, RES_CHRATR_FONTSIZE); - rOut << SvxEscapementItem(6 * 100 / 24, 100, RES_CHRATR_ESCAPEMENT); - break; - case 245: // footnote text - rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE); - break; - case 246: // heading 9 - case 247: // und heading 8 - case 248: // und heading 7 - rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE); - rOut << SvxPostureItem( - rOut.GetPostureItalic()?ITALIC_NONE:ITALIC_NORMAL, RES_CHRATR_POSTURE); - rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE); - break; - case 249: // heading 6 - rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE); - rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE); - rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE); - break; - case 250: // heading 5 - rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE); - rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT); - rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE); - break; - case 251: // heading 4 - rOut << SvxLRSpaceItem(360, 0, 0, 0, RES_LR_SPACE); - rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE); - rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE); - break; - case 252: // heading 3 - rOut << SvxLRSpaceItem(360, 0, 0, 0, RES_LR_SPACE); - rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT); - rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE); - break; - case 253: // heading 2 - rOut << SvxULSpaceItem(120, 0, RES_UL_SPACE); - rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT); - rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE); - rOut << SvxFontItem(rMan.GetFont(2)); - break; - case 254: // heading 1 - rOut << SvxULSpaceItem(240, 0, RES_UL_SPACE); - rOut << SvxWeightItem(rOut.GetWeightBold()?WEIGHT_NORMAL:WEIGHT_BOLD, RES_CHRATR_WEIGHT); - rOut << SvxUnderlineItem(UNDERLINE_SINGLE, RES_CHRATR_UNDERLINE); - rOut << SvxFontHeightItem(240, 100, RES_CHRATR_FONTSIZE); - rOut << SvxFontItem(rMan.GetFont(2)); - break; - case 255: // Normal indent - rOut << SvxLRSpaceItem(720, 0, 0, 0, RES_LR_SPACE); - break; - case 0: // Normal - rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE); - break; - default: // custom defined - rOut << SvxFontHeightItem(200, 100, RES_CHRATR_FONTSIZE); - break; - } -} - -void Ww1StyleSheet::OutOne(Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 stc) -{ - const RES_POOL_COLLFMT_TYPE RES_NONE = RES_POOLCOLL_DOC_END; - RES_POOL_COLLFMT_TYPE aType = RES_NONE; - - switch (stc) - { - case 222: // Null - aType = RES_POOLCOLL_TEXT; break; //??? - case 223: // annotation reference - break; - case 224: // annotation text - break; - case 225: // table of contents 8 - aType = RES_POOLCOLL_TOX_CNTNT8; break; - case 226: // table of contents 7 - aType = RES_POOLCOLL_TOX_CNTNT7; break; - case 227: // table of contents 6 - aType = RES_POOLCOLL_TOX_CNTNT6; break; - case 228: // table of contents 5 - aType = RES_POOLCOLL_TOX_CNTNT5; break; - case 229: // table of contents 4 - aType = RES_POOLCOLL_TOX_CNTNT4; break; - case 230: // table of contents 3 - aType = RES_POOLCOLL_TOX_CNTNT3; break; - case 231: // table of contents 2 - aType = RES_POOLCOLL_TOX_CNTNT2; break; - case 232: // table of contents 1 - aType = RES_POOLCOLL_TOX_CNTNT1; break; - case 233: // index 7 - break; - case 234: // index 6 - break; - case 235: // index 5 - break; - case 236: // index 4 - break; - case 237: // index 3 - aType = RES_POOLCOLL_TOX_IDX3; break; - case 238: // index 2 - aType = RES_POOLCOLL_TOX_IDX2; break; - case 239: // index 1 - aType = RES_POOLCOLL_TOX_IDX1; break; - case 240: // line number - break; - case 241: // index heading - break; - case 242: // footer - aType = RES_POOLCOLL_FOOTER; break; - case 243: // header - aType = RES_POOLCOLL_HEADER; break; - case 244: // footnote reference - break; - case 245: // footnote text - aType = RES_POOLCOLL_FOOTNOTE; break; - case 246: // heading 9 - break; - case 247: // heading 8 - break; - case 248: // heading 7 - break; - case 249: // heading 6 - break; - case 250: // heading 5 - aType = RES_POOLCOLL_HEADLINE5; break; - case 251: // heading 4 - aType = RES_POOLCOLL_HEADLINE4; break; - case 252: // heading 3 - aType = RES_POOLCOLL_HEADLINE3; break; - case 253: // heading 2 - aType = RES_POOLCOLL_HEADLINE2; break; - case 254: // heading 1 - aType = RES_POOLCOLL_HEADLINE1; break; - case 255: // Normal indent - aType = RES_POOLCOLL_TEXT_IDENT; break; - case 0: // Normal - aType = RES_POOLCOLL_STANDARD; break; - } - if (aType == RES_NONE) - rOut.BeginStyle(stc, GetStyle(stc).GetName() ); - else - rOut.BeginStyle(stc, aType); - OutDefaults(rOut, rMan, stc); - GetStyle(stc).Out(rOut, rMan); - rOut.EndStyle(); -} -// OutOneWithBase() reads a style using OutOne() -// Additionally, it reads the base style, if this has not happened yet -void Ww1StyleSheet::OutOneWithBase(Ww1Shell& rOut, Ww1Manager& rMan, - sal_uInt16 stc, sal_uInt8* pbStopRecur ) -{ -// SH: reading linearly is shit, because BasedOn cannot be set. Also, -// toggle and modify attributes (tabs, for example) don't work. - - Ww1Style& rSty = GetStyle(stc); - sal_uInt16 nBase = rSty.GetnBase(); - if( nBase != stc - && !rOut.IsStyleImported( nBase ) - && GetStyle(nBase).IsUsed() - && !pbStopRecur[nBase] ){ - - pbStopRecur[nBase] = 1; - OutOneWithBase( rOut, rMan, nBase, pbStopRecur ); // Recursive - } - OutOne( rOut, rMan, stc ); -} - -void Ww1StyleSheet::Out(Ww1Shell& rOut, Ww1Manager& rMan) -{ - sal_uInt16 stc; - sal_uInt8 bStopRecur[256]; - memset( bStopRecur, sal_False, sizeof(bStopRecur) ); - -// First pass: Styles with base styles recursively - for (stc=0;stc<Count();stc++) - if (GetStyle(stc).IsUsed() && !rOut.IsStyleImported( stc ) ) - OutOneWithBase( rOut, rMan, stc, bStopRecur ); - -// Second pass: Follow-Styles - for (stc=0;stc<Count();stc++){ - Ww1Style& rSty = GetStyle(stc); - if ( rSty.IsUsed() ){ - sal_uInt16 nNext = rSty.GetnNext(); - if( nNext != stc && GetStyle(nNext).IsUsed() ) - rOut.NextStyle( stc, nNext ); - } - } -} - -// Picture -static sal_uLong GuessPicSize(W1_PIC* pPic) -{ - sal_uInt16 maxx = pPic->mfp.xExtGet(); - sal_uInt16 padx = ((maxx + 7) / 8) * 8; - sal_uInt16 maxy = pPic->mfp.yExtGet(); - return 120L + (sal_uLong)padx * maxy; -} - -// Reads 4-bit format, writes 8-bit -void Ww1Picture::WriteBmp(SvStream& rOut) -{ - long nSize = pPic->lcbGet() - (sizeof(*pPic)-sizeof(pPic->rgb)); - sal_uInt8* p = &pPic->rgbGet(); - sal_uInt16 maxx = pPic->mfp.xExtGet(); - sal_uInt16 padx = ((maxx + 7) / 8) * 8; - sal_uInt16 maxy = pPic->mfp.yExtGet(); - - p+= sizeof(SVBT16); nSize -= sizeof(SVBT16); - p+= sizeof(SVBT16); nSize -= sizeof(SVBT16); -#if OSL_DEBUG_LEVEL > 0 - sal_uInt16 x = SVBT16ToShort(p); - (void) x; -#endif - p+= sizeof(SVBT16); nSize -= sizeof(SVBT16); -#if OSL_DEBUG_LEVEL > 0 - sal_uInt16 y = SVBT16ToShort(p); - (void) y; -#endif - p+= sizeof(SVBT16); nSize -= sizeof(SVBT16); -#if OSL_DEBUG_LEVEL > 0 - sal_uInt16 planes = SVBT16ToShort(p); - (void) planes; -#endif - p+= sizeof(SVBT16); nSize -= sizeof(SVBT16); -#if OSL_DEBUG_LEVEL > 0 - sal_uInt16 bitcount = SVBT16ToShort(p); - (void) bitcount; -#endif - p+= sizeof(SVBT16); nSize -= sizeof(SVBT16); - -#if OSL_DEBUG_LEVEL > 0 - OSL_ENSURE(x==maxx, "Ww1Picture"); - OSL_ENSURE(y==maxy, "Ww1Picture"); - OSL_ENSURE(planes==1, "Ww1Picture"); - OSL_ENSURE(bitcount==4, "Ww1Picture"); -#endif - - OSL_ENSURE(16*3+padx*maxy/2==nSize, "Ww1Picture"); - - SVBT32 tmpLong; - SVBT16 tmpShort; - sal_uInt8 tmpByte; -#define wLong(n) \ - UInt32ToSVBT32(n, tmpLong); \ - if ((rOut.Write(tmpLong, sizeof(SVBT32))) != sizeof(SVBT32)) goto error; -#define wShort(n) \ - ShortToSVBT16(n, tmpShort); \ - if ((rOut.Write(tmpShort, sizeof(SVBT16))) != sizeof(SVBT16)) goto error; -#define wByte(n) \ - tmpByte = n; \ - if ((rOut.Write(&tmpByte, sizeof(sal_uInt8))) != sizeof(sal_uInt8)) goto error; - wByte('B'); wByte('M'); - wLong(54 + 4 * 16 + padx * maxy); - wLong(0); - wLong(54 + 4 * 16); - wLong(40); - wLong(maxx); - wLong(maxy); - wShort(1); - wShort(8); - wLong(0); - wLong(0); - wLong(0); - wLong(0); - wLong(16); - wLong(16); - sal_uInt16 i; - for (i=0;nSize>0&&i<16;i++) - { - wByte(*p); - p++; - nSize -= sizeof(sal_uInt8); - wByte(*p); - p++; - nSize -= sizeof(sal_uInt8); - wByte(*p); - p++; - nSize -= sizeof(sal_uInt8); - wByte(0); - } - OSL_ENSURE(padx*maxy/2==nSize, "Ww1Picture"); - sal_uInt16 j; - { - sal_uInt8* pBuf = new sal_uInt8[padx]; - for (j=0;nSize>0&&j<maxy;j++) - { - sal_uInt8* q = pBuf; - for (i=0;nSize>0&&i<maxx;i+=2) - { - *q++ = *p>>4; - *q++ = *p&0xf; - p++; - nSize -= sizeof(sal_uInt8); - } - for (;i<padx;i+=2) - { - *q++ = 0; - p++; - nSize -= sizeof(sal_uInt8); - } - if(rOut.Write(pBuf, padx) != padx){ - delete [] pBuf; - goto error; - } - } - delete [] pBuf; - } - OSL_ENSURE(nSize==0, "Ww1Picture"); -#undef wLong -#undef wShort -#undef wByte - rOut.Seek(0); - return; -error: - ; -} - -void Ww1Picture::Out(Ww1Shell& rOut, Ww1Manager& /*rMan*/) -{ - Graphic* pGraphic = 0; - sal_uInt16 mm; - switch (mm = pPic->mfp.mmGet()) - { - case 8: // embedded metafile - { - SvMemoryStream aOut(8192, 8192); - aOut.Write(&pPic->rgbGet(), pPic->lcbGet() - - (sizeof(*pPic)-sizeof(pPic->rgb))); - aOut.Seek(0); - GDIMetaFile aWMF; - if (ReadWindowMetafile( aOut, aWMF, NULL ) && aWMF.GetActionSize() > 0) - { - aWMF.SetPrefMapMode(MapMode(MAP_100TH_MM)); - Size aOldSiz(aWMF.GetPrefSize()); - Size aNewSiz(pPic->mfp.xExtGet(), pPic->mfp.yExtGet()); - boost::rational<sal_Int64> aFracX(aNewSiz.Width(), aOldSiz.Width()); - boost::rational<sal_Int64> aFracY(aNewSiz.Height(), aOldSiz.Height()); - aWMF.Scale(aFracX, aFracY); - aWMF.SetPrefSize(aNewSiz); - pGraphic = new Graphic(aWMF); - } - break; - } - case 94: // embedded name SH:??? Which one is it? Embedded or Name ? - case 98: // TIFF name - { - OUString aDir( (sal_Char*)&pPic->rgbGet(), - (sal_uInt16)(pPic->lcbGet() - (sizeof(*pPic)-sizeof(pPic->rgb))), - RTL_TEXTENCODING_MS_1252 ); - - rOut.AddGraphic( aDir ); - } - break; - case 97: // embedded bitmap - { - sal_uLong nSiz = GuessPicSize(pPic); - SvMemoryStream aOut(nSiz, 8192); - WriteBmp(aOut); - Bitmap aBmp; - ReadDIB(aBmp, aOut, true); - pGraphic = new Graphic(aBmp); - } - //fall-through - default: - OSL_ENSURE(pPic->mfp.mmGet() == 97, "Ww1Picture"); - } - if (pGraphic) - rOut << *pGraphic; -} - -void Ww1HeaderFooter::Start(Ww1Shell& rOut, Ww1Manager& rMan) -{ - // Only gets called for SEPs anyway, no further validation necessary: - if (!rMan.Pushed()) - { - while (++(*this)) - switch (eHeaderFooterMode) - { - case FtnSep: - break; - case FtnFollowSep: - break; - case FtnNote: - break; - case EvenHeadL: - break; - case OddHeadL: - { - sal_uLong begin = 0; - sal_uLong end = 0; - if (FillOddHeadL(begin, end)) - { - Ww1HddText* pText = new Ww1HddText(rMan.GetFib()); - pText->Seek(begin); - pText->SetCount(end-begin); - rOut.BeginHeader(); - rMan.Push1(pText, pText->Offset(rMan.GetFib()), begin, - new Ww1HeaderFooterFields(rMan.GetFib())); - rOut << rMan; - rMan.Pop(); - rOut.EndHeaderFooter(); - return; - } - } - break; - case EvenFootL: - break; - case OddFootL: - { - sal_uLong begin = 0; - sal_uLong end = 0; - if (FillOddFootL(begin, end)) - { - Ww1HddText* pText = new Ww1HddText(rMan.GetFib()); - pText->Seek(begin); - pText->SetCount(end-begin); - rOut.BeginFooter(); - rMan.Push1(pText, pText->Offset(rMan.GetFib()), begin, - new Ww1HeaderFooterFields(rMan.GetFib())); - rOut << rMan; - rMan.Pop(); - rOut.EndHeaderFooter(); - return; - } - } - break; - case FirstHeadL: - break; - default: - break; - } - } -} - -void Ww1HeaderFooter::Stop(Ww1Shell& rOut, Ww1Manager& rMan, sal_Unicode&) -{ - if (!rMan.Pushed() && eHeaderFooterMode != None) - { - Start(rOut, rMan); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww1/w1par.cxx b/sw/source/filter/ww1/w1par.cxx deleted file mode 100644 index d57f7d82dbcc..000000000000 --- a/sw/source/filter/ww1/w1par.cxx +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <pam.hxx> -#include <doc.hxx> -#include <ndtxt.hxx> -#include <fltini.hxx> -#include <w1par.hxx> -#include <swfltopt.hxx> -#include <mdiexp.hxx> -#include <swerror.h> -#include <statstr.hrc> - -// Initializing the field FilterFlags -static sal_uLong WW1_Read_FieldIniFlags() -{ - // sal_uInt16 i; - static const sal_Char* aNames[ 1 ] = { "WinWord/WW1F" }; - sal_uInt32 aVal[ 1 ]; - SwFilterOptions aOpt( 1, aNames, aVal ); - sal_uLong nFieldFlags = aVal[ 0 ]; - - if ( SwFltGetFlag( nFieldFlags, SwFltControlStack::HYPO ) ) - { - SwFltSetFlag( nFieldFlags, SwFltControlStack::BOOK_TO_VAR_REF ); - SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_DO_ID ); - SwFltSetFlag( nFieldFlags, SwFltControlStack::TAGS_IN_TEXT ); - SwFltSetFlag( nFieldFlags, SwFltControlStack::ALLOW_FLD_CR ); - } - return nFieldFlags; -} - -// StarWriter-Interface -// One method returns the call interface for the Writer. -// Read() reads a file. For this, two objects get created. The Shell, -// which collects all information, and the manager, which reads it -// from the file. -sal_uLong WW1Reader::Read(SwDoc& rDoc, const OUString& rBaseURL, SwPaM& rPam, const OUString& /*cName*/) -{ - sal_uLong nRet = ERR_SWG_READ_ERROR; - OSL_ENSURE(pStrm!=NULL, "W1-Read without Stream"); - if (pStrm != NULL) - { - bool bNew = !bInsertMode; // New Doc ( no insert ) - - sal_uLong nFieldFlags = WW1_Read_FieldIniFlags(); - Ww1Shell* pRdr = new Ww1Shell( rDoc, rPam, rBaseURL, bNew, nFieldFlags ); - if( pRdr ) - { - Ww1Manager* pMan = new Ww1Manager( *pStrm, nFieldFlags ); - if( pMan ) - { - if( !pMan->GetError() ) - { - ::StartProgress( STR_STATSTR_W4WREAD, 0, 100, - rDoc.GetDocShell() ); - ::SetProgressState( 0, rDoc.GetDocShell() ); - // just push everything over now - *pRdr << *pMan; - if( !pMan->GetError() ) - // signal absence of errors - nRet = 0; // would be better: WARN_SWG_FEATURES_LOST; - ::EndProgress( rDoc.GetDocShell() ); - } - else - { - if( pMan->GetFib().GetFIB().fComplexGet() ) - nRet = ERR_WW6_FASTSAVE_ERR; - } - } - delete pMan; - } - delete pRdr; - } - Ww1Sprm::DeinitTab(); - return nRet; -} - -// The shell is the interface from filter to Writer. It is derived -// from SwFltShell and contains all relevant extensions for ww1. -// SwFltShell is used in common with ww-filter. Information read from -// the file gets 'piped' into the shell, like would be done for a -// stream. -Ww1Shell::Ww1Shell( SwDoc& rD, SwPaM& rPam, const OUString& rBaseURL, bool bNew, sal_uLong nFieldFlags) - : SwFltShell(&rD, rPam, rBaseURL, bNew, nFieldFlags) -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww1/w1par.hxx b/sw/source/filter/ww1/w1par.hxx deleted file mode 100644 index 51463a800378..000000000000 --- a/sw/source/filter/ww1/w1par.hxx +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SW_SOURCE_FILTER_WW1_W1PAR_HXX -#define INCLUDED_SW_SOURCE_FILTER_WW1_W1PAR_HXX - -#include <fltshell.hxx> -#include <w1class.hxx> - -class Ww1Shell : public SwFltShell -{ -public: - Ww1Shell(SwDoc&, SwPaM&, const OUString& rBaseURL, bool bNew, sal_uLong nFieldFlags); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww1/w1sprm.cxx b/sw/source/filter/ww1/w1sprm.cxx deleted file mode 100644 index dea460de6d79..000000000000 --- a/sw/source/filter/ww1/w1sprm.cxx +++ /dev/null @@ -1,632 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <hintids.hxx> -#include <tools/solar.h> -#include <editeng/paperinf.hxx> -#include <editeng/lrspitem.hxx> -#include <editeng/adjustitem.hxx> -#include <editeng/spltitem.hxx> -#include <editeng/keepitem.hxx> -#include <editeng/boxitem.hxx> -#include <editeng/shaditem.hxx> -#include <editeng/ulspitem.hxx> -#include <editeng/lspcitem.hxx> -#include <editeng/tstpitem.hxx> -#include <fmtclds.hxx> -#include <fmtfsize.hxx> -#include <pam.hxx> -#include <ndtxt.hxx> -#include <charatr.hxx> -#include <frmatr.hxx> -#include <doc.hxx> -#include <fltini.hxx> -#include <docufld.hxx> -#include <pagedesc.hxx> -#include <flddat.hxx> -#include <reffld.hxx> -#include <expfld.hxx> -#include <w1par.hxx> -#include <mdiexp.hxx> -#include <swerror.h> -#include <statstr.hrc> - -using ::editeng::SvxBorderLine; -using namespace ::com::sun::star; - -void Ww1Sprm::Stop( Ww1Shell& rOut, Ww1Manager& rMan) -{ - if(IsUsed()) - for(short i=Count()-1;i>=0;i--){ // backwards - sal_uInt8 nId; - sal_uInt16 nSize; - sal_uInt8* pSprm; - Fill(i, nId, nSize, pSprm); - GetTab(nId).Stop(rOut, nId, pSprm, nSize, rMan); - } -} - -void Ww1Sprm::Start( - Ww1Shell& rOut, Ww1Manager& rMan, sal_uInt16 i) -{ - sal_uInt8 nId; - sal_uInt16 nSize; - sal_uInt8* pSprm; - Fill(i, nId, nSize, pSprm); - GetTab(nId).Start(rOut, nId, pSprm, nSize, rMan); -} - -void Ww1Sprm::Start( - Ww1Shell& rOut, Ww1Manager& rMan) -{ - if(IsUsed()) - for(sal_uInt16 i=0;i<Count();i++) - Start(rOut, rMan, i); -} - -void Ww1SingleSprm::Start( - Ww1Shell&, sal_uInt8 /*nId*/, sal_uInt8*, sal_uInt16, Ww1Manager&) -{ -} - -void Ww1SingleSprm::Stop( - Ww1Shell&, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) -{ -// OSL_ENSURE(FALSE, "Unknown Sprm"); -} - -// STOP -// The following defines are used for implementing the SingleSprm -// classes' Stop() members, because they normally merely put -// EndItem(s) into the shell. -#define STOP1(Class, Code) \ - void Class::Stop( \ - Ww1Shell& rOut, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) { \ - rOut.EndItem(Code); } -#define STOP2(Class, Code1, Code2) \ - void Class::Stop( \ - Ww1Shell& rOut, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager&) { \ - rOut.EndItem(Code1).EndItem(Code2); } - -// SingleSprmXxxxx -// This starts the evaluation of the actual sprms. Each sprmtyp has -// its own class implementing the virtual methods start and stop. The -// classes are referenced from the sprm table, a static member of -// Ww1Sprm. When an sprm is encountered in the document, the virtual -// methods will be called at the formatting boundaries. -void Ww1SingleSprmPDxaLeft::Start( - Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&) -{ - SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE)); - short nPara = SVBT16ToShort(pSprm); - if(nPara < 0) - nPara = 0; - if(aLR.GetTxtFirstLineOfst() < -nPara) - aLR.SetTxtFirstLineOfst(-nPara); // otherwise SetTxtLeft() refuses to work - aLR.SetTxtLeft(nPara); - rOut << aLR; -} - -void Ww1SingleSprmPDxaRight::Start( - Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&) -{ - SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE)); - short nPara = SVBT16ToShort(pSprm); - if(nPara < 0) - nPara = 0; - aLR.SetRight(nPara); - rOut << aLR; -} - -void Ww1SingleSprmPDxaLeft1::Start( - Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&) -{ - SvxLRSpaceItem aLR((SvxLRSpaceItem&)rOut.GetAttr(RES_LR_SPACE)); - short nPara = SVBT16ToShort(pSprm); - if(-nPara >(short)aLR.GetTxtLeft()) - nPara = -(short)aLR.GetTxtLeft(); - aLR.SetTxtFirstLineOfst(nPara); - rOut << aLR; -} - -STOP1(Ww1SingleSprmPDxa, RES_LR_SPACE) - -void Ww1SingleSprmPJc::Start( - Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&) -{ - static SvxAdjust const aAdj[] = { - SVX_ADJUST_LEFT, - SVX_ADJUST_CENTER, - SVX_ADJUST_RIGHT, - SVX_ADJUST_BLOCK }; - sal_uInt8 nPara = *pSprm; - nPara %=SAL_N_ELEMENTS(aAdj); - rOut << SvxAdjustItem(aAdj[nPara], RES_PARATR_ADJUST); -} - -STOP1(Ww1SingleSprmPJc, RES_PARATR_ADJUST) - -void Ww1SingleSprmPFKeep::Start( - Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&) -{ - rOut << SvxFmtSplitItem((*pSprm & 1) == 0, RES_PARATR_SPLIT); -} - -STOP1(Ww1SingleSprmPFKeep, RES_PARATR_SPLIT) - -void Ww1SingleSprmPFKeepFollow::Start( - Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&) -{ - rOut << SvxFmtKeepItem((*pSprm & 1) != 0, RES_KEEP); -} - -STOP1(Ww1SingleSprmPFKeepFollow, RES_KEEP) - -void Ww1SingleSprmPPageBreakBefore::Start( - Ww1Shell& rOut, sal_uInt8, sal_uInt8* pSprm, sal_uInt16, Ww1Manager&) -{ - rOut << SvxFmtBreakItem(*pSprm & 1? - SVX_BREAK_PAGE_BEFORE:SVX_BREAK_NONE, RES_BREAK ); -} - -STOP1(Ww1SingleSprmPPageBreakBefore, RES_BREAK) - -SvxBorderLine* Ww1SingleSprmPBrc::SetBorder(SvxBorderLine* pLine, W1_BRC10* pBrc) -{ - sal_uInt16 nCode; - ::editeng::SvxBorderStyle eStyle = table::BorderLineStyle::SOLID; - if(pBrc->dxpLine2WidthGet() == 0) - { - switch(pBrc->dxpLine1WidthGet()) - { - default: OSL_FAIL("unknown linewidth"); - case 0: return 0; // no line - case 1: nCode = DEF_LINE_WIDTH_0; break; - case 2: nCode = DEF_LINE_WIDTH_1; break; - case 3: nCode = DEF_LINE_WIDTH_2; break; - case 4: nCode = DEF_LINE_WIDTH_3; break; - case 5: nCode = DEF_LINE_WIDTH_4; break; - case 6: - nCode = DEF_LINE_WIDTH_5; - eStyle = table::BorderLineStyle::DOTTED; - break; - case 7: - nCode = DEF_LINE_WIDTH_5; - eStyle = table::BorderLineStyle::DASHED; - break; - } - pLine->SetWidth( nCode ); - pLine->SetBorderLineStyle( eStyle ); - } - else - { - if ( pBrc->dxpLine1WidthGet() == 1 && pBrc->dxpLine2WidthGet() == 1 ) - { - pLine->SetBorderLineStyle( table::BorderLineStyle::DOUBLE ); - pLine->SetWidth( DEF_LINE_WIDTH_0 ); - } - else - OSL_ENSURE(false, "unknown linewidth"); - } - return pLine; -} - -void Ww1SingleSprmPBrc::Start( - Ww1Shell& rOut, sal_uInt8, - W1_BRC10* pBrc, - sal_uInt16 -#if OSL_DEBUG_LEVEL > 0 - nSize -#endif - , - Ww1Manager& /*rMan*/, - SvxBoxItem& aBox) -{ -#if OSL_DEBUG_LEVEL > 0 - OSL_ENSURE(sizeof(W1_BRC10) == nSize, "sizemissmatch"); -#endif - if(pBrc->dxpSpaceGet()) - aBox.SetDistance(10 + 20 * pBrc->dxpSpaceGet()); - //??? Why 10+... ???? - - if( rOut.IsInFly() ) - rOut.SetFlyFrmAttr( aBox ); - else - rOut << aBox; - - if(pBrc->fShadowGet()) - { - Color aBlack(COL_BLACK); // black... - SvxShadowItem aS(RES_SHADOW,(const Color*)&aBlack, 32, - SVX_SHADOW_BOTTOMRIGHT); // 1.6 tw wide - if( rOut.IsInFly() ) - rOut.SetFlyFrmAttr( aS ); - else - rOut << aS; - } -} - -STOP2(Ww1SingleSprmPBrc, RES_BOX, RES_SHADOW) - -static sal_uInt16 nBrcTrans[BRC_ANZ] = - { BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT }; - -void Ww1SingleSprmPBrc10::Start( - Ww1Shell& rOut, sal_uInt8 nId, sal_uInt8* pSprm, sal_uInt16 nSize, Ww1Manager& rMan) -{ - - W1_BRC10* pBrc =(W1_BRC10*)pSprm; - const SfxPoolItem &rItem = ( ( rOut.IsInFly() ) ? - rOut.GetFlyFrmAttr(RES_BOX) :rOut.GetAttr(RES_BOX)); - const SvxBoxItem &rBoxItem = (const SvxBoxItem&)rItem; - SvxBoxItem aBox( rBoxItem ); - SvxBorderLine aLine; - aBox.SetLine(SetBorder(&aLine, pBrc), nBrcTrans[nLine] ); - Ww1SingleSprmPBrc::Start(rOut, nId, pBrc, nSize, rMan, aBox); -} - -STOP1(Ww1SingleSprmParaSpace, RES_UL_SPACE) - -void Ww1SingleSprmPDyaBefore::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/) -{ - short nPara = SVBT16ToShort(pSprm); - if(nPara < 0) - nPara = -nPara; - SvxULSpaceItem aUL((SvxULSpaceItem&)rOut.GetAttr(RES_UL_SPACE)); - aUL.SetUpper(nPara); - rOut << aUL; -} - -void Ww1SingleSprmPDyaAfter::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/) -{ - short nPara = SVBT16ToShort(pSprm); - if(nPara < 0) - nPara = -nPara; - SvxULSpaceItem aUL((SvxULSpaceItem&)rOut.GetAttr(RES_UL_SPACE)); - aUL.SetLower(nPara); - rOut << aUL; -} - -STOP1(Ww1SingleSprmPDyaLine, RES_PARATR_LINESPACING) - -void Ww1SingleSprmPDyaLine::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/) -{ - short nSpace = SVBT16ToShort(pSprm); - if(nSpace < 0) - nSpace = -nSpace; - SvxLineSpacingItem aLSpc( LINE_SPACE_DEFAULT_HEIGHT, RES_PARATR_LINESPACING ); - {// MultilineSpace(proportional) - long n = nSpace * 100 / 240; // W1: 240 = 100%, SW: 100 = 100% - if(n>200) - n = 200; // SW_UI-Maximum - aLSpc.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO; - aLSpc.SetPropLineSpace((sal_uInt8)n); - } - rOut << aLSpc; -} - -void Ww1SingleSprmPChgTabsPapx::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/) -{ - - short nLeftPMgn = 0; // Coordinates approximately equal ?? - - short i; - sal_uInt8 nDel = pSprm[1]; - sal_uInt8* pDel = pSprm + 2; // Del - Array - sal_uInt8 nIns = pSprm[nDel*2+2]; - sal_uInt8* pIns = pSprm + 2*nDel + 3; // Ins - Array - W1_TBD* pTyp = (W1_TBD*)(pSprm + 2*nDel + 2*nIns + 3);// Typ - Array - - SvxTabStopItem aAttr( (SvxTabStopItem&)rOut.GetNodeOrStyAttr( RES_PARATR_TABSTOP )); - - SvxTabStop aTabStop; - - for( i=0; i<nDel; i++ ){ - sal_uInt16 nPos = aAttr.GetPos( SVBT16ToShort( pDel + i*2 ) - nLeftPMgn ); - if( nPos != SVX_TAB_NOTFOUND ) - aAttr.Remove( nPos, 1 ); - } - - for( i=0; i<nIns; i++ ){ - short nPos = SVBT16ToShort( pIns + i*2 ) - nLeftPMgn; - if( nPos < 0 ) - continue; - aTabStop.GetTabPos() = nPos; - switch( pTyp[i].jcGet() ){ - case 0: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_LEFT; break; - case 1: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_CENTER; break; - case 2: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_RIGHT; break; - case 3: aTabStop.GetAdjustment() = SVX_TAB_ADJUST_DECIMAL; break; - case 4: continue; // ignore Bar - } - - switch( pTyp[i].tlcGet() ){ - case 0: aTabStop.GetFill() = ' '; break; - case 1: aTabStop.GetFill() = '.'; break; - case 2: aTabStop.GetFill() = '-'; break; - case 3: - case 4: aTabStop.GetFill() = '_'; break; - } - - sal_uInt16 nPos2 = aAttr.GetPos( nPos ); - if( nPos2 != SVX_TAB_NOTFOUND ) - aAttr.Remove( nPos2, 1 ); // otherwise Insert() refuses to work - - aAttr.Insert( aTabStop ); - } - rOut << aAttr; -} - -STOP1(Ww1SingleSprmPChgTabsPapx, RES_PARATR_TABSTOP) - -void Ww1SingleSprmSGprfIhdt::Start( - Ww1Shell& /*rOut*/, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& rMan) -{ - rMan.GetSep().SetGrpfIhdt(*pSprm); -} - -void Ww1SingleSprmSColumns::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/) -{ - short nColSpace = 708; // default 1,25 cm - short nNettoWidth = -1; //~ mdt: dxaLeft/Right missing... - short nCols = SVBT16ToShort(pSprm); - nCols++; - if (nCols < 2) - return; - SwFmtCol aCol; - aCol.Init(nCols, nColSpace, nNettoWidth); - rOut.GetPageDesc().GetMaster().SetFmtAttr(aCol); -} - -void Ww1SingleSprmPTtp::Start( - Ww1Shell& /*rOut*/, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager& rMan) -{ - rMan.SetInTtp( true ); // Special case: will be reset at - // InTable::Stop instead of InTtp::Stop, - // because evaluation happens in InTable -} - -void Ww1SingleSprmPTtp::Stop( - Ww1Shell& rOut, sal_uInt8, sal_uInt8*, sal_uInt16, Ww1Manager& rMan) -{ - if (rOut.IsInTable() && rMan.HasInTable()) - rOut.NextTableRow(); -} - -void Ww1SingleSprmPFInTable::Start( - Ww1Shell& /*rOut*/, sal_uInt8, sal_uInt8*, sal_uInt16, - Ww1Manager& /*rMan*/) -{ -} - -void Ww1SingleSprmPFInTable::Stop( - Ww1Shell& -#if OSL_DEBUG_LEVEL > 0 - rOut -#endif - , - sal_uInt8, sal_uInt8*, sal_uInt16, - Ww1Manager& /*rMan*/) -{ -#if OSL_DEBUG_LEVEL > 0 - OSL_ENSURE(rOut.IsInTable(), ""); -#endif -} - -void Ww1SingleSprmTDxaGapHalf::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/) -{ - short nSpace = SVBT16ToShort(pSprm); - rOut.SetCellSpace(nSpace); -} - -void Ww1SingleSprmTDefTable10::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 nSize, Ww1Manager& /*rMan*/) -{ - sal_uInt16 i; - sal_uInt8 *p = pSprm + 2; // skip length word - sal_uInt8 nCount = *p; - p++; - nSize -= 3; -// Still missing: -// - GapHalf -// - potential thinning of cell borders - - if( nCount < 1 || nCount > 32 || nSize < ( nCount + 1 ) * 2 ) - return; - -// Let's read the cell positions for starters - short nPos = SVBT16ToShort( p ); // signed, can be negative !!! - - { - short nWholeWidth = SVBT16ToShort( p + 2 * nCount ) - nPos; - rOut.SetTableWidth( (sal_uInt16)nWholeWidth ); // set table width - -// Set table position - long nMidTab = nPos + nWholeWidth / 2; // table center - const SwFrmFmt &rFmt = rOut.GetPageDesc().GetMaster(); - const SvxLRSpaceItem& rLR = rFmt.GetLRSpace(); - long nRight = rFmt.GetFrmSize().GetWidth() - - rLR.GetLeft() - rLR.GetRight(); - - sal_Int16 eOri = text::HoriOrientation::LEFT; - if( nPos > MINLAY ){ // positioned by twiddling - if ( nMidTab <= nRight / 3 ) // 1/3rd of page - eOri = text::HoriOrientation::LEFT; - else if ( nMidTab <= 2 * nRight / 3 ) // 2/3rd of page - eOri = text::HoriOrientation::CENTER; - else - eOri = text::HoriOrientation::RIGHT; - } - rOut.SetTableOrient( eOri ); - } - - sal_uInt8* pEndPos = p+2; - sal_uInt8* pTc0 = ( nSize >= nCount * 10 ) ? pEndPos + 2 * nCount : 0; - sal_uInt16 nCellsDeleted = 0; // for merged cells - - for( i = 0; i < nCount; i++ ){ -// Collect info - W1_TC* pTc = (W1_TC*)pTc0; - bool bMerged = (pTc) ? pTc->fMergedGet() : sal_False; - -// set cell widths - sal_uInt16 nPos1 = SVBT16ToShort( pEndPos ); - if( !bMerged ) - rOut.SetCellWidth( nPos1 - nPos, i - nCellsDeleted ); - // set cell width - // Interaction with GapHalf still missing - // ( GapHalf is being ignored for now ) - pEndPos+=2; - nPos = nPos1; - - if( pTc0 ){ // are there actually TCs ? - W1_TC* pTc2 = (W1_TC*)pTc0; - bool bMerged2 = pTc2->fMergedGet(); - if( !bMerged2 ){ -// and now the borders - SvxBoxItem aBox( (SvxBoxItem&)rOut.GetCellAttr( RES_BOX )); - SvxBorderLine aLine; - W1_BRC10* pBrc = pTc2->rgbrcGet(); - for( sal_uInt16 j=0; j<4; j++ ){ - aBox.SetLine(Ww1SingleSprmPBrc::SetBorder(&aLine, pBrc), - nBrcTrans[j]); - pBrc++; - } - rOut.SetCellBorder( aBox, i - nCellsDeleted ); - }else{ -// remove merged cells - rOut.DeleteCell( i - nCellsDeleted ); - nCellsDeleted++; - } - pTc0+=sizeof(W1_TC); // 10 - } - } -} - -void Ww1SingleSprmTDyaRowHeight::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/) -{ - short nSpace = SVBT16ToShort(pSprm); - rOut.SetCellHeight(nSpace); -} - -// I don't need Fastsave attributes as dummies - -void Ww1SingleSprmPpc::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& rMan) -{ - sal_uInt8 nPpc = *pSprm; - - if (rOut.IsInTable()) // PMW does not know Flys in tables - return; - - RndStdIds eAnchor; // binding - - switch ( ( nPpc & 0x30 ) >> 4 ) // Y binding determines Sw binding - { - case 0: - eAnchor = FLY_AT_PARA; // Vert Margin - break; - default: - eAnchor = FLY_AT_PAGE; // Vert Page or unknown - break; // 2=Vert. Paragraph, 3=Use Default - } - - if( !rOut.IsInFly() && rMan.IsInStyle() ){ - rOut.BeginFly( eAnchor ); // start StyleFly - }else{ - rOut.SetFlyAnchor( eAnchor ); // set anchor - } -} - -void Ww1SingleSprmPDxaAbs::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& rMan) -{ - short nXPos = SVBT16ToShort(pSprm); - - if( rMan.IsInStyle() && !rOut.IsInFly() ){ - rOut.BeginFly(); // Fly ohne PPc-Attribut - } - - sal_Int16 eHRel = text::RelOrientation::FRAME; - sal_Int16 eHAlign = text::HoriOrientation::NONE; - - switch( nXPos ){ // Special x positions ? - case 0: - case -12: eHAlign = text::HoriOrientation::NONE; nXPos = 0; break; // Cheat: inside -> left - // actually text::HoriOrientation::LEFT, but then - // an outer margin moves the Fly - case -4: eHAlign = text::HoriOrientation::CENTER; nXPos = 0; break; - case -8: // right - case -16: eHAlign = text::HoriOrientation::RIGHT; nXPos = 0; break; // Cheat: outside -> right - - } - rOut.SetFlyXPos( nXPos, eHRel, eHAlign ); -} - -void Ww1SingleSprmPDyaAbs::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/) -{ - short nYPos = SVBT16ToShort(pSprm); - sal_Int16 eVRel = text::RelOrientation::FRAME; - sal_Int16 eVAlign = text::VertOrientation::NONE; - - switch( nYPos ){ // special y positions ? - case -4: eVAlign = text::VertOrientation::TOP; nYPos = 0; break; - case -8: eVAlign = text::VertOrientation::CENTER; nYPos = 0; break; - case -12: eVAlign = text::VertOrientation::BOTTOM; nYPos = 0; break; - - } - rOut.SetFlyYPos( nYPos, eVRel, eVAlign ); -} - -void Ww1SingleSprmPDxaWidth::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/) -{ - short nDxaWidth = SVBT16ToShort(pSprm); - rOut.SetFlyFrmAttr( SwFmtFrmSize( ATT_VAR_SIZE, nDxaWidth, MINFLY ) ); -} - -void Ww1SingleSprmPFromText::Start( - Ww1Shell& rOut, sal_uInt8 /*nId*/, sal_uInt8* pSprm, sal_uInt16 /*nSize*/, Ww1Manager& /*rMan*/) -{ - if( rOut.IsInFly() ){ // Appears outside of Fly as well, but then it - // obviously has no meaning. It definitely does - // not implicitly start a new Fly - short nFromText = SVBT16ToShort(pSprm); - - SvxLRSpaceItem aLR( RES_LR_SPACE ); - aLR.SetTxtLeft( nFromText ); - aLR.SetRight( nFromText ); - rOut.SetFlyFrmAttr( aLR ); - - rOut.SetFlyFrmAttr( SvxULSpaceItem( nFromText, nFromText, RES_UL_SPACE ) ); - } -} - -#undef STOP1 -#undef STOP2 - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww1/w1struct.hxx b/sw/source/filter/ww1/w1struct.hxx deleted file mode 100644 index f8b7de9ee52a..000000000000 --- a/sw/source/filter/ww1/w1struct.hxx +++ /dev/null @@ -1,837 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SW_SOURCE_FILTER_WW1_W1STRUCT_HXX -#define INCLUDED_SW_SOURCE_FILTER_WW1_W1STRUCT_HXX - -// star view -#include <string.h> -#include <tools/solar.h> - -class Ww1Shell; -class Ww1Manager; - -struct W1_FIB -{ - SVBT16 wIdent;// 0x0 int magic number - sal_uInt16 wIdentGet() { - return SVBT16ToShort(wIdent); } - SVBT16 nFib;// 0x2 FIB version written - sal_uInt16 nFibGet() { - return SVBT16ToShort(nFib); } - SVBT16 nProduct;// 0x4 product version written by - sal_uInt16 nProductGet() { - return SVBT16ToShort(nProduct); } - SVBT16 nlocale;// 0x6 language stamp---localized version; - sal_uInt16 nlocaleGet() { - return SVBT16ToShort(nlocale); } - SVBT16 pnNext;// 0x8 - sal_uInt16 pnNextGet() { - return SVBT16ToShort(pnNext); } - SVBT16 fFlags; - sal_uInt16 fFlagsGet() { - return SVBT16ToShort(fFlags); } - // SVBT16 fDot :1;// 0xa 0001 - bool fDotGet() { - return 0 != ((fFlagsGet() >> 0) & 1); } - // SVBT16 fGlsy :1;// 0002 - bool fGlsyGet() { - return 0 != ((fFlagsGet() >> 1) & 1); } - // SVBT16 fComplex :1;// 0004 when 1, file is in complex, fast-saved format. - bool fComplexGet() { - return 0 != ((fFlagsGet() >> 2) & 1); } - // SVBT16 fHasPic :1;// 0008 file contains 1 or more pictures - bool fHasPicGet() { - return 0 != ((fFlagsGet() >> 3) & 1); } - // SVBT16 cQuickSaves :4;// 00F0 count of times file was quicksaved - sal_uInt16 cQuickSavesGet() { - return (sal_uInt16)((fFlagsGet() >> 4) & 0xf); } - // SVBT16 u1 :8;// FF00 unused - sal_uInt16 u1Get() { - return (sal_uInt16)((fFlagsGet() >> 8) & 0xff); } - SVBT16 nFibBack;// 0xc - sal_uInt16 nFibBackGet() { - return SVBT16ToShort(nFibBack); } - SVBT16 u2[5];// 0xe reserved - SVBT32 fcMin;// 0x18 file offset of first character of text - sal_uLong fcMinGet() { - return SVBT32ToUInt32(fcMin); } - SVBT32 fcMac;// 0x1c file offset of last character of text + 1 - sal_uLong fcMacGet() { - return SVBT32ToUInt32(fcMac); } - SVBT32 cbMac;// 0x20 file offset of last byte written to file + 1. - sal_uLong cbMacGet() { - return SVBT32ToUInt32(cbMac); } - SVBT32 u4[4];// 0x24 reserved - SVBT32 ccpText;// 0x34 length of main document text stream - sal_uLong ccpTextGet() { - return SVBT32ToUInt32(ccpText); } - SVBT32 ccpFtn;// 0x38 length of footnote subdocument text stream - sal_uLong ccpFtnGet() { - return SVBT32ToUInt32(ccpFtn); } - SVBT32 ccpHdd;// 0x3c length of header subdocument text stream - sal_uLong ccpHddGet() { - return SVBT32ToUInt32(ccpHdd); } - SVBT32 ccpMcr;// 0x40 length of macro subdocument text stream - sal_uLong ccpMcrGet() { - return SVBT32ToUInt32(ccpMcr); } - SVBT32 ccpAtn;// 0x44 length of annotation subdocument text stream - sal_uLong ccpAtnGet() { - return SVBT32ToUInt32(ccpAtn); } - SVBT32 cp5[4];// 0x48 - SVBT32 fcStshfOrig;// 0x58 file offset of original allocation for STSH in file - sal_uLong fcStshfOrigGet() { - return SVBT32ToUInt32(fcStshfOrig); } - SVBT16 cbStshfOrig;// 0x5c count of bytes of original STSH allocation - sal_uInt16 cbStshfOrigGet() { - return SVBT16ToShort(cbStshfOrig); } - SVBT32 fcStshf;// 0x5e file offset of STSH in file. - sal_uLong fcStshfGet() { - return SVBT32ToUInt32(fcStshf); } - SVBT16 cbStshf;// 0x62 count of bytes of current STSH allocation - sal_uInt16 cbStshfGet() { - return SVBT16ToShort(cbStshf); } - SVBT32 fcPlcffndRef;// 0x64 file offset of footnote reference PLC. - sal_uLong fcPlcffndRefGet() { - return SVBT32ToUInt32(fcPlcffndRef); } - SVBT16 cbPlcffndRef;// 0x68 count of bytes of footnote reference PLC - sal_uInt16 cbPlcffndRefGet() { - return SVBT16ToShort(cbPlcffndRef); } - // == 0 if no footnotes defined in document. - - SVBT32 fcPlcffndTxt;// 0x6a file offset of footnote text PLC. - sal_uLong fcPlcffndTxtGet() { - return SVBT32ToUInt32(fcPlcffndTxt); } - SVBT16 cbPlcffndTxt;// 0x6e count of bytes of footnote text PLC. - sal_uInt16 cbPlcffndTxtGet() { - return SVBT16ToShort(cbPlcffndTxt); } - // == 0 if no footnotes defined in document - - SVBT32 fcPlcfandRef;// 0x70 file offset of annotation reference PLC. - sal_uLong fcPlcfandRefGet() { - return SVBT32ToUInt32(fcPlcfandRef); } - SVBT16 cbPlcfandRef;// 0x74 count of bytes of annotation reference PLC. - sal_uInt16 cbPlcfandRefGet() { - return SVBT16ToShort(cbPlcfandRef); } - - SVBT32 fcPlcfandTxt;// 0x76 file offset of annotation text PLC. - sal_uLong fcPlcfandTxtGet() { - return SVBT32ToUInt32(fcPlcfandTxt); } - SVBT16 cbPlcfandTxt;// 0x7a count of bytes of the annotation text PLC - sal_uInt16 cbPlcfandTxtGet() { - return SVBT16ToShort(cbPlcfandTxt); } - - SVBT32 fcPlcfsed;// 8x7c file offset of section descriptor PLC. - sal_uLong fcPlcfsedGet() { - return SVBT32ToUInt32(fcPlcfsed); } - SVBT16 cbPlcfsed;// 0x80 count of bytes of section descriptor PLC. - sal_uInt16 cbPlcfsedGet() { - return SVBT16ToShort(cbPlcfsed); } - - SVBT32 fcPlcfpgd;// 0x82 file offset of paragraph descriptor PLC - sal_uLong fcPlcfpgdGet() { - return SVBT32ToUInt32(fcPlcfpgd); } - SVBT16 cbPlcfpgd;// 0x86 count of bytes of paragraph descriptor PLC. - sal_uInt16 cbPlcfpgdGet() { - return SVBT16ToShort(cbPlcfpgd); } - // ==0 if file was never repaginated - // Should not be written by third party creators - - SVBT32 fcPlcfphe;// 0x88 file offset of PLC of paragraph heights. - sal_uLong fcPlcfpheGet() { - return SVBT32ToUInt32(fcPlcfphe); } - SVBT16 cbPlcfphe;// 0x8c count of bytes of paragraph height PLC. - sal_uInt16 cbPlcfpheGet() { - return SVBT16ToShort(cbPlcfphe); } - // ==0 when file is non-complex. - - SVBT32 fcSttbfglsy;// 0x8e file offset of glossary string table. - sal_uLong fcSttbfglsyGet() { - return SVBT32ToUInt32(fcSttbfglsy); } - SVBT16 cbSttbfglsy;// 0x92 count of bytes of glossary string table. - sal_uInt16 cbSttbfglsyGet() { - return SVBT16ToShort(cbSttbfglsy); } - // == 0 for non-glossary documents. - // !=0 for glossary documents. - - SVBT32 fcPlcfglsy;// 0x94 file offset of glossary PLC. - sal_uLong fcPlcfglsyGet() { - return SVBT32ToUInt32(fcPlcfglsy); } - SVBT16 cbPlcfglsy;// 0x98 count of bytes of glossary PLC. - sal_uInt16 cbPlcfglsyGet() { - return SVBT16ToShort(cbPlcfglsy); } - // == 0 for non-glossary documents. - // !=0 for glossary documents. - - SVBT32 fcPlcfhdd;// 0x9a byte offset of header PLC. - sal_uLong fcPlcfhddGet() { - return SVBT32ToUInt32(fcPlcfhdd); } - SVBT16 cbPlcfhdd;// 0x9e count of bytes of header PLC. - sal_uInt16 cbPlcfhddGet() { - return SVBT16ToShort(cbPlcfhdd); } - // == 0 if document contains no headers - - SVBT32 fcPlcfbteChpx;// 0xa0 file offset of character property bin table.PLC. - sal_uLong fcPlcfbteChpxGet() { - return SVBT32ToUInt32(fcPlcfbteChpx); } - SVBT16 cbPlcfbteChpx;// 0xa4 count of bytes of character property bin table PLC. - sal_uInt16 cbPlcfbteChpxGet() { - return SVBT16ToShort(cbPlcfbteChpx); } - - SVBT32 fcPlcfbtePapx;// 0xa6 file offset of paragraph property bin table.PLC. - sal_uLong fcPlcfbtePapxGet() { - return SVBT32ToUInt32(fcPlcfbtePapx); } - SVBT16 cbPlcfbtePapx;// 0xaa count of bytes of paragraph property bin table PLC. - sal_uInt16 cbPlcfbtePapxGet() { - return SVBT16ToShort(cbPlcfbtePapx); } - - SVBT32 fcPlcfsea;// 0xac file offset of PLC reserved for private use. The SEA is 6 bytes long. - sal_uLong fcPlcfseaGet() { - return SVBT32ToUInt32(fcPlcfsea); } - SVBT16 cbPlcfsea;// 0xb0 count of bytes of private use PLC. - sal_uInt16 cbPlcfseaGet() { - return SVBT16ToShort(cbPlcfsea); } - - SVBT32 fcSttbfffn;// 0xb2 file offset of font information STTBF. See the FFN file structure definition. - sal_uLong fcSttbfffnGet() { - return SVBT32ToUInt32(fcSttbfffn); } - SVBT16 cbSttbfffn;// 0xb6 count of bytes in sttbfffn. - sal_uInt16 cbSttbfffnGet() { - return SVBT16ToShort(cbSttbfffn); } - - SVBT32 fcPlcffldMom;// 0xb8 offset in doc stream to the PLC of field positions in the main document. - sal_uLong fcPlcffldMomGet() { - return SVBT32ToUInt32(fcPlcffldMom); } - SVBT16 cbPlcffldMom;// 0xbc - sal_uInt16 cbPlcffldMomGet() { - return SVBT16ToShort(cbPlcffldMom); } - - SVBT32 fcPlcffldHdr;// 0xbe offset in doc stream to the PLC of field positions in the header subdocument. - sal_uLong fcPlcffldHdrGet() { - return SVBT32ToUInt32(fcPlcffldHdr); } - SVBT16 cbPlcffldHdr;// 0xc2 - sal_uInt16 cbPlcffldHdrGet() { - return SVBT16ToShort(cbPlcffldHdr); } - - SVBT32 fcPlcffldFtn;// 0xc4 offset in doc stream to the PLC of field positions in the footnote subdocument. - sal_uLong fcPlcffldFtnGet() { - return SVBT32ToUInt32(fcPlcffldFtn); } - SVBT16 cbPlcffldFtn;// 0xc8 - sal_uInt16 cbPlcffldFtnGet() { - return SVBT16ToShort(cbPlcffldFtn); } - - SVBT32 fcPlcffldAtn;// 0xca offset in doc stream to the PLC of field positions in the annotation subdocument. - sal_uLong fcPlcffldAtnGet() { - return SVBT32ToUInt32(fcPlcffldAtn); } - SVBT16 cbPlcffldAtn;// 0xce - sal_uInt16 cbPlcffldAtnGet() { - return SVBT16ToShort(cbPlcffldAtn); } - - SVBT32 fcPlcffldMcr;// 0xd0 offset in doc stream to the PLC of field positions in the macro subdocument. - sal_uLong fcPlcffldMcrGet() { - return SVBT32ToUInt32(fcPlcffldMcr); } - SVBT16 cbPlcffldMcr;// 0xd4 - sal_uInt16 cbPlcffldMcrGet() { - return SVBT16ToShort(cbPlcffldMcr); } - - SVBT32 fcSttbfbkmk;// 0xd6 offset in document stream of the STTBF that records bookmark names in the main document - sal_uLong fcSttbfbkmkGet() { - return SVBT32ToUInt32(fcSttbfbkmk); } - SVBT16 cbSttbfbkmk;// 0xda - sal_uInt16 cbSttbfbkmkGet() { - return SVBT16ToShort(cbSttbfbkmk); } - - SVBT32 fcPlcfbkf;// 0xdc offset in document stream of the PLCF that records the beginning CP offsets of bookmarks in the main document. See BKF - sal_uLong fcPlcfbkfGet() { - return SVBT32ToUInt32(fcPlcfbkf); } - SVBT16 cbPlcfbkf;// 0xe0 - sal_uInt16 cbPlcfbkfGet() { - return SVBT16ToShort(cbPlcfbkf); } - - SVBT32 fcPlcfbkl;// 0xe2 offset in document stream of the PLCF that records the ending CP offsets of bookmarks recorded in the main document. See the BKL structure definition. - sal_uLong fcPlcfbklGet() { - return SVBT32ToUInt32(fcPlcfbkl); } - SVBT16 cbPlcfbkl;// 0xe6 SVBT16 - sal_uInt16 cbPlcfbklGet() { - return SVBT16ToShort(cbPlcfbkl); } - - SVBT32 fcCmds;// 0xe8 FC - sal_uLong fcCmdsGet() { - return SVBT32ToUInt32(fcCmds); } - SVBT16 cbCmds;// 0xec - sal_uInt16 cbCmdsGet() { - return SVBT16ToShort(cbCmds); } - - SVBT32 fcPlcmcr;// 0xee FC - sal_uLong fcPlcmcrGet() { - return SVBT32ToUInt32(fcPlcmcr); } - SVBT16 cbPlcmcr;// 0xf2 - sal_uInt16 cbPlcmcrGet() { - return SVBT16ToShort(cbPlcmcr); } - - SVBT32 fcSttbfmcr;// 0xf4 FC - sal_uLong fcSttbfmcrGet() { - return SVBT32ToUInt32(fcSttbfmcr); } - SVBT16 cbSttbfmcr;// 0xf8 - sal_uInt16 cbSttbfmcrGet() { - return SVBT16ToShort(cbSttbfmcr); } - - SVBT32 fcPrEnv;// 0xfa - sal_uLong fcPrEnvGet() { - return SVBT32ToUInt32(fcPrEnv); } - SVBT16 cbPrEnv;// 0xfe - sal_uInt16 cbPrEnvGet() { - return SVBT16ToShort(cbPrEnv); } - - SVBT32 fcWss;// 0x100 file offset of Window Save State data structure. See WSS. - sal_uLong fcWssGet() { - return SVBT32ToUInt32(fcWss); } - SVBT16 cbWss;// 0x100 count of bytes of WSS. ==0 if unable to store the window state. - sal_uInt16 cbWssGet() { - return SVBT16ToShort(cbWss); } - - SVBT32 fcDop;// 0x106 file offset of document property data structure. - sal_uLong fcDopGet() { - return SVBT32ToUInt32(fcDop); } - SVBT16 cbDop;// 0x10a count of bytes of document properties. - sal_uInt16 cbDopGet() { - return SVBT16ToShort(cbDop); } - - SVBT32 fcSttbfAssoc;// 0x10c offset to STTBF of associated strings. See STTBFASSOC. - sal_uLong fcSttbfAssocGet() { - return SVBT32ToUInt32(fcSttbfAssoc); } - SVBT16 cbSttbfAssoc;// 0x110 - sal_uInt16 cbSttbfAssocGet() { - return SVBT16ToShort(cbSttbfAssoc); } - - SVBT32 fcClx;// 0x112 file offset of beginning of information for complex files. - sal_uLong fcClxGet() { - return SVBT32ToUInt32(fcClx); } - SVBT16 cbClx;// 0x116 count of bytes of complex file information. 0 if file is non-complex. - sal_uInt16 cbClxGet() { - return SVBT16ToShort(cbClx); } - - SVBT32 fcPlcfpgdFtn;// 0x118 file offset of page descriptor PLC for footnote subdocument. - sal_uLong fcPlcfpgdFtnGet() { - return SVBT32ToUInt32(fcPlcfpgdFtn); } - SVBT16 cbPlcfpgdFtn;// 0x11C count of bytes of page descriptor PLC for footnote subdocument. - sal_uInt16 cbPlcfpgdFtnGet() { - return SVBT16ToShort(cbPlcfpgdFtn); } - // ==0 if document has not been paginated. The length of the PGD is 8 bytes. - - SVBT32 fcSpare1;// 0x11e file offset of the name of the original file. - sal_uLong fcSpare1Get() { - return SVBT32ToUInt32(fcSpare1); } - SVBT16 cbSpare1;// 0x122 count of bytes of the name of the original file. - sal_uInt16 cbSpare1Get() { - return SVBT16ToShort(cbSpare1); } - SVBT32 fcSpare2;// 0x124 file offset of the name of the original file. - sal_uLong fcSpare2Get() { - return SVBT32ToUInt32(fcSpare2); } - SVBT16 cbSpare2;// 0x128 count of bytes of the name of the original file. - sal_uInt16 cbSpare2Get() { - return SVBT16ToShort(cbSpare2); } - SVBT32 fcSpare3;// 0x12a file offset of the name of the original file. - sal_uLong fcSpare3Get() { - return SVBT32ToUInt32(fcSpare3); } - SVBT16 cbSpare3;// 0x12e count of bytes of the name of the original file. - sal_uInt16 cbSpare3Get() { - return SVBT16ToShort(cbSpare3); } - SVBT32 fcSpare4;// 0x130 file offset of the name of the original file. - sal_uLong fcSpare4Get() { - return SVBT32ToUInt32(fcSpare4); } - SVBT16 cbSpare4;// 0x134 count of bytes of the name of the original file. - sal_uInt16 cbSpare4Get() { - return SVBT16ToShort(cbSpare4); } - - SVBT16 cpnBteChp;// 0x18E count of CHPX FKPs recorded in file. In non-complex files if the number of - sal_uInt16 cpnBteChpGet() { - return SVBT16ToShort(cpnBteChp); } - // entries in the plcfbteChpx is less than this, the plcfbteChpx is incomplete. - SVBT16 cpnBtePap;// 0x190 count of PAPX FKPs recorded in file. In non-complex files if the number of - sal_uInt16 cpnBtePapGet() { - return SVBT16ToShort(cpnBtePap); } - // entries in the plcfbtePapx is less than this, the plcfbtePapx is incomplete. -}; - -struct W1_DOP //Document Properties -{ - SVBT16 fFlags; - sal_uInt16 fFlagsGet() { - return SVBT16ToShort(fFlags); } - // SVBT16 fFacingPages : 1;// 1 when facing pages should be printed - bool fFacingPagesGet() { - return 0 != ((fFlagsGet() >> 0) & 1); } - // SVBT16 fWidowControl : 1;// 1 when widow control is in effect. 0 when widow control disabled. - bool fWidowControlGet() { - return 0 != ((fFlagsGet() >> 1) & 1); } - // SVBT16 : 3;// unused - // SVBT16 fpc : 2;// 1 footnote position code: 0 as endnotes, 1 at bottom of page, 2 immediately beneath text - sal_uInt16 fpcGet() { - return (sal_uInt16)((fFlagsGet() >> 5) & 3); } - // SVBT16 fWide : 1;// Landscape - bool fWideGet() { - return 0 != ((fFlagsGet() >> 7) & 1); } - // SVBT16 grpfIhdt : 8;// 0 specification of document headers and footers. See explanation under Headers and Footers topic. - sal_uInt16 grpfIhdtGet() { - return (sal_uInt16)((fFlagsGet() >> 8) & 0xff); } - SVBT16 fFtnFlags; - sal_uInt16 fFtnFlagsGet() { - return SVBT16ToShort(fFtnFlags); } - // SVBT16 fFtnRestart : 1; - bool fFtnRestartGet() { - return 0 != ((fFtnFlagsGet() >> 0) & 1); } - // SVBT16 nFtn : 15;// 1 initial footnote number for document - sal_uInt16 nFtnGet() { - return (sal_uInt16)((fFtnFlagsGet() >> 1) & 0x7fff); } - SVBT16 fRvsFlags; - sal_uInt16 fRvsFlagsGet() { - return SVBT16ToShort(fRvsFlags); } - // SVBT16 irmBar : 8; - sal_uInt16 irmBarGet() { - return (sal_uInt16)((fRvsFlagsGet() >> 0) & 0xff); } - // SVBT16 irmProps : 7; - sal_uInt16 irmPropsGet() { - return (sal_uInt16)((fRvsFlagsGet() >> 8) & 0x7f); } - // SVBT16 fRevMarking : 1;// when 1, Word will mark revisions as the document is edited - bool fRevMarkingGet() { - return 0 != ((fRvsFlagsGet() >> 15) & 1); } - SVBT16 fSveFlags; - sal_uInt16 fSveFlagsGet() { - return SVBT16ToShort(fSveFlags); } - // SVBT16 fBackup : 1;// always make backup when document saved when 1. - bool fBackupGet() { - return 0 != ((fSveFlagsGet() >> 0) & 1); } - // SVBT16 fExactCWords : 1; - bool fExactCWordsGet() { - return 0 != ((fSveFlagsGet() >> 1) & 1); } - // SVBT16 fPagHidden : 1; - bool fPagHiddenGet() { - return 0 != ((fSveFlagsGet() >> 2) & 1); } - // SVBT16 fPagResults : 1; - bool fPagResultsGet() { - return 0 != ((fSveFlagsGet() >> 3) & 1); } - // SVBT16 fLockAtn : 1;// when 1, annotations are locked for editing - bool fLockAtnGet() { - return 0 != ((fSveFlagsGet() >> 4) & 1); } - // SVBT16 fMirrorMargins : 1;// swap margins on left/right pages when 1. - bool fMirrorMarginsGet() { - return 0 != ((fSveFlagsGet() >> 5) & 1); } - // SVBT16 : 10;// unused - SVBT16 fSpares; - sal_uInt16 fSparesGet() { - return SVBT16ToShort(fSpares); } - SVBT16 yaPage; - sal_uInt16 yaPageGet() { - return SVBT16ToShort(yaPage); } - SVBT16 xaPage; - sal_uInt16 xaPageGet() { - return SVBT16ToShort(xaPage); } - SVBT16 dyaTop; - sal_uInt16 dyaTopGet() { - return SVBT16ToShort(dyaTop); } - SVBT16 dxaLeft; - sal_uInt16 dxaLeftGet() { - return SVBT16ToShort(dxaLeft); } - SVBT16 dyaBottom; - sal_uInt16 dyaBottomGet() { - return SVBT16ToShort(dyaBottom); } - SVBT16 dxaRight; - sal_uInt16 dxaRightGet() { - return SVBT16ToShort(dxaRight); } - SVBT16 dxaGutter; - sal_uInt16 dxaGutterGet() { - return SVBT16ToShort(dxaGutter); } - SVBT16 dxaTab;// 720 twips default tab width - sal_uInt16 dxaTabGet() { - return SVBT16ToShort(dxaTab); } - SVBT16 wSpare; - sal_uInt16 wSpareGet() { - return SVBT16ToShort(wSpare); } - SVBT16 dxaHotZ;// width of hyphenation hot zone measured in twips - sal_uInt16 dxaHotZGet() { - return SVBT16ToShort(dxaHotZ); } - SVBT16 rgwSpare[2];// reserved - SVBT32 dttmCreated;// DTTM date and time document was created - sal_uLong dttmCreatedGet() { - return SVBT32ToUInt32(dttmCreated); } - SVBT32 dttmRevised;// DTTM date and time document was last revised - sal_uLong dttmRevisedGet() { - return SVBT32ToUInt32(dttmRevised); } - SVBT32 dttmLastPrint;// DTTM date and time document was last printed - sal_uLong dttmLastPrintGet() { - return SVBT32ToUInt32(dttmLastPrint); } - SVBT16 nRevision;// number of times document has been revised since its creation - sal_uInt16 nRevisionGet() { - return SVBT16ToShort(nRevision); } - SVBT32 tmEdited;// time document was last edited - sal_uLong tmEditedGet() { - return SVBT32ToUInt32(tmEdited); } - SVBT32 cWords;// count of words tallied by last Word Count execution - sal_uLong cWordsGet() { - return SVBT32ToUInt32(cWords); } - SVBT32 cCh;// count of characters tallied by last Word Count execution - sal_uLong cChGet() { - return SVBT32ToUInt32(cCh); } - SVBT16 cPg;// count of pages tallied by last Word Count execution - sal_uInt16 cPgGet() { - return SVBT16ToShort(cPg); } - SVBT16 rgwSpareDocSum[2]; -}; -// cbDOP is 66. - -struct W1_CHP -{ - SVBT16 fChar; - SVBT16 ftc; // Font Code - sal_uInt8 hps; // Font size in half points - sal_uInt8 hpsPos; // Sub/Superscript ( signed number, 0 = normal ) - SVBT16 fText; - SVBT32 fcPic; // not stored in File - sal_uInt8 fnPic; // internal - SVBT16 hpsLargeChp; // ??? - - W1_CHP() { memset( this, 0, sizeof( *this)); } - - sal_uInt16 fCharGet() { return SVBT16ToShort(fChar); } - void fCharSet(sal_uInt16 n) { ShortToSVBT16(n, fChar); } - bool fBoldGet() { return 0 != ((fCharGet() >> 0) & 1); } - void fBoldSet(bool b) { fCharSet( ( fCharGet() & 0xfffe ) | ( (sal_uInt16)b << 0 ) ); } - bool fItalicGet() { return 0 != ((fCharGet() >> 1) & 1); } - void fItalicSet(bool b) { fCharSet( ( fCharGet() & 0xfffd ) | ( (sal_uInt16)b << 1 ) ); } - bool fStrikeGet() { return 0 != ((fCharGet() >> 2) & 1); } - bool fOutlineGet() { return 0 != ((fCharGet() >> 3) & 1); } - bool fFldVanishGet() { return 0 != ((fCharGet() >> 4) & 1); } - bool fSmallCapsGet() { return 0 != ((fCharGet() >> 5) & 1); } - bool fCapsGet() { return 0 != ((fCharGet() >> 6) & 1); } - bool fVanishGet() { return 0 != ((fCharGet() >> 7) & 1); } - bool fRMarkGet() { return 0 != ((fCharGet() >> 8) & 1); } - bool fSpecGet() { return 0 != ((fCharGet() >> 9) & 1); } - bool fsIcoGet() { return 0 != ((fCharGet() >> 10) & 1); } - bool fsFtcGet() { return 0 != ((fCharGet() >> 11) & 1); } - void fsFtcSet(bool b) { fCharSet( ( fCharGet() & 0xf7ff ) | ( (sal_uInt16)b << 11 ) ); } - bool fsHpsGet() { return 0 != ((fCharGet() >> 12) & 1); } - void fsHpsSet(bool b) { fCharSet( ( fCharGet() & 0xefff ) | ( (sal_uInt16)b << 12 ) ); } - bool fsKulGet() { return 0 != ((fCharGet() >> 13) & 1); } - void fsKulSet(bool b) { fCharSet( ( fCharGet() & 0xdfff ) | ( (sal_uInt16)b << 13 ) ); } - bool fsPosGet() { return 0 != ((fCharGet() >> 14) & 1); } - bool fsSpaceGet() { return 0 != ((fCharGet() >> 15) & 1); } - // SVBT16 fBold :1;// 1 == opposite boldness of style - // SVBT16 fItalic :1;// 1 == opposite of style - // SVBT16 fStrike :1;// 1 == opposite of style - // SVBT16 fOutline :1;// 1 == opposite of style - // SVBT16 fFldVanish :1;// 1 == opposite of style - // SVBT16 fSmallCaps :1;// 1 == opposite of style - // SVBT16 fCaps :1;// 1 == opposite of style - // SVBT16 fVanish :1;// 1 == opposite of style - // SVBT16 fRMark :1;// ??? - // SVBT16 fSpec :1;// 1 == opposite of style - // SVBT16 fsIco :1;// 1 == Color (ico) different to style - // SVBT16 fsFtc :1;// 1 == FontCode (ftc) different to style - // SVBT16 fsHps :1;// 1 == FontSize (hps) different to style - // SVBT16 fsKul :1;// 1 == Underline Code (kul) different to style - // SVBT16 fsPos :1;// 1 == Char position (hpsPos) different to style - // SVBT16 fsSpace :1;// 1 == Char Spacing (qpsSpace) different to style - - sal_uInt16 ftcGet() { return SVBT16ToShort(ftc); } - void ftcSet(sal_uInt16 n) { ShortToSVBT16(n, ftc); } - void hpsSet(sal_uInt8 n) { hps = n; } - sal_uInt8 hpsGet() { return hps; } - - sal_uInt8 hpsPosGet() { return hpsPos; } - sal_uInt16 fTextGet() { return SVBT16ToShort(fText); } - void fTextSet(sal_uInt16 n) { ShortToSVBT16(n, fText); } - sal_uInt16 qpsSpaceGet() { return (sal_uInt16)((fTextGet() >> 0) & 0x3f); } - sal_uInt16 wSpare2Get() { return (sal_uInt16)((fTextGet() >> 6) & 3); } - sal_uInt16 icoGet() { return (sal_uInt16)((fTextGet() >> 8) & 0xf); } - sal_uInt16 kulGet() { return (sal_uInt16)((fTextGet() >> 12) & 7); } - void kulSet(sal_uInt16 n) { fTextSet( ( fTextGet() & 0x8fff ) | ( ( n & 7 ) << 12 ) ); } - bool fSysVanishGet() { return 0 != ((fTextGet() >> 15) & 1); } - // SVBT16 qpsSpace :6;// Char Spacing, -7 .. 56; 57 = -7, 63 = -1 - // SVBT16 wSpare2 : 2;// reserved - // SVBT16 ico :4;// color of Text: 0=black, 1=blue, 2=cyan, 3=green, 4=magenta, 5=red, 6=yellow, 7=white - // SVBT16 kul: 3;// Underline code: 0=none, 1=single, 2=by word, 3=double, 4=dotted - // SVBT16 fSysVanish: 1;// used internally - - sal_uLong fcPicGet() { return SVBT32ToUInt32(fcPic); } - sal_uInt16 fnPicGet() { return fnPic; } - sal_uInt16 hpsLargeChpGet() { return SVBT16ToShort(hpsLargeChp); } - - void Out(Ww1Shell&, Ww1Manager&); -}; - -struct W1_FFN ///////////////////////////////////////// Font Descriptor -{ - sal_uInt8 cbFfnM1;// 0x0 total length of FFN - 1. - sal_uInt16 cbFfnM1Get() { - return static_cast<sal_uInt8>(cbFfnM1); } - sal_uInt8 fFlags; - sal_uInt16 fFlagsGet() { - return static_cast<sal_uInt8>(fFlags); } - // sal_uInt8 prg : 2;// 0x1:03 pitch request - sal_uInt16 prgGet() { - return (sal_uInt16)((fFlagsGet() >> 0) & 3); } - // sal_uInt8 fTrueType : 1;// 0x1:04 when 1, font is a TrueType font - bool fTrueTypeGet() { - return 0 != ((fFlagsGet() >> 2) & 1); } - // sal_uInt8 : 1;// 0x1:08 reserved - // sal_uInt8 ff : 3;// 0x1:70 font family id - sal_uInt16 ffGet() { - return (sal_uInt16)((fFlagsGet() >> 4) & 7); } - // sal_uInt8 : 1;// 0x1:80 reserved - sal_uInt8 szFfn[65];// 0x6 zero terminated string that records name of font. - // Careful: the array may be smaller!!! - // Possibly followed by a second sz which records the name of an - // alternate font to use if the first named font does not exist - // on this system. Maximal size of szFfn is 65 characters. - sal_uInt8* szFfnGet() { return szFfn; } -}; - -struct W1_PHE // Paragraph Height -{ - SVBT16 fFlags; - sal_uInt16 fFlagsGet() { - return SVBT16ToShort(fFlags); } - bool fSpareGet() { - return 0 != (fFlagsGet() & 1); } - bool fUnkGet() { - return 0 != ((fFlagsGet() >> 1) & 1); } - bool fDiffLinesGet() { - return 0 != ((fFlagsGet() >> 2) & 1); } - sal_uInt8 clMacGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((fFlagsGet() >> 8) & 0xff); } - SVBT16 dxaCol; - sal_uInt16 dxaColGet() { - return SVBT16ToShort(dxaCol); } - SVBT16 xxx; // note the triple usage.... see doc. - sal_uInt16 dylHeightGet() { - return SVBT16ToShort(xxx); } - sal_uInt16 dylLineGet() { - return SVBT16ToShort(xxx); } - sal_uInt16 fStyleDirtyGet() { - return SVBT16ToShort(xxx); } -}; - -struct W1_PAPX // Paragraph Property Difference -{ - sal_uInt8 stc; - sal_uInt8 stcGet() { return stc; } - W1_PHE phe; - sal_uInt8 grpprl[1]; - sal_uInt8* grpprlGet() { - return grpprl; } -}; - -struct W1_BRC // Border Code -{ - SVBT16 aBits; - sal_uInt16 aBitsGet() { - return SVBT16ToShort(aBits); } - // SVBT16 dxpLineWidth : 3;// 0007 When dxpLineWidth is 0, 1, 2, 3, 4, or 5, - // this field is the width of a single line of border - // in units of 0.75 points Must be nonzero when brcType - // is nonzero. 6 == dotted, 7 == dashed. - sal_uInt8 dxpLineWidthGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 0) & 0x0007); } - // SVBT16 brcType : 2;// 0018 border type code: 0 == none, 1 == single, 2 == thick, - // 3 == double - sal_uInt8 brcTypeGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 3) & 0x0003); } - // SVBT16 fShadow : 1;// 0020 when 1, border is drawn with shadow. Must be 0 - // when BRC is a substructure of the TC - sal_uInt8 fShadowGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 5) & 0x0001); } - // SVBT16 ico : 5;// 07C0 color code (see chp.ico) - sal_uInt8 icoGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 6) & 0x001f); } - // SVBT16 dxpSpace : 5;// F800 width of space to maintain between border and - // text within border. Must be 0 when BRC is a - // substructure of the TC. Stored in points for Windows. - sal_uInt8 dxpSpaceGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 11) & 0x001f); } -}; - -struct W1_BRC10 // Border Code Word 1.0 -{ - SVBT16 aBits; - sal_uInt16 aBitsGet() { - return SVBT16ToShort(aBits); } - sal_uInt8 dxpLine2WidthGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 0) & 0x0007); } - sal_uInt8 dxpSpaceBetweenGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 3) & 0x0007); } - sal_uInt8 dxpLine1WidthGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 6) & 0x0007); } - sal_uInt8 dxpSpaceGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 9) & 0x001f); } - sal_uInt8 fShadowGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 14) & 0x0001); } - sal_uInt8 fSpareGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((aBitsGet() >> 15) & 0x0001); } -}; - -struct W1_FLD // FieldDescriptor -{ - sal_uInt8 ch; // boundary-type (begin(19), separator (20), end (21)) - sal_uInt8 chGet() { return ch; } - sal_uInt8 flt; // field type / flags - sal_uInt8 fltGet() { return flt; } - // variant, when ch==21: - bool fDifferGet() { - return (fltGet() >> 0) & 1; } - bool fResultDirtyGet() { - return (fltGet() >> 2) & 1; } - bool ResultEditedGet() { - return (fltGet() >> 3) & 1; } - bool fLockedGet() { - return (fltGet() >> 4) & 1; } - bool fPrivateResultGet() { - return (fltGet() >> 5) & 1; } - bool fNestedGet() { - return (fltGet() >> 6) & 1; } -}; - -struct W1_PIC // PictureStructure -{ - SVBT32 lcb;// 0x0 number of bytes in the PIC structure plus size of following picture data which may be a Window's metafile, a bitmap, or the filename of a TIFF file. - sal_uLong lcbGet() { - return SVBT32ToUInt32(lcb); } - SVBT16 cbHeader;// 0x4 number of bytes in the PIC (to allow for future expansion). - sal_uInt16 cbHeaderGet() { - return SVBT16ToShort(cbHeader); } - struct MFP { - SVBT16 mm;// 0x6 int - sal_uInt16 mmGet() { - return SVBT16ToShort(mm); } - SVBT16 xExt;// 0x8 int - sal_uInt16 xExtGet() { - return SVBT16ToShort(xExt); } - SVBT16 yExt;// 0xa int - sal_uInt16 yExtGet() { - return SVBT16ToShort(yExt); } - SVBT16 hMF;// 0xc int - sal_uInt16 hMFGet() { - return SVBT16ToShort(hMF); } - } mfp; - union W1_MFP_BMP { - sal_uInt8 bm[14];// 0xe BITMAP(14 bytes) Window's bitmap structure when PIC describes a BITMAP. - sal_uInt8 rcWinMF[14];// 0xe rc (rectangle - 8 bytes) rect for window origin and extents when metafile is stored -- ignored if 0 - } MFP_BMP; - SVBT16 dxaGoal;// 0x1c horizontal measurement in twips of the rectangle the picture should be imaged within. - sal_uInt16 dxaGoalGet() { - return SVBT16ToShort(dxaGoal); } - SVBT16 dyaGoal;// 0x1e vertical measurement in twips of the rectangle the picture should be imaged within. - sal_uInt16 dyaGoalGet() { - return SVBT16ToShort(dyaGoal); } - SVBT16 mx;// 0x20 horizontal scaling factor supplied by user in .1% units. - sal_uInt16 mxGet() { - return SVBT16ToShort(mx); } - SVBT16 my;// 0x22 vertical scaling factor supplied by user in .1% units. - sal_uInt16 myGet() { - return SVBT16ToShort(my); } - SVBT16 dxaCropLeft;// 0x24 the amount the picture has been cropped on the left in twips. - sal_uInt16 dxaCropLeftGet() { - return SVBT16ToShort(dxaCropLeft); } - SVBT16 dyaCropTop;// 0x26 the amount the picture has been cropped on the top in twips. - sal_uInt16 dyaCropTopGet() { - return SVBT16ToShort(dyaCropTop); } - SVBT16 dxaCropRight;// 0x28 the amount the picture has been cropped on the right in twips. - sal_uInt16 dxaCropRightGet() { - return SVBT16ToShort(dxaCropRight); } - SVBT16 dyaCropBottom;// 0x2a the amount the picture has been cropped on the bottom in twips. - sal_uInt16 dyaCropBottomGet() { - return SVBT16ToShort(dyaCropBottom); } - SVBT16 flags; - sal_uInt16 flagsGet() { - return SVBT16ToShort(flags); } -// brcl : 4;// 000F Obsolete, superseded by brcTop, etc. In - sal_uInt8 brclGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >(flagsGet() & 0xf); } -// fFrameEmpty : 1;// 0010 picture consists of a single frame - bool fFrameEmptyGet() { - return sal::static_int_cast< sal_uInt8, sal_uInt16 >((flagsGet() >> 4) & 1); } -// win6 stuff: -// fBitmap : 1;// 0020 ==1, when picture is just a bitmap -// sal_Bool fBitmapGet() { -// return (flagsGet() >> 5) & 1; } -// fDrawHatch : 1;// 0040 ==1, when picture is an active OLE object -// sal_Bool fDrawHatchGet() { -// return (flagsGet() >> 6) & 1; } -// fError : 1;// 0080 ==1, when picture is just an error message -// sal_Bool fErrorGet() { -// return (flagsGet() >> 7) & 1; } -// bpp : 8;// FF00 bits per pixel, 0 = unknown -// sal_uInt8 bppGet() { -// return (flagsGet() >> 8) & 0xff; } -// SVBT16 rgbrc[4]; -// sal_uInt16 rgbrcGet(sal_uInt16 nIndex) { -// return SVBT16ToShort(rgbrc[nIndex]); } -// W1_BRC brcTop;// 0x2e specification for border above picture -// W1_BRC brcLeft;// 0x30 specification for border to the left -// W1_BRC brcBottom;// 0x32 specification for border below picture -// W1_BRC brcRight;// 0x34 specification for border to the right -// SVBT16 dxaOrigin;// 0x36 horizontal offset of hand annotation origin -// sal_uInt16 dxaOriginGet() { -// return SVBT16ToShort(dxaOrigin); } -// SVBT16 dyaOrigin;// 0x38 vertical offset of hand annotation origin -// sal_uInt16 dyaOriginGet() { -// return SVBT16ToShort(dyaOrigin); } - sal_uInt8 rgb;// 0x3a variable array of bytes containing Window's metafile, bitmap or TIFF file filename. - sal_uInt8& rgbGet() { return rgb; } -}; - -struct W1_TBD -{ - sal_uInt8 aBits1; - sal_uInt8 aBits1Get() { return aBits1; } -// sal_uInt8 jc : 3;// 0x07 justification code: 0=left tab, 1=centered tab, 2=right tab, 3=decimal tab, 4=bar - sal_uInt8 jcGet() { - return aBits1Get() & 0x07; } -// sal_uInt8 tlc : 3;// 0x38 tab leader code: 0=no leader, 1=dotted leader, - // 2=hyphenated leader, 3=single line leader, 4=heavy line leader - sal_uInt8 tlcGet() { - return (aBits1Get() >> 3 ) & 0x07; } -// * int :2 C0 reserved -}; - -struct W1_TC -{ - sal_uInt8 aBits1; - sal_uInt8 aBits1Get() { return aBits1; } - sal_uInt8 fFirstMergedGet() { - return aBits1Get() & 0x01; } - sal_uInt8 fMergedGet() { - return (aBits1Get() >> 1 ) & 0x01; } - sal_uInt8 aBits2; -// SVBT16 fFirstMerged : 1;// 0001 set to 1 when cell is first cell of a range of cells that have been merged. -// SVBT16 fMerged : 1;// 0002 set to 1 when cell has been merged with preceding cell. -// SVBT16 fUnused : 14;// FFFC reserved - W1_BRC10 rgbrc[4];// notational convenience for referring to brcTop, brcLeft, etc fields. - W1_BRC10* rgbrcGet() { - return rgbrc; } -// BRC brcTop;// specification of the top border of a table cell -// BRC brcLeft;// specification of left border of table row -// BRC brcBottom;// specification of bottom border of table row -// BRC brcRight;// specification of right border of table row. -}; -// cbTC (count of bytes of a TC) is 10(decimal), A(hex). - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index b7be7533163d..462f0a6c9d20 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -422,8 +422,7 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium ) if( pOldFilter && ( pOldFilter->GetUserData() == FILTER_WW8 || pOldFilter->GetUserData() == "CWW6" || - pOldFilter->GetUserData() == "WW6" || - pOldFilter->GetUserData() == "WW1" ) ) + pOldFilter->GetUserData() == "WW6" ) ) { // when saving it in our own fileformat, then remove the template // name from the docinfo. |