LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/filter/xcl97 - xcl97rec.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 300 832 36.1 %
Date: 2013-07-09 Functions: 75 149 50.3 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10