LCOV - code coverage report
Current view: top level - libreoffice/sc/source/filter/oox - drawingmanager.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 138 0.7 %
Date: 2012-12-27 Functions: 2 18 11.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             : #include "drawingmanager.hxx"
      21             : 
      22             : #include <com/sun/star/awt/Rectangle.hpp>
      23             : #include <com/sun/star/drawing/CircleKind.hpp>
      24             : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
      25             : #include <com/sun/star/drawing/PolygonKind.hpp>
      26             : #include <com/sun/star/drawing/XShapes.hpp>
      27             : #include "oox/core/filterbase.hxx"
      28             : #include "oox/drawingml/fillproperties.hxx"
      29             : #include "oox/drawingml/lineproperties.hxx"
      30             : #include "oox/drawingml/shapepropertymap.hxx"
      31             : #include "oox/helper/containerhelper.hxx"
      32             : #include "oox/token/tokens.hxx"
      33             : #include "biffinputstream.hxx"
      34             : #include "unitconverter.hxx"
      35             : 
      36             : namespace oox {
      37             : namespace xls {
      38             : 
      39             : // ============================================================================
      40             : 
      41             : using namespace ::com::sun::star::awt;
      42             : using namespace ::com::sun::star::drawing;
      43             : using namespace ::com::sun::star::lang;
      44             : using namespace ::com::sun::star::uno;
      45             : using namespace ::oox::drawingml;
      46             : 
      47             : using ::rtl::OUString;
      48             : 
      49             : // ============================================================================
      50             : 
      51             : namespace {
      52             : 
      53             : // OBJ record -----------------------------------------------------------------
      54             : 
      55             : const sal_uInt16 BIFF_OBJTYPE_GROUP         = 0;
      56             : const sal_uInt16 BIFF_OBJTYPE_LINE          = 1;
      57             : const sal_uInt16 BIFF_OBJTYPE_RECTANGLE     = 2;
      58             : const sal_uInt16 BIFF_OBJTYPE_OVAL          = 3;
      59             : const sal_uInt16 BIFF_OBJTYPE_ARC           = 4;
      60             : const sal_uInt16 BIFF_OBJTYPE_CHART         = 5;
      61             : const sal_uInt16 BIFF_OBJTYPE_TEXT          = 6;
      62             : const sal_uInt16 BIFF_OBJTYPE_BUTTON        = 7;
      63             : const sal_uInt16 BIFF_OBJTYPE_PICTURE       = 8;
      64             : const sal_uInt16 BIFF_OBJTYPE_POLYGON       = 9;        // new in BIFF4
      65             : const sal_uInt16 BIFF_OBJTYPE_CHECKBOX      = 11;       // new in BIFF5
      66             : const sal_uInt16 BIFF_OBJTYPE_OPTIONBUTTON  = 12;
      67             : const sal_uInt16 BIFF_OBJTYPE_EDIT          = 13;
      68             : const sal_uInt16 BIFF_OBJTYPE_LABEL         = 14;
      69             : const sal_uInt16 BIFF_OBJTYPE_DIALOG        = 15;
      70             : const sal_uInt16 BIFF_OBJTYPE_SPIN          = 16;
      71             : const sal_uInt16 BIFF_OBJTYPE_SCROLLBAR     = 17;
      72             : const sal_uInt16 BIFF_OBJTYPE_LISTBOX       = 18;
      73             : const sal_uInt16 BIFF_OBJTYPE_GROUPBOX      = 19;
      74             : const sal_uInt16 BIFF_OBJTYPE_DROPDOWN      = 20;
      75             : const sal_uInt16 BIFF_OBJTYPE_NOTE          = 25;       // new in BIFF8
      76             : const sal_uInt16 BIFF_OBJTYPE_DRAWING       = 30;
      77             : const sal_uInt16 BIFF_OBJTYPE_UNKNOWN       = 0xFFFF;   // for internal use only
      78             : 
      79             : const sal_uInt16 BIFF_OBJ_HIDDEN            = 0x0100;
      80             : const sal_uInt16 BIFF_OBJ_VISIBLE           = 0x0200;
      81             : const sal_uInt16 BIFF_OBJ_PRINTABLE         = 0x0400;
      82             : 
      83             : // line formatting ------------------------------------------------------------
      84             : 
      85             : const sal_uInt8 BIFF_OBJ_LINE_AUTOCOLOR     = 64;
      86             : 
      87             : const sal_uInt8 BIFF_OBJ_LINE_SOLID         = 0;
      88             : const sal_uInt8 BIFF_OBJ_LINE_DASH          = 1;
      89             : const sal_uInt8 BIFF_OBJ_LINE_DOT           = 2;
      90             : const sal_uInt8 BIFF_OBJ_LINE_DASHDOT       = 3;
      91             : const sal_uInt8 BIFF_OBJ_LINE_DASHDOTDOT    = 4;
      92             : const sal_uInt8 BIFF_OBJ_LINE_MEDTRANS      = 5;
      93             : const sal_uInt8 BIFF_OBJ_LINE_DARKTRANS     = 6;
      94             : const sal_uInt8 BIFF_OBJ_LINE_LIGHTTRANS    = 7;
      95             : const sal_uInt8 BIFF_OBJ_LINE_NONE          = 255;
      96             : 
      97             : const sal_uInt8 BIFF_OBJ_LINE_HAIR          = 0;
      98             : const sal_uInt8 BIFF_OBJ_LINE_THIN          = 1;
      99             : const sal_uInt8 BIFF_OBJ_LINE_MEDIUM        = 2;
     100             : const sal_uInt8 BIFF_OBJ_LINE_THICK         = 3;
     101             : 
     102             : const sal_uInt8 BIFF_OBJ_LINE_AUTO          = 0x01;
     103             : 
     104             : const sal_uInt8 BIFF_OBJ_ARROW_NONE         = 0;
     105             : const sal_uInt8 BIFF_OBJ_ARROW_OPEN         = 1;
     106             : const sal_uInt8 BIFF_OBJ_ARROW_FILLED       = 2;
     107             : const sal_uInt8 BIFF_OBJ_ARROW_OPENBOTH     = 3;
     108             : const sal_uInt8 BIFF_OBJ_ARROW_FILLEDBOTH   = 4;
     109             : 
     110             : const sal_uInt8 BIFF_OBJ_ARROW_NARROW       = 0;
     111             : const sal_uInt8 BIFF_OBJ_ARROW_MEDIUM       = 1;
     112             : const sal_uInt8 BIFF_OBJ_ARROW_WIDE         = 2;
     113             : 
     114             : const sal_uInt8 BIFF_OBJ_LINE_TL            = 0;
     115             : const sal_uInt8 BIFF_OBJ_LINE_TR            = 1;
     116             : const sal_uInt8 BIFF_OBJ_LINE_BR            = 2;
     117             : const sal_uInt8 BIFF_OBJ_LINE_BL            = 3;
     118             : 
     119             : const sal_uInt8 BIFF_OBJ_ARC_TR             = 0;
     120             : const sal_uInt8 BIFF_OBJ_ARC_TL             = 1;
     121             : const sal_uInt8 BIFF_OBJ_ARC_BL             = 2;
     122             : const sal_uInt8 BIFF_OBJ_ARC_BR             = 3;
     123             : 
     124             : const sal_uInt16 BIFF_OBJ_POLY_CLOSED       = 0x0100;
     125             : 
     126             : // fill formatting ------------------------------------------------------------
     127             : 
     128             : const sal_uInt8 BIFF_OBJ_FILL_AUTOCOLOR     = 65;
     129             : 
     130             : const sal_uInt8 BIFF_OBJ_PATT_NONE          = 0;
     131             : const sal_uInt8 BIFF_OBJ_PATT_SOLID         = 1;
     132             : 
     133             : const sal_uInt8 BIFF_OBJ_FILL_AUTO          = 0x01;
     134             : 
     135             : // text formatting ------------------------------------------------------------
     136             : 
     137             : const sal_uInt8 BIFF_OBJ_HOR_LEFT           = 1;
     138             : const sal_uInt8 BIFF_OBJ_HOR_CENTER         = 2;
     139             : const sal_uInt8 BIFF_OBJ_HOR_RIGHT          = 3;
     140             : const sal_uInt8 BIFF_OBJ_HOR_JUSTIFY        = 4;
     141             : 
     142             : const sal_uInt8 BIFF_OBJ_VER_TOP            = 1;
     143             : const sal_uInt8 BIFF_OBJ_VER_CENTER         = 2;
     144             : const sal_uInt8 BIFF_OBJ_VER_BOTTOM         = 3;
     145             : const sal_uInt8 BIFF_OBJ_VER_JUSTIFY        = 4;
     146             : 
     147             : const sal_uInt16 BIFF_OBJ_ORIENT_NONE       = 0;
     148             : const sal_uInt16 BIFF_OBJ_ORIENT_STACKED    = 1;        /// Stacked top to bottom.
     149             : const sal_uInt16 BIFF_OBJ_ORIENT_90CCW      = 2;        /// 90 degr. counterclockwise.
     150             : const sal_uInt16 BIFF_OBJ_ORIENT_90CW       = 3;        /// 90 degr. clockwise.
     151             : 
     152             : const sal_uInt16 BIFF_OBJ_TEXT_AUTOSIZE     = 0x0080;
     153             : const sal_uInt16 BIFF_OBJ_TEXT_LOCKED       = 0x0200;
     154             : 
     155             : const sal_Int32 BIFF_OBJ_TEXT_MARGIN        = 20000;    /// Automatic text margin (EMUs).
     156             : 
     157             : // BIFF8 OBJ sub records ------------------------------------------------------
     158             : 
     159             : const sal_uInt16 BIFF_OBJCMO_PRINTABLE      = 0x0010;   /// Object printable.
     160             : const sal_uInt16 BIFF_OBJCMO_AUTOLINE       = 0x2000;   /// Automatic line formatting.
     161             : const sal_uInt16 BIFF_OBJCMO_AUTOFILL       = 0x4000;   /// Automatic fill formatting.
     162             : 
     163             : // ----------------------------------------------------------------------------
     164             : 
     165             : } // namespace
     166             : 
     167             : // ============================================================================
     168             : // Model structures for BIFF OBJ record data
     169             : // ============================================================================
     170             : 
     171           0 : BiffObjLineModel::BiffObjLineModel() :
     172             :     mnColorIdx( BIFF_OBJ_LINE_AUTOCOLOR ),
     173             :     mnStyle( BIFF_OBJ_LINE_SOLID ),
     174             :     mnWidth( BIFF_OBJ_LINE_HAIR ),
     175           0 :     mbAuto( true )
     176             : {
     177           0 : }
     178             : 
     179           0 : BiffInputStream& operator>>( BiffInputStream& rStrm, BiffObjLineModel& rModel )
     180             : {
     181             :     sal_uInt8 nFlags;
     182           0 :     rStrm >> rModel.mnColorIdx >> rModel.mnStyle >> rModel.mnWidth >> nFlags;
     183           0 :     rModel.mbAuto = getFlag( nFlags, BIFF_OBJ_LINE_AUTO );
     184           0 :     return rStrm;
     185             : }
     186             : 
     187             : // ============================================================================
     188             : 
     189           0 : BiffObjFillModel::BiffObjFillModel() :
     190             :     mnBackColorIdx( BIFF_OBJ_LINE_AUTOCOLOR ),
     191             :     mnPattColorIdx( BIFF_OBJ_FILL_AUTOCOLOR ),
     192             :     mnPattern( BIFF_OBJ_PATT_SOLID ),
     193           0 :     mbAuto( true )
     194             : {
     195           0 : }
     196             : 
     197           0 : BiffInputStream& operator>>( BiffInputStream& rStrm, BiffObjFillModel& rModel )
     198             : {
     199             :     sal_uInt8 nFlags;
     200           0 :     rStrm >> rModel.mnBackColorIdx >> rModel.mnPattColorIdx >> rModel.mnPattern >> nFlags;
     201           0 :     rModel.mbAuto = getFlag( nFlags, BIFF_OBJ_FILL_AUTO );
     202           0 :     return rStrm;
     203             : }
     204             : 
     205             : // ============================================================================
     206             : // BIFF drawing objects
     207             : // ============================================================================
     208             : 
     209           0 : BiffDrawingObjectContainer::BiffDrawingObjectContainer()
     210             : {
     211           0 : }
     212             : 
     213           0 : void BiffDrawingObjectContainer::convertAndInsert( BiffDrawingBase& rDrawing, const Reference< XShapes >& rxShapes, const Rectangle* pParentRect ) const
     214             : {
     215           0 :     maObjects.forEachMem( &BiffDrawingObjectBase::convertAndInsert, ::boost::ref( rDrawing ), ::boost::cref( rxShapes ), pParentRect );
     216           0 : }
     217             : 
     218             : // ============================================================================
     219             : 
     220           0 : BiffDrawingObjectBase::BiffDrawingObjectBase( const WorksheetHelper& rHelper ) :
     221             :     WorksheetHelper( rHelper ),
     222             :     maAnchor( rHelper ),
     223             :     mnObjId( BIFF_OBJ_INVALID_ID ),
     224             :     mnObjType( BIFF_OBJTYPE_UNKNOWN ),
     225             :     mbHidden( false ),
     226             :     mbVisible( true ),
     227             :     mbPrintable( true ),
     228             :     mbAreaObj( false ),
     229             :     mbSimpleMacro( true ),
     230             :     mbProcessShape( true ),
     231             :     mbInsertShape( true ),
     232           0 :     mbCustomDff( false )
     233             : {
     234           0 : }
     235             : 
     236           0 : BiffDrawingObjectBase::~BiffDrawingObjectBase()
     237             : {
     238           0 : }
     239             : 
     240           0 : Reference< XShape > BiffDrawingObjectBase::convertAndInsert( BiffDrawingBase& rDrawing,
     241             :         const Reference< XShapes >& rxShapes, const Rectangle* pParentRect ) const
     242             : {
     243           0 :     Reference< XShape > xShape;
     244           0 :     if( rxShapes.is() && mbProcessShape && !mbHidden )  // TODO: support for hidden objects?
     245             :     {
     246             :         // base class 'ShapeAnchor' calculates the shape rectangle in 1/100 mm
     247             :         // in BIFF3-BIFF5, all shapes have absolute anchor (also children of group shapes)
     248           0 :         Rectangle aShapeRect = maAnchor.calcAnchorRectHmm( getDrawPageSize() );
     249             : 
     250             :         // convert the shape, if the calculated rectangle is not empty
     251           0 :         bool bHasWidth = aShapeRect.Width > 0;
     252           0 :         bool bHasHeight = aShapeRect.Height > 0;
     253           0 :         if( mbAreaObj ? (bHasWidth && bHasHeight) : (bHasWidth || bHasHeight) )
     254             :         {
     255           0 :             xShape = implConvertAndInsert( rDrawing, rxShapes, aShapeRect );
     256             :             /*  Notify the drawing that a new shape has been inserted (but not
     257             :                 for children of group shapes). For convenience, pass the
     258             :                 rectangle that contains position and size of the shape. */
     259           0 :             if( !pParentRect && xShape.is() )
     260           0 :                 rDrawing.notifyShapeInserted( xShape, aShapeRect );
     261             :         }
     262             :     }
     263           0 :     return xShape;
     264             : }
     265             : 
     266           0 : void BiffDrawingObjectBase::convertLineProperties( ShapePropertyMap& rPropMap, const BiffObjLineModel& rLineModel, sal_uInt16 nArrows ) const
     267             : {
     268           0 :     if( rLineModel.mbAuto )
     269             :     {
     270           0 :         BiffObjLineModel aAutoModel;
     271           0 :         aAutoModel.mbAuto = false;
     272           0 :         convertLineProperties( rPropMap, aAutoModel, nArrows );
     273           0 :         return;
     274             :     }
     275             : 
     276             :     /*  Convert line formatting to DrawingML line formatting and let the
     277             :         DrawingML code do the hard work. */
     278           0 :     LineProperties aLineProps;
     279             : 
     280           0 :     if( rLineModel.mnStyle == BIFF_OBJ_LINE_NONE )
     281             :     {
     282           0 :         aLineProps.maLineFill.moFillType = XML_noFill;
     283             :     }
     284             :     else
     285             :     {
     286           0 :         aLineProps.maLineFill.moFillType = XML_solidFill;
     287           0 :         aLineProps.maLineFill.maFillColor.setPaletteClr( rLineModel.mnColorIdx );
     288           0 :         aLineProps.moLineCompound = XML_sng;
     289           0 :         aLineProps.moLineCap = XML_flat;
     290           0 :         aLineProps.moLineJoint = XML_round;
     291             : 
     292             :         // line width: use 0.35 mm per BIFF line width step
     293           0 :         sal_Int32 nLineWidth = 0;
     294           0 :         switch( rLineModel.mnWidth )
     295             :         {
     296             :             default:
     297           0 :             case BIFF_OBJ_LINE_HAIR:    nLineWidth = 0;     break;
     298           0 :             case BIFF_OBJ_LINE_THIN:    nLineWidth = 20;    break;
     299           0 :             case BIFF_OBJ_LINE_MEDIUM:  nLineWidth = 40;    break;
     300           0 :             case BIFF_OBJ_LINE_THICK:   nLineWidth = 60;    break;
     301             :         }
     302           0 :         aLineProps.moLineWidth = getLimitedValue< sal_Int32, sal_Int64 >( convertHmmToEmu( nLineWidth ), 0, SAL_MAX_INT32 );
     303             : 
     304             :         // dash style and transparency
     305           0 :         switch( rLineModel.mnStyle )
     306             :         {
     307             :             default:
     308             :             case BIFF_OBJ_LINE_SOLID:
     309           0 :                 aLineProps.moPresetDash = XML_solid;
     310           0 :             break;
     311             :             case BIFF_OBJ_LINE_DASH:
     312           0 :                 aLineProps.moPresetDash = XML_lgDash;
     313           0 :             break;
     314             :             case BIFF_OBJ_LINE_DOT:
     315           0 :                 aLineProps.moPresetDash = XML_dot;
     316           0 :             break;
     317             :             case BIFF_OBJ_LINE_DASHDOT:
     318           0 :                 aLineProps.moPresetDash = XML_lgDashDot;
     319           0 :             break;
     320             :             case BIFF_OBJ_LINE_DASHDOTDOT:
     321           0 :                 aLineProps.moPresetDash = XML_lgDashDotDot;
     322           0 :             break;
     323             :             case BIFF_OBJ_LINE_MEDTRANS:
     324           0 :                 aLineProps.moPresetDash = XML_solid;
     325           0 :                 aLineProps.maLineFill.maFillColor.addTransformation( XML_alpha, 50 * PER_PERCENT );
     326           0 :             break;
     327             :             case BIFF_OBJ_LINE_DARKTRANS:
     328           0 :                 aLineProps.moPresetDash = XML_solid;
     329           0 :                 aLineProps.maLineFill.maFillColor.addTransformation( XML_alpha, 75 * PER_PERCENT );
     330           0 :             break;
     331             :             case BIFF_OBJ_LINE_LIGHTTRANS:
     332           0 :                 aLineProps.moPresetDash = XML_solid;
     333           0 :                 aLineProps.maLineFill.maFillColor.addTransformation( XML_alpha, 25 * PER_PERCENT );
     334           0 :             break;
     335             :         }
     336             : 
     337             :         // line ends
     338           0 :         bool bLineStart = false;
     339           0 :         bool bLineEnd = false;
     340           0 :         bool bFilled = false;
     341           0 :         switch( extractValue< sal_uInt8 >( nArrows, 0, 4 ) )
     342             :         {
     343           0 :             case BIFF_OBJ_ARROW_OPEN:       bLineStart = false; bLineEnd = true;  bFilled = false;  break;
     344           0 :             case BIFF_OBJ_ARROW_OPENBOTH:   bLineStart = true;  bLineEnd = true;  bFilled = false;  break;
     345           0 :             case BIFF_OBJ_ARROW_FILLED:     bLineStart = false; bLineEnd = true;  bFilled = true;   break;
     346           0 :             case BIFF_OBJ_ARROW_FILLEDBOTH: bLineStart = true;  bLineEnd = true;  bFilled = true;   break;
     347             :         }
     348           0 :         if( bLineStart || bLineEnd )
     349             :         {
     350             :             // arrow type (open or closed)
     351           0 :             sal_Int32 nArrowType = bFilled ? XML_triangle : XML_arrow;
     352           0 :             aLineProps.maStartArrow.moArrowType = bLineStart ? nArrowType : XML_none;
     353           0 :             aLineProps.maEndArrow.moArrowType   = bLineEnd   ? nArrowType : XML_none;
     354             : 
     355             :             // arrow width
     356           0 :             sal_Int32 nArrowWidth = XML_med;
     357           0 :             switch( extractValue< sal_uInt8 >( nArrows, 4, 4 ) )
     358             :             {
     359           0 :                 case BIFF_OBJ_ARROW_NARROW: nArrowWidth = XML_sm;   break;
     360           0 :                 case BIFF_OBJ_ARROW_MEDIUM: nArrowWidth = XML_med;  break;
     361           0 :                 case BIFF_OBJ_ARROW_WIDE:   nArrowWidth = XML_lg;   break;
     362             :             }
     363           0 :             aLineProps.maStartArrow.moArrowWidth = aLineProps.maEndArrow.moArrowWidth = nArrowWidth;
     364             : 
     365             :             // arrow length
     366           0 :             sal_Int32 nArrowLength = XML_med;
     367           0 :             switch( extractValue< sal_uInt8 >( nArrows, 8, 4 ) )
     368             :             {
     369           0 :                 case BIFF_OBJ_ARROW_NARROW: nArrowLength = XML_sm;  break;
     370           0 :                 case BIFF_OBJ_ARROW_MEDIUM: nArrowLength = XML_med; break;
     371           0 :                 case BIFF_OBJ_ARROW_WIDE:   nArrowLength = XML_lg;  break;
     372             :             }
     373           0 :             aLineProps.maStartArrow.moArrowLength = aLineProps.maEndArrow.moArrowLength = nArrowLength;
     374             :         }
     375             :     }
     376             : 
     377           0 :     aLineProps.pushToPropMap( rPropMap, getBaseFilter().getGraphicHelper() );
     378             : }
     379             : 
     380           0 : void BiffDrawingObjectBase::convertFillProperties( ShapePropertyMap& rPropMap, const BiffObjFillModel& rFillModel ) const
     381             : {
     382           0 :     if( rFillModel.mbAuto )
     383             :     {
     384           0 :         BiffObjFillModel aAutoModel;
     385           0 :         aAutoModel.mbAuto = false;
     386           0 :         convertFillProperties( rPropMap, aAutoModel );
     387           0 :         return;
     388             :     }
     389             : 
     390             :     /*  Convert fill formatting to DrawingML fill formatting and let the
     391             :         DrawingML code do the hard work. */
     392           0 :     FillProperties aFillProps;
     393             : 
     394           0 :     if( rFillModel.mnPattern == BIFF_OBJ_PATT_NONE )
     395             :     {
     396           0 :         aFillProps.moFillType = XML_noFill;
     397             :     }
     398             :     else
     399             :     {
     400             :         const sal_Int32 spnPatternPresets[] = {
     401             :             XML_TOKEN_INVALID, XML_TOKEN_INVALID, XML_pct50, XML_pct50, XML_pct25,
     402             :             XML_dkHorz, XML_dkVert, XML_dkDnDiag, XML_dkUpDiag, XML_smCheck, XML_trellis,
     403             :             XML_ltHorz, XML_ltVert, XML_ltDnDiag, XML_ltUpDiag, XML_smGrid, XML_diagCross,
     404           0 :             XML_pct20, XML_pct10 };
     405           0 :         sal_Int32 nPatternPreset = STATIC_ARRAY_SELECT( spnPatternPresets, rFillModel.mnPattern, XML_TOKEN_INVALID );
     406           0 :         if( nPatternPreset == XML_TOKEN_INVALID )
     407             :         {
     408           0 :             aFillProps.moFillType = XML_solidFill;
     409           0 :             aFillProps.maFillColor.setPaletteClr( rFillModel.mnPattColorIdx );
     410             :         }
     411             :         else
     412             :         {
     413           0 :             aFillProps.moFillType = XML_pattFill;
     414           0 :             aFillProps.maPatternProps.maPattFgColor.setPaletteClr( rFillModel.mnPattColorIdx );
     415           0 :             aFillProps.maPatternProps.maPattBgColor.setPaletteClr( rFillModel.mnBackColorIdx );
     416           0 :             aFillProps.maPatternProps.moPattPreset = nPatternPreset;
     417             :         }
     418             : #if 0
     419             :         static const sal_uInt8 sppnPatterns[][ 8 ] =
     420             :         {
     421             :             { 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55 },
     422             :             { 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD },
     423             :             { 0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22 },
     424             :             { 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00 },
     425             :             { 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC },
     426             :             { 0x33, 0x66, 0xCC, 0x99, 0x33, 0x66, 0xCC, 0x99 },
     427             :             { 0xCC, 0x66, 0x33, 0x99, 0xCC, 0x66, 0x33, 0x99 },
     428             :             { 0xCC, 0xCC, 0x33, 0x33, 0xCC, 0xCC, 0x33, 0x33 },
     429             :             { 0xCC, 0xFF, 0x33, 0xFF, 0xCC, 0xFF, 0x33, 0xFF },
     430             :             { 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00 },
     431             :             { 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88 },
     432             :             { 0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88 },
     433             :             { 0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11 },
     434             :             { 0xFF, 0x11, 0x11, 0x11, 0xFF, 0x11, 0x11, 0x11 },
     435             :             { 0xAA, 0x44, 0xAA, 0x11, 0xAA, 0x44, 0xAA, 0x11 },
     436             :             { 0x88, 0x00, 0x22, 0x00, 0x88, 0x00, 0x22, 0x00 },
     437             :             { 0x80, 0x00, 0x08, 0x00, 0x80, 0x00, 0x08, 0x00 }
     438             :         };
     439             :         const sal_uInt8* const pnPattern = sppnPatterns[ ::std::min< size_t >( rFillData.mnPattern - 2, STATIC_ARRAY_SIZE( sppnPatterns ) ) ];
     440             :         // create 2-colored 8x8 DIB
     441             :         SvMemoryStream aMemStrm;
     442             : //      { 0x0C, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00 }
     443             :         aMemStrm << sal_uInt32( 12 ) << sal_Int16( 8 ) << sal_Int16( 8 ) << sal_uInt16( 1 ) << sal_uInt16( 1 );
     444             :         aMemStrm << sal_uInt8( 0xFF ) << sal_uInt8( 0xFF ) << sal_uInt8( 0xFF );
     445             :         aMemStrm << sal_uInt8( 0x00 ) << sal_uInt8( 0x00 ) << sal_uInt8( 0x00 );
     446             :         for( size_t nIdx = 0; nIdx < 8; ++nIdx )
     447             :             aMemStrm << sal_uInt32( pnPattern[ nIdx ] ); // 32-bit little-endian
     448             :         aMemStrm.Seek( STREAM_SEEK_TO_BEGIN );
     449             :         Bitmap aBitmap;
     450             :         aBitmap.Read( aMemStrm, FALSE );
     451             :         XOBitmap aXOBitmap( aBitmap );
     452             :         aXOBitmap.Bitmap2Array();
     453             :         aXOBitmap.SetBitmapType( XBITMAP_8X8 );
     454             :         if( aXOBitmap.GetBackgroundColor().GetColor() == COL_BLACK )
     455             :             ::std::swap( aPattColor, aBackColor );
     456             :         aXOBitmap.SetPixelColor( aPattColor );
     457             :         aXOBitmap.SetBackgroundColor( aBackColor );
     458             :         rSdrObj.SetMergedItem( XFillStyleItem( XFILL_BITMAP ) );
     459             :         rSdrObj.SetMergedItem( XFillBitmapItem( EMPTY_STRING, aXOBitmap ) );
     460             : #endif
     461             :     }
     462             : 
     463           0 :     aFillProps.pushToPropMap( rPropMap, getBaseFilter().getGraphicHelper() );
     464             : }
     465             : 
     466             : // ============================================================================
     467             : // BIFF drawing page
     468             : // ============================================================================
     469             : 
     470           0 : BiffDrawingBase::BiffDrawingBase( const WorksheetHelper& rHelper, const Reference< XDrawPage >& rxDrawPage ) :
     471             :     WorksheetHelper( rHelper ),
     472           0 :     mxDrawPage( rxDrawPage )
     473             : {
     474           0 : }
     475             : 
     476           0 : void BiffDrawingBase::finalizeImport()
     477             : {
     478           0 :     Reference< XShapes > xShapes( mxDrawPage, UNO_QUERY );
     479             :     OSL_ENSURE( xShapes.is(), "BiffDrawingBase::finalizeImport - no shapes container" );
     480           0 :     if( !xShapes.is() )
     481           0 :         return;
     482             : 
     483             :     // process list of objects to be skipped
     484           0 :     for( BiffObjIdVector::const_iterator aIt = maSkipObjs.begin(), aEnd = maSkipObjs.end(); aIt != aEnd; ++aIt )
     485           0 :         if( BiffDrawingObjectBase* pDrawingObj = maObjMapId.get( *aIt ).get() )
     486           0 :             pDrawingObj->setProcessShape( false );
     487             : 
     488             :     // process drawing objects without DFF data
     489           0 :     maRawObjs.convertAndInsert( *this, xShapes );
     490             : }
     491             : 
     492             : // ============================================================================
     493             : 
     494           0 : BiffSheetDrawing::BiffSheetDrawing( const WorksheetHelper& rHelper ) :
     495           0 :     BiffDrawingBase( rHelper, rHelper.getDrawPage() )
     496             : {
     497           0 : }
     498             : 
     499           0 : void BiffSheetDrawing::notifyShapeInserted( const Reference< XShape >& /*rxShape*/, const Rectangle& rShapeRect )
     500             : {
     501             :     // collect all shape positions in the WorksheetHelper base class
     502           0 :     extendShapeBoundingBox( rShapeRect );
     503           0 : }
     504             : 
     505             : // ============================================================================
     506             : 
     507             : } // namespace xls
     508           9 : } // namespace oox
     509             : 
     510             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10