LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/filter/inc - xeescher.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 19 31.6 %
Date: 2013-07-09 Functions: 9 33 27.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             : #ifndef SC_XEESCHER_HXX
      21             : #define SC_XEESCHER_HXX
      22             : 
      23             : #include <vcl/graph.hxx>
      24             : #include <filter/msfilter/escherex.hxx>
      25             : #include "xcl97rec.hxx"
      26             : #include "xlescher.hxx"
      27             : #include <com/sun/star/chart/XChartDocument.hpp>
      28             : #include "svx/sdtaitm.hxx"
      29             : #include <boost/shared_ptr.hpp>
      30             : #include "rtl/ustring.hxx"
      31             : 
      32             : class ScPostIt;
      33             : 
      34             : namespace com { namespace sun { namespace star {
      35             :     namespace script { struct ScriptEventDescriptor; }
      36             : } } }
      37             : 
      38             : // DFF client anchor ==========================================================
      39             : 
      40             : /** Base class for DFF client anchor atoms used in spreadsheets. */
      41           2 : class XclExpDffAnchorBase : public EscherExClientAnchor_Base, protected XclExpRoot
      42             : {
      43             : public:
      44             :     /** Constructs a dummy client anchor. */
      45             :     explicit            XclExpDffAnchorBase( const XclExpRoot& rRoot, sal_uInt16 nFlags = 0 );
      46             : 
      47             :     /** Sets the flags according to the passed SdrObject. */
      48             :     void                SetFlags( const SdrObject& rSdrObj );
      49             :     /** Sets the anchor position and flags according to the passed SdrObject. */
      50             :     void                SetSdrObject( const SdrObject& rSdrObj );
      51             : 
      52             :     /** Writes the DFF client anchor structure with the current anchor position. */
      53             :     void                WriteDffData( EscherEx& rEscherEx ) const;
      54             : 
      55             :     /** Called from SVX DFF converter.
      56             :         @param rRect  The object anchor rectangle to be exported (in twips). */
      57             :     virtual void        WriteData( EscherEx& rEscherEx, const Rectangle& rRect );
      58             : 
      59             : private:
      60             :     virtual void        ImplSetFlags( const SdrObject& rSdrObj );
      61             :     virtual void        ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit );
      62             : 
      63             : protected:  // for access in derived classes
      64             :     XclObjAnchor        maAnchor;       /// The client anchor data.
      65             :     sal_uInt16          mnFlags;        /// Flags for DFF stream export.
      66             : };
      67             : 
      68             : // ----------------------------------------------------------------------------
      69             : 
      70             : /** Represents the position (anchor) of an object in a Calc sheet. */
      71           4 : class XclExpDffSheetAnchor : public XclExpDffAnchorBase
      72             : {
      73             : public:
      74             :     explicit            XclExpDffSheetAnchor( const XclExpRoot& rRoot );
      75             : 
      76             : private:
      77             :     virtual void        ImplSetFlags( const SdrObject& rSdrObj );
      78             :     virtual void        ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit );
      79             : 
      80             : private:
      81             :     SCTAB               mnScTab;        /// Calc sheet index.
      82             : };
      83             : 
      84             : // ----------------------------------------------------------------------------
      85             : 
      86             : /** Represents the position (anchor) of a shape in an embedded draw page. */
      87           0 : class XclExpDffEmbeddedAnchor : public XclExpDffAnchorBase
      88             : {
      89             : public:
      90             :     explicit            XclExpDffEmbeddedAnchor( const XclExpRoot& rRoot,
      91             :                             const Size& rPageSize, sal_Int32 nScaleX, sal_Int32 nScaleY );
      92             : 
      93             : private:
      94             :     virtual void        ImplSetFlags( const SdrObject& rSdrObj );
      95             :     virtual void        ImplCalcAnchorRect( const Rectangle& rRect, MapUnit eMapUnit );
      96             : 
      97             : private:
      98             :     Size                maPageSize;
      99             :     sal_Int32           mnScaleX;
     100             :     sal_Int32           mnScaleY;
     101             : };
     102             : 
     103             : // ----------------------------------------------------------------------------
     104             : 
     105             : /** Represents the position (anchor) of a note object. */
     106           0 : class XclExpDffNoteAnchor : public XclExpDffAnchorBase
     107             : {
     108             : public:
     109             :     explicit            XclExpDffNoteAnchor( const XclExpRoot& rRoot, const Rectangle& rRect );
     110             : };
     111             : 
     112             : // ----------------------------------------------------------------------------
     113             : 
     114             : /** Represents the position (anchor) of a cell dropdown object. */
     115           0 : class XclExpDffDropDownAnchor : public XclExpDffAnchorBase
     116             : {
     117             : public:
     118             :     explicit            XclExpDffDropDownAnchor( const XclExpRoot& rRoot, const ScAddress& rScPos );
     119             : };
     120             : 
     121             : // MSODRAWING* records ========================================================
     122             : 
     123             : /** Base class for records holding DFF stream fragments. */
     124          23 : class XclExpMsoDrawingBase : public XclExpRecord
     125             : {
     126             : public:
     127             :     explicit            XclExpMsoDrawingBase( XclEscherEx& rEscherEx, sal_uInt16 nRecId );
     128             : 
     129             : private:
     130             :     virtual void        WriteBody( XclExpStream& rStrm );
     131             : 
     132             : protected:
     133             :     XclEscherEx&        mrEscherEx;         /// Reference to the DFF converter containing the DFF stream.
     134             :     sal_uInt32          mnFragmentKey;      /// The key of the DFF stream fragment to be written by this record.
     135             : };
     136             : 
     137             : // ----------------------------------------------------------------------------
     138             : 
     139             : /** The MSODRAWINGGROUP record contains the DGGCONTAINER with global DFF data
     140             :     such as the picture container.
     141             :  */
     142          18 : class XclExpMsoDrawingGroup : public XclExpMsoDrawingBase
     143             : {
     144             : public:
     145             :     explicit            XclExpMsoDrawingGroup( XclEscherEx& rEscherEx );
     146             : };
     147             : 
     148             : // ----------------------------------------------------------------------------
     149             : 
     150             : /** One or more MSODRAWING records contain the DFF stream data for a drawing
     151             :     shape.
     152             :  */
     153          28 : class XclExpMsoDrawing : public XclExpMsoDrawingBase
     154             : {
     155             : public:
     156             :     explicit            XclExpMsoDrawing( XclEscherEx& rEscherEx );
     157             : };
     158             : 
     159             : // ============================================================================
     160             : 
     161             : /** Provides export of bitmap data to an IMGDATA record. */
     162           0 : class XclExpImgData : public XclExpRecordBase
     163             : {
     164             : public:
     165             :     explicit            XclExpImgData( const Graphic& rGraphic, sal_uInt16 nRecId );
     166             : 
     167             :     /** Writes the BITMAP record. */
     168             :     virtual void        Save( XclExpStream& rStrm );
     169             :     virtual void        SaveXml( XclExpXmlStream& rStrm );
     170             : 
     171             : private:
     172             :     Graphic             maGraphic;      /// The VCL graphic.
     173             :     sal_uInt16          mnRecId;        /// Record identifier for the IMGDATA record.
     174             : };
     175             : 
     176             : // ============================================================================
     177             : 
     178             : /** Helper class for form controils to manage spreadsheet links . */
     179             : class XclExpControlHelper : protected XclExpRoot
     180             : {
     181             : public:
     182             :     explicit            XclExpControlHelper( const XclExpRoot& rRoot );
     183             :     virtual             ~XclExpControlHelper();
     184             : 
     185             : protected:
     186             :     /** Tries to get spreadsheet cell link and source range link from the passed shape. */
     187             :     void                ConvertSheetLinks(
     188             :                             ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
     189             : 
     190             : 
     191             :     /** Returns the Excel token array of the cell link, or 0, if no link present. */
     192           0 :     inline const XclTokenArray* GetCellLinkTokArr() const { return mxCellLink.get(); }
     193             :     /** Returns the Excel token array of the source range, or 0, if no link present. */
     194           0 :     inline const XclTokenArray* GetSourceRangeTokArr() const { return mxSrcRange.get(); }
     195             :     /** Returns the number of entries in the source range, or 0, if no source set. */
     196           0 :     inline sal_uInt16   GetSourceEntryCount() const { return mnEntryCount; }
     197             : 
     198             :     /** Writes a formula with special style only valid in OBJ records. */
     199             :     void                WriteFormula( XclExpStream& rStrm, const XclTokenArray& rTokArr ) const;
     200             :     /** Writes a formula subrecord with special style only valid in OBJ records. */
     201             :     void                WriteFormulaSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId, const XclTokenArray& rTokArr ) const;
     202             : 
     203             : private:
     204             :     XclTokenArrayRef    mxCellLink;     /// Formula for linked cell.
     205             :     XclTokenArrayRef    mxSrcRange;     /// Formula for source data range.
     206             :     sal_uInt16          mnEntryCount;   /// Number of entries in source range.
     207             : };
     208             : 
     209             : class XclMacroHelper : public XclExpControlHelper
     210             : {
     211             : protected:
     212             :     XclTokenArrayRef    mxMacroLink;    /// Token array containing a link to an attached macro.
     213             : 
     214             : public:
     215             :     explicit            XclMacroHelper( const XclExpRoot& rRoot );
     216             :     virtual             ~XclMacroHelper();
     217             :     /** Writes an ftMacro subrecord containing a macro link, or nothing, if no macro present. */
     218             :     void                WriteMacroSubRec( XclExpStream& rStrm  );
     219             :     /** Sets the name of a macro for object of passed type
     220             :         @return  true = The passed event descriptor was valid, macro name has been found. */
     221             :     bool                SetMacroLink( const ::com::sun::star::script::ScriptEventDescriptor& rEvent,  const XclTbxEventType& nEventType );
     222             : 
     223             :     /** Sets the name of a macro
     224             :         @return  true = The passed macro name has been found. */
     225             :     bool                SetMacroLink( const String& rMacro );
     226             : };
     227             : 
     228             : class XclExpShapeObj : public XclObjAny, public XclMacroHelper
     229             : {
     230             : public:
     231             :     explicit            XclExpShapeObj( XclExpObjectManager& rRoot, ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape );
     232             :     virtual             ~XclExpShapeObj();
     233             : private:
     234             :     virtual void        WriteSubRecs( XclExpStream& rStrm );
     235             : };
     236             : 
     237             : // ----------------------------------------------------------------------------
     238             : 
     239             : //delete for exporting OCX
     240             : //#if EXC_EXP_OCX_CTRL
     241             : 
     242             : /** Represents an OBJ record for an OCX form control. */
     243           0 : class XclExpOcxControlObj : public XclObj, public XclExpControlHelper
     244             : {
     245             : public:
     246             :     explicit            XclExpOcxControlObj(
     247             :                             XclExpObjectManager& rObjMgr,
     248             :                             ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
     249             :                             const Rectangle* pChildAnchor,
     250             :                             const String& rClassName,
     251             :                             sal_uInt32 nStrmStart, sal_uInt32 nStrmSize );
     252             : 
     253             : private:
     254             :     virtual void        WriteSubRecs( XclExpStream& rStrm );
     255             : 
     256             : private:
     257             :     OUString            maClassName;        /// Class name of the control.
     258             :     sal_uInt32          mnStrmStart;        /// Start position in 'Ctls' stream.
     259             :     sal_uInt32          mnStrmSize;         /// Size in 'Ctls' stream.
     260             : };
     261             : 
     262             : //#else
     263             : 
     264             : /** Represents an OBJ record for an TBX form control. */
     265           0 : class XclExpTbxControlObj : public XclObj, public XclMacroHelper
     266             : {
     267             : public:
     268             :     explicit            XclExpTbxControlObj(
     269             :                             XclExpObjectManager& rObjMgr,
     270             :                             ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
     271             :                             const Rectangle* pChildAnchor );
     272             : 
     273             :     /** Sets the name of a macro attached to this control.
     274             :         @return  true = The passed event descriptor was valid, macro name has been found. */
     275             :     bool                SetMacroLink( const ::com::sun::star::script::ScriptEventDescriptor& rEvent );
     276             : 
     277             : private:
     278             :     virtual void        WriteSubRecs( XclExpStream& rStrm );
     279             : 
     280             :     /** Writes a subrecord containing a cell link, or nothing, if no link present. */
     281             :     void                WriteCellLinkSubRec( XclExpStream& rStrm, sal_uInt16 nSubRecId );
     282             :     /** Writes the ftSbs sub structure containing scrollbar data. */
     283             :     void                WriteSbs( XclExpStream& rStrm );
     284             : 
     285             : private:
     286             :     ScfInt16Vec         maMultiSel;     /// Indexes of all selected entries in a multi selection.
     287             :     XclTbxEventType     meEventType;    /// Type of supported macro event.
     288             :     sal_Int32           mnHeight;       /// Height of the control.
     289             :     sal_uInt16          mnState;        /// Checked/unchecked state.
     290             :     sal_Int16           mnLineCount;    /// Combobox dropdown line count.
     291             :     sal_Int16           mnSelEntry;     /// Selected entry in combobox (1-based).
     292             :     sal_uInt16          mnScrollValue;  /// Scrollbar: Current value.
     293             :     sal_uInt16          mnScrollMin;    /// Scrollbar: Minimum value.
     294             :     sal_uInt16          mnScrollMax;    /// Scrollbar: Maximum value.
     295             :     sal_uInt16          mnScrollStep;   /// Scrollbar: Single step.
     296             :     sal_uInt16          mnScrollPage;   /// Scrollbar: Page step.
     297             :     bool                mbFlatButton;   /// False = 3D button style; True = Flat button style.
     298             :     bool                mbFlatBorder;   /// False = 3D border style; True = Flat border style.
     299             :     bool                mbMultiSel;     /// true = Multi selection in listbox.
     300             :     bool                mbScrollHor;    /// Scrollbar: true = horizontal.
     301             : };
     302             : 
     303             : //#endif
     304             : 
     305             : // ----------------------------------------------------------------------------
     306             : 
     307             : class XclExpChart;
     308             : 
     309             : /** A chart object. This is the drawing object wrapper for the chart data. */
     310             : class XclExpChartObj : public XclObj, protected XclExpRoot
     311             : {
     312             : public:
     313             :     typedef ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDocument > XChartDocRef;
     314             :     typedef ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > XShapeRef;
     315             :     explicit            XclExpChartObj(
     316             :                             XclExpObjectManager& rObjMgr,
     317             :                             ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape,
     318             :                             const Rectangle* pChildAnchor );
     319             :     virtual             ~XclExpChartObj();
     320             : 
     321             :     /** Writes the OBJ record and the entire chart substream. */
     322             :     virtual void        Save( XclExpStream& rStrm );
     323             :     virtual void        SaveXml( XclExpXmlStream& rStrm );
     324             :     virtual void        WriteChartObj( sax_fastparser::FSHelperPtr pDrawing, XclExpXmlStream& rStrm );
     325             :     void WriteShapeTransformation( sax_fastparser::FSHelperPtr pFS, const XShapeRef& rXShape, sal_Bool bFlipH = false, sal_Bool bFlipV = false, sal_Int32 nRotation = 0 );
     326             : 
     327             : private:
     328             :     typedef boost::shared_ptr< XclExpChart > XclExpChartRef;
     329             :     XclExpChartRef      mxChart;        /// The chart itself (BOF/EOF substream data).
     330             :     XShapeRef mxShape;
     331             :     XChartDocRef mxChartDoc;
     332             : };
     333             : 
     334             : // ============================================================================
     335             : 
     336             : /** Represents a NOTE record containing the relevant data of a cell note.
     337             : 
     338             :     NOTE records differ significantly in various BIFF versions. This class
     339             :     encapsulates all needed actions for each supported BIFF version.
     340             :     BIFF5/BIFF7: Stores the note text and generates a single or multiple NOTE
     341             :     records on saving.
     342             :     BIFF8: Creates the Escher object containing the drawing information and the
     343             :     note text.
     344             :  */
     345           0 : class XclExpNote : public XclExpRecord
     346             : {
     347             : public:
     348             :     /** Constructs a NOTE record from the passed note object and/or the text.
     349             :         @descr  The additional text will be separated from the note text with
     350             :             an empty line.
     351             :         @param rScPos  The Calc cell address of the note.
     352             :         @param pScNote  The Calc note object. May be 0 to create a note from rAddText only.
     353             :         @param rAddText  Additional text appended to the note text. */
     354             :     explicit            XclExpNote(
     355             :                             const XclExpRoot& rRoot,
     356             :                             const ScAddress& rScPos,
     357             :                             const ScPostIt* pScNote,
     358             :                             const String& rAddText );
     359             : 
     360             :     /** Writes the NOTE record, if the respective Escher object is present. */
     361             :     virtual void        Save( XclExpStream& rStrm );
     362             : 
     363             :     void                WriteXml( sal_Int32 nAuthorId, XclExpXmlStream& rStrm );
     364             : 
     365           0 :     const XclExpString& GetAuthor() const { return maAuthor; }
     366             : private:
     367             :     /** Writes the body of the NOTE record. */
     368             :     virtual void        WriteBody( XclExpStream& rStrm );
     369             : 
     370             : private:
     371             :     XclExpString        maAuthor;       /// Name of the author.
     372             :     String              maOrigNoteText; /// Original main text of the note.
     373             :     OString        maNoteText;     /// Main text of the note (<=BIFF7).
     374             :     XclExpStringRef     mpNoteContents; /// Text and formatting data (OOXML)
     375             :     ScAddress           maScPos;        /// Calc cell address of the note.
     376             :     sal_uInt16          mnObjId;        /// Escher object ID (BIFF8).
     377             :     bool                mbVisible;      /// true = permanently visible.
     378             :     SdrTextHorzAdjust   meTHA;          /// text horizontal adjust
     379             :     SdrTextVertAdjust   meTVA;          /// text vertical adjust
     380             :     bool                mbAutoScale;    /// Auto scale text
     381             :     bool                mbLocked;       /// Position & Size locked
     382             :     bool                mbAutoFill;     /// Auto Fill Style
     383             :     bool                mbAutoLine;     /// Auto Line Style
     384             :     bool                mbColHidden;    /// Column containing the comment is hidden
     385             :     bool                mbRowHidden;    /// Row containing the comment is hidden
     386             :     Rectangle           maCommentFrom;  /// From and From Offset
     387             :     Rectangle           maCommentTo;    /// To and To Offsets
     388             : };
     389             : 
     390             : // ============================================================================
     391             : 
     392           0 : class XclExpComments : public XclExpRecord
     393             : {
     394             : public:
     395             :     typedef XclExpRecordList< XclExpNote >
     396             :                         XclExpNoteList;
     397             : 
     398             :                         XclExpComments( SCTAB nTab, XclExpNoteList& rNotes );
     399             : 
     400             :     virtual void        SaveXml( XclExpXmlStream& rStrm );
     401             : 
     402             : private:
     403             :     SCTAB               mnTab;
     404             :     XclExpNoteList&     mrNotes;
     405             : };
     406             : 
     407             : // object manager =============================================================
     408             : 
     409             : class XclExpObjectManager : public XclExpRoot
     410             : {
     411             : public:
     412             :     explicit            XclExpObjectManager( const XclExpRoot& rRoot );
     413             :     virtual             ~XclExpObjectManager();
     414             : 
     415             :     /** Creates a new DFF client anchor object. Caller takes ownership! May be
     416             :         overwritten in derived  classes. */
     417             :     virtual XclExpDffAnchorBase* CreateDffAnchor() const;
     418             : 
     419             :     /** Creates and returns the MSODRAWINGGROUP record containing global DFF
     420             :         data in the DGGCONTAINER. */
     421             :     boost::shared_ptr< XclExpRecordBase > CreateDrawingGroup();
     422             : 
     423             :     /** Initializes the object manager for a new sheet. */
     424             :     void                StartSheet();
     425             : 
     426             :     /** Processes a drawing page and returns the record block containing all
     427             :         related records (MSODRAWING, OBJ, TXO, charts, etc.). */
     428             :     boost::shared_ptr< XclExpRecordBase > ProcessDrawing( SdrPage* pSdrPage );
     429             :     /** Processes a collection of UNO shapes and returns the record block
     430             :         containing all related records (MSODRAWING, OBJ, TXO, charts, etc.). */
     431             :     boost::shared_ptr< XclExpRecordBase > ProcessDrawing( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes );
     432             : 
     433             :     /** Finalizes the object manager after conversion of all sheets. */
     434             :     void                EndDocument();
     435             : 
     436           2 :     inline XclEscherEx& GetEscherEx() { return *mxEscherEx; }
     437             :     XclExpMsoDrawing*   GetMsodrawingPerSheet();
     438             :     bool                HasObj() const;
     439             :     sal_uInt16          AddObj( XclObj* pObjRec );
     440             :     XclObj*             RemoveLastObj();
     441             : 
     442             : protected:
     443             :     explicit            XclExpObjectManager( const XclExpObjectManager& rParent );
     444             : 
     445             : private:
     446             :     void                InitStream( bool bTempFile );
     447             : 
     448             : private:
     449             :     boost::shared_ptr< ::utl::TempFile > mxTempFile;
     450             :     boost::shared_ptr< SvStream >  mxDffStrm;
     451             :     boost::shared_ptr< XclEscherEx > mxEscherEx;
     452             :     boost::shared_ptr< XclExpObjList > mxObjList;
     453             : };
     454             : 
     455             : // ----------------------------------------------------------------------------
     456             : 
     457           0 : class XclExpEmbeddedObjectManager : public XclExpObjectManager
     458             : {
     459             : public:
     460             :     explicit            XclExpEmbeddedObjectManager(
     461             :                             const XclExpObjectManager& rParent,
     462             :                             const Size& rPageSize,
     463             :                             sal_Int32 nScaleX, sal_Int32 nScaleY );
     464             : 
     465             :     /** Creates a new DFF client anchor object for embedded objects according
     466             :         to the scaling data passed to the constructor. Caller takes ownership! */
     467             :     virtual XclExpDffAnchorBase* CreateDffAnchor() const;
     468             : 
     469             : private:
     470             :     Size                maPageSize;
     471             :     sal_Int32           mnScaleX;
     472             :     sal_Int32           mnScaleY;
     473             : };
     474             : 
     475             : // ============================================================================
     476             : 
     477             : #endif
     478             : 
     479             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10