LCOV - code coverage report
Current view: top level - sc/source/filter/inc - xeescher.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 19 0.0 %
Date: 2014-04-14 Functions: 0 33 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10