LCOV - code coverage report
Current view: top level - sc/source/filter/xcl97 - xcl97rec.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 827 0.1 %
Date: 2012-08-25 Functions: 2 149 1.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 1165 0.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <svx/svdpool.hxx>
      31                 :            : #include <svx/sdtaitm.hxx>
      32                 :            : #include <svx/svdotext.hxx>
      33                 :            : #include <editeng/editobj.hxx>
      34                 :            : #include <svx/svdoole2.hxx>
      35                 :            : #include <sot/storage.hxx>
      36                 :            : #include <svl/itemset.hxx>
      37                 :            : #include <svx/svdpage.hxx>
      38                 :            : #include <svx/svdocapt.hxx>
      39                 :            : #include <svx/unoapi.hxx>
      40                 :            : #include <editeng/writingmodeitem.hxx>
      41                 :            : #include <vcl/svapp.hxx>
      42                 :            : #include <rtl/math.hxx>
      43                 :            : #include <svl/zformat.hxx>
      44                 :            : #include "cell.hxx"
      45                 :            : #include "drwlayer.hxx"
      46                 :            : 
      47                 :            : #include "xcl97rec.hxx"
      48                 :            : #include "xcl97esc.hxx"
      49                 :            : #include "editutil.hxx"
      50                 :            : #include "xecontent.hxx"
      51                 :            : #include "xeescher.hxx"
      52                 :            : #include "xestyle.hxx"
      53                 :            : #include "xelink.hxx"
      54                 :            : 
      55                 :            : #include "scitems.hxx"
      56                 :            : 
      57                 :            : #include <unotools/fltrcfg.hxx>
      58                 :            : #include <editeng/brshitem.hxx>
      59                 :            : #include <editeng/boxitem.hxx>
      60                 :            : #include <editeng/frmdiritem.hxx>
      61                 :            : #include <editeng/adjitem.hxx>
      62                 :            : #include <editeng/eeitem.hxx>
      63                 :            : #include <filter/msfilter/msoleexp.hxx>
      64                 :            : 
      65                 :            : #include <unotools/localedatawrapper.hxx>
      66                 :            : 
      67                 :            : #include <stdio.h>
      68                 :            : 
      69                 :            : #include "document.hxx"
      70                 :            : #include "conditio.hxx"
      71                 :            : #include "rangelst.hxx"
      72                 :            : #include "stlpool.hxx"
      73                 :            : #include "viewopti.hxx"
      74                 :            : #include "scextopt.hxx"
      75                 :            : #include "docoptio.hxx"
      76                 :            : #include "patattr.hxx"
      77                 :            : #include "tabprotection.hxx"
      78                 :            : #include "stlalgorithm.hxx"
      79                 :            : 
      80                 :            : #include <com/sun/star/sheet/XCellAddressable.hpp>
      81                 :            : #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
      82                 :            : #include <oox/token/tokens.hxx>
      83                 :            : #include <oox/export/shapes.hxx>
      84                 :            : #include <oox/export/utils.hxx>
      85                 :            : #include <oox/export/vmlexport.hxx>
      86                 :            : 
      87                 :            : using ::rtl::OString;
      88                 :            : using ::rtl::OUString;
      89                 :            : using namespace ::com::sun::star;
      90                 :            : using ::com::sun::star::uno::Reference;
      91                 :            : using ::oox::drawingml::DrawingML;
      92                 :            : using ::com::sun::star::uno::UNO_QUERY;
      93                 :            : using ::com::sun::star::beans::XPropertySet;
      94                 :            : using ::com::sun::star::drawing::XShape;
      95                 :            : using ::oox::drawingml::ShapeExport;
      96                 :            : using ::oox::vml::VMLExport;
      97                 :            : using namespace oox;
      98                 :            : 
      99                 :            : // ============================================================================
     100                 :            : 
     101                 :            : sal_Int32 XclExpObjList::mnDrawingMLCount;
     102                 :            : sal_Int32 XclExpObjList::mnVmlCount;
     103                 :            : 
     104                 :          0 : XclExpObjList::XclExpObjList( const XclExpRoot& rRoot, XclEscherEx& rEscherEx ) :
     105                 :            :     XclExpRoot( rRoot ),
     106                 :          0 :     mnScTab( rRoot.GetCurrScTab() ),
     107                 :            :     mrEscherEx( rEscherEx ),
     108   [ #  #  #  # ]:          0 :     pSolverContainer( 0 )
     109                 :            : {
     110 [ #  # ][ #  # ]:          0 :     pMsodrawingPerSheet = new XclExpMsoDrawing( rEscherEx );
     111                 :            :     // open the DGCONTAINER and the patriarch group shape
     112         [ #  # ]:          0 :     mrEscherEx.OpenContainer( ESCHER_DgContainer );
     113         [ #  # ]:          0 :     Rectangle aRect( 0, 0, 0, 0 );
     114         [ #  # ]:          0 :     mrEscherEx.EnterGroup( &aRect );
     115         [ #  # ]:          0 :     mrEscherEx.UpdateDffFragmentEnd();
     116                 :          0 : }
     117                 :            : 
     118         [ #  # ]:          0 : XclExpObjList::~XclExpObjList()
     119                 :            : {
     120         [ #  # ]:          0 :     ::std::for_each(maObjs.begin(), maObjs.end(), ScDeleteObjectByPtr<XclObj>());
     121 [ #  # ][ #  # ]:          0 :     delete pMsodrawingPerSheet;
     122 [ #  # ][ #  # ]:          0 :     delete pSolverContainer;
     123         [ #  # ]:          0 : }
     124                 :            : 
     125                 :          0 : sal_uInt16 XclExpObjList::Add( XclObj* pObj )
     126                 :            : {
     127                 :            :     OSL_ENSURE( maObjs.size() < 0xFFFF, "XclExpObjList::Add: too much for Xcl" );
     128                 :            : 
     129                 :          0 :     size_t nSize = maObjs.size();
     130                 :            : 
     131         [ #  # ]:          0 :     if ( nSize < 0xFFFF )
     132                 :            :     {
     133                 :          0 :         maObjs.push_back(pObj);
     134                 :          0 :         ++nSize;
     135                 :          0 :         pObj->SetId( nSize );
     136                 :          0 :         pObj->SetTab( mnScTab );
     137                 :            :     }
     138                 :            :     else
     139                 :            :     {
     140         [ #  # ]:          0 :         delete pObj;
     141                 :          0 :         nSize = 0;
     142                 :            :     }
     143                 :            : 
     144                 :          0 :     return nSize;
     145                 :            : }
     146                 :            : 
     147                 :          0 : void XclExpObjList::pop_back ()
     148                 :            : {
     149                 :          0 :     maObjs.pop_back();
     150                 :          0 : }
     151                 :            : 
     152                 :          0 : void XclExpObjList::EndSheet()
     153                 :            : {
     154                 :            :     // Is there still something in the stream? -> The solver container
     155         [ #  # ]:          0 :     if( mrEscherEx.HasPendingDffData() )
     156         [ #  # ]:          0 :         pSolverContainer = new XclExpMsoDrawing( mrEscherEx );
     157                 :            : 
     158                 :            :     // close the DGCONTAINER created by XclExpObjList ctor MSODRAWING
     159                 :          0 :     mrEscherEx.CloseContainer();
     160                 :          0 : }
     161                 :            : 
     162                 :          0 : void XclExpObjList::Save( XclExpStream& rStrm )
     163                 :            : {
     164                 :            :     //! Escher must be written, even if there are no objects
     165         [ #  # ]:          0 :     pMsodrawingPerSheet->Save( rStrm );
     166                 :            : 
     167                 :          0 :     std::vector<XclObj*>::iterator pIter;
     168 [ #  # ][ #  # ]:          0 :     for ( pIter = maObjs.begin(); pIter != maObjs.end(); ++pIter )
     169         [ #  # ]:          0 :         (*pIter)->Save( rStrm );
     170                 :            : 
     171         [ #  # ]:          0 :     if( pSolverContainer )
     172         [ #  # ]:          0 :         pSolverContainer->Save( rStrm );
     173                 :          0 : }
     174                 :            : 
     175                 :          0 : static bool IsVmlObject( const XclObj *rObj )
     176                 :            : {
     177         [ #  # ]:          0 :     switch( rObj->GetObjType() )
     178                 :            :     {
     179                 :            :         case EXC_OBJTYPE_NOTE:
     180                 :          0 :             return true;
     181                 :            :         default:
     182                 :          0 :             return false;
     183                 :            :     }
     184                 :            : }
     185                 :            : 
     186                 :            : 
     187                 :          0 : static sal_Int32 GetVmlObjectCount( XclExpObjList& rList )
     188                 :            : {
     189                 :          0 :     sal_Int32 nNumVml = 0;
     190                 :            : 
     191                 :          0 :     std::vector<XclObj*>::iterator pIter;
     192 [ #  # ][ #  # ]:          0 :     for ( pIter = rList.begin(); pIter != rList.end(); ++pIter )
     193         [ #  # ]:          0 :         if( IsVmlObject( *pIter ) )
     194                 :          0 :             ++nNumVml;
     195                 :            : 
     196                 :          0 :     return nNumVml;
     197                 :            : }
     198                 :            : 
     199                 :            : 
     200                 :          0 : static void SaveDrawingMLObjects( XclExpObjList& rList, XclExpXmlStream& rStrm, sal_Int32& nDrawingMLCount )
     201                 :            : {
     202         [ #  # ]:          0 :     sal_Int32 nVmlObjects = GetVmlObjectCount( rList );
     203         [ #  # ]:          0 :     if( (rList.size() - nVmlObjects) == 0 )
     204                 :          0 :         return;
     205                 :            : 
     206                 :          0 :     sal_Int32 nDrawing = ++nDrawingMLCount;
     207                 :          0 :     OUString sId;
     208                 :            :     sax_fastparser::FSHelperPtr pDrawing = rStrm.CreateOutputStream(
     209                 :            :             XclXmlUtils::GetStreamName( "xl/", "drawings/drawing", nDrawing ),
     210                 :            :             XclXmlUtils::GetStreamName( "../", "drawings/drawing", nDrawing ),
     211         [ #  # ]:          0 :             rStrm.GetCurrentStream()->getOutputStream(),
     212                 :            :             "application/vnd.openxmlformats-officedocument.drawing+xml",
     213                 :            :             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",
     214 [ #  # ][ #  # ]:          0 :             &sId );
         [ #  # ][ #  # ]
     215                 :            : 
     216         [ #  # ]:          0 :     rStrm.GetCurrentStream()->singleElement( XML_drawing,
     217                 :            :             FSNS( XML_r, XML_id ),  XclXmlUtils::ToOString( sId ).getStr(),
     218 [ #  # ][ #  # ]:          0 :             FSEND );
     219                 :            : 
     220 [ #  # ][ #  # ]:          0 :     rStrm.PushStream( pDrawing );
                 [ #  # ]
     221                 :            :     pDrawing->startElement( FSNS( XML_xdr, XML_wsDr ),
     222                 :            :             FSNS( XML_xmlns, XML_xdr ), "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
     223                 :            :             FSNS( XML_xmlns, XML_a ),   "http://schemas.openxmlformats.org/drawingml/2006/main",
     224                 :            :             FSNS( XML_xmlns, XML_r ),   "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
     225         [ #  # ]:          0 :             FSEND );
     226                 :            : 
     227                 :          0 :     std::vector<XclObj*>::iterator pIter;
     228 [ #  # ][ #  # ]:          0 :     for ( pIter = rList.begin(); pIter != rList.end(); ++pIter )
     229                 :            :     {
     230         [ #  # ]:          0 :         if( IsVmlObject( *pIter ) )
     231                 :          0 :             continue;
     232         [ #  # ]:          0 :         (*pIter)->SaveXml( rStrm );
     233                 :            :     }
     234                 :            : 
     235         [ #  # ]:          0 :     pDrawing->endElement( FSNS( XML_xdr, XML_wsDr ) );
     236                 :            : 
     237 [ #  # ][ #  # ]:          0 :     rStrm.PopStream();
     238                 :            : }
     239                 :            : 
     240                 :            : 
     241                 :          0 : static void SaveVmlObjects( XclExpObjList& rList, XclExpXmlStream& rStrm, sal_Int32& nVmlCount )
     242                 :            : {
     243 [ #  # ][ #  # ]:          0 :     if( GetVmlObjectCount( rList ) == 0 )
     244                 :          0 :         return;
     245                 :            : 
     246                 :          0 :     sal_Int32 nDrawing = ++nVmlCount;
     247                 :          0 :     OUString sId;
     248                 :            :     sax_fastparser::FSHelperPtr pVmlDrawing = rStrm.CreateOutputStream(
     249                 :            :             XclXmlUtils::GetStreamName( "xl/", "drawings/vmlDrawing", nDrawing ),
     250                 :            :             XclXmlUtils::GetStreamName( "../", "drawings/vmlDrawing", nDrawing ),
     251         [ #  # ]:          0 :             rStrm.GetCurrentStream()->getOutputStream(),
     252                 :            :             "application/vnd.openxmlformats-officedocument.vmlDrawing",
     253                 :            :             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
     254 [ #  # ][ #  # ]:          0 :             &sId );
         [ #  # ][ #  # ]
     255                 :            : 
     256         [ #  # ]:          0 :     rStrm.GetCurrentStream()->singleElement( XML_legacyDrawing,
     257                 :            :             FSNS( XML_r, XML_id ),  XclXmlUtils::ToOString( sId ).getStr(),
     258 [ #  # ][ #  # ]:          0 :             FSEND );
     259                 :            : 
     260 [ #  # ][ #  # ]:          0 :     rStrm.PushStream( pVmlDrawing );
                 [ #  # ]
     261                 :            :     pVmlDrawing->startElement( XML_xml,
     262                 :            :             FSNS( XML_xmlns, XML_v ),   "urn:schemas-microsoft-com:vml",
     263                 :            :             FSNS( XML_xmlns, XML_o ),   "urn:schemas-microsoft-com:office:office",
     264                 :            :             FSNS( XML_xmlns, XML_x ),   "urn:schemas-microsoft-com:office:excel",
     265         [ #  # ]:          0 :             FSEND );
     266                 :            : 
     267                 :          0 :     std::vector<XclObj*>::iterator pIter;
     268 [ #  # ][ #  # ]:          0 :     for ( pIter = rList.begin(); pIter != rList.end(); ++pIter )
     269                 :            :     {
     270         [ #  # ]:          0 :         if( !IsVmlObject( *pIter ) )
     271                 :          0 :             continue;
     272         [ #  # ]:          0 :         (*pIter)->SaveXml( rStrm );
     273                 :            :     }
     274                 :            : 
     275         [ #  # ]:          0 :     pVmlDrawing->endElement( XML_xml );
     276                 :            : 
     277 [ #  # ][ #  # ]:          0 :     rStrm.PopStream();
     278                 :            : }
     279                 :            : 
     280                 :            : 
     281                 :          0 : void XclExpObjList::SaveXml( XclExpXmlStream& rStrm )
     282                 :            : {
     283         [ #  # ]:          0 :     if( pSolverContainer )
     284                 :          0 :         pSolverContainer->SaveXml( rStrm );
     285                 :            : 
     286         [ #  # ]:          0 :     if( maObjs.empty())
     287                 :          0 :         return;
     288                 :            : 
     289                 :          0 :     SaveDrawingMLObjects( *this, rStrm, mnDrawingMLCount );
     290                 :          0 :     SaveVmlObjects( *this, rStrm, mnVmlCount );
     291                 :            : }
     292                 :            : 
     293                 :            : 
     294                 :          0 : void XclExpObjList::ResetCounters()
     295                 :            : {
     296                 :          0 :     mnDrawingMLCount    = 0;
     297                 :          0 :     mnVmlCount          = 0;
     298                 :          0 : }
     299                 :            : 
     300                 :            : // --- class XclObj --------------------------------------------------
     301                 :            : 
     302                 :          0 : XclObj::XclObj( XclExpObjectManager& rObjMgr, sal_uInt16 nObjType, bool bOwnEscher ) :
     303                 :            :     XclExpRecord( EXC_ID_OBJ, 26 ),
     304         [ #  # ]:          0 :     mrEscherEx( rObjMgr.GetEscherEx() ),
     305                 :            :     pClientTextbox( NULL ),
     306                 :            :     pTxo( NULL ),
     307                 :            :     mnObjType( nObjType ),
     308                 :            :     nObjId(0),
     309                 :            :     nGrbit( 0x6011 ),   // AutoLine, AutoFill, Printable, Locked
     310         [ #  # ]:          0 :     bFirstOnSheet( !rObjMgr.HasObj() ),
     311                 :          0 :     mbOwnEscher( bOwnEscher )
     312                 :            : {
     313                 :            :     //! first object continues the first MSODRAWING record
     314         [ #  # ]:          0 :     if ( bFirstOnSheet )
     315         [ #  # ]:          0 :         pMsodrawing = rObjMgr.GetMsodrawingPerSheet();
     316                 :            :     else
     317 [ #  # ][ #  # ]:          0 :         pMsodrawing = new XclExpMsoDrawing( mrEscherEx );
     318                 :          0 : }
     319                 :            : 
     320                 :          0 : XclObj::~XclObj()
     321                 :            : {
     322         [ #  # ]:          0 :     if ( !bFirstOnSheet )
     323 [ #  # ][ #  # ]:          0 :         delete pMsodrawing;
     324 [ #  # ][ #  # ]:          0 :     delete pClientTextbox;
     325 [ #  # ][ #  # ]:          0 :     delete pTxo;
     326         [ #  # ]:          0 : }
     327                 :            : 
     328                 :          0 : void XclObj::ImplWriteAnchor( const XclExpRoot& /*rRoot*/, const SdrObject* pSdrObj, const Rectangle* pChildAnchor )
     329                 :            : {
     330         [ #  # ]:          0 :     if( pChildAnchor )
     331                 :            :     {
     332                 :          0 :         mrEscherEx.AddChildAnchor( *pChildAnchor );
     333                 :            :     }
     334         [ #  # ]:          0 :     else if( pSdrObj )
     335                 :            :     {
     336         [ #  # ]:          0 :         ::std::auto_ptr< XclExpDffAnchorBase > xDffAnchor( mrEscherEx.CreateDffAnchor( *pSdrObj ) );
     337 [ #  # ][ #  # ]:          0 :         xDffAnchor->WriteDffData( mrEscherEx );
     338                 :            :     }
     339                 :          0 : }
     340                 :            : 
     341                 :          0 : void XclObj::SetEscherShapeType( sal_uInt16 nType )
     342                 :            : {
     343                 :            : //2do: what about the other defined ot... types?
     344   [ #  #  #  #  :          0 :     switch ( nType )
                #  #  # ]
     345                 :            :     {
     346                 :            :         case ESCHER_ShpInst_Line :
     347                 :          0 :             mnObjType = EXC_OBJTYPE_LINE;
     348                 :          0 :         break;
     349                 :            :         case ESCHER_ShpInst_Rectangle :
     350                 :            :         case ESCHER_ShpInst_RoundRectangle :
     351                 :          0 :             mnObjType = EXC_OBJTYPE_RECTANGLE;
     352                 :          0 :         break;
     353                 :            :         case ESCHER_ShpInst_Ellipse :
     354                 :          0 :             mnObjType = EXC_OBJTYPE_OVAL;
     355                 :          0 :         break;
     356                 :            :         case ESCHER_ShpInst_Arc :
     357                 :          0 :             mnObjType = EXC_OBJTYPE_ARC;
     358                 :          0 :         break;
     359                 :            :         case ESCHER_ShpInst_TextBox :
     360                 :          0 :             mnObjType = EXC_OBJTYPE_TEXT;
     361                 :          0 :         break;
     362                 :            :         case ESCHER_ShpInst_PictureFrame :
     363                 :          0 :             mnObjType = EXC_OBJTYPE_PICTURE;
     364                 :          0 :         break;
     365                 :            :         default:
     366                 :          0 :             mnObjType = EXC_OBJTYPE_DRAWING;
     367                 :            :     }
     368                 :          0 : }
     369                 :            : 
     370                 :          0 : void XclObj::SetText( const XclExpRoot& rRoot, const SdrTextObj& rObj )
     371                 :            : {
     372                 :            :     OSL_ENSURE( !pClientTextbox, "XclObj::SetText: already set" );
     373         [ #  # ]:          0 :     if ( !pClientTextbox )
     374                 :            :     {
     375                 :          0 :         mrEscherEx.UpdateDffFragmentEnd();
     376         [ #  # ]:          0 :         pClientTextbox = new XclExpMsoDrawing( mrEscherEx );
     377                 :          0 :         mrEscherEx.AddAtom( 0, ESCHER_ClientTextbox );    // TXO record
     378                 :          0 :         mrEscherEx.UpdateDffFragmentEnd();
     379         [ #  # ]:          0 :         pTxo = new XclTxo( rRoot, rObj );
     380                 :            :     }
     381                 :          0 : }
     382                 :            : 
     383                 :          0 : void XclObj::WriteBody( XclExpStream& rStrm )
     384                 :            : {
     385                 :            :     OSL_ENSURE( mnObjType != EXC_OBJTYPE_UNKNOWN, "XclObj::WriteBody - unknown type" );
     386                 :            : 
     387                 :            :     // create a substream to be able to create subrecords
     388         [ #  # ]:          0 :     SvMemoryStream aMemStrm;
     389 [ #  # ][ #  # ]:          0 :     ::std::auto_ptr< XclExpStream > pXclStrm( new XclExpStream( aMemStrm, rStrm.GetRoot() ) );
     390                 :            : 
     391                 :            :     // write the ftCmo subrecord
     392         [ #  # ]:          0 :     pXclStrm->StartRecord( EXC_ID_OBJCMO, 18 );
     393 [ #  # ][ #  # ]:          0 :     *pXclStrm << mnObjType << nObjId << nGrbit;
                 [ #  # ]
     394         [ #  # ]:          0 :     pXclStrm->WriteZeroBytes( 12 );
     395         [ #  # ]:          0 :     pXclStrm->EndRecord();
     396                 :            : 
     397                 :            :     // write other subrecords
     398         [ #  # ]:          0 :     WriteSubRecs( *pXclStrm );
     399                 :            : 
     400                 :            :     // write the ftEnd subrecord
     401         [ #  # ]:          0 :     pXclStrm->StartRecord( EXC_ID_OBJEND, 0 );
     402         [ #  # ]:          0 :     pXclStrm->EndRecord();
     403                 :            : 
     404                 :            :     // copy the data to the OBJ record
     405                 :          0 :     pXclStrm.reset();
     406         [ #  # ]:          0 :     aMemStrm.Seek( 0 );
     407 [ #  # ][ #  # ]:          0 :     rStrm.CopyFromStream( aMemStrm );
                 [ #  # ]
     408                 :          0 : }
     409                 :            : 
     410                 :          0 : void XclObj::Save( XclExpStream& rStrm )
     411                 :            : {
     412                 :            :     // MSODRAWING record (msofbtSpContainer)
     413         [ #  # ]:          0 :     if ( !bFirstOnSheet )
     414                 :          0 :         pMsodrawing->Save( rStrm );
     415                 :            : 
     416                 :            :     // OBJ
     417                 :          0 :     XclExpRecord::Save( rStrm );
     418                 :            : 
     419                 :            :     // second MSODRAWING record and TXO and CONTINUE records
     420                 :          0 :     SaveTextRecs( rStrm );
     421                 :          0 : }
     422                 :            : 
     423                 :          0 : void XclObj::WriteSubRecs( XclExpStream& /*rStrm*/ )
     424                 :            : {
     425                 :          0 : }
     426                 :            : 
     427                 :          0 : void XclObj::SaveTextRecs( XclExpStream& rStrm )
     428                 :            : {
     429                 :            :     // MSODRAWING record (msofbtClientTextbox)
     430         [ #  # ]:          0 :     if ( pClientTextbox )
     431                 :          0 :         pClientTextbox->Save( rStrm );
     432                 :            :     // TXO and CONTINUE records
     433         [ #  # ]:          0 :     if ( pTxo )
     434                 :          0 :         pTxo->Save( rStrm );
     435                 :          0 : }
     436                 :            : 
     437                 :            :   // --- class XclObjComment ------------------------------------------
     438                 :            : 
     439                 :          0 : XclObjComment::XclObjComment( XclExpObjectManager& rObjMgr, const Rectangle& rRect, const EditTextObject& rEditObj, SdrCaptionObj* pCaption, bool bVisible, const ScAddress& rAddress, Rectangle &rFrom, Rectangle &rTo ) :
     440                 :            :     XclObj( rObjMgr, EXC_OBJTYPE_NOTE, true )
     441                 :            :             , maScPos( rAddress )
     442                 :          0 :             , mpCaption( static_cast< SdrCaptionObj* >( pCaption->Clone() ) )
     443                 :            :             , mbVisible( bVisible )
     444                 :            :             , maFrom ( rFrom )
     445         [ #  # ]:          0 :             , maTo ( rTo )
     446                 :            : {
     447         [ #  # ]:          0 :     ProcessEscherObj( rObjMgr.GetRoot(), rRect, pCaption, bVisible);
     448                 :            :     // TXO
     449 [ #  # ][ #  # ]:          0 :     pTxo = new XclTxo( rObjMgr.GetRoot(), rEditObj, pCaption );
     450                 :          0 : }
     451                 :            : 
     452                 :          0 : static void lcl_FillProps( EscherPropertyContainer& rPropOpt, SdrObject* pCaption, bool bVisible )
     453                 :            : {
     454         [ #  # ]:          0 :     if( pCaption )
     455                 :            :     {
     456                 :          0 :         Reference< XShape > aXShape = GetXShapeForSdrObject( pCaption );
     457         [ #  # ]:          0 :         Reference< XPropertySet > aXPropSet( aXShape, UNO_QUERY );
     458         [ #  # ]:          0 :         if( aXPropSet.is() )
     459                 :            :         {
     460         [ #  # ]:          0 :             rPropOpt.CreateFillProperties( aXPropSet,  sal_True);
     461                 :            : 
     462         [ #  # ]:          0 :             rPropOpt.AddOpt( ESCHER_Prop_lTxid, 0 );                        // undocumented
     463         [ #  # ]:          0 :             rPropOpt.AddOpt( 0x0158, 0x00000000 );                          // undocumented
     464                 :            : 
     465                 :          0 :             sal_uInt32 nValue = 0;
     466 [ #  # ][ #  # ]:          0 :             if( !rPropOpt.GetOpt( ESCHER_Prop_FitTextToShape, nValue ) )
     467         [ #  # ]:          0 :                 rPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x00080008 );      // bool field
     468                 :            : 
     469 [ #  # ][ #  # ]:          0 :             if( rPropOpt.GetOpt( ESCHER_Prop_fillColor, nValue ) )
     470                 :            :             {
     471                 :            :                 // If the Colour is the same as the 'ToolTip' System colour then
     472                 :            :                 // use the default rather than the explicit colour value. This will
     473                 :            :                 // be incorrect where user has chosen to use this colour explicity.
     474                 :          0 :                 Color aColor = Color( (sal_uInt8)nValue, (sal_uInt8)( nValue >> 8 ), (sal_uInt8)( nValue >> 16 ) );
     475         [ #  # ]:          0 :                 const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
     476         [ #  # ]:          0 :                 if( aColor == rSett.GetHelpColor().GetColor() )
     477                 :            :                 {
     478         [ #  # ]:          0 :                     rPropOpt.AddOpt( ESCHER_Prop_fillColor, 0x08000050 );
     479         [ #  # ]:          0 :                     rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0x08000050 );
     480                 :            :                 }
     481                 :            :             }
     482                 :            :             else
     483         [ #  # ]:          0 :                 rPropOpt.AddOpt( ESCHER_Prop_fillColor, 0x08000050 );
     484                 :            : 
     485 [ #  # ][ #  # ]:          0 :             if( !rPropOpt.GetOpt( ESCHER_Prop_fillBackColor, nValue ) )
     486         [ #  # ]:          0 :                 rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, 0x08000050 );
     487 [ #  # ][ #  # ]:          0 :             if( !rPropOpt.GetOpt( ESCHER_Prop_fNoFillHitTest, nValue ) )
     488         [ #  # ]:          0 :                 rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x00110010 );      // bool field
     489 [ #  # ][ #  # ]:          0 :             if( !rPropOpt.GetOpt( ESCHER_Prop_shadowColor, nValue ) )
     490         [ #  # ]:          0 :                 rPropOpt.AddOpt( ESCHER_Prop_shadowColor, 0x00000000 );
     491 [ #  # ][ #  # ]:          0 :             if( !rPropOpt.GetOpt( ESCHER_Prop_fshadowObscured, nValue ) )       // bool field
     492         [ #  # ]:          0 :                 rPropOpt.AddOpt( ESCHER_Prop_fshadowObscured, 0x00030003 );     // bool field
     493                 :          0 :         }
     494                 :            :     }
     495                 :            : 
     496                 :          0 :     sal_uInt32 nFlags = 0x000A0000;
     497                 :          0 :     ::set_flag( nFlags, sal_uInt32(2), !bVisible );
     498         [ #  # ]:          0 :     rPropOpt.AddOpt( ESCHER_Prop_fPrint, nFlags );                  // bool field
     499                 :          0 : }
     500                 :            : 
     501                 :          0 : void XclObjComment::ProcessEscherObj( const XclExpRoot& rRoot, const Rectangle& rRect, SdrObject* pCaption, const bool bVisible )
     502                 :            : {
     503         [ #  # ]:          0 :     EscherPropertyContainer aPropOpt;
     504                 :            : 
     505                 :            : 
     506         [ #  # ]:          0 :     lcl_FillProps( aPropOpt, pCaption, bVisible );
     507                 :            : 
     508                 :          0 :     nGrbit = 0;     // all off: AutoLine, AutoFill, Printable, Locked
     509         [ #  # ]:          0 :     mrEscherEx.OpenContainer( ESCHER_SpContainer );
     510         [ #  # ]:          0 :     mrEscherEx.AddShape( ESCHER_ShpInst_TextBox, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
     511         [ #  # ]:          0 :     aPropOpt.Commit( mrEscherEx.GetStream() );
     512                 :            : 
     513 [ #  # ][ #  # ]:          0 :     XclExpDffNoteAnchor( rRoot, rRect ).WriteDffData( mrEscherEx );
                 [ #  # ]
     514                 :            : 
     515         [ #  # ]:          0 :     mrEscherEx.AddAtom( 0, ESCHER_ClientData );                        // OBJ record
     516         [ #  # ]:          0 :     mrEscherEx.UpdateDffFragmentEnd();
     517                 :            : 
     518                 :            :     //! Be sure to construct the MSODRAWING ClientTextbox record _after_ the
     519                 :            :     //! base OBJ's MSODRAWING record Escher data is completed.
     520 [ #  # ][ #  # ]:          0 :     pClientTextbox = new XclExpMsoDrawing( mrEscherEx );
     521         [ #  # ]:          0 :     mrEscherEx.AddAtom( 0, ESCHER_ClientTextbox );    // TXO record
     522         [ #  # ]:          0 :     mrEscherEx.UpdateDffFragmentEnd();
     523 [ #  # ][ #  # ]:          0 :     mrEscherEx.CloseContainer();   // ESCHER_SpContainer
     524                 :          0 : }
     525                 :            : 
     526         [ #  # ]:          0 : XclObjComment::~XclObjComment()
     527                 :            : {
     528         [ #  # ]:          0 : }
     529                 :            : 
     530                 :          0 : void XclObjComment::Save( XclExpStream& rStrm )
     531                 :            : {
     532                 :            :     // content of this record
     533                 :          0 :     XclObj::Save( rStrm );
     534                 :          0 : }
     535                 :            : 
     536         [ #  # ]:          0 : class VmlCommentExporter : public VMLExport
     537                 :            : {
     538                 :            :     ScAddress           maScPos;
     539                 :            :     SdrCaptionObj*      mpCaption;
     540                 :            :     bool                mbVisible;
     541                 :            :     Rectangle           maFrom;
     542                 :            :     Rectangle           maTo;
     543                 :            : 
     544                 :            : public:
     545                 :            :                         VmlCommentExporter ( sax_fastparser::FSHelperPtr p, ScAddress aScPos, SdrCaptionObj* pCaption, bool bVisible, Rectangle &aFrom, Rectangle &aTo );
     546                 :            : protected:
     547                 :            :     virtual void        Commit( EscherPropertyContainer& rProps, const Rectangle& rRect );
     548                 :            :     using VMLExport::StartShape;
     549                 :            :     virtual sal_Int32   StartShape();
     550                 :            :     using VMLExport::EndShape;
     551                 :            :     virtual void        EndShape( sal_Int32 nShapeElement );
     552                 :            : };
     553                 :            : 
     554                 :            : 
     555                 :          0 : VmlCommentExporter::VmlCommentExporter( sax_fastparser::FSHelperPtr p, ScAddress aScPos, SdrCaptionObj* pCaption,
     556                 :            :                                         bool bVisible, Rectangle &aFrom, Rectangle &aTo )
     557                 :            :     : VMLExport( p )
     558                 :            :     , maScPos( aScPos )
     559                 :            :     , mpCaption( pCaption )
     560                 :            :     , mbVisible( bVisible )
     561                 :            :     , maFrom ( aFrom )
     562         [ #  # ]:          0 :     , maTo ( aTo )
     563                 :            : {
     564                 :          0 : }
     565                 :            : 
     566                 :          0 : void VmlCommentExporter::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect )
     567                 :            : {
     568                 :          0 :     lcl_FillProps( rProps, mpCaption, mbVisible );
     569                 :          0 :     rProps.AddOpt( ESCHER_Prop_fHidden, mbVisible );            // bool field
     570                 :            : 
     571                 :            :     // shadow property value for comment ( set in lcl_FillProps [*] ) has been
     572                 :            :     // overwritten by new value ( 0x20000 ) in the generic part of the export
     573                 :            :     // ( see  EscherPropertyContainer::CreateShadowProperties )
     574                 :            :     // Safer option here is to just force the needed value here for oox vml
     575                 :            :     // export alone ( and avoid potential problems with binary export )
     576                 :            :     // #TODO investigate value of ESCHER_Prop_fshadowObscured generally
     577                 :            :     // in binary export ( if indeed this value is good for binary export )
     578                 :            :     // we can change the heuristics and/or initialisation path and get
     579                 :            :     // rid of line below.
     580                 :            :     // [*] lcl_FillProps seems to be called twice when exporting to xlsx
     581                 :            :     // once from XclObjComment::ProcessEscherObj #TODO look into that also
     582                 :          0 :     rProps.AddOpt( ESCHER_Prop_fshadowObscured, 0x00030003 ); // force value for comments
     583                 :            : 
     584                 :          0 :     VMLExport::Commit( rProps, rRect );
     585                 :          0 : }
     586                 :            : 
     587                 :          0 : sal_Int32 VmlCommentExporter::StartShape()
     588                 :            : {
     589         [ #  # ]:          0 :     AddShapeAttribute( XML_type, OString( "#_x0000_t202") );
     590                 :            : 
     591                 :          0 :     sal_Int32 nId = VMLExport::StartShape();
     592                 :            : 
     593                 :          0 :     return nId;
     594                 :            : }
     595                 :            : 
     596                 :          0 : void VmlCommentExporter::EndShape( sal_Int32 nShapeElement )
     597                 :            : {
     598                 :            :     char pAnchor[100];
     599         [ #  # ]:          0 :     sax_fastparser::FSHelperPtr pVmlDrawing = GetFS();
     600                 :            :     snprintf( pAnchor, 100, "%ld, %ld, %ld, %ld, %ld, %ld, %ld, %ld",
     601                 :          0 :                   maFrom.Left(), maFrom.Top(), maFrom.Right(), maFrom.Bottom(),
     602                 :          0 :                   maTo.Left(), maTo.Top(), maTo.Right(), maTo.Bottom() );
     603                 :            : 
     604                 :            :     pVmlDrawing->startElement( FSNS( XML_x, XML_ClientData ),
     605                 :            :             XML_ObjectType, "Note",
     606         [ #  # ]:          0 :             FSEND );
     607                 :            :     pVmlDrawing->singleElement( FSNS( XML_x, XML_MoveWithCells ),
     608         [ #  # ]:          0 :             FSEND );
     609                 :            :     pVmlDrawing->singleElement( FSNS( XML_x, XML_SizeWithCells ),
     610         [ #  # ]:          0 :             FSEND );
     611 [ #  # ][ #  # ]:          0 :     XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Anchor ), pAnchor );
         [ #  # ][ #  # ]
     612 [ #  # ][ #  # ]:          0 :     XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_AutoFill ), "False" );
         [ #  # ][ #  # ]
     613 [ #  # ][ #  # ]:          0 :     XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Row ), maScPos.Row() );
         [ #  # ][ #  # ]
     614 [ #  # ][ #  # ]:          0 :     XclXmlUtils::WriteElement( pVmlDrawing, FSNS( XML_x, XML_Column ), sal_Int32( maScPos.Col() ) );
         [ #  # ][ #  # ]
     615         [ #  # ]:          0 :     pVmlDrawing->endElement( FSNS( XML_x, XML_ClientData ) );
     616                 :            : 
     617 [ #  # ][ #  # ]:          0 :     VMLExport::EndShape( nShapeElement );
     618                 :          0 : }
     619                 :            : 
     620                 :          0 : void XclObjComment::SaveXml( XclExpXmlStream& rStrm )
     621                 :            : {
     622 [ #  # ][ #  # ]:          0 :     VmlCommentExporter aCommentExporter( rStrm.GetCurrentStream(), maScPos, mpCaption.get(), mbVisible, maFrom, maTo );
         [ #  # ][ #  # ]
     623 [ #  # ][ #  # ]:          0 :     aCommentExporter.AddSdrObject( *mpCaption );
     624                 :          0 : }
     625                 :            : 
     626                 :            : 
     627                 :            : // --- class XclObjDropDown ------------------------------------------
     628                 :            : 
     629                 :          0 : XclObjDropDown::XclObjDropDown( XclExpObjectManager& rObjMgr, const ScAddress& rPos, sal_Bool bFilt ) :
     630                 :            :     XclObj( rObjMgr, EXC_OBJTYPE_DROPDOWN, true ),
     631                 :          0 :     bIsFiltered( bFilt )
     632                 :            : {
     633                 :          0 :     SetLocked( sal_True );
     634                 :          0 :     SetPrintable( false );
     635                 :          0 :     SetAutoFill( sal_True );
     636                 :          0 :     SetAutoLine( false );
     637                 :          0 :     nGrbit |= 0x0100;   // undocumented
     638         [ #  # ]:          0 :     mrEscherEx.OpenContainer( ESCHER_SpContainer );
     639         [ #  # ]:          0 :     mrEscherEx.AddShape( ESCHER_ShpInst_HostControl, SHAPEFLAG_HAVEANCHOR | SHAPEFLAG_HAVESPT );
     640         [ #  # ]:          0 :     EscherPropertyContainer aPropOpt;
     641         [ #  # ]:          0 :     aPropOpt.AddOpt( ESCHER_Prop_LockAgainstGrouping, 0x01040104 ); // bool field
     642         [ #  # ]:          0 :     aPropOpt.AddOpt( ESCHER_Prop_FitTextToShape, 0x00080008 );      // bool field
     643         [ #  # ]:          0 :     aPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x00010000 );      // bool field
     644         [ #  # ]:          0 :     aPropOpt.AddOpt( ESCHER_Prop_fNoLineDrawDash, 0x00080000 );     // bool field
     645         [ #  # ]:          0 :     aPropOpt.AddOpt( ESCHER_Prop_fPrint, 0x000A0000 );              // bool field
     646         [ #  # ]:          0 :     aPropOpt.Commit( mrEscherEx.GetStream() );
     647                 :            : 
     648 [ #  # ][ #  # ]:          0 :     XclExpDffDropDownAnchor( rObjMgr.GetRoot(), rPos ).WriteDffData( mrEscherEx );
                 [ #  # ]
     649                 :            : 
     650         [ #  # ]:          0 :     mrEscherEx.AddAtom( 0, ESCHER_ClientData );                        // OBJ record
     651         [ #  # ]:          0 :     mrEscherEx.UpdateDffFragmentEnd();
     652         [ #  # ]:          0 :     mrEscherEx.CloseContainer();   // ESCHER_SpContainer
     653                 :            : 
     654                 :            :     // old size + ftSbs + ftLbsData
     655         [ #  # ]:          0 :     AddRecSize( 24 + 20 );
     656                 :          0 : }
     657                 :            : 
     658                 :          0 : XclObjDropDown::~XclObjDropDown()
     659                 :            : {
     660         [ #  # ]:          0 : }
     661                 :            : 
     662                 :          0 : void XclObjDropDown::WriteSubRecs( XclExpStream& rStrm )
     663                 :            : {
     664                 :            :     // ftSbs subrecord - Scroll bars (dummy)
     665         [ #  # ]:          0 :     rStrm.StartRecord( EXC_ID_OBJSBS, 20 );
     666         [ #  # ]:          0 :     rStrm.WriteZeroBytes( 20 );
     667         [ #  # ]:          0 :     rStrm.EndRecord();
     668                 :            : 
     669                 :            :     // ftLbsData subrecord - Listbox data
     670                 :          0 :     sal_uInt16 nDropDownFlags = 0;
     671                 :          0 :     ::insert_value( nDropDownFlags, EXC_OBJ_DROPDOWN_SIMPLE, 0, 2 );
     672                 :          0 :     ::set_flag( nDropDownFlags, EXC_OBJ_DROPDOWN_FILTERED, bIsFiltered );
     673         [ #  # ]:          0 :     rStrm.StartRecord( EXC_ID_OBJLBSDATA, 16 );
     674 [ #  # ][ #  # ]:          0 :     rStrm   << (sal_uInt32)0 << (sal_uInt16)0 << (sal_uInt16)0x0301 << (sal_uInt16)0
         [ #  # ][ #  # ]
     675 [ #  # ][ #  # ]:          0 :             << nDropDownFlags << sal_uInt16( 20 ) << sal_uInt16( 130 );
                 [ #  # ]
     676         [ #  # ]:          0 :     rStrm.EndRecord();
     677                 :          0 : }
     678                 :            : 
     679                 :            : // --- class XclTxo --------------------------------------------------
     680                 :            : 
     681                 :          0 : sal_uInt8 lcl_GetHorAlignFromItemSet( const SfxItemSet& rItemSet )
     682                 :            : {
     683                 :          0 :     sal_uInt8 nHorAlign = EXC_OBJ_HOR_LEFT;
     684                 :            : 
     685   [ #  #  #  #  :          0 :     switch( static_cast< const SvxAdjustItem& >( rItemSet.Get( EE_PARA_JUST ) ).GetAdjust() )
                      # ]
     686                 :            :     {
     687                 :          0 :         case SVX_ADJUST_LEFT:   nHorAlign = EXC_OBJ_HOR_LEFT;      break;
     688                 :          0 :         case SVX_ADJUST_CENTER: nHorAlign = EXC_OBJ_HOR_CENTER;    break;
     689                 :          0 :         case SVX_ADJUST_RIGHT:  nHorAlign = EXC_OBJ_HOR_RIGHT;     break;
     690                 :          0 :         case SVX_ADJUST_BLOCK:  nHorAlign = EXC_OBJ_HOR_JUSTIFY;   break;
     691                 :            :         default:;
     692                 :            :     }
     693                 :          0 :     return nHorAlign;
     694                 :            : }
     695                 :            : 
     696                 :          0 : sal_uInt8 lcl_GetVerAlignFromItemSet( const SfxItemSet& rItemSet )
     697                 :            : {
     698                 :          0 :     sal_uInt8 nVerAlign = EXC_OBJ_VER_TOP;
     699                 :            : 
     700   [ #  #  #  #  :          0 :     switch( static_cast< const SdrTextVertAdjustItem& >( rItemSet.Get( SDRATTR_TEXT_VERTADJUST ) ).GetValue() )
                      # ]
     701                 :            :     {
     702                 :          0 :         case SDRTEXTVERTADJUST_TOP:     nVerAlign = EXC_OBJ_VER_TOP;       break;
     703                 :          0 :         case SDRTEXTVERTADJUST_CENTER:  nVerAlign = EXC_OBJ_VER_CENTER;    break;
     704                 :          0 :         case SDRTEXTVERTADJUST_BOTTOM:  nVerAlign = EXC_OBJ_VER_BOTTOM;    break;
     705                 :          0 :         case SDRTEXTVERTADJUST_BLOCK:   nVerAlign = EXC_OBJ_VER_JUSTIFY;   break;
     706                 :            :     }
     707                 :          0 :     return nVerAlign;
     708                 :            : }
     709                 :            : 
     710                 :          0 : XclTxo::XclTxo( const String& rString, sal_uInt16 nFontIx ) :
     711         [ #  # ]:          0 :     mpString( new XclExpString( rString ) ),
     712                 :            :     mnRotation( EXC_OBJ_ORIENT_NONE ),
     713                 :            :     mnHorAlign( EXC_OBJ_HOR_LEFT ),
     714 [ #  # ][ #  # ]:          0 :     mnVerAlign( EXC_OBJ_VER_TOP )
     715                 :            : {
     716         [ #  # ]:          0 :     if( mpString->Len() )
     717                 :            :     {
     718                 :            :         // If there is text, Excel *needs* the 2nd CONTINUE record with at least two format runs
     719         [ #  # ]:          0 :         mpString->AppendFormat( 0, nFontIx );
     720         [ #  # ]:          0 :         mpString->AppendFormat( mpString->Len(), EXC_FONT_APP );
     721                 :            :     }
     722                 :          0 : }
     723                 :            : 
     724                 :          0 : XclTxo::XclTxo( const XclExpRoot& rRoot, const SdrTextObj& rTextObj ) :
     725                 :            :     mpString( XclExpStringHelper::CreateString( rRoot, rTextObj ) ),
     726                 :            :     mnRotation( EXC_OBJ_ORIENT_NONE ),
     727                 :            :     mnHorAlign( EXC_OBJ_HOR_LEFT ),
     728         [ #  # ]:          0 :     mnVerAlign( EXC_OBJ_VER_TOP )
     729                 :            : {
     730                 :            :     // additional alignment and orientation items
     731         [ #  # ]:          0 :     const SfxItemSet& rItemSet = rTextObj.GetMergedItemSet();
     732                 :            : 
     733                 :            :     // horizontal alignment
     734         [ #  # ]:          0 :     SetHorAlign( lcl_GetHorAlignFromItemSet( rItemSet ) );
     735                 :            : 
     736                 :            :     // vertical alignment
     737         [ #  # ]:          0 :     SetVerAlign( lcl_GetVerAlignFromItemSet( rItemSet ) );
     738                 :            : 
     739                 :            :     // rotation
     740         [ #  # ]:          0 :     long nAngle = rTextObj.GetRotateAngle();
     741 [ #  # ][ #  # ]:          0 :     if( (4500 < nAngle) && (nAngle < 13500) )
     742                 :          0 :         mnRotation = EXC_OBJ_ORIENT_90CCW;
     743 [ #  # ][ #  # ]:          0 :     else if( (22500 < nAngle) && (nAngle < 31500) )
     744                 :          0 :         mnRotation = EXC_OBJ_ORIENT_90CW;
     745                 :            :     else
     746                 :          0 :         mnRotation = EXC_OBJ_ORIENT_NONE;
     747                 :          0 : }
     748                 :            : 
     749                 :          0 : XclTxo::XclTxo( const XclExpRoot& rRoot, const EditTextObject& rEditObj, SdrObject* pCaption ) :
     750                 :            :     mpString( XclExpStringHelper::CreateString( rRoot, rEditObj ) ),
     751                 :            :     mnRotation( EXC_OBJ_ORIENT_NONE ),
     752                 :            :     mnHorAlign( EXC_OBJ_HOR_LEFT ),
     753         [ #  # ]:          0 :     mnVerAlign( EXC_OBJ_VER_TOP )
     754                 :            : {
     755         [ #  # ]:          0 :     if(pCaption)
     756                 :            :     {
     757                 :            :         // Excel has one alignment per NoteObject while Calc supports
     758                 :            :         // one alignment per paragraph - use the first paragraph
     759                 :            :         // alignment (if set) as our overall alignment.
     760         [ #  # ]:          0 :         String aParaText( rEditObj.GetText( 0 ) );
     761         [ #  # ]:          0 :         if( aParaText.Len() )
     762                 :            :         {
     763         [ #  # ]:          0 :             SfxItemSet aSet( rEditObj.GetParaAttribs( 0));
     764                 :          0 :             const SfxPoolItem* pItem = NULL;
     765 [ #  # ][ #  # ]:          0 :             if( aSet.GetItemState( EE_PARA_JUST, sal_True, &pItem ) == SFX_ITEM_SET )
     766                 :            :             {
     767                 :          0 :                 SvxAdjust eEEAlign = static_cast< const SvxAdjustItem& >( *pItem ).GetAdjust();
     768 [ #  # ][ #  # ]:          0 :                 pCaption->SetMergedItem( SvxAdjustItem( eEEAlign, EE_PARA_JUST ) );
                 [ #  # ]
     769         [ #  # ]:          0 :             }
     770                 :            :         }
     771         [ #  # ]:          0 :         const SfxItemSet& rItemSet = pCaption->GetMergedItemSet();
     772                 :            : 
     773                 :            :         // horizontal alignment
     774         [ #  # ]:          0 :         SetHorAlign( lcl_GetHorAlignFromItemSet( rItemSet ) );
     775                 :            : 
     776                 :            :         // vertical alignment
     777         [ #  # ]:          0 :         SetVerAlign( lcl_GetVerAlignFromItemSet( rItemSet ) );
     778                 :            : 
     779                 :            :         // orientation alignment
     780         [ #  # ]:          0 :         const SvxWritingModeItem& rItem = static_cast< const SvxWritingModeItem& >( rItemSet.Get( SDRATTR_TEXTDIRECTION ) );
     781         [ #  # ]:          0 :         if( rItem.GetValue() == com::sun::star::text::WritingMode_TB_RL )
     782         [ #  # ]:          0 :             mnRotation = EXC_OBJ_ORIENT_90CW;
     783                 :            :     }
     784                 :          0 : }
     785                 :            : 
     786                 :          0 : void XclTxo::SaveCont( XclExpStream& rStrm )
     787                 :            : {
     788                 :            :     OSL_ENSURE( mpString.get(), "XclTxo::SaveCont - missing string" );
     789                 :            : 
     790                 :            :     // #i96858# do not save existing string formatting if text is empty
     791 [ #  # ][ #  # ]:          0 :     sal_uInt16 nRunLen = mpString->IsEmpty() ? 0 : (8 * mpString->GetFormatsCount());
     792                 :            :     // alignment
     793                 :          0 :     sal_uInt16 nFlags = 0;
     794                 :          0 :     ::insert_value( nFlags, mnHorAlign, 1, 3 );
     795                 :          0 :     ::insert_value( nFlags, mnVerAlign, 4, 3 );
     796                 :            : 
     797 [ #  # ][ #  # ]:          0 :     rStrm << nFlags << mnRotation;
     798         [ #  # ]:          0 :     rStrm.WriteZeroBytes( 6 );
     799 [ #  # ][ #  # ]:          0 :     rStrm << mpString->Len() << nRunLen << sal_uInt32( 0 );
                 [ #  # ]
     800                 :          0 : }
     801                 :            : 
     802                 :          0 : void XclTxo::Save( XclExpStream& rStrm )
     803                 :            : {
     804                 :            :     // Write the TXO part
     805                 :          0 :     ExcRecord::Save( rStrm );
     806                 :            : 
     807                 :            :     // CONTINUE records are only written if there is some text
     808         [ #  # ]:          0 :     if( !mpString->IsEmpty() )
     809                 :            :     {
     810                 :            :         // CONTINUE for character array
     811                 :          0 :         rStrm.StartRecord( EXC_ID_CONT, mpString->GetBufferSize() + 1 );
     812                 :          0 :         rStrm << static_cast< sal_uInt8 >( mpString->GetFlagField() & EXC_STRF_16BIT ); // only Unicode flag
     813                 :          0 :         mpString->WriteBuffer( rStrm );
     814                 :          0 :         rStrm.EndRecord();
     815                 :            : 
     816                 :            :         // CONTINUE for formatting runs
     817                 :          0 :         rStrm.StartRecord( EXC_ID_CONT, 8 * mpString->GetFormatsCount() );
     818                 :          0 :         const XclFormatRunVec& rFormats = mpString->GetFormats();
     819 [ #  # ][ #  # ]:          0 :         for( XclFormatRunVec::const_iterator aIt = rFormats.begin(), aEnd = rFormats.end(); aIt != aEnd; ++aIt )
     820 [ #  # ][ #  # ]:          0 :             rStrm << aIt->mnChar << aIt->mnFontIdx << sal_uInt32( 0 );
                 [ #  # ]
     821                 :          0 :         rStrm.EndRecord();
     822                 :            :     }
     823                 :          0 : }
     824                 :            : 
     825                 :          0 : sal_uInt16 XclTxo::GetNum() const
     826                 :            : {
     827                 :          0 :     return EXC_ID_TXO;
     828                 :            : }
     829                 :            : 
     830                 :          0 : sal_Size XclTxo::GetLen() const
     831                 :            : {
     832                 :          0 :     return 18;
     833                 :            : }
     834                 :            : 
     835                 :            : // --- class XclObjOle -------------------------------------------
     836                 :            : 
     837                 :          0 : XclObjOle::XclObjOle( XclExpObjectManager& rObjMgr, const SdrObject& rObj ) :
     838                 :            :     XclObj( rObjMgr, EXC_OBJTYPE_PICTURE ),
     839                 :            :     rOleObj( rObj ),
     840 [ #  # ][ #  # ]:          0 :     pRootStorage( rObjMgr.GetRoot().GetRootStorage() )
     841                 :            : {
     842                 :          0 : }
     843                 :            : 
     844                 :          0 : XclObjOle::~XclObjOle()
     845                 :            : {
     846         [ #  # ]:          0 : }
     847                 :            : 
     848                 :          0 : void XclObjOle::WriteSubRecs( XclExpStream& rStrm )
     849                 :            : {
     850                 :            :     // write only as embedded, not linked
     851         [ #  # ]:          0 :     String          aStorageName( RTL_CONSTASCII_USTRINGPARAM( "MBD" ) );
     852                 :            :     sal_Char        aBuf[ sizeof(sal_uInt32) * 2 + 1 ];
     853                 :            :     // FIXME Eeek! Is this just a way to get a unique id?
     854                 :          0 :     sal_uInt32          nPictureId = sal_uInt32(sal_uIntPtr(this) >> 2);
     855                 :          0 :     sprintf( aBuf, "%08X", static_cast< unsigned int >( nPictureId ) );
     856         [ #  # ]:          0 :     aStorageName.AppendAscii( aBuf );
     857                 :            :     SotStorageRef    xOleStg = pRootStorage->OpenSotStorage( aStorageName,
     858         [ #  # ]:          0 :                             STREAM_READWRITE| STREAM_SHARE_DENYALL );
     859         [ #  # ]:          0 :     if( xOleStg.Is() )
     860                 :            :     {
     861         [ #  # ]:          0 :         uno::Reference < embed::XEmbeddedObject > xObj( ((SdrOle2Obj&)rOleObj).GetObjRef() );
     862         [ #  # ]:          0 :         if ( xObj.is() )
     863                 :            :         {
     864                 :            :             // set version to "old" version, because it must be
     865                 :            :             // saved in MS notation.
     866                 :          0 :             sal_uInt32                  nFl = 0;
     867         [ #  # ]:          0 :             const SvtFilterOptions& rFltOpts = SvtFilterOptions::Get();
     868 [ #  # ][ #  # ]:          0 :             if( rFltOpts.IsMath2MathType() )
     869                 :          0 :                 nFl |= OLE_STARMATH_2_MATHTYPE;
     870                 :            : 
     871 [ #  # ][ #  # ]:          0 :             if( rFltOpts.IsWriter2WinWord() )
     872                 :          0 :                 nFl |= OLE_STARWRITER_2_WINWORD;
     873                 :            : 
     874 [ #  # ][ #  # ]:          0 :             if( rFltOpts.IsCalc2Excel() )
     875                 :          0 :                 nFl |= OLE_STARCALC_2_EXCEL;
     876                 :            : 
     877 [ #  # ][ #  # ]:          0 :             if( rFltOpts.IsImpress2PowerPoint() )
     878                 :          0 :                 nFl |= OLE_STARIMPRESS_2_POWERPOINT;
     879                 :            : 
     880                 :          0 :             SvxMSExportOLEObjects   aOLEExpFilt( nFl );
     881         [ #  # ]:          0 :             aOLEExpFilt.ExportOLEObject( xObj, *xOleStg );
     882                 :            : 
     883                 :            :             // OBJCF subrecord, undocumented as usual
     884         [ #  # ]:          0 :             rStrm.StartRecord( EXC_ID_OBJCF, 2 );
     885         [ #  # ]:          0 :             rStrm << sal_uInt16(0x0002);
     886         [ #  # ]:          0 :             rStrm.EndRecord();
     887                 :            : 
     888                 :            :             // OBJFLAGS subrecord, undocumented as usual
     889         [ #  # ]:          0 :             rStrm.StartRecord( EXC_ID_OBJFLAGS, 2 );
     890                 :          0 :             sal_uInt16 nFlags = EXC_OBJ_PIC_MANUALSIZE;
     891         [ #  # ]:          0 :             ::set_flag( nFlags, EXC_OBJ_PIC_SYMBOL, ((SdrOle2Obj&)rOleObj).GetAspect() == embed::Aspects::MSOLE_ICON );
     892         [ #  # ]:          0 :             rStrm << nFlags;
     893         [ #  # ]:          0 :             rStrm.EndRecord();
     894                 :            : 
     895                 :            :             // OBJPICTFMLA subrecord, undocumented as usual
     896 [ #  # ][ #  # ]:          0 :             XclExpString aName( xOleStg->GetUserName() );
                 [ #  # ]
     897         [ #  # ]:          0 :             sal_uInt16 nPadLen = (sal_uInt16)(aName.GetSize() & 0x01);
     898         [ #  # ]:          0 :             sal_uInt16 nFmlaLen = static_cast< sal_uInt16 >( 12 + aName.GetSize() + nPadLen );
     899                 :          0 :             sal_uInt16 nSubRecLen = nFmlaLen + 6;
     900                 :            : 
     901         [ #  # ]:          0 :             rStrm.StartRecord( EXC_ID_OBJPICTFMLA, nSubRecLen );
     902         [ #  # ]:          0 :             rStrm   << nFmlaLen
     903 [ #  # ][ #  # ]:          0 :                     << sal_uInt16( 5 ) << sal_uInt32( 0 ) << sal_uInt8( 2 )
                 [ #  # ]
     904 [ #  # ][ #  # ]:          0 :                     << sal_uInt32( 0 ) << sal_uInt8( 3 )
     905         [ #  # ]:          0 :                     << aName;
     906         [ #  # ]:          0 :             if( nPadLen )
     907         [ #  # ]:          0 :                 rStrm << sal_uInt8( 0 );       // pad byte
     908         [ #  # ]:          0 :             rStrm << nPictureId;
     909         [ #  # ]:          0 :             rStrm.EndRecord();
     910                 :          0 :         }
     911 [ #  # ][ #  # ]:          0 :     }
     912                 :          0 : }
     913                 :            : 
     914                 :          0 : void XclObjOle::Save( XclExpStream& rStrm )
     915                 :            : {
     916                 :            :     // content of this record
     917                 :          0 :     XclObj::Save( rStrm );
     918                 :          0 : }
     919                 :            : 
     920                 :            : // --- class XclObjAny -------------------------------------------
     921                 :            : 
     922                 :          0 : XclObjAny::XclObjAny( XclExpObjectManager& rObjMgr, const Reference< XShape >& rShape )
     923                 :            :     : XclObj( rObjMgr, EXC_OBJTYPE_UNKNOWN )
     924                 :          0 :     , mxShape( rShape )
     925                 :            : {
     926                 :          0 : }
     927                 :            : 
     928                 :          0 : XclObjAny::~XclObjAny()
     929                 :            : {
     930         [ #  # ]:          0 : }
     931                 :            : 
     932                 :          0 : void XclObjAny::WriteSubRecs( XclExpStream& rStrm )
     933                 :            : {
     934         [ #  # ]:          0 :     if( mnObjType == EXC_OBJTYPE_GROUP )
     935                 :            :         // ftGmo subrecord
     936                 :          0 :         rStrm << EXC_ID_OBJGMO << sal_uInt16(2) << sal_uInt16(0);
     937                 :          0 : }
     938                 :            : 
     939                 :          0 : void XclObjAny::Save( XclExpStream& rStrm )
     940                 :            : {
     941         [ #  # ]:          0 :     if( mnObjType == EXC_OBJTYPE_GROUP )
     942                 :            :         // old size + ftGmo
     943                 :          0 :         AddRecSize( 6 );
     944                 :            : 
     945                 :            :     // content of this record
     946                 :          0 :     XclObj::Save( rStrm );
     947                 :          0 : }
     948                 :            : 
     949                 :            : // --- class ExcBof8_Base --------------------------------------------
     950                 :            : 
     951                 :          0 : ExcBof8_Base::ExcBof8_Base()
     952                 :            : {
     953                 :          0 :     nVers           = 0x0600;
     954                 :          0 :     nRupBuild       = 0x0dbb;
     955                 :          0 :     nRupYear        = 0x07cc;
     956                 :            : //  nFileHistory    = 0x00000001;   // last edited by Microsoft Excel for Windows
     957                 :          0 :     nFileHistory    = 0x00000000;
     958                 :          0 :     nLowestBiffVer  = 0x00000006;   // Biff8
     959                 :          0 : }
     960                 :          0 : void XclObjAny::WriteFromTo( XclExpXmlStream& rStrm, const Reference< XShape >& rShape, SCTAB nTab )
     961                 :            : {
     962 [ #  # ][ #  # ]:          0 :     sax_fastparser::FSHelperPtr pDrawing = rStrm.GetCurrentStream();
     963                 :            : 
     964 [ #  # ][ #  # ]:          0 :     awt::Point  aTopLeft    = rShape->getPosition();
     965 [ #  # ][ #  # ]:          0 :     awt::Size   aSize       = rShape->getSize();
     966         [ #  # ]:          0 :     Rectangle   aLocation( aTopLeft.X, aTopLeft.Y, aTopLeft.X + aSize.Width, aTopLeft.Y + aSize.Height );
     967         [ #  # ]:          0 :     ScRange     aRange      = rStrm.GetRoot().GetDoc().GetRange( nTab, aLocation );
     968                 :          0 :     Rectangle   aRangeRect  = rStrm.GetRoot().GetDoc().GetMMRect( aRange.aStart.Col(), aRange.aStart.Row(),
     969                 :          0 :             aRange.aEnd.Col()-1, aRange.aEnd.Row()-1,
     970         [ #  # ]:          0 :             nTab );
     971                 :            : 
     972                 :            : 
     973                 :            :     pDrawing->startElement( FSNS( XML_xdr, XML_from ),
     974         [ #  # ]:          0 :             FSEND );
     975 [ #  # ][ #  # ]:          0 :     XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_col ), (sal_Int32) aRange.aStart.Col() );
         [ #  # ][ #  # ]
     976                 :            :     XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_colOff ),
     977 [ #  # ][ #  # ]:          0 :             MM100toEMU( aLocation.Left() - aRangeRect.Left() ) );
         [ #  # ][ #  # ]
     978 [ #  # ][ #  # ]:          0 :     XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_row ), (sal_Int32) aRange.aStart.Row() );
         [ #  # ][ #  # ]
     979                 :            :     XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_rowOff ),
     980 [ #  # ][ #  # ]:          0 :             MM100toEMU( aLocation.Top() - aRangeRect.Top() ) );
         [ #  # ][ #  # ]
     981         [ #  # ]:          0 :     pDrawing->endElement( FSNS( XML_xdr, XML_from ) );
     982                 :            : 
     983                 :            :     pDrawing->startElement( FSNS( XML_xdr, XML_to ),
     984         [ #  # ]:          0 :             FSEND );
     985 [ #  # ][ #  # ]:          0 :     XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_col ), (sal_Int32) aRange.aEnd.Col() );
         [ #  # ][ #  # ]
     986                 :            :     XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_colOff ),
     987 [ #  # ][ #  # ]:          0 :             MM100toEMU( aLocation.Right() - aRangeRect.Right() ) );
         [ #  # ][ #  # ]
     988 [ #  # ][ #  # ]:          0 :     XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_row ), (sal_Int32) aRange.aEnd.Row() );
         [ #  # ][ #  # ]
     989                 :            :     XclXmlUtils::WriteElement( pDrawing, FSNS( XML_xdr, XML_rowOff ),
     990 [ #  # ][ #  # ]:          0 :             MM100toEMU( aLocation.Bottom() - aRangeRect.Bottom() ) );
         [ #  # ][ #  # ]
     991 [ #  # ][ #  # ]:          0 :     pDrawing->endElement( FSNS( XML_xdr, XML_to ) );
     992                 :          0 : }
     993                 :            : 
     994                 :          0 : void XclObjAny::WriteFromTo( XclExpXmlStream& rStrm, const XclObjAny& rObj )
     995                 :            : {
     996         [ #  # ]:          0 :     WriteFromTo( rStrm, rObj.GetShape(), rObj.GetTab() );
     997                 :          0 : }
     998                 :            : 
     999                 :            : static const char*
    1000                 :          0 : GetEditAs( XclObjAny& rObj )
    1001                 :            : {
    1002 [ #  # ][ #  # ]:          0 :     if( const SdrObject* pShape = EscherEx::GetSdrObject( rObj.GetShape() ) )
    1003                 :            :     {
    1004                 :            :         // OOXTODO: returning "twoCell"
    1005         [ #  # ]:          0 :         switch( ScDrawLayer::GetAnchorType( *pShape ) )
    1006                 :            :         {
    1007                 :          0 :             case SCA_CELL:  return "oneCell";
    1008                 :          0 :             default:        break;
    1009                 :            :         }
    1010                 :            :     }
    1011                 :          0 :     return "absolute";
    1012                 :            : }
    1013                 :            : 
    1014                 :            : 
    1015                 :          0 : void XclObjAny::SaveXml( XclExpXmlStream& rStrm )
    1016                 :            : {
    1017                 :            :     // ignore group shapes at the moment, we don't process them correctly
    1018                 :            :     // leading to ms2010 rejecting the content
    1019 [ #  # ][ #  # ]:          0 :     if( !mxShape.is() || mxShape->getShapeType() == "com.sun.star.drawing.GroupShape" )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1020                 :          0 :         return;
    1021                 :            : 
    1022 [ #  # ][ #  # ]:          0 :     sax_fastparser::FSHelperPtr pDrawing = rStrm.GetCurrentStream();
    1023                 :            : 
    1024 [ #  # ][ #  # ]:          0 :     ShapeExport aDML( XML_xdr, pDrawing, NULL, &rStrm, DrawingML::DOCUMENT_XLSX );
                 [ #  # ]
    1025                 :            : 
    1026                 :            :     pDrawing->startElement( FSNS( XML_xdr, XML_twoCellAnchor ), // OOXTODO: oneCellAnchor, absoluteAnchor
    1027                 :            :             XML_editAs, GetEditAs( *this ),
    1028 [ #  # ][ #  # ]:          0 :             FSEND );
    1029         [ #  # ]:          0 :     Reference< XPropertySet > xPropSet( mxShape, UNO_QUERY );
    1030         [ #  # ]:          0 :     if (xPropSet.is())
    1031                 :            :     {
    1032         [ #  # ]:          0 :         WriteFromTo( rStrm, *this );
    1033         [ #  # ]:          0 :         aDML.WriteShape( mxShape );
    1034                 :            :     }
    1035                 :            : 
    1036                 :            :     pDrawing->singleElement( FSNS( XML_xdr, XML_clientData),
    1037                 :            :             // OOXTODO: XML_fLocksWithSheet
    1038                 :            :             // OOXTODO: XML_fPrintsWithSheet
    1039         [ #  # ]:          0 :             FSEND );
    1040 [ #  # ][ #  # ]:          0 :     pDrawing->endElement( FSNS( XML_xdr, XML_twoCellAnchor ) );
                 [ #  # ]
    1041                 :            : }
    1042                 :            : 
    1043                 :            : 
    1044                 :            : 
    1045                 :          0 : void ExcBof8_Base::SaveCont( XclExpStream& rStrm )
    1046                 :            : {
    1047                 :          0 :     rStrm.DisableEncryption();
    1048                 :          0 :     rStrm   << nVers << nDocType << nRupBuild << nRupYear
    1049                 :          0 :             << nFileHistory << nLowestBiffVer;
    1050                 :          0 : }
    1051                 :            : 
    1052                 :            : 
    1053                 :          0 : sal_uInt16 ExcBof8_Base::GetNum() const
    1054                 :            : {
    1055                 :          0 :     return 0x0809;
    1056                 :            : }
    1057                 :            : 
    1058                 :            : 
    1059                 :          0 : sal_Size ExcBof8_Base::GetLen() const
    1060                 :            : {
    1061                 :          0 :     return 16;
    1062                 :            : }
    1063                 :            : 
    1064                 :            : 
    1065                 :            : // --- class ExcBof8 -------------------------------------------------
    1066                 :            : 
    1067                 :          0 : ExcBof8::ExcBof8()
    1068                 :            : {
    1069                 :          0 :     nDocType = 0x0010;
    1070                 :          0 : }
    1071                 :            : 
    1072                 :            : 
    1073                 :            : // --- class ExcBofW8 ------------------------------------------------
    1074                 :            : 
    1075                 :          0 : ExcBofW8::ExcBofW8()
    1076                 :            : {
    1077                 :          0 :     nDocType = 0x0005;
    1078                 :          0 : }
    1079                 :            : 
    1080                 :            : 
    1081                 :            : // --- class ExcBundlesheet8 -----------------------------------------
    1082                 :            : 
    1083                 :          0 : ExcBundlesheet8::ExcBundlesheet8( RootData& rRootData, SCTAB _nTab ) :
    1084                 :            :     ExcBundlesheetBase( rRootData, static_cast<sal_uInt16>(_nTab) ),
    1085 [ #  # ][ #  # ]:          0 :     sUnicodeName( rRootData.pER->GetTabInfo().GetScTabName( _nTab ) )
                 [ #  # ]
    1086                 :            : {
    1087                 :          0 : }
    1088                 :            : 
    1089                 :            : 
    1090                 :          0 : ExcBundlesheet8::ExcBundlesheet8( const String& rString ) :
    1091                 :            :     ExcBundlesheetBase(),
    1092         [ #  # ]:          0 :     sUnicodeName( rString )
    1093                 :            : {
    1094                 :          0 : }
    1095                 :            : 
    1096                 :            : 
    1097                 :          0 : XclExpString ExcBundlesheet8::GetName() const
    1098                 :            : {
    1099                 :          0 :     return XclExpString( sUnicodeName, EXC_STR_8BITLENGTH );
    1100                 :            : }
    1101                 :            : 
    1102                 :            : 
    1103                 :          0 : void ExcBundlesheet8::SaveCont( XclExpStream& rStrm )
    1104                 :            : {
    1105                 :          0 :     nOwnPos = rStrm.GetSvStreamPos();
    1106                 :            :     // write dummy position, real position comes later
    1107                 :          0 :     rStrm.DisableEncryption();
    1108                 :          0 :     rStrm << sal_uInt32(0);
    1109                 :          0 :     rStrm.EnableEncryption();
    1110 [ #  # ][ #  # ]:          0 :     rStrm << nGrbit << GetName();
    1111                 :          0 : }
    1112                 :            : 
    1113                 :            : 
    1114                 :          0 : sal_Size ExcBundlesheet8::GetLen() const
    1115                 :            : {   // Text max 255 chars
    1116         [ #  # ]:          0 :     return 8 + GetName().GetBufferSize();
    1117                 :            : }
    1118                 :            : 
    1119                 :            : 
    1120                 :          0 : void ExcBundlesheet8::SaveXml( XclExpXmlStream& rStrm )
    1121                 :            : {
    1122                 :          0 :     OUString sId;
    1123                 :            :     rStrm.CreateOutputStream(
    1124                 :            :             XclXmlUtils::GetStreamName( "xl/", "worksheets/sheet", nTab+1),
    1125                 :            :             XclXmlUtils::GetStreamName( NULL, "worksheets/sheet", nTab+1),
    1126         [ #  # ]:          0 :             rStrm.GetCurrentStream()->getOutputStream(),
    1127                 :            :             "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
    1128                 :            :             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",
    1129 [ #  # ][ #  # ]:          0 :             &sId );
         [ #  # ][ #  # ]
                 [ #  # ]
    1130                 :            : 
    1131         [ #  # ]:          0 :     rStrm.GetCurrentStream()->singleElement( XML_sheet,
    1132                 :            :             XML_name,               XclXmlUtils::ToOString( sUnicodeName ).getStr(),
    1133                 :            :             XML_sheetId,            rtl::OString::valueOf( (sal_Int32)( nTab+1 ) ).getStr(),
    1134                 :            :             XML_state,              nGrbit == 0x0000 ? "visible" : "hidden",
    1135                 :            :             FSNS( XML_r, XML_id ),  XclXmlUtils::ToOString( sId ).getStr(),
    1136 [ #  # ][ #  # ]:          0 :             FSEND );
         [ #  # ][ #  # ]
    1137                 :          0 : }
    1138                 :            : 
    1139                 :            : 
    1140                 :            : 
    1141                 :            : // --- class XclObproj -----------------------------------------------
    1142                 :            : 
    1143                 :          0 : sal_uInt16 XclObproj::GetNum() const
    1144                 :            : {
    1145                 :          0 :     return 0x00D3;
    1146                 :            : }
    1147                 :            : 
    1148                 :            : 
    1149                 :          0 : sal_Size XclObproj::GetLen() const
    1150                 :            : {
    1151                 :          0 :     return 0;
    1152                 :            : }
    1153                 :            : 
    1154                 :            : 
    1155                 :            : // ---- class XclCodename --------------------------------------------
    1156                 :            : 
    1157         [ #  # ]:          0 : XclCodename::XclCodename( const String& r ) : aName( r )
    1158                 :            : {
    1159                 :          0 : }
    1160                 :            : 
    1161                 :            : 
    1162                 :          0 : void XclCodename::SaveCont( XclExpStream& rStrm )
    1163                 :            : {
    1164                 :          0 :     rStrm << aName;
    1165                 :          0 : }
    1166                 :            : 
    1167                 :            : 
    1168                 :          0 : sal_uInt16 XclCodename::GetNum() const
    1169                 :            : {
    1170                 :          0 :     return 0x01BA;
    1171                 :            : }
    1172                 :            : 
    1173                 :            : 
    1174                 :          0 : sal_Size XclCodename::GetLen() const
    1175                 :            : {
    1176                 :          0 :     return aName.GetSize();
    1177                 :            : }
    1178                 :            : 
    1179                 :            : 
    1180                 :            : 
    1181                 :            : // ---- Scenarios ----------------------------------------------------
    1182                 :            : 
    1183                 :          0 : ExcEScenarioCell::ExcEScenarioCell( sal_uInt16 nC, sal_uInt16 nR, const String& rTxt ) :
    1184                 :            :         nCol( nC ),
    1185                 :            :         nRow( nR ),
    1186                 :          0 :         sText( rTxt, EXC_STR_DEFAULT, 255 )
    1187                 :            : {
    1188                 :          0 : }
    1189                 :            : 
    1190                 :          0 : void ExcEScenarioCell::WriteAddress( XclExpStream& rStrm ) const
    1191                 :            : {
    1192                 :          0 :     rStrm << nRow << nCol;
    1193                 :          0 : }
    1194                 :            : 
    1195                 :          0 : void ExcEScenarioCell::WriteText( XclExpStream& rStrm ) const
    1196                 :            : {
    1197                 :          0 :     rStrm << sText;
    1198                 :          0 : }
    1199                 :            : 
    1200                 :          0 : void ExcEScenarioCell::SaveXml( XclExpXmlStream& rStrm ) const
    1201                 :            : {
    1202         [ #  # ]:          0 :     rStrm.GetCurrentStream()->singleElement( XML_inputCells,
    1203                 :            :             // OOXTODO: XML_deleted,
    1204                 :            :             // OOXTODO: XML_numFmtId,
    1205                 :            :             XML_r,      XclXmlUtils::ToOString( ScAddress( nCol, nRow, 0 ) ).getStr(),
    1206                 :            :             // OOXTODO: XML_undone,
    1207                 :            :             XML_val,    XclXmlUtils::ToOString( sText ).getStr(),
    1208 [ #  # ][ #  # ]:          0 :             FSEND );
    1209                 :          0 : }
    1210                 :            : 
    1211                 :            : 
    1212                 :            : 
    1213                 :            : 
    1214 [ #  # ][ #  # ]:          0 : ExcEScenario::ExcEScenario( const XclExpRoot& rRoot, SCTAB nTab )
         [ #  # ][ #  # ]
    1215                 :            : {
    1216         [ #  # ]:          0 :     String  sTmpName;
    1217         [ #  # ]:          0 :     String  sTmpComm;
    1218                 :          0 :     rtl::OUString aTmp;
    1219                 :          0 :     Color   aDummyCol;
    1220                 :            :     sal_uInt16  nFlags;
    1221                 :            : 
    1222                 :          0 :     ScDocument& rDoc = rRoot.GetDoc();
    1223         [ #  # ]:          0 :     rDoc.GetName(nTab, aTmp);
    1224         [ #  # ]:          0 :     sTmpName = aTmp;
    1225         [ #  # ]:          0 :     sName.Assign( sTmpName, EXC_STR_8BITLENGTH );
    1226         [ #  # ]:          0 :     nRecLen = 8 + sName.GetBufferSize();
    1227                 :            : 
    1228         [ #  # ]:          0 :     rDoc.GetScenarioData( nTab, aTmp, aDummyCol, nFlags );
    1229         [ #  # ]:          0 :     sTmpComm = aTmp;
    1230         [ #  # ]:          0 :     sComment.Assign( sTmpComm, EXC_STR_DEFAULT, 255 );
    1231         [ #  # ]:          0 :     if( sComment.Len() )
    1232         [ #  # ]:          0 :         nRecLen += sComment.GetSize();
    1233         [ #  # ]:          0 :     nProtected = (nFlags & SC_SCENARIO_PROTECT) ? 1 : 0;
    1234                 :            : 
    1235         [ #  # ]:          0 :     sUserName.Assign( rRoot.GetUserName(), EXC_STR_DEFAULT, 255 );
    1236         [ #  # ]:          0 :     nRecLen += sUserName.GetSize();
    1237                 :            : 
    1238         [ #  # ]:          0 :     const ScRangeList* pRList = rDoc.GetScenarioRanges( nTab );
    1239         [ #  # ]:          0 :     if( !pRList )
    1240                 :          0 :         return;
    1241                 :            : 
    1242                 :          0 :     sal_Bool    bContLoop = sal_True;
    1243                 :            :     SCROW   nRow;
    1244                 :            :     SCCOL   nCol;
    1245         [ #  # ]:          0 :     String  sText;
    1246                 :            :     double  fVal;
    1247                 :            : 
    1248 [ #  # ][ #  # ]:          0 :     for( size_t nRange = 0; (nRange < pRList->size()) && bContLoop; nRange++ )
         [ #  # ][ #  # ]
    1249                 :            :     {
    1250         [ #  # ]:          0 :         const ScRange* pRange = (*pRList)[nRange];
    1251 [ #  # ][ #  # ]:          0 :         for( nRow = pRange->aStart.Row(); (nRow <= pRange->aEnd.Row()) && bContLoop; nRow++ )
                 [ #  # ]
    1252 [ #  # ][ #  # ]:          0 :             for( nCol = pRange->aStart.Col(); (nCol <= pRange->aEnd.Col()) && bContLoop; nCol++ )
                 [ #  # ]
    1253                 :            :             {
    1254 [ #  # ][ #  # ]:          0 :                 if( rDoc.HasValueData( nCol, nRow, nTab ) )
    1255                 :            :                 {
    1256         [ #  # ]:          0 :                     rDoc.GetValue( nCol, nRow, nTab, fVal );
    1257                 :            :                     sText = ::rtl::math::doubleToUString( fVal,
    1258                 :            :                             rtl_math_StringFormat_Automatic,
    1259                 :            :                             rtl_math_DecimalPlaces_Max,
    1260         [ #  # ]:          0 :                             ScGlobal::pLocaleData->getNumDecimalSep()[0],
    1261         [ #  # ]:          0 :                             sal_True );
    1262                 :            :                 }
    1263                 :            :                 else
    1264         [ #  # ]:          0 :                     rDoc.GetString( nCol, nRow, nTab, sText );
    1265                 :            :                 bContLoop = Append( static_cast<sal_uInt16>(nCol),
    1266         [ #  # ]:          0 :                         static_cast<sal_uInt16>(nRow), sText );
    1267                 :            :             }
    1268 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1269                 :            : }
    1270                 :            : 
    1271                 :          0 : ExcEScenario::~ExcEScenario()
    1272                 :            : {
    1273         [ #  # ]:          0 : }
    1274                 :            : 
    1275                 :          0 : sal_Bool ExcEScenario::Append( sal_uInt16 nCol, sal_uInt16 nRow, const String& rTxt )
    1276                 :            : {
    1277         [ #  # ]:          0 :     if( aCells.size() == EXC_SCEN_MAXCELL )
    1278                 :          0 :         return false;
    1279                 :            : 
    1280         [ #  # ]:          0 :     ExcEScenarioCell aCell(nCol, nRow, rTxt);
    1281         [ #  # ]:          0 :     aCells.push_back(aCell);
    1282         [ #  # ]:          0 :     nRecLen += 6 + aCell.GetStringBytes();        // 4 bytes address, 2 bytes ifmt
    1283                 :          0 :     return sal_True;
    1284                 :            : }
    1285                 :            : 
    1286                 :          0 : void ExcEScenario::SaveCont( XclExpStream& rStrm )
    1287                 :            : {
    1288                 :          0 :     sal_uInt16 count = aCells.size();
    1289                 :            : 
    1290         [ #  # ]:          0 :     rStrm   << (sal_uInt16) count               // number of cells
    1291         [ #  # ]:          0 :             << nProtected                       // fProtection
    1292         [ #  # ]:          0 :             << (sal_uInt8) 0                    // fHidden
    1293         [ #  # ]:          0 :             << (sal_uInt8) sName.Len()          // length of scen name
    1294         [ #  # ]:          0 :             << (sal_uInt8) sComment.Len()       // length of comment
    1295         [ #  # ]:          0 :             << (sal_uInt8) sUserName.Len();     // length of user name
    1296         [ #  # ]:          0 :     sName.WriteFlagField( rStrm );
    1297         [ #  # ]:          0 :     sName.WriteBuffer( rStrm );
    1298                 :            : 
    1299         [ #  # ]:          0 :     rStrm << sUserName;
    1300                 :            : 
    1301         [ #  # ]:          0 :     if( sComment.Len() )
    1302         [ #  # ]:          0 :         rStrm << sComment;
    1303                 :            : 
    1304                 :          0 :     std::vector<ExcEScenarioCell>::iterator pIter;
    1305 [ #  # ][ #  # ]:          0 :     for( pIter = aCells.begin(); pIter != aCells.end(); ++pIter )
    1306         [ #  # ]:          0 :         pIter->WriteAddress( rStrm );           // pos of cell
    1307 [ #  # ][ #  # ]:          0 :     for( pIter = aCells.begin(); pIter != aCells.end(); ++pIter )
    1308         [ #  # ]:          0 :         pIter->WriteText( rStrm );              // string content
    1309         [ #  # ]:          0 :     rStrm.SetSliceSize( 2 );
    1310         [ #  # ]:          0 :     rStrm.WriteZeroBytes( 2 * count );  // date format
    1311                 :          0 : }
    1312                 :            : 
    1313                 :          0 : sal_uInt16 ExcEScenario::GetNum() const
    1314                 :            : {
    1315                 :          0 :     return 0x00AF;
    1316                 :            : }
    1317                 :            : 
    1318                 :          0 : sal_Size ExcEScenario::GetLen() const
    1319                 :            : {
    1320                 :          0 :     return nRecLen;
    1321                 :            : }
    1322                 :            : 
    1323                 :          0 : void ExcEScenario::SaveXml( XclExpXmlStream& rStrm )
    1324                 :            : {
    1325         [ #  # ]:          0 :     sax_fastparser::FSHelperPtr& rWorkbook = rStrm.GetCurrentStream();
    1326                 :            :     rWorkbook->startElement( XML_scenario,
    1327                 :            :             XML_name,       XclXmlUtils::ToOString( sName ).getStr(),
    1328                 :            :             XML_locked,     XclXmlUtils::ToPsz( nProtected ),
    1329                 :            :             // OOXTODO: XML_hidden,
    1330                 :          0 :             XML_count,      OString::valueOf( (sal_Int32) aCells.size() ).getStr(),
    1331         [ #  # ]:          0 :             XML_user,       XESTRING_TO_PSZ( sUserName ),
           [ #  #  #  # ]
                 [ #  # ]
    1332 [ #  # ][ #  # ]:          0 :             XML_comment,    XESTRING_TO_PSZ( sComment ),
         [ #  # ][ #  # ]
    1333 [ #  # ][ #  # ]:          0 :             FSEND );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1334                 :            : 
    1335                 :          0 :     std::vector<ExcEScenarioCell>::iterator pIter;
    1336 [ #  # ][ #  # ]:          0 :     for( pIter = aCells.begin(); pIter != aCells.end(); ++pIter )
    1337         [ #  # ]:          0 :         pIter->SaveXml( rStrm );
    1338                 :            : 
    1339         [ #  # ]:          0 :     rWorkbook->endElement( XML_scenario );
    1340                 :          0 : }
    1341                 :            : 
    1342                 :            : 
    1343                 :            : 
    1344                 :            : 
    1345                 :          0 : ExcEScenarioManager::ExcEScenarioManager( const XclExpRoot& rRoot, SCTAB nTab ) :
    1346         [ #  # ]:          0 :         nActive( 0 )
    1347                 :            : {
    1348                 :          0 :     ScDocument& rDoc = rRoot.GetDoc();
    1349 [ #  # ][ #  # ]:          0 :     if( rDoc.IsScenario( nTab ) )
    1350                 :          0 :         return;
    1351                 :            : 
    1352                 :          0 :     SCTAB nFirstTab = nTab + 1;
    1353                 :          0 :     SCTAB nNewTab       = nFirstTab;
    1354                 :            : 
    1355 [ #  # ][ #  # ]:          0 :     while( rDoc.IsScenario( nNewTab ) )
    1356                 :            :     {
    1357 [ #  # ][ #  # ]:          0 :         aScenes.push_back( new ExcEScenario( rRoot, nNewTab ) );
                 [ #  # ]
    1358                 :            : 
    1359 [ #  # ][ #  # ]:          0 :         if( rDoc.IsActiveScenario( nNewTab ) )
    1360                 :          0 :             nActive = static_cast<sal_uInt16>(nNewTab - nFirstTab);
    1361                 :          0 :         nNewTab++;
    1362                 :            :     }
    1363                 :            : }
    1364                 :            : 
    1365                 :          0 : ExcEScenarioManager::~ExcEScenarioManager()
    1366                 :            : {
    1367                 :          0 :     std::vector<ExcEScenario*>::iterator pIter;
    1368 [ #  # ][ #  # ]:          0 :     for( pIter = aScenes.begin(); pIter != aScenes.end(); ++pIter )
    1369 [ #  # ][ #  # ]:          0 :         delete *pIter;
    1370         [ #  # ]:          0 : }
    1371                 :            : 
    1372                 :          0 : void ExcEScenarioManager::SaveCont( XclExpStream& rStrm )
    1373                 :            : {
    1374                 :          0 :     rStrm   << (sal_uInt16) aScenes.size()  // number of scenarios
    1375                 :          0 :             << nActive                      // active scen
    1376                 :          0 :             << nActive                      // last displayed
    1377                 :          0 :             << (sal_uInt16) 0;              // reference areas
    1378                 :          0 : }
    1379                 :            : 
    1380                 :          0 : void ExcEScenarioManager::Save( XclExpStream& rStrm )
    1381                 :            : {
    1382         [ #  # ]:          0 :     if( !aScenes.empty() )
    1383         [ #  # ]:          0 :         ExcRecord::Save( rStrm );
    1384                 :            : 
    1385                 :          0 :     std::vector<ExcEScenario*>::iterator pIter;
    1386 [ #  # ][ #  # ]:          0 :     for( pIter = aScenes.begin(); pIter != aScenes.end(); ++pIter )
    1387         [ #  # ]:          0 :         (*pIter)->Save( rStrm );
    1388                 :          0 : }
    1389                 :            : 
    1390                 :          0 : void ExcEScenarioManager::SaveXml( XclExpXmlStream& rStrm )
    1391                 :            : {
    1392         [ #  # ]:          0 :     if( aScenes.empty() )
    1393                 :          0 :         return;
    1394                 :            : 
    1395         [ #  # ]:          0 :     sax_fastparser::FSHelperPtr& rWorkbook = rStrm.GetCurrentStream();
    1396                 :            :     rWorkbook->startElement( XML_scenarios,
    1397                 :            :             XML_current,    OString::valueOf( (sal_Int32)nActive ).getStr(),
    1398                 :            :             XML_show,       OString::valueOf( (sal_Int32)nActive ).getStr(),
    1399                 :            :             // OOXTODO: XML_sqref,
    1400         [ #  # ]:          0 :             FSEND );
    1401                 :            : 
    1402                 :          0 :     std::vector<ExcEScenario*>::iterator pIter;
    1403 [ #  # ][ #  # ]:          0 :     for( pIter = aScenes.begin(); pIter != aScenes.end(); ++pIter )
    1404         [ #  # ]:          0 :         (*pIter)->SaveXml( rStrm );
    1405                 :            : 
    1406         [ #  # ]:          0 :     rWorkbook->endElement( XML_scenarios );
    1407                 :            : }
    1408                 :            : 
    1409                 :          0 : sal_uInt16 ExcEScenarioManager::GetNum() const
    1410                 :            : {
    1411                 :          0 :     return 0x00AE;
    1412                 :            : }
    1413                 :            : 
    1414                 :          0 : sal_Size ExcEScenarioManager::GetLen() const
    1415                 :            : {
    1416                 :          0 :     return 8;
    1417                 :            : }
    1418                 :            : 
    1419                 :            : // ============================================================================
    1420                 :            : 
    1421                 :            : struct XclExpTabProtectOption
    1422                 :            : {
    1423                 :            :     ScTableProtection::Option   eOption;
    1424                 :            :     sal_uInt16                  nMask;
    1425                 :            : };
    1426                 :            : 
    1427                 :          0 : XclExpSheetProtectOptions::XclExpSheetProtectOptions( const XclExpRoot& rRoot, SCTAB nTab ) :
    1428                 :          0 :     XclExpRecord( 0x0867, 23 )
    1429                 :            : {
    1430                 :            :     static const XclExpTabProtectOption aTable[] =
    1431                 :            :     {
    1432                 :            :         { ScTableProtection::OBJECTS,               0x0001 },
    1433                 :            :         { ScTableProtection::SCENARIOS,             0x0002 },
    1434                 :            :         { ScTableProtection::FORMAT_CELLS,          0x0004 },
    1435                 :            :         { ScTableProtection::FORMAT_COLUMNS,        0x0008 },
    1436                 :            :         { ScTableProtection::FORMAT_ROWS,           0x0010 },
    1437                 :            :         { ScTableProtection::INSERT_COLUMNS,        0x0020 },
    1438                 :            :         { ScTableProtection::INSERT_ROWS,           0x0040 },
    1439                 :            :         { ScTableProtection::INSERT_HYPERLINKS,     0x0080 },
    1440                 :            : 
    1441                 :            :         { ScTableProtection::DELETE_COLUMNS,        0x0100 },
    1442                 :            :         { ScTableProtection::DELETE_ROWS,           0x0200 },
    1443                 :            :         { ScTableProtection::SELECT_LOCKED_CELLS,   0x0400 },
    1444                 :            :         { ScTableProtection::SORT,                  0x0800 },
    1445                 :            :         { ScTableProtection::AUTOFILTER,            0x1000 },
    1446                 :            :         { ScTableProtection::PIVOT_TABLES,          0x2000 },
    1447                 :            :         { ScTableProtection::SELECT_UNLOCKED_CELLS, 0x4000 },
    1448                 :            : 
    1449                 :            :         { ScTableProtection::NONE,                  0x0000 }
    1450                 :            :     };
    1451                 :            : 
    1452                 :          0 :     mnOptions = 0x0000;
    1453         [ #  # ]:          0 :     ScTableProtection* pProtect = rRoot.GetDoc().GetTabProtection(nTab);
    1454         [ #  # ]:          0 :     if (!pProtect)
    1455                 :          0 :         return;
    1456                 :            : 
    1457         [ #  # ]:          0 :     for (int i = 0; aTable[i].nMask != 0x0000; ++i)
    1458                 :            :     {
    1459 [ #  # ][ #  # ]:          0 :         if ( pProtect->isOptionEnabled(aTable[i].eOption) )
    1460                 :          0 :             mnOptions |= aTable[i].nMask;
    1461                 :            :     }
    1462                 :            : }
    1463                 :            : 
    1464                 :          0 : void XclExpSheetProtectOptions::WriteBody( XclExpStream& rStrm )
    1465                 :            : {
    1466                 :          0 :     sal_uInt16 nBytes = 0x0867;
    1467                 :          0 :     rStrm << nBytes;
    1468                 :            : 
    1469                 :          0 :     sal_uChar nZero = 0x00;
    1470         [ #  # ]:          0 :     for (int i = 0; i < 9; ++i)
    1471                 :          0 :         rStrm << nZero;
    1472                 :            : 
    1473                 :          0 :     nBytes = 0x0200;
    1474                 :          0 :     rStrm << nBytes;
    1475                 :          0 :     nBytes = 0x0100;
    1476                 :          0 :     rStrm << nBytes;
    1477                 :          0 :     nBytes = 0xFFFF;
    1478                 :          0 :     rStrm << nBytes << nBytes;
    1479                 :            : 
    1480                 :          0 :     rStrm << mnOptions;
    1481                 :          0 :     nBytes = 0;
    1482                 :          0 :     rStrm << nBytes;
    1483                 :          0 : }
    1484                 :            : 
    1485                 :            : // ============================================================================
    1486                 :            : 
    1487                 :            : 
    1488                 :            : 
    1489                 :            : 
    1490                 :          0 : void XclCalccount::SaveCont( XclExpStream& rStrm )
    1491                 :            : {
    1492                 :          0 :     rStrm << nCount;
    1493                 :          0 : }
    1494                 :            : 
    1495                 :            : 
    1496                 :          0 : XclCalccount::XclCalccount( const ScDocument& rDoc )
    1497                 :            : {
    1498         [ #  # ]:          0 :     nCount = rDoc.GetDocOptions().GetIterCount();
    1499                 :          0 : }
    1500                 :            : 
    1501                 :            : 
    1502                 :          0 : sal_uInt16 XclCalccount::GetNum() const
    1503                 :            : {
    1504                 :          0 :     return 0x000C;
    1505                 :            : }
    1506                 :            : 
    1507                 :            : 
    1508                 :          0 : sal_Size XclCalccount::GetLen() const
    1509                 :            : {
    1510                 :          0 :     return 2;
    1511                 :            : }
    1512                 :            : 
    1513                 :            : 
    1514                 :          0 : void XclCalccount::SaveXml( XclExpXmlStream& rStrm )
    1515                 :            : {
    1516                 :            :     rStrm.WriteAttributes(
    1517                 :            :             XML_iterateCount, OString::valueOf( (sal_Int32)nCount ).getStr(),
    1518         [ #  # ]:          0 :             FSEND );
    1519                 :          0 : }
    1520                 :            : 
    1521                 :            : 
    1522                 :            : 
    1523                 :            : 
    1524                 :          0 : void XclIteration::SaveCont( XclExpStream& rStrm )
    1525                 :            : {
    1526                 :          0 :     rStrm << nIter;
    1527                 :          0 : }
    1528                 :            : 
    1529                 :            : 
    1530                 :          0 : XclIteration::XclIteration( const ScDocument& rDoc )
    1531                 :            : {
    1532 [ #  # ][ #  # ]:          0 :     nIter = rDoc.GetDocOptions().IsIter()? 1 : 0;
    1533                 :          0 : }
    1534                 :            : 
    1535                 :            : 
    1536                 :          0 : sal_uInt16 XclIteration::GetNum() const
    1537                 :            : {
    1538                 :          0 :     return 0x0011;
    1539                 :            : }
    1540                 :            : 
    1541                 :            : 
    1542                 :          0 : sal_Size XclIteration::GetLen() const
    1543                 :            : {
    1544                 :          0 :     return 2;
    1545                 :            : }
    1546                 :            : 
    1547                 :            : 
    1548                 :          0 : void XclIteration::SaveXml( XclExpXmlStream& rStrm )
    1549                 :            : {
    1550                 :            :     rStrm.WriteAttributes(
    1551                 :            :             XML_iterate, XclXmlUtils::ToPsz( nIter == 1 ),
    1552                 :          0 :             FSEND );
    1553                 :          0 : }
    1554                 :            : 
    1555                 :            : 
    1556                 :            : 
    1557                 :            : 
    1558                 :          0 : void XclDelta::SaveCont( XclExpStream& rStrm )
    1559                 :            : {
    1560                 :          0 :     rStrm << fDelta;
    1561                 :          0 : }
    1562                 :            : 
    1563                 :            : 
    1564                 :            : 
    1565                 :          0 : XclDelta::XclDelta( const ScDocument& rDoc )
    1566                 :            : {
    1567         [ #  # ]:          0 :     fDelta = rDoc.GetDocOptions().GetIterEps();
    1568                 :          0 : }
    1569                 :            : 
    1570                 :            : 
    1571                 :          0 : sal_uInt16 XclDelta::GetNum() const
    1572                 :            : {
    1573                 :          0 :     return 0x0010;
    1574                 :            : }
    1575                 :            : 
    1576                 :            : 
    1577                 :          0 : sal_Size XclDelta::GetLen() const
    1578                 :            : {
    1579                 :          0 :     return 8;
    1580                 :            : }
    1581                 :            : 
    1582                 :            : 
    1583                 :          0 : void XclDelta::SaveXml( XclExpXmlStream& rStrm )
    1584                 :            : {
    1585                 :            :     rStrm.WriteAttributes(
    1586                 :            :             XML_iterateDelta, OString::valueOf( fDelta ).getStr(),
    1587         [ #  # ]:          0 :             FSEND );
    1588                 :          0 : }
    1589                 :            : 
    1590                 :            : // ============================================================================
    1591                 :            : 
    1592                 :          0 : XclExpFileEncryption::XclExpFileEncryption( const XclExpRoot& rRoot ) :
    1593                 :            :     XclExpRecord(0x002F, 54),
    1594                 :          0 :     mrRoot(rRoot)
    1595                 :            : {
    1596                 :          0 : }
    1597                 :            : 
    1598                 :          0 : XclExpFileEncryption::~XclExpFileEncryption()
    1599                 :            : {
    1600         [ #  # ]:          0 : }
    1601                 :            : 
    1602                 :          0 : void XclExpFileEncryption::WriteBody( XclExpStream& rStrm )
    1603                 :            : {
    1604                 :            :     // 0x0000 - neither standard nor strong encryption
    1605                 :            :     // 0x0001 - standard or strong encryption
    1606         [ #  # ]:          0 :     rStrm << static_cast<sal_uInt16>(0x0001);
    1607                 :            : 
    1608                 :            :     // 0x0000 - non standard encryption
    1609                 :            :     // 0x0001 - standard encryption
    1610                 :          0 :     sal_uInt16 nStdEnc = 0x0001;
    1611 [ #  # ][ #  # ]:          0 :     rStrm << nStdEnc << nStdEnc;
    1612                 :            : 
    1613                 :            :     sal_uInt8 pnDocId[16];
    1614                 :            :     sal_uInt8 pnSalt[16];
    1615                 :            :     sal_uInt8 pnSaltHash[16];
    1616 [ #  # ][ #  # ]:          0 :     XclExpEncrypterRef xEnc( new XclExpBiff8Encrypter(mrRoot) );
                 [ #  # ]
    1617         [ #  # ]:          0 :     xEnc->GetDocId(pnDocId);
    1618         [ #  # ]:          0 :     xEnc->GetSalt(pnSalt);
    1619         [ #  # ]:          0 :     xEnc->GetSaltDigest(pnSaltHash);
    1620                 :            : 
    1621         [ #  # ]:          0 :     rStrm.Write(pnDocId, 16);
    1622         [ #  # ]:          0 :     rStrm.Write(pnSalt, 16);
    1623         [ #  # ]:          0 :     rStrm.Write(pnSaltHash, 16);
    1624                 :            : 
    1625 [ #  # ][ #  # ]:          0 :     rStrm.SetEncrypter(xEnc);
         [ #  # ][ #  # ]
    1626                 :          0 : }
    1627                 :            : 
    1628                 :            : // ============================================================================
    1629                 :            : 
    1630                 :          0 : XclExpInterfaceHdr::XclExpInterfaceHdr( sal_uInt16 nCodePage ) :
    1631                 :          0 :     XclExpUInt16Record( EXC_ID_INTERFACEHDR, nCodePage )
    1632                 :            : {
    1633                 :          0 : }
    1634                 :            : 
    1635                 :          0 : void XclExpInterfaceHdr::WriteBody( XclExpStream& rStrm )
    1636                 :            : {
    1637                 :          0 :     rStrm.DisableEncryption();
    1638                 :          0 :     rStrm << GetValue();
    1639                 :          0 : }
    1640                 :            : 
    1641                 :            : // ============================================================================
    1642                 :            : 
    1643                 :          0 : XclExpInterfaceEnd::XclExpInterfaceEnd() :
    1644                 :          0 :     XclExpRecord(0x00E2, 0) {}
    1645                 :            : 
    1646         [ #  # ]:          0 : XclExpInterfaceEnd::~XclExpInterfaceEnd() {}
    1647                 :            : 
    1648                 :          0 : void XclExpInterfaceEnd::WriteBody( XclExpStream& rStrm )
    1649                 :            : {
    1650                 :            :     // Don't forget to re-enable encryption.
    1651                 :          0 :     rStrm.EnableEncryption();
    1652                 :          0 : }
    1653                 :            : 
    1654                 :            : // ============================================================================
    1655                 :            : 
    1656                 :          0 : XclExpWriteAccess::XclExpWriteAccess() :
    1657                 :          0 :     XclExpRecord(0x005C, 112)
    1658                 :            : {
    1659                 :          0 : }
    1660                 :            : 
    1661                 :          0 : XclExpWriteAccess::~XclExpWriteAccess()
    1662                 :            : {
    1663         [ #  # ]:          0 : }
    1664                 :            : 
    1665                 :          0 : void XclExpWriteAccess::WriteBody( XclExpStream& rStrm )
    1666                 :            : {
    1667                 :            :     static const sal_uInt8 aData[] = {
    1668                 :            :         0x04, 0x00, 0x00,  'C',  'a',  'l',  'c', 0x20,
    1669                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1670                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1671                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1672                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1673                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1674                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1675                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1676                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1677                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1678                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1679                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1680                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
    1681                 :            :         0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };
    1682                 :            : 
    1683                 :          0 :     sal_Size nDataSize = sizeof(aData);
    1684         [ #  # ]:          0 :     for (sal_Size i = 0; i < nDataSize; ++i)
    1685                 :          0 :         rStrm << aData[i];
    1686                 :          0 : }
    1687                 :            : 
    1688                 :            : // ============================================================================
    1689                 :            : 
    1690                 :          0 : XclExpFileSharing::XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash, bool bRecommendReadOnly ) :
    1691                 :            :     XclExpRecord( EXC_ID_FILESHARING ),
    1692                 :            :     mnPasswordHash( nPasswordHash ),
    1693         [ #  # ]:          0 :     mbRecommendReadOnly( bRecommendReadOnly )
    1694                 :            : {
    1695         [ #  # ]:          0 :     if( rRoot.GetBiff() <= EXC_BIFF5 )
    1696         [ #  # ]:          0 :         maUserName.AssignByte( rRoot.GetUserName(), rRoot.GetTextEncoding(), EXC_STR_8BITLENGTH );
    1697                 :            :     else
    1698         [ #  # ]:          0 :         maUserName.Assign( rRoot.GetUserName() );
    1699                 :          0 : }
    1700                 :            : 
    1701                 :          0 : void XclExpFileSharing::Save( XclExpStream& rStrm )
    1702                 :            : {
    1703 [ #  # ][ #  # ]:          0 :     if( (mnPasswordHash != 0) || mbRecommendReadOnly )
    1704                 :          0 :         XclExpRecord::Save( rStrm );
    1705                 :          0 : }
    1706                 :            : 
    1707                 :          0 : void XclExpFileSharing::WriteBody( XclExpStream& rStrm )
    1708                 :            : {
    1709         [ #  # ]:          0 :     rStrm << sal_uInt16( mbRecommendReadOnly ? 1 : 0 ) << mnPasswordHash << maUserName;
    1710                 :          0 : }
    1711                 :            : 
    1712                 :            : // ============================================================================
    1713                 :            : 
    1714                 :          0 : XclExpProt4Rev::XclExpProt4Rev() :
    1715                 :          0 :     XclExpRecord(0x01AF, 2)
    1716                 :            : {
    1717                 :          0 : }
    1718                 :            : 
    1719                 :          0 : XclExpProt4Rev::~XclExpProt4Rev()
    1720                 :            : {
    1721         [ #  # ]:          0 : }
    1722                 :            : 
    1723                 :          0 : void XclExpProt4Rev::WriteBody( XclExpStream& rStrm )
    1724                 :            : {
    1725                 :          0 :     rStrm << static_cast<sal_uInt16>(0x0000);
    1726                 :          0 : }
    1727                 :            : 
    1728                 :            : // ============================================================================
    1729                 :            : 
    1730                 :          0 : XclExpProt4RevPass::XclExpProt4RevPass() :
    1731                 :          0 :     XclExpRecord(0x01BC, 2)
    1732                 :            : {
    1733                 :          0 : }
    1734                 :            : 
    1735                 :          0 : XclExpProt4RevPass::~XclExpProt4RevPass()
    1736                 :            : {
    1737         [ #  # ]:          0 : }
    1738                 :            : 
    1739                 :          0 : void XclExpProt4RevPass::WriteBody( XclExpStream& rStrm )
    1740                 :            : {
    1741                 :          0 :     rStrm << static_cast<sal_uInt16>(0x0000);
    1742                 :          0 : }
    1743                 :            : 
    1744                 :            : // ============================================================================
    1745                 :            : 
    1746                 :            : static const sal_uInt8 nDataRecalcId[] = {
    1747                 :            :     0xC1, 0x01, 0x00, 0x00, 0x54, 0x8D, 0x01, 0x00
    1748                 :            : };
    1749                 :            : 
    1750                 :          0 : XclExpRecalcId::XclExpRecalcId() :
    1751                 :          0 :     XclExpDummyRecord(0x01C1, nDataRecalcId, sizeof(nDataRecalcId))
    1752                 :            : {
    1753                 :          0 : }
    1754                 :            : 
    1755                 :            : // ============================================================================
    1756                 :            : 
    1757                 :            : static const sal_uInt8 nDataBookExt[] = {
    1758                 :            :     0x63, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    1759                 :            :     0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    1760                 :            :     0x02
    1761                 :            : };
    1762                 :            : 
    1763                 :          0 : XclExpBookExt::XclExpBookExt() :
    1764                 :          0 :     XclExpDummyRecord(0x0863, nDataBookExt, sizeof(nDataBookExt))
    1765                 :            : {
    1766                 :          0 : }
    1767                 :            : 
    1768                 :            : // ============================================================================
    1769                 :            : 
    1770                 :          0 : XclRefmode::XclRefmode( const ScDocument& rDoc ) :
    1771                 :          0 :     XclExpBoolRecord( 0x000F, rDoc.GetAddressConvention() != formula::FormulaGrammar::CONV_XL_R1C1 )
    1772                 :            : {
    1773                 :          0 : }
    1774                 :            : 
    1775                 :          0 : void XclRefmode::SaveXml( XclExpXmlStream& rStrm )
    1776                 :            : {
    1777                 :            :     rStrm.WriteAttributes(
    1778                 :          0 :             XML_refMode, GetBool() ? "A1" : "R1C1",
    1779         [ #  # ]:          0 :             FSEND );
    1780 [ +  - ][ +  - ]:         24 : }
    1781                 :            : 
    1782                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10