LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/inc - drawingbase.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 4 6 66.7 %
Date: 2012-12-27 Functions: 4 7 57.1 %
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 OOX_XLS_DRAWINGBASE_HXX
      21             : #define OOX_XLS_DRAWINGBASE_HXX
      22             : 
      23             : #include "oox/drawingml/drawingmltypes.hxx"
      24             : #include "worksheethelper.hxx"
      25             : 
      26             : #include <com/sun/star/drawing/XShape.hpp>
      27             : #include <com/sun/star/table/XCell.hpp>
      28             : 
      29             : namespace oox {
      30             : namespace xls {
      31             : 
      32             : // ============================================================================
      33             : 
      34             : /** Absolute position in a spreadsheet (in EMUs) independent from cells. */
      35             : struct AnchorPointModel : public ::oox::drawingml::EmuPoint
      36             : {
      37           2 :     inline explicit     AnchorPointModel() : ::oox::drawingml::EmuPoint( -1, -1 ) {}
      38           0 :     inline bool         isValid() const { return (X >= 0) && (Y >= 0); }
      39             : };
      40             : 
      41             : // ----------------------------------------------------------------------------
      42             : 
      43             : /** Absolute size in a spreadsheet (in EMUs). */
      44             : struct AnchorSizeModel : public ::oox::drawingml::EmuSize
      45             : {
      46           2 :     inline explicit     AnchorSizeModel() : ::oox::drawingml::EmuSize( -1, -1 ) {}
      47           0 :     inline bool         isValid() const { return (Width >= 0) && (Height >= 0); }
      48             : };
      49             : 
      50             : // ----------------------------------------------------------------------------
      51             : 
      52             : /** Position in spreadsheet (cell position and offset inside cell). */
      53             : struct CellAnchorModel
      54             : {
      55             :     sal_Int32           mnCol;              /// Column index.
      56             :     sal_Int32           mnRow;              /// Row index.
      57             :     sal_Int64           mnColOffset;        /// X offset inside the column.
      58             :     sal_Int64           mnRowOffset;        /// Y offset inside the row.
      59             : 
      60             :     explicit            CellAnchorModel();
      61           4 :     inline bool         isValid() const { return (mnCol >= 0) && (mnRow >= 0); }
      62             : };
      63             : 
      64             : // ----------------------------------------------------------------------------
      65             : 
      66             : /** Application-specific client data of a shape. */
      67             : struct AnchorClientDataModel
      68             : {
      69             :     bool                mbLocksWithSheet;
      70             :     bool                mbPrintsWithSheet;
      71             : 
      72             :     explicit            AnchorClientDataModel();
      73             : };
      74             : 
      75             : // ============================================================================
      76             : 
      77             : /** Contains the position of a shape in the spreadsheet. Supports different
      78             :     shape anchor modes (absolute, one-cell, two-cell). */
      79           2 : class ShapeAnchor : public WorksheetHelper
      80             : {
      81             : public:
      82             :     explicit            ShapeAnchor( const WorksheetHelper& rHelper );
      83             : 
      84             :     /** Imports the shape anchor (one of the elements xdr:absoluteAnchor, xdr:oneCellAnchor, xdr:twoCellAnchor). */
      85             :     void                importAnchor( sal_Int32 nElement, const AttributeList& rAttribs );
      86             :     /** Imports the absolute anchor position from the xdr:pos element. */
      87             :     void                importPos( const AttributeList& rAttribs );
      88             :     /** Imports the absolute anchor size from the xdr:ext element. */
      89             :     void                importExt( const AttributeList& rAttribs );
      90             :     /** Imports the shape client data from the xdr:clientData element. */
      91             :     void                importClientData( const AttributeList& rAttribs );
      92             :     /** Sets an attribute of the cell-dependent anchor position from xdr:from and xdr:to elements. */
      93             :     void                setCellPos( sal_Int32 nElement, sal_Int32 nParentContext, const ::rtl::OUString& rValue );
      94             :     /** Imports the client anchor settings from a VML element. */
      95             :     void                importVmlAnchor( const ::rtl::OUString& rAnchor );
      96             : 
      97             :     /** Calculates the resulting shape anchor in EMUs. */
      98             :     ::oox::drawingml::EmuRectangle calcAnchorRectEmu(
      99             :                             const ::com::sun::star::awt::Size& rPageSizeHmm ) const;
     100             :     /** Calculates the resulting shape anchor in 1/100 mm. */
     101             :     ::com::sun::star::awt::Rectangle calcAnchorRectHmm(
     102             :                             const ::com::sun::star::awt::Size& rPageSizeHmm ) const;
     103             : private:
     104             :     /** Converts the passed anchor to an absolute position in EMUs. */
     105             :     ::oox::drawingml::EmuPoint calcCellAnchorEmu( const CellAnchorModel& rModel ) const;
     106             : 
     107             : private:
     108             :     enum AnchorType
     109             :     {
     110             :         ANCHOR_INVALID,         /// Anchor type is unknown.
     111             :         ANCHOR_ABSOLUTE,        /// Absolute anchor (top-left corner and size in absolute units).
     112             :         ANCHOR_ONECELL,         /// One-cell anchor (top-left corner at cell, size in absolute units).
     113             :         ANCHOR_TWOCELL,         /// Two-cell anchor (top-left and bottom-right corner at cell).
     114             :         ANCHOR_VML
     115             :     };
     116             : 
     117             :     /** Specifies how cell positions from CellAnchorModel have to be processed. */
     118             :     enum CellAnchorType
     119             :     {
     120             :         CELLANCHOR_EMU,             /// Offsets are given in EMUs.
     121             :         CELLANCHOR_PIXEL,           /// Offsets are given in screen pixels.
     122             :         CELLANCHOR_COLROW           /// Offsets are given in fractions of column width or row height.
     123             :     };
     124             : 
     125             :     AnchorType          meAnchorType;       /// Type of this shape anchor.
     126             :     CellAnchorType      meCellAnchorType;   /// Type of the cell anchor models.
     127             :     AnchorPointModel    maPos;              /// Top-left position, if anchor is of type absolute.
     128             :     AnchorSizeModel     maSize;             /// Anchor size, if anchor is not of type two-cell.
     129             :     CellAnchorModel     maFrom;             /// Top-left position, if anchor is not of type absolute.
     130             :     CellAnchorModel     maTo;               /// Bottom-right position, if anchor is of type two-cell.
     131             :     AnchorClientDataModel maClientData;     /// Shape client data.
     132             :     sal_Int32           mnEditAs;           /// Anchor mode as shown in the UI.
     133             : };
     134             : 
     135             : // ============================================================================
     136             : 
     137             : } // namespace xls
     138             : } // namespace oox
     139             : 
     140             : #endif
     141             : 
     142             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10