LCOV - code coverage report
Current view: top level - libreoffice/lotuswordpro/source/filter - lwpdocdata.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 141 149 94.6 %
Date: 2012-12-27 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  *  The Contents of this file are made available subject to the terms of
       5             :  *  either of the following licenses
       6             :  *
       7             :  *         - GNU Lesser General Public License Version 2.1
       8             :  *         - Sun Industry Standards Source License Version 1.1
       9             :  *
      10             :  *  Sun Microsystems Inc., October, 2000
      11             :  *
      12             :  *  GNU Lesser General Public License Version 2.1
      13             :  *  =============================================
      14             :  *  Copyright 2000 by Sun Microsystems, Inc.
      15             :  *  901 San Antonio Road, Palo Alto, CA 94303, USA
      16             :  *
      17             :  *  This library is free software; you can redistribute it and/or
      18             :  *  modify it under the terms of the GNU Lesser General Public
      19             :  *  License version 2.1, as published by the Free Software Foundation.
      20             :  *
      21             :  *  This library is distributed in the hope that it will be useful,
      22             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      23             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24             :  *  Lesser General Public License for more details.
      25             :  *
      26             :  *  You should have received a copy of the GNU Lesser General Public
      27             :  *  License along with this library; if not, write to the Free Software
      28             :  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
      29             :  *  MA  02111-1307  USA
      30             :  *
      31             :  *
      32             :  *  Sun Industry Standards Source License Version 1.1
      33             :  *  =================================================
      34             :  *  The contents of this file are subject to the Sun Industry Standards
      35             :  *  Source License Version 1.1 (the "License"); You may not use this file
      36             :  *  except in compliance with the License. You may obtain a copy of the
      37             :  *  License at http://www.openoffice.org/license.html.
      38             :  *
      39             :  *  Software provided under this License is provided on an "AS IS" basis,
      40             :  *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
      41             :  *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
      42             :  *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
      43             :  *  See the License for the specific provisions governing your rights and
      44             :  *  obligations concerning the Software.
      45             :  *
      46             :  *  The Initial Developer of the Original Code is: IBM Corporation
      47             :  *
      48             :  *  Copyright: 2008 by IBM Corporation
      49             :  *
      50             :  *  All Rights Reserved.
      51             :  *
      52             :  *  Contributor(s): _______________________________________
      53             :  *
      54             :  *
      55             :  ************************************************************************/
      56             : #include "lwpdocdata.hxx"
      57             : #include "xfilter/xfofficemeta.hxx"
      58             : #include "localtime.hxx"
      59             : #include    <rtl/ustrbuf.hxx>
      60             : #include "lwpfilehdr.hxx"
      61             : #include "lwpglobalmgr.hxx"
      62             : 
      63           4 : LwpDocData::LwpDocData(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
      64           4 :     :LwpObject(objHdr, pStrm)//m_pEditorAttrList(0)
      65           4 : {}
      66             : 
      67           8 : LwpDocData::~LwpDocData()
      68             : {
      69           8 : }
      70             : 
      71           4 : void LwpDocData::Read()
      72             : {
      73             :     //XFDateTime
      74             :     //////////////////////////////////////////////////////////////////////////
      75             :     //doc options
      76             :     //cOptionFlag
      77           4 :     m_DocOptions.nOptionFlag = m_pObjStrm->QuickReaduInt16();
      78             :     //cEncrypt1Password
      79           4 :     m_DocOptions.encrypt1password.Read(m_pObjStrm);
      80             :     //cEncrypt2Password
      81           4 :     m_DocOptions.encrypt2password.Read(m_pObjStrm);
      82             :     //cCharecterSet
      83           4 :     m_DocOptions.characterSet.Read(m_pObjStrm);
      84             :     //cGrammerSet
      85           4 :     m_DocOptions.grammerSet.Read(m_pObjStrm);
      86             :     //cShowMarginMarks
      87           4 :     m_DocOptions.nMarginMarks = m_pObjStrm->QuickReaduInt16();
      88             :     //cMarginMarksLocation
      89           4 :     m_DocOptions.nMarginMarksLocation = m_pObjStrm->QuickReaduInt16();
      90             :     //cMarginMarksChar
      91           4 :     m_DocOptions.nMarginMarksChar = m_pObjStrm->QuickReaduInt16();
      92           4 :     m_pObjStrm->SkipExtra();
      93             :     //////////////////////////////////////////////////////////////////////////
      94             :     //doc info
      95             :     //cDescription
      96           4 :     m_DocInfo.description.Read(m_pObjStrm);
      97             :     //cKeyWord
      98           4 :     m_DocInfo.keywords.Read(m_pObjStrm);
      99             :     //cCreatedBy
     100           4 :     m_DocInfo.createdBy.Read(m_pObjStrm);
     101             :     //cCreationTime
     102           4 :     m_DocInfo.nCreationTime = m_pObjStrm->QuickReadInt32();
     103           4 :     LtgLocalTime(m_DocInfo.nCreationTime,m_nCreationTime);
     104             :     //cLastRevisionTime
     105           4 :     m_DocInfo.nLastRevisionTime = m_pObjStrm->QuickReadInt32();
     106           4 :     LtgLocalTime(m_DocInfo.nLastRevisionTime,m_nLastRevisionTime);
     107             :     //cTotalEditTime
     108           4 :     m_DocInfo.nTotalEditTime = m_pObjStrm->QuickReadInt32();
     109             : 
     110           4 :     m_nTotalEditTime.tm_hour = m_DocInfo.nTotalEditTime / 60;
     111           4 :     m_nTotalEditTime.tm_min = m_DocInfo.nTotalEditTime % 60;
     112           4 :     m_nTotalEditTime.tm_sec = 0;
     113             :     //cpVerDocInfo
     114           4 :     m_DocInfo.cpVerDocInfo.ReadIndexed(m_pObjStrm);
     115             : 
     116             :     //EditorList
     117           4 :     m_DocInfo.nNumEditedBy = m_pObjStrm->QuickReaduInt16();
     118           4 :     LwpAtomHolder* pCDLNList = new LwpAtomHolder[m_DocInfo.nNumEditedBy];
     119           4 :     LwpAtomHolder* pEditorList = new LwpAtomHolder[m_DocInfo.nNumEditedBy];
     120           4 :     sal_uInt16 i = 0;
     121          13 :     for ( i = 0; i < m_DocInfo.nNumEditedBy; i++)
     122             :     {
     123             :         //CDLNList
     124           9 :         pCDLNList[i].Read(m_pObjStrm);  //cName
     125           9 :         m_pObjStrm->SkipExtra();
     126             :         //CEditedBy
     127           9 :         pEditorList[i].Read(m_pObjStrm);    //cName
     128           9 :         m_pObjStrm->SkipExtra();
     129             :     }
     130             : 
     131           4 :     m_pObjStrm->SkipExtra();
     132             : 
     133           4 :     delete [] pCDLNList;
     134           4 :     delete [] pEditorList;
     135             :     //////////////////////////////////////////////////////////////////////////
     136             :     //doc control
     137             :     //cGreeting
     138           4 :     m_DocControl.cGreeting.Read(m_pObjStrm);
     139             :     //cFlags
     140           4 :     m_DocControl.nFlags = m_pObjStrm->QuickReaduInt16();
     141             : 
     142             :     //cDocControlProtection
     143           4 :     m_DocControl.nDocControlProtection = m_pObjStrm->QuickReaduInt16();
     144             :     //Len
     145           4 :     m_DocControl.nLen1 = m_pObjStrm->QuickReaduInt16();
     146             :     //skip doc control password string
     147           4 :     m_pObjStrm->SeekRel(m_DocControl.nLen1);
     148             : 
     149             :     //cFileProtection
     150           4 :     m_DocControl.nFileProtection = m_pObjStrm->QuickReaduInt16();
     151             :     //Len
     152           4 :     m_DocControl.nLen2 = m_pObjStrm->QuickReaduInt16();
     153             :     //skip file password string
     154           4 :     m_pObjStrm->SeekRel(m_DocControl.nLen2);
     155             : 
     156             :     //cAutoVersioning
     157           4 :     m_DocControl.nAutoVersioning = m_pObjStrm->QuickReaduInt16();
     158             :     //cDocControlOnlyEditor
     159           4 :     m_DocControl.cDocControlOnlyEditor.Read(m_pObjStrm);
     160             :     //cEditorVerification
     161           4 :     m_DocControl.nEditorVerification = m_pObjStrm->QuickReaduInt16();
     162             : 
     163           4 :     m_pObjStrm->SkipExtra();
     164             :     //////////////////////////////////////////////////////////////////////////
     165             :     //editor list
     166             :     //numeditors
     167           4 :     sal_uInt16 numeditors = m_pObjStrm->QuickReaduInt16();
     168           4 :     LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
     169             : 
     170          17 :     for (i = 0;i<numeditors;i++)
     171             :     {
     172          13 :         LwpEditorAttr* pEditorAttr = new LwpEditorAttr;
     173             :         //cName
     174          13 :         pEditorAttr->cName.Read(m_pObjStrm);
     175             :         //cInitials
     176          13 :         pEditorAttr->cInitials.Read(m_pObjStrm);
     177             :         //cHiLite
     178          13 :         pEditorAttr->cHiLiteColor.Read(m_pObjStrm);
     179             : 
     180             :         //cID
     181          13 :         pEditorAttr->nID = m_pObjStrm->QuickReaduInt16();
     182             : 
     183             :         //cInsFontOver
     184             :         //CFontAttributeOverride --cAttrBits
     185          13 :         pEditorAttr->cInsFontOver.cFontAttributeOverride.cAttrBits = m_pObjStrm->QuickReaduInt16();
     186             :         //CFontAttributeOverride --cAttrOverrideBits
     187          13 :         pEditorAttr->cInsFontOver.cFontAttributeOverride.cAttrOverrideBits = m_pObjStrm->QuickReaduInt16();
     188             :         //CFontAttributeOverride --cAttrApplyBits
     189          13 :         pEditorAttr->cInsFontOver.cFontAttributeOverride.cAttrApplyBits = m_pObjStrm->QuickReaduInt16();
     190             :         //CFontAttributeOverride --cAttrOverrideBits2
     191          13 :         pEditorAttr->cInsFontOver.cFontAttributeOverride.cAttrOverrideBits2 = m_pObjStrm->QuickReaduInt8();
     192             :         //CFontAttributeOverride --cAttrApplyBits2
     193          13 :         pEditorAttr->cInsFontOver.cFontAttributeOverride.cAttrApplyBits2 = m_pObjStrm->QuickReaduInt8();
     194             :         //CFontAttributeOverride --cCase
     195          13 :         pEditorAttr->cInsFontOver.cFontAttributeOverride.cCase = m_pObjStrm->QuickReaduInt8();
     196             :         //CFontAttributeOverride --cUnder
     197          13 :         pEditorAttr->cInsFontOver.cFontAttributeOverride.cUnder = m_pObjStrm->QuickReaduInt8();
     198          13 :         m_pObjStrm->SkipExtra();
     199             :         //CFontDescriptionOverrideBase--cOverrideBits
     200          13 :         pEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cOverrideBits = m_pObjStrm->QuickReaduInt8();
     201             :         //CFontDescriptionOverrideBase--cApplyBits
     202          13 :         pEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cApplyBits = m_pObjStrm->QuickReaduInt8();
     203             :         //CFontDescriptionOverrideBase--cPointSize
     204          13 :         pEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cPointSize = m_pObjStrm->QuickReadInt32();
     205             :         //CFontDescriptionOverrideBase--cOverstrike
     206          13 :         pEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cOverstrike = m_pObjStrm->QuickReaduInt8();
     207             :         //CFontDescriptionOverrideBase--cTightness
     208          13 :         pEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cTightness = m_pObjStrm->QuickReaduInt16();
     209             :         //CFontDescriptionOverrideBase--cColor
     210          13 :         pEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cColor.Read(m_pObjStrm);
     211             : 
     212             :         //CFontDescriptionOverrideBase--cBackgroundColor
     213          13 :         pEditorAttr->cInsFontOver.cFontDescriptionOverrideBase.cBackgroundColor.Read(m_pObjStrm);
     214             : 
     215          13 :         m_pObjStrm->SkipExtra();
     216             :         //cFaceName
     217          13 :         pEditorAttr->cInsFontOver.cFaceName.Read(m_pObjStrm);
     218             :         //cAltFaceName
     219          13 :         pEditorAttr->cInsFontOver.cAltFaceName.Read(m_pObjStrm);
     220          13 :         m_pObjStrm->SkipExtra();
     221             : 
     222             :         //cDelFontOver
     223             :         //CFontAttributeOverride --cAttrBits
     224          13 :         pEditorAttr->cDelFontOver.cFontAttributeOverride.cAttrBits = m_pObjStrm->QuickReaduInt16();
     225             :         //CFontAttributeOverride --cAttrOverrideBits
     226          13 :         pEditorAttr->cDelFontOver.cFontAttributeOverride.cAttrOverrideBits = m_pObjStrm->QuickReaduInt16();
     227             :         //CFontAttributeOverride --cAttrApplyBits
     228          13 :         pEditorAttr->cDelFontOver.cFontAttributeOverride.cAttrApplyBits = m_pObjStrm->QuickReaduInt16();
     229             :         //CFontAttributeOverride --cAttrOverrideBits2
     230          13 :         pEditorAttr->cDelFontOver.cFontAttributeOverride.cAttrOverrideBits2 = m_pObjStrm->QuickReaduInt8();
     231             :         //CFontAttributeOverride --cAttrApplyBits2
     232          13 :         pEditorAttr->cDelFontOver.cFontAttributeOverride.cAttrApplyBits2 = m_pObjStrm->QuickReaduInt8();
     233             :         //CFontAttributeOverride --cCase
     234          13 :         pEditorAttr->cDelFontOver.cFontAttributeOverride.cCase = m_pObjStrm->QuickReaduInt8();
     235             :         //CFontAttributeOverride --cUnder
     236          13 :         pEditorAttr->cDelFontOver.cFontAttributeOverride.cUnder = m_pObjStrm->QuickReaduInt8();
     237          13 :         m_pObjStrm->SkipExtra();
     238             :         //CFontDescriptionOverrideBase--cOverrideBits
     239          13 :         pEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cOverrideBits = m_pObjStrm->QuickReaduInt8();
     240             :         //CFontDescriptionOverrideBase--cApplyBits
     241          13 :         pEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cApplyBits = m_pObjStrm->QuickReaduInt8();
     242             :         //CFontDescriptionOverrideBase--cPointSize
     243          13 :         pEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cPointSize = m_pObjStrm->QuickReadInt32();
     244             :         //CFontDescriptionOverrideBase--cOverstrike
     245          13 :         pEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cOverstrike = m_pObjStrm->QuickReaduInt8();
     246             :         //CFontDescriptionOverrideBase--cTightness
     247          13 :         pEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cTightness = m_pObjStrm->QuickReaduInt16();
     248             :         //CFontDescriptionOverrideBase--cColor
     249          13 :         pEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cColor.Read(m_pObjStrm);
     250             : 
     251             :         //CFontDescriptionOverrideBase--cBackgroundColor
     252          13 :         pEditorAttr->cDelFontOver.cFontDescriptionOverrideBase.cBackgroundColor.Read(m_pObjStrm);
     253             : 
     254          13 :         m_pObjStrm->SkipExtra();
     255             :         //cFaceName
     256          13 :         pEditorAttr->cDelFontOver.cFaceName.Read(m_pObjStrm);
     257             :         //cAltFaceName
     258          13 :         pEditorAttr->cDelFontOver.cAltFaceName.Read(m_pObjStrm);
     259          13 :         m_pObjStrm->SkipExtra();
     260             : 
     261             :         //cAbilities
     262          13 :         pEditorAttr->nAbilities = m_pObjStrm->QuickReaduInt16();
     263             :         //cLocks
     264          13 :         pEditorAttr->nLocks = m_pObjStrm->QuickReaduInt16();
     265             :         //cSuggestions
     266          13 :         pEditorAttr->nSuggestions = m_pObjStrm->QuickReaduInt16();
     267             : 
     268             :         //cDelTextAttr
     269             :         //m_pEditorAttrList[i].cDelTextAttr.Read(m_pObjStrm);
     270          13 :         if (m_pObjStrm->QuickReadBool())
     271             :         {
     272           0 :             pEditorAttr->cDelTextAttr.cOverride.cValues = m_pObjStrm->QuickReaduInt16();
     273           0 :             pEditorAttr->cDelTextAttr.cOverride.cOverride = m_pObjStrm->QuickReaduInt16();
     274           0 :             pEditorAttr->cDelTextAttr.cOverride.cApply = m_pObjStrm->QuickReaduInt16();
     275           0 :             m_pObjStrm->SkipExtra();
     276           0 :             pEditorAttr->cDelTextAttr.cHideLevels = m_pObjStrm->QuickReaduInt16();
     277             : 
     278           0 :             if (LwpFileHeader::m_nFileRevision>= 0x000b)
     279             :             {
     280           0 :                 pEditorAttr->cDelTextAttr.cBaselineOffset = m_pObjStrm->QuickReadInt32();
     281             :             }
     282             :             else
     283             :             {
     284           0 :                 pEditorAttr->cDelTextAttr.cBaselineOffset = 0;
     285             :             }
     286             :         }
     287          13 :         m_pObjStrm->SkipExtra();
     288             : 
     289          13 :         m_pObjStrm->SkipExtra();
     290             : 
     291          13 :         pGlobal->SetEditorAttrMap(pEditorAttr->nID, pEditorAttr);
     292             :     }
     293           4 : }
     294           8 : rtl::OUString   LwpDocData::DateTimeToOUString(LtTm& dt)
     295             : {
     296           8 :     rtl::OUStringBuffer buf;
     297           8 :     buf.append((sal_Int32)dt.tm_year);
     298           8 :     buf.append( A2OUSTR("-") );
     299           8 :     buf.append((sal_Int32)dt.tm_mon);
     300           8 :     buf.append( A2OUSTR("-") );
     301           8 :     buf.append((sal_Int32)dt.tm_mday);
     302           8 :     buf.append( A2OUSTR("T") );
     303           8 :     buf.append((sal_Int32)dt.tm_hour);
     304           8 :     buf.append( A2OUSTR(":") );
     305           8 :     buf.append((sal_Int32)dt.tm_min);
     306           8 :     buf.append( A2OUSTR(":") );
     307           8 :     buf.append((sal_Int32)dt.tm_sec);
     308           8 :     buf.append( A2OUSTR(".") );
     309           8 :     buf.append((sal_Int32)0);
     310             : 
     311           8 :     return buf.makeStringAndClear();
     312             : }
     313           4 : rtl::OUString   LwpDocData::TimeToOUString(LtTm& dt)
     314             : {
     315             :     //PT3H43M44S
     316           4 :     rtl::OUStringBuffer buf;
     317           4 :     buf.append( A2OUSTR("PT") );
     318           4 :     buf.append((sal_Int32)dt.tm_hour);
     319           4 :     buf.append( A2OUSTR("H") );
     320           4 :     buf.append((sal_Int32)dt.tm_min);
     321           4 :     buf.append( A2OUSTR("M") );
     322           4 :     buf.append((sal_Int32)dt.tm_sec);
     323           4 :     buf.append( A2OUSTR("S") );
     324             : 
     325           4 :     return buf.makeStringAndClear();
     326             : }
     327           4 : void LwpDocData::Parse(IXFStream *pOutputStream)
     328             : {
     329             :     //<!DOCTYPE office:document-meta PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "office.dtd">
     330             :     //<office:document-meta xmlns:office="http://openoffice.org/2000/office" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" office:version="1.0">
     331             :     //</office:document-meta>
     332           4 :     XFOfficeMeta xfMeta;
     333           4 :     xfMeta.SetCreator(m_DocInfo.createdBy.str());
     334           4 :     xfMeta.SetDescription(m_DocInfo.description.str());
     335           4 :     xfMeta.SetKeywords(m_DocInfo.keywords.str());
     336           4 :     xfMeta.SetCreationTime(DateTimeToOUString(m_nCreationTime));
     337           4 :     xfMeta.SetLastTime(DateTimeToOUString(m_nLastRevisionTime));
     338           4 :     xfMeta.SetEditTime(TimeToOUString(m_nTotalEditTime));
     339           4 :     xfMeta.ToXml(pOutputStream);
     340           4 : }
     341             : 
     342             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10