LCOV - code coverage report
Current view: top level - oox/source/drawingml/chart - objectformatter.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 239 242 98.8 %
Date: 2014-11-03 Functions: 46 47 97.9 %
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 "drawingml/chart/objectformatter.hxx"
      21             : 
      22             : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      23             : #include <com/sun/star/util/XNumberFormatTypes.hpp>
      24             : #include <osl/thread.h>
      25             : #include <rtl/strbuf.hxx>
      26             : #include "oox/core/xmlfilterbase.hxx"
      27             : #include "oox/drawingml/fillproperties.hxx"
      28             : #include "oox/drawingml/lineproperties.hxx"
      29             : #include "oox/drawingml/shapepropertymap.hxx"
      30             : #include "drawingml/textbody.hxx"
      31             : #include "drawingml/textparagraph.hxx"
      32             : #include "oox/drawingml/theme.hxx"
      33             : #include "drawingml/chart/chartspacemodel.hxx"
      34             : #include "oox/helper/modelobjecthelper.hxx"
      35             : 
      36             : namespace oox {
      37             : namespace drawingml {
      38             : namespace chart {
      39             : 
      40             : using namespace ::com::sun::star::chart2;
      41             : using namespace ::com::sun::star::frame;
      42             : using namespace ::com::sun::star::graphic;
      43             : using namespace ::com::sun::star::lang;
      44             : using namespace ::com::sun::star::uno;
      45             : using namespace ::com::sun::star::util;
      46             : 
      47             : using ::oox::core::XmlFilterBase;
      48             : 
      49             : namespace {
      50             : 
      51             : struct AutoFormatPatternEntry
      52             : {
      53             :     sal_Int32           mnColorToken;       /// Theme color token.
      54             :     sal_Int32           mnModToken;         /// Color modification token.
      55             :     sal_Int32           mnModValue;         /// Color modification value.
      56             : };
      57             : 
      58             : #define AUTOFORMAT_PATTERN_COLOR( color_token ) \
      59             :     { color_token, XML_TOKEN_INVALID, 0 }
      60             : 
      61             : #define AUTOFORMAT_PATTERN_COLORMOD( color_token, mod_token, mod_value ) \
      62             :     { color_token, mod_token, mod_value }
      63             : 
      64             : #define AUTOFORMAT_PATTERN_END() \
      65             :     AUTOFORMAT_PATTERN_COLOR( XML_TOKEN_INVALID )
      66             : 
      67             : static const AutoFormatPatternEntry spAutoFormatPattern1[] =
      68             : {
      69             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 88500 ),
      70             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 55000 ),
      71             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 78000 ),
      72             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 92500 ),
      73             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 70000 ),
      74             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 30000 ),
      75             :     AUTOFORMAT_PATTERN_END()
      76             : };
      77             : 
      78             : static const AutoFormatPatternEntry spAutoFormatPattern2[] =
      79             : {
      80             :     AUTOFORMAT_PATTERN_COLOR( XML_accent1 ),
      81             :     AUTOFORMAT_PATTERN_COLOR( XML_accent2 ),
      82             :     AUTOFORMAT_PATTERN_COLOR( XML_accent3 ),
      83             :     AUTOFORMAT_PATTERN_COLOR( XML_accent4 ),
      84             :     AUTOFORMAT_PATTERN_COLOR( XML_accent5 ),
      85             :     AUTOFORMAT_PATTERN_COLOR( XML_accent6 ),
      86             :     AUTOFORMAT_PATTERN_END()
      87             : };
      88             : 
      89             : static const AutoFormatPatternEntry spAutoFormatPattern3[] =
      90             : {
      91             :     AUTOFORMAT_PATTERN_COLORMOD( XML_accent1, XML_shade, 50000 ),
      92             :     AUTOFORMAT_PATTERN_COLORMOD( XML_accent2, XML_shade, 50000 ),
      93             :     AUTOFORMAT_PATTERN_COLORMOD( XML_accent3, XML_shade, 50000 ),
      94             :     AUTOFORMAT_PATTERN_COLORMOD( XML_accent4, XML_shade, 50000 ),
      95             :     AUTOFORMAT_PATTERN_COLORMOD( XML_accent5, XML_shade, 50000 ),
      96             :     AUTOFORMAT_PATTERN_COLORMOD( XML_accent6, XML_shade, 50000 ),
      97             :     AUTOFORMAT_PATTERN_END()
      98             : };
      99             : 
     100             : static const AutoFormatPatternEntry spAutoFormatPattern4[] =
     101             : {
     102             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint,  5000 ),
     103             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 55000 ),
     104             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 78000 ),
     105             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 15000 ),
     106             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 70000 ),
     107             :     AUTOFORMAT_PATTERN_COLORMOD( XML_dk1, XML_tint, 30000 ),
     108             :     AUTOFORMAT_PATTERN_END()
     109             : };
     110             : 
     111             : #undef AUTOFORMAT_PATTERN_COLOR
     112             : #undef AUTOFORMAT_PATTERN_COLORMOD
     113             : #undef AUTOFORMAT_PATTERN_END
     114             : 
     115             : struct AutoFormatEntry
     116             : {
     117             :     sal_Int32           mnFirstStyleIdx;    /// First chart style index.
     118             :     sal_Int32           mnLastStyleIdx;     /// Last chart style index.
     119             :     sal_Int32           mnThemedIdx;        /// Themed style index.
     120             :     sal_Int32           mnColorToken;       /// Theme color token.
     121             :     sal_Int32           mnModToken;         /// Color modification token.
     122             :     sal_Int32           mnModValue;         /// Color modification value.
     123             :     sal_Int32           mnRelLineWidth;     /// Relative line width (percent).
     124             :     const AutoFormatPatternEntry* mpPattern;/// Color cycling pattern for data series.
     125             :     bool                mbFadedColor;       /// True = Faded color for data series.
     126             : };
     127             : 
     128             : #define AUTOFORMAT_COLOR( first, last, themed_style, color_token ) \
     129             :     { first, last, themed_style, color_token, XML_TOKEN_INVALID, 0, 100, 0, false }
     130             : 
     131             : #define AUTOFORMAT_COLORMOD( first, last, themed_style, color_token, mod_token, mod_value ) \
     132             :     { first, last, themed_style, color_token, mod_token, mod_value, 100, 0, false }
     133             : 
     134             : #define AUTOFORMAT_ACCENTSMOD( first, themed_style, mod_token, mod_value ) \
     135             :     AUTOFORMAT_COLORMOD( first,     first,     themed_style, XML_accent1, mod_token, mod_value ), \
     136             :     AUTOFORMAT_COLORMOD( first + 1, first + 1, themed_style, XML_accent2, mod_token, mod_value ), \
     137             :     AUTOFORMAT_COLORMOD( first + 2, first + 2, themed_style, XML_accent3, mod_token, mod_value ), \
     138             :     AUTOFORMAT_COLORMOD( first + 3, first + 3, themed_style, XML_accent4, mod_token, mod_value ), \
     139             :     AUTOFORMAT_COLORMOD( first + 4, first + 4, themed_style, XML_accent5, mod_token, mod_value ), \
     140             :     AUTOFORMAT_COLORMOD( first + 5, first + 5, themed_style, XML_accent6, mod_token, mod_value )
     141             : 
     142             : #define AUTOFORMAT_PATTERN( first, last, themed_style, line_width, pattern ) \
     143             :     { first, last, themed_style, XML_TOKEN_INVALID, XML_TOKEN_INVALID, 0, line_width, pattern, false }
     144             : 
     145             : #define AUTOFORMAT_FADED( first, last, themed_style, color_token, line_width ) \
     146             :     { first, last, themed_style, color_token, XML_TOKEN_INVALID, 0, line_width, 0, true }
     147             : 
     148             : #define AUTOFORMAT_FADEDACCENTS( first, themed_style, line_width ) \
     149             :     AUTOFORMAT_FADED( first,     first,     themed_style, XML_accent1, line_width ), \
     150             :     AUTOFORMAT_FADED( first + 1, first + 1, themed_style, XML_accent2, line_width ), \
     151             :     AUTOFORMAT_FADED( first + 2, first + 2, themed_style, XML_accent3, line_width ), \
     152             :     AUTOFORMAT_FADED( first + 3, first + 3, themed_style, XML_accent4, line_width ), \
     153             :     AUTOFORMAT_FADED( first + 4, first + 4, themed_style, XML_accent5, line_width ), \
     154             :     AUTOFORMAT_FADED( first + 5, first + 5, themed_style, XML_accent6, line_width )
     155             : 
     156             : #define AUTOFORMAT_INVISIBLE( first, last ) \
     157             :     AUTOFORMAT_COLOR( first, last, -1, XML_TOKEN_INVALID )
     158             : 
     159             : #define AUTOFORMAT_END() \
     160             :     AUTOFORMAT_INVISIBLE( -1, -1 )
     161             : 
     162             : static const AutoFormatEntry spNoFormats[] =
     163             : {
     164             :     AUTOFORMAT_INVISIBLE( 1, 48 ),
     165             :     AUTOFORMAT_END()
     166             : };
     167             : 
     168             : static const AutoFormatEntry spDataTableLines[] =
     169             : {
     170             :     AUTOFORMAT_COLORMOD(  1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ),
     171             :     AUTOFORMAT_COLORMOD( 33, 40, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 75000 ),
     172             :     // 41...48: no line, same as Chart2
     173             :     AUTOFORMAT_END()
     174             : };
     175             : 
     176             : static const AutoFormatEntry spPlotArea2dFills[] =
     177             : {
     178             :     AUTOFORMAT_COLOR(       1, 32, THEMED_STYLE_SUBTLE, XML_bg1 ),
     179             :     AUTOFORMAT_COLORMOD(   33, 34, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 20000 ),
     180             :     AUTOFORMAT_ACCENTSMOD( 35,     THEMED_STYLE_SUBTLE,          XML_tint, 20000 ), // tint not documented!?
     181             :     AUTOFORMAT_COLORMOD(   41, 48, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 95000 ),
     182             :     AUTOFORMAT_END()
     183             : };
     184             : 
     185             : static const AutoFormatEntry spWallFloorLines[] =
     186             : {
     187             :     AUTOFORMAT_COLORMOD(  1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ),
     188             :     AUTOFORMAT_COLORMOD( 33, 40, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 75000 ),
     189             :     // 41...48: no line, same as Chart2
     190             :     AUTOFORMAT_END()
     191             : };
     192             : 
     193             : static const AutoFormatEntry spWallFloorFills[] =
     194             : {
     195             :     AUTOFORMAT_INVISIBLE(   1, 32 ),
     196             :     AUTOFORMAT_COLORMOD(   33, 34, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 20000 ),
     197             :     AUTOFORMAT_ACCENTSMOD( 35,     THEMED_STYLE_SUBTLE,          XML_tint, 20000 ), // tint not documented!?
     198             :     AUTOFORMAT_COLORMOD(   41, 48, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 95000 ),
     199             :     AUTOFORMAT_END()
     200             : };
     201             : 
     202             : static const AutoFormatEntry spAxisLines[] =
     203             : {
     204             :     AUTOFORMAT_COLORMOD(  1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ),   // tint not documented!?
     205             :     AUTOFORMAT_COLORMOD( 33, 48, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 75000 ),   // tint not documented!?
     206             :     AUTOFORMAT_END()
     207             : };
     208             : 
     209             : static const AutoFormatEntry spMajorGridLines[] =
     210             : {
     211             :     AUTOFORMAT_COLORMOD(  1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ),   // tint not documented!?
     212             :     AUTOFORMAT_COLORMOD( 33, 48, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 75000 ),   // tint not documented!?
     213             :     AUTOFORMAT_END()
     214             : };
     215             : 
     216             : static const AutoFormatEntry spMinorGridLines[] =
     217             : {
     218             :     AUTOFORMAT_COLORMOD(  1, 40, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 50000 ),
     219             :     AUTOFORMAT_COLORMOD( 41, 48, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 90000 ),
     220             :     AUTOFORMAT_END()
     221             : };
     222             : 
     223             : static const AutoFormatEntry spOtherLines[] =
     224             : {
     225             :     AUTOFORMAT_COLOR(     1, 32, THEMED_STYLE_SUBTLE, XML_tx1 ),
     226             :     AUTOFORMAT_COLOR(    33, 34, THEMED_STYLE_SUBTLE, XML_dk1 ),
     227             :     AUTOFORMAT_COLORMOD( 35, 40, THEMED_STYLE_SUBTLE, XML_dk1, XML_shade, 25000 ),
     228             :     AUTOFORMAT_COLOR(    41, 48, THEMED_STYLE_SUBTLE, XML_lt1 ),
     229             :     AUTOFORMAT_END()
     230             : };
     231             : 
     232             : static const AutoFormatEntry spLinearSeriesLines[] =
     233             : {
     234             :     AUTOFORMAT_PATTERN(       1,  1, THEMED_STYLE_SUBTLE, 300, spAutoFormatPattern1 ),
     235             :     AUTOFORMAT_PATTERN(       2,  2, THEMED_STYLE_SUBTLE, 300, spAutoFormatPattern2 ),
     236             :     AUTOFORMAT_FADEDACCENTS(  3,     THEMED_STYLE_SUBTLE, 300 ),
     237             :     AUTOFORMAT_PATTERN(       9,  9, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern1 ),
     238             :     AUTOFORMAT_PATTERN(      10, 10, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern2 ),
     239             :     AUTOFORMAT_FADEDACCENTS( 11,     THEMED_STYLE_SUBTLE, 500 ),
     240             :     AUTOFORMAT_PATTERN(      17, 17, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern1 ),
     241             :     AUTOFORMAT_PATTERN(      18, 18, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern2 ),
     242             :     AUTOFORMAT_FADEDACCENTS( 19,     THEMED_STYLE_SUBTLE, 500 ),
     243             :     AUTOFORMAT_PATTERN(      25, 25, THEMED_STYLE_SUBTLE, 700, spAutoFormatPattern1 ),
     244             :     AUTOFORMAT_PATTERN(      26, 26, THEMED_STYLE_SUBTLE, 700, spAutoFormatPattern2 ),
     245             :     AUTOFORMAT_FADEDACCENTS( 27,     THEMED_STYLE_SUBTLE, 700 ),
     246             :     AUTOFORMAT_PATTERN(      33, 33, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern1 ),
     247             :     AUTOFORMAT_PATTERN(      34, 34, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern2 ),
     248             :     AUTOFORMAT_FADEDACCENTS( 35,     THEMED_STYLE_SUBTLE, 500 ),
     249             :     AUTOFORMAT_PATTERN(      41, 42, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern4 ),
     250             :     AUTOFORMAT_PATTERN(      42, 42, THEMED_STYLE_SUBTLE, 500, spAutoFormatPattern2 ),
     251             :     AUTOFORMAT_FADEDACCENTS( 43,     THEMED_STYLE_SUBTLE, 500 ),
     252             :     AUTOFORMAT_END()
     253             : };
     254             : 
     255             : static const AutoFormatEntry spFilledSeriesLines[] =
     256             : {
     257             :     AUTOFORMAT_INVISIBLE(   1,  8 ),
     258             :     AUTOFORMAT_COLOR(       9, 16, THEMED_STYLE_SUBTLE, XML_lt1 ),
     259             :     AUTOFORMAT_INVISIBLE(  17, 32 ),
     260             :     AUTOFORMAT_COLORMOD(   33, 33, THEMED_STYLE_SUBTLE, XML_dk1, XML_shade, 50000 ),
     261             :     AUTOFORMAT_PATTERN(    34, 34, THEMED_STYLE_SUBTLE, 100, spAutoFormatPattern3 ),
     262             :     AUTOFORMAT_ACCENTSMOD( 35,     THEMED_STYLE_SUBTLE,          XML_shade, 50000 ),
     263             :     AUTOFORMAT_INVISIBLE(  41, 48 ),
     264             :     AUTOFORMAT_END()
     265             : };
     266             : 
     267             : static const AutoFormatEntry spFilledSeries2dFills[] =
     268             : {
     269             :     AUTOFORMAT_PATTERN(       1,  1, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern1 ),
     270             :     AUTOFORMAT_PATTERN(       2,  2, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern2 ),
     271             :     AUTOFORMAT_FADEDACCENTS(  3,     THEMED_STYLE_SUBTLE,  100 ),
     272             :     AUTOFORMAT_PATTERN(       9,  9, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern1 ),
     273             :     AUTOFORMAT_PATTERN(      10, 10, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern2 ),
     274             :     AUTOFORMAT_FADEDACCENTS( 11,     THEMED_STYLE_SUBTLE,  100 ),
     275             :     AUTOFORMAT_PATTERN(      17, 17, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern1 ),
     276             :     AUTOFORMAT_PATTERN(      18, 18, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
     277             :     AUTOFORMAT_FADEDACCENTS( 19,     THEMED_STYLE_INTENSE, 100 ),
     278             :     AUTOFORMAT_PATTERN(      25, 25, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern1 ),
     279             :     AUTOFORMAT_PATTERN(      26, 26, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
     280             :     AUTOFORMAT_FADEDACCENTS( 27,     THEMED_STYLE_INTENSE, 100 ),
     281             :     AUTOFORMAT_PATTERN(      33, 33, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern1 ),
     282             :     AUTOFORMAT_PATTERN(      34, 34, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern2 ),
     283             :     AUTOFORMAT_FADEDACCENTS( 35,     THEMED_STYLE_SUBTLE,  100 ),
     284             :     AUTOFORMAT_PATTERN(      41, 42, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern4 ),
     285             :     AUTOFORMAT_PATTERN(      42, 42, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
     286             :     AUTOFORMAT_FADEDACCENTS( 43,     THEMED_STYLE_INTENSE, 100 ),
     287             :     AUTOFORMAT_END()
     288             : };
     289             : 
     290             : static const AutoFormatEntry spFilledSeries3dFills[] =
     291             : {
     292             :     AUTOFORMAT_PATTERN(       1,  1, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern1 ),
     293             :     AUTOFORMAT_PATTERN(       2,  2, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern2 ),
     294             :     AUTOFORMAT_FADEDACCENTS(  3,     THEMED_STYLE_SUBTLE,  100 ),
     295             :     AUTOFORMAT_PATTERN(       9,  9, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern1 ),
     296             :     AUTOFORMAT_PATTERN(      10, 10, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern2 ),
     297             :     AUTOFORMAT_FADEDACCENTS( 11,     THEMED_STYLE_SUBTLE,  100 ),
     298             :     AUTOFORMAT_PATTERN(      17, 17, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern1 ),
     299             :     AUTOFORMAT_PATTERN(      18, 18, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
     300             :     AUTOFORMAT_FADEDACCENTS( 19,     THEMED_STYLE_SUBTLE,  100 ),
     301             :     AUTOFORMAT_PATTERN(      25, 25, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern1 ),
     302             :     AUTOFORMAT_PATTERN(      26, 26, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
     303             :     AUTOFORMAT_FADEDACCENTS( 27,     THEMED_STYLE_SUBTLE,  100 ),
     304             :     AUTOFORMAT_PATTERN(      33, 33, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern1 ),
     305             :     AUTOFORMAT_PATTERN(      34, 34, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern2 ),
     306             :     AUTOFORMAT_FADEDACCENTS( 35,     THEMED_STYLE_SUBTLE,  100 ),
     307             :     AUTOFORMAT_PATTERN(      41, 42, THEMED_STYLE_SUBTLE,  100, spAutoFormatPattern4 ),
     308             :     AUTOFORMAT_PATTERN(      42, 42, THEMED_STYLE_INTENSE, 100, spAutoFormatPattern2 ),
     309             :     AUTOFORMAT_FADEDACCENTS( 43,     THEMED_STYLE_SUBTLE,  100 ),
     310             :     AUTOFORMAT_END()
     311             : };
     312             : 
     313             : static const AutoFormatEntry spFilledSeriesEffects[] =
     314             : {
     315             :     // 1...8: no effect, same as Chart2
     316             :     AUTOFORMAT_COLOR(  9, 16, THEMED_STYLE_SUBTLE,   XML_dk1 ),
     317             :     AUTOFORMAT_COLOR( 17, 24, THEMED_STYLE_MODERATE, XML_dk1 ),
     318             :     AUTOFORMAT_COLOR( 25, 32, THEMED_STYLE_INTENSE,  XML_dk1 ),
     319             :     // 33...40: no effect, same as Chart2
     320             :     AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_INTENSE,  XML_dk1 ),
     321             :     AUTOFORMAT_END()
     322             : };
     323             : 
     324             : static const AutoFormatEntry spUpDownBarLines[] =
     325             : {
     326             :     AUTOFORMAT_COLOR(       1, 16, THEMED_STYLE_SUBTLE, XML_tx1 ),
     327             :     AUTOFORMAT_INVISIBLE(  17, 32 ),
     328             :     AUTOFORMAT_COLOR(      33, 34, THEMED_STYLE_SUBTLE, XML_dk1 ),
     329             :     AUTOFORMAT_ACCENTSMOD( 35,     THEMED_STYLE_SUBTLE, XML_shade, 25000 ),
     330             :     AUTOFORMAT_INVISIBLE(  41, 48 ),
     331             :     AUTOFORMAT_END()
     332             : };
     333             : 
     334             : static const AutoFormatEntry spUpBarFills[] =
     335             : {
     336             :     AUTOFORMAT_COLORMOD(    1,  1, THEMED_STYLE_SUBTLE,  XML_dk1, XML_tint, 25000 ),
     337             :     AUTOFORMAT_COLORMOD(    2,  2, THEMED_STYLE_SUBTLE,  XML_dk1, XML_tint,  5000 ),
     338             :     AUTOFORMAT_ACCENTSMOD(  3,     THEMED_STYLE_SUBTLE,           XML_tint, 25000 ),
     339             :     AUTOFORMAT_COLORMOD(    9,  9, THEMED_STYLE_SUBTLE,  XML_dk1, XML_tint, 25000 ),
     340             :     AUTOFORMAT_COLORMOD(   10, 10, THEMED_STYLE_SUBTLE,  XML_dk1, XML_tint,  5000 ),
     341             :     AUTOFORMAT_ACCENTSMOD( 11,     THEMED_STYLE_SUBTLE,           XML_tint, 25000 ),
     342             :     AUTOFORMAT_COLORMOD(   17, 17, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 25000 ),
     343             :     AUTOFORMAT_COLORMOD(   18, 18, THEMED_STYLE_INTENSE, XML_dk1, XML_tint,  5000 ),
     344             :     AUTOFORMAT_ACCENTSMOD( 19,     THEMED_STYLE_INTENSE,          XML_tint, 25000 ),
     345             :     AUTOFORMAT_COLORMOD(   25, 25, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 25000 ),
     346             :     AUTOFORMAT_COLORMOD(   26, 26, THEMED_STYLE_INTENSE, XML_dk1, XML_tint,  5000 ),
     347             :     AUTOFORMAT_ACCENTSMOD( 27,     THEMED_STYLE_INTENSE,          XML_tint, 25000 ),
     348             :     AUTOFORMAT_COLOR(      33, 40, THEMED_STYLE_SUBTLE,  XML_lt1 ),
     349             :     AUTOFORMAT_COLORMOD(   41, 41, THEMED_STYLE_INTENSE, XML_dk1, XML_tint, 25000 ),
     350             :     AUTOFORMAT_COLOR(      42, 42, THEMED_STYLE_INTENSE, XML_lt1 ),
     351             :     AUTOFORMAT_ACCENTSMOD( 43,     THEMED_STYLE_INTENSE,          XML_tint, 25000 ),
     352             :     AUTOFORMAT_END()
     353             : };
     354             : 
     355             : static const AutoFormatEntry spDownBarFills[] =
     356             : {
     357             :     AUTOFORMAT_COLORMOD(    1,  1, THEMED_STYLE_SUBTLE,  XML_dk1, XML_tint,  85000 ),
     358             :     AUTOFORMAT_COLORMOD(    2,  2, THEMED_STYLE_SUBTLE,  XML_dk1, XML_tint,  95000 ),
     359             :     AUTOFORMAT_ACCENTSMOD(  3,     THEMED_STYLE_SUBTLE,           XML_shade, 25000 ),
     360             :     AUTOFORMAT_COLORMOD(    9,  9, THEMED_STYLE_SUBTLE,  XML_dk1, XML_tint,  85000 ),
     361             :     AUTOFORMAT_COLORMOD(   10, 10, THEMED_STYLE_SUBTLE,  XML_dk1, XML_tint,  95000 ),
     362             :     AUTOFORMAT_ACCENTSMOD( 11,     THEMED_STYLE_SUBTLE,           XML_shade, 25000 ),
     363             :     AUTOFORMAT_COLORMOD(   17, 17, THEMED_STYLE_INTENSE, XML_dk1, XML_tint,  85000 ),
     364             :     AUTOFORMAT_COLORMOD(   18, 18, THEMED_STYLE_INTENSE, XML_dk1, XML_tint,  95000 ),
     365             :     AUTOFORMAT_ACCENTSMOD( 19,     THEMED_STYLE_INTENSE,          XML_shade, 25000 ),
     366             :     AUTOFORMAT_COLORMOD(   25, 25, THEMED_STYLE_INTENSE, XML_dk1, XML_tint,  85000 ),
     367             :     AUTOFORMAT_COLORMOD(   26, 26, THEMED_STYLE_INTENSE, XML_dk1, XML_tint,  95000 ),
     368             :     AUTOFORMAT_ACCENTSMOD( 27,     THEMED_STYLE_INTENSE,          XML_shade, 25000 ),
     369             :     AUTOFORMAT_COLORMOD(   33, 33, THEMED_STYLE_SUBTLE,  XML_dk1, XML_tint,  85000 ),
     370             :     AUTOFORMAT_COLORMOD(   34, 34, THEMED_STYLE_SUBTLE,  XML_dk1, XML_tint,  95000 ),
     371             :     AUTOFORMAT_ACCENTSMOD( 27,     THEMED_STYLE_SUBTLE,           XML_shade, 25000 ),
     372             :     AUTOFORMAT_COLORMOD(   41, 41, THEMED_STYLE_INTENSE, XML_dk1, XML_tint,  85000 ),
     373             :     AUTOFORMAT_COLOR(      42, 42, THEMED_STYLE_INTENSE, XML_dk1 ),
     374             :     AUTOFORMAT_ACCENTSMOD( 43,     THEMED_STYLE_INTENSE,          XML_shade, 25000 ),
     375             :     AUTOFORMAT_END()
     376             : };
     377             : 
     378             : static const AutoFormatEntry spUpDownBarEffects[] =
     379             : {
     380             :     // 1...8: no effect, same as Chart2
     381             :     AUTOFORMAT_COLOR(  9, 16, THEMED_STYLE_SUBTLE,   XML_dk1 ),
     382             :     AUTOFORMAT_COLOR( 17, 24, THEMED_STYLE_MODERATE, XML_dk1 ),
     383             :     AUTOFORMAT_COLOR( 25, 32, THEMED_STYLE_INTENSE,  XML_dk1 ),
     384             :     // 33...40: no effect, same as Chart2
     385             :     AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_INTENSE,  XML_dk1 ),
     386             :     AUTOFORMAT_END()
     387             : };
     388             : 
     389             : #undef AUTOFORMAT_COLOR
     390             : #undef AUTOFORMAT_COLORMOD
     391             : #undef AUTOFORMAT_ACCENTSMOD
     392             : #undef AUTOFORMAT_PATTERN
     393             : #undef AUTOFORMAT_FADED
     394             : #undef AUTOFORMAT_FADEDACCENTS
     395             : #undef AUTOFORMAT_INVISIBLE
     396             : #undef AUTOFORMAT_END
     397             : 
     398       17472 : const AutoFormatEntry* lclGetAutoFormatEntry( const AutoFormatEntry* pEntries, sal_Int32 nStyle )
     399             : {
     400       23350 :     for( ; pEntries && (pEntries->mnFirstStyleIdx >= 0); ++pEntries )
     401       12186 :         if( (pEntries->mnFirstStyleIdx <= nStyle) && (nStyle <= pEntries->mnLastStyleIdx) )
     402        6308 :             return pEntries;
     403       11164 :     return 0;
     404             : }
     405             : 
     406             : struct AutoTextEntry
     407             : {
     408             :     sal_Int32           mnFirstStyleIdx;    /// First chart style index.
     409             :     sal_Int32           mnLastStyleIdx;     /// Last chart style index.
     410             :     sal_Int32           mnThemedFont;       /// Themed font (minor/major).
     411             :     sal_Int32           mnColorToken;       /// Theme color token.
     412             :     sal_Int32           mnDefFontSize;      /// Default font size (1/100 points).
     413             :     sal_Int32           mnRelFontSize;      /// Font size relative to chart global font (percent).
     414             :     bool                mbBold;             /// True = bold font.
     415             : };
     416             : 
     417             : #define AUTOTEXT_COLOR( first, last, themed_font, color_token, def_font_size, rel_font_size, bold ) \
     418             :     { first, last, themed_font, color_token, def_font_size, rel_font_size, bold }
     419             : 
     420             : #define AUTOTEXT_END() \
     421             :     AUTOTEXT_COLOR( -1, -1, XML_none, XML_TOKEN_INVALID, 1000, 100, false )
     422             : 
     423             : static const AutoTextEntry spChartTitleTexts[] =
     424             : {
     425             :     AUTOTEXT_COLOR(  1, 40, XML_minor, XML_tx1, 1800, 120, true ),
     426             :     AUTOTEXT_COLOR( 41, 48, XML_minor, XML_lt1, 1800, 120, true ),
     427             :     AUTOTEXT_END()
     428             : };
     429             : 
     430             : static const AutoTextEntry spAxisTitleTexts[] =
     431             : {
     432             :     AUTOTEXT_COLOR(  1, 40, XML_minor, XML_tx1, 1000, 100, true ),
     433             :     AUTOTEXT_COLOR( 41, 48, XML_minor, XML_lt1, 1000, 100, true ),
     434             :     AUTOTEXT_END()
     435             : };
     436             : 
     437             : static const AutoTextEntry spOtherTexts[] =
     438             : {
     439             :     AUTOTEXT_COLOR(  1, 40, XML_minor, XML_tx1, 1000, 100, false ),
     440             :     AUTOTEXT_COLOR( 41, 48, XML_minor, XML_lt1, 1000, 100, false ),
     441             :     AUTOTEXT_END()
     442             : };
     443             : 
     444             : #undef AUTOTEXT_COLOR
     445             : #undef AUTOTEXT_END
     446             : 
     447        5824 : const AutoTextEntry* lclGetAutoTextEntry( const AutoTextEntry* pEntries, sal_Int32 nStyle )
     448             : {
     449        5824 :     for( ; pEntries && (pEntries->mnFirstStyleIdx >= 0); ++pEntries )
     450        1792 :         if( (pEntries->mnFirstStyleIdx <= nStyle) && (nStyle <= pEntries->mnLastStyleIdx) )
     451        1792 :             return pEntries;
     452        4032 :     return 0;
     453             : }
     454             : 
     455             : // These PropIds arrays will be indexed into using a ShapePropertyId enum (include/oox/drawingml/shapepropertymap.hxx)
     456             : 
     457             : /** Property identifiers for common chart objects, to be used in ShapePropertyInfo. */
     458             : static const sal_Int32 spnCommonPropIds[] =
     459             : {
     460             :     PROP_LineStyle, PROP_LineWidth, PROP_LineColor, PROP_LineTransparence, PROP_LineDashName,
     461             :     PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
     462             :     PROP_FillStyle, PROP_FillColor, PROP_FillTransparence, PROP_INVALID, PROP_FillGradientName,
     463             :     PROP_FillBitmapName, PROP_FillBitmapMode, PROP_FillBitmapSizeX, PROP_FillBitmapSizeY,
     464             :     PROP_FillBitmapPositionOffsetX, PROP_FillBitmapPositionOffsetY, PROP_FillBitmapRectanglePoint,
     465             :     PROP_END_LIST
     466             : };
     467             : 
     468             : /** Property identifiers for linear data series, to be used in ShapePropertyInfo. */
     469             : static const sal_Int32 spnLinearPropIds[] =
     470             : {
     471             :     PROP_LineStyle, PROP_LineWidth, PROP_Color, PROP_Transparency, PROP_LineDashName,
     472             :     PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
     473             :     PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
     474             :     PROP_INVALID, PROP_INVALID, PROP_INVALID, PROP_INVALID,
     475             :     PROP_INVALID, PROP_INVALID, PROP_INVALID,
     476             :     PROP_END_LIST
     477             : };
     478             : 
     479             : /** Property identifiers for filled data series, to be used in ShapePropertyInfo. */
     480             : static const sal_Int32 spnFilledPropIds[] =
     481             : {
     482             :     PROP_BorderStyle,
     483             :     PROP_BorderWidth,
     484             :     PROP_BorderColor,
     485             :     PROP_BorderTransparency,
     486             :     PROP_BorderDashName,
     487             :     PROP_INVALID,
     488             :     PROP_INVALID,
     489             :     PROP_INVALID,
     490             :     PROP_INVALID,
     491             :     PROP_INVALID,
     492             :     PROP_INVALID,
     493             :     PROP_INVALID,
     494             :     PROP_FillStyle,
     495             :     PROP_Color,
     496             :     PROP_Transparency,
     497             :     PROP_FillTransparenceGradientName,
     498             :     PROP_GradientName,
     499             :     PROP_FillBitmapName,
     500             :     PROP_FillBitmapMode,
     501             :     PROP_FillBitmapSizeX,
     502             :     PROP_FillBitmapSizeY,
     503             :     PROP_FillBitmapPositionOffsetX,
     504             :     PROP_FillBitmapPositionOffsetY,
     505             :     PROP_FillBitmapRectanglePoint,
     506             :     PROP_END_LIST
     507             : };
     508             : 
     509             : /** Property info for common chart objects, to be used in ShapePropertyMap. */
     510         136 : static const ShapePropertyInfo saCommonPropInfo( spnCommonPropIds, false, true, true, true );
     511             : /** Property info for linear data series, to be used in ShapePropertyMap. */
     512         136 : static const ShapePropertyInfo saLinearPropInfo( spnLinearPropIds, false, true, true, true );
     513             : /** Property info for filled data series, to be used in ShapePropertyMap. */
     514         136 : static const ShapePropertyInfo saFilledPropInfo( spnFilledPropIds, false, true, true, true );
     515             : 
     516             : /** Contains information about formatting of a specific chart object type. */
     517             : struct ObjectTypeFormatEntry
     518             : {
     519             :     ObjectType          meObjType;          /// Object type for automatic format.
     520             :     const ShapePropertyInfo* mpPropInfo;    /// Property info for the ShapePropertyMap class.
     521             :     const AutoFormatEntry* mpAutoLines;     /// Automatic line formatting for all chart styles.
     522             :     const AutoFormatEntry* mpAutoFills;     /// Automatic fill formatting for all chart styles.
     523             :     const AutoFormatEntry* mpAutoEffects;   /// Automatic effect formatting for all chart styles.
     524             :     const AutoTextEntry* mpAutoTexts;       /// Automatic text attributes for all chart styles.
     525             :     bool                mbIsFrame;          /// True = object is a frame, false = object is a line.
     526             : };
     527             : 
     528             : #define TYPEFORMAT_FRAME( obj_type, prop_type, auto_texts, auto_lines, auto_fills, auto_effects ) \
     529             :     { obj_type, prop_type, auto_lines, auto_fills, auto_effects, auto_texts, true }
     530             : 
     531             : #define TYPEFORMAT_LINE( obj_type, prop_type, auto_texts, auto_lines ) \
     532             :     { obj_type, prop_type, auto_lines, 0, 0, auto_texts, false }
     533             : 
     534             : static const ObjectTypeFormatEntry spObjTypeFormatEntries[] =
     535             : {
     536             :     //                object type                property info      auto text          auto line            auto fill              auto effect
     537             :     TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE,     &saCommonPropInfo, 0,                 spNoFormats,         spNoFormats,           0 /* eq to Ch2 */ ),
     538             :     TYPEFORMAT_FRAME( OBJECTTYPE_CHARTTITLE,     &saCommonPropInfo, spChartTitleTexts, 0 /* eq to Ch2 */,   0 /* eq to Ch2 */,     0 /* eq to Ch2 */ ),
     539             :     TYPEFORMAT_FRAME( OBJECTTYPE_LEGEND,         &saCommonPropInfo, spOtherTexts,      spNoFormats,         spNoFormats,           0 /* eq to Ch2 */ ),
     540             :     TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA2D,     &saCommonPropInfo, 0,                 0 /* eq to Ch2 */,   spPlotArea2dFills,     0 /* eq to Ch2 */ ),
     541             :     TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA3D,     &saCommonPropInfo, 0,                 0 /* eq to Ch2 */,   0 /* eq to Ch2 */,     0 /* eq to Ch2 */ ),
     542             :     TYPEFORMAT_FRAME( OBJECTTYPE_WALL,           &saCommonPropInfo, 0,                 spWallFloorLines,    spWallFloorFills,      0 /* eq to Ch2 */ ),
     543             :     TYPEFORMAT_FRAME( OBJECTTYPE_FLOOR,          &saCommonPropInfo, 0,                 spWallFloorLines,    spWallFloorFills,      0 /* eq to Ch2 */ ),
     544             :     TYPEFORMAT_LINE(  OBJECTTYPE_AXIS,           &saCommonPropInfo, spOtherTexts,      spAxisLines ),
     545             :     TYPEFORMAT_FRAME( OBJECTTYPE_AXISTITLE,      &saCommonPropInfo, spAxisTitleTexts,  0 /* eq to Ch2 */,   0 /* eq to Ch2 */,     0 /* eq to Ch2 */ ),
     546             :     TYPEFORMAT_FRAME( OBJECTTYPE_AXISUNIT,       &saCommonPropInfo, spAxisTitleTexts,  0 /* eq in Ch2 */,   0 /* eq in Ch2 */,     0 /* eq in Ch2 */ ),
     547             :     TYPEFORMAT_LINE(  OBJECTTYPE_MAJORGRIDLINE,  &saCommonPropInfo, 0,                 spMajorGridLines ),
     548             :     TYPEFORMAT_LINE(  OBJECTTYPE_MINORGRIDLINE,  &saCommonPropInfo, 0,                 spMinorGridLines ),
     549             :     TYPEFORMAT_LINE(  OBJECTTYPE_LINEARSERIES2D, &saLinearPropInfo, 0,                 spLinearSeriesLines ),
     550             :     TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES2D, &saFilledPropInfo, 0,                 spFilledSeriesLines, spFilledSeries2dFills, spFilledSeriesEffects ),
     551             :     TYPEFORMAT_FRAME( OBJECTTYPE_FILLEDSERIES3D, &saFilledPropInfo, 0,                 spFilledSeriesLines, spFilledSeries3dFills, spFilledSeriesEffects ),
     552             :     TYPEFORMAT_FRAME( OBJECTTYPE_DATALABEL,      &saCommonPropInfo, spOtherTexts,      0 /* eq to Ch2 */,   0 /* eq to Ch2 */,     0 /* eq to Ch2 */ ),
     553             :     TYPEFORMAT_LINE(  OBJECTTYPE_TRENDLINE,      &saCommonPropInfo, 0,                 spOtherLines ),
     554             :     TYPEFORMAT_FRAME( OBJECTTYPE_TRENDLINELABEL, &saCommonPropInfo, spOtherTexts,      0 /* eq to Ch2 */,   0 /* eq to Ch2 */,     0 /* eq to Ch2 */ ),
     555             :     TYPEFORMAT_LINE(  OBJECTTYPE_ERRORBAR,       &saCommonPropInfo, 0,                 spOtherLines ),
     556             :     TYPEFORMAT_LINE(  OBJECTTYPE_SERLINE,        &saCommonPropInfo, 0,                 spOtherLines ),
     557             :     TYPEFORMAT_LINE(  OBJECTTYPE_LEADERLINE,     &saCommonPropInfo, 0,                 spOtherLines ),
     558             :     TYPEFORMAT_LINE(  OBJECTTYPE_DROPLINE,       &saCommonPropInfo, 0,                 spOtherLines ),
     559             :     TYPEFORMAT_LINE(  OBJECTTYPE_HILOLINE,       &saLinearPropInfo, 0,                 spOtherLines ),
     560             :     TYPEFORMAT_FRAME( OBJECTTYPE_UPBAR,          &saCommonPropInfo, 0,                 spUpDownBarLines,    spUpBarFills,          spUpDownBarEffects ),
     561             :     TYPEFORMAT_FRAME( OBJECTTYPE_DOWNBAR,        &saCommonPropInfo, 0,                 spUpDownBarLines,    spDownBarFills,        spUpDownBarEffects ),
     562             :     TYPEFORMAT_LINE(  OBJECTTYPE_DATATABLE,      &saCommonPropInfo, spOtherTexts,      spDataTableLines )
     563             : };
     564             : 
     565             : #undef TYPEFORMAT_FRAME
     566             : #undef TYPEFORMAT_LINE
     567             : 
     568         468 : void lclConvertPictureOptions( FillProperties& orFillProps, const PictureOptionsModel& rPicOptions )
     569             : {
     570         468 :     bool bStacked = (rPicOptions.mnPictureFormat == XML_stack) || (rPicOptions.mnPictureFormat == XML_stackScale);
     571         468 :     orFillProps.maBlipProps.moBitmapMode = bStacked ? XML_tile : XML_stretch;
     572         468 : }
     573             : 
     574             : } // namespace
     575             : 
     576             : struct ObjectFormatterData;
     577             : 
     578       23296 : class DetailFormatterBase
     579             : {
     580             : public:
     581             :     explicit            DetailFormatterBase(
     582             :                             ObjectFormatterData& rData,
     583             :                             const AutoFormatEntry* pAutoFormatEntry );
     584             :     explicit            DetailFormatterBase(
     585             :                             ObjectFormatterData& rData,
     586             :                             const AutoTextEntry* pAutoTextEntry );
     587             : 
     588             : protected:
     589             :     /** Returns the placeholder color which may depend on the passed series index. */
     590             :     sal_Int32           getPhColor( sal_Int32 nSeriesIdx ) const;
     591             : 
     592             : private:
     593             :     /** Resolves and returns the scheme color with the passed transformation. */
     594             :     sal_Int32           getSchemeColor( sal_Int32 nColorToken, sal_Int32 nModToken, sal_Int32 nModValue ) const;
     595             : 
     596             : protected:
     597             :     typedef ::std::vector< sal_Int32 > ColorPatternVec;
     598             : 
     599             :     ObjectFormatterData& mrData;            /// Shared formatter data.
     600             :     sal_Int32           mnPhClr;            /// RGB placeholder color for themed style.
     601             :     ColorPatternVec     maColorPattern;     /// Different cycling colors for data series.
     602             : };
     603             : 
     604        5824 : class LineFormatter : public DetailFormatterBase
     605             : {
     606             : public:
     607             :     explicit            LineFormatter(
     608             :                             ObjectFormatterData& rData,
     609             :                             const AutoFormatEntry* pAutoFormatEntry );
     610             : 
     611             :     /** Converts line formatting to the passed property set. */
     612             :     void                convertFormatting(
     613             :                             ShapePropertyMap& rPropMap,
     614             :                             const ModelRef< Shape >& rxShapeProp,
     615             :                             sal_Int32 nSeriesIdx );
     616             : 
     617             : private:
     618             :     LinePropertiesPtr   mxAutoLine;         /// Automatic line properties.
     619             : };
     620             : 
     621        5824 : class FillFormatter : public DetailFormatterBase
     622             : {
     623             : public:
     624             :     explicit            FillFormatter(
     625             :                             ObjectFormatterData& rData,
     626             :                             const AutoFormatEntry* pAutoFormatEntry,
     627             :                             const ObjectType eObjType );
     628             : 
     629             :     /** Converts area formatting to the passed property set. */
     630             :     void                convertFormatting(
     631             :                             ShapePropertyMap& rPropMap,
     632             :                             const ModelRef< Shape >& rxShapeProp,
     633             :                             const PictureOptionsModel* pPicOptions,
     634             :                             sal_Int32 nSeriesIdx );
     635             : 
     636             : private:
     637             :     FillPropertiesPtr   mxAutoFill;         /// Automatic fill properties.
     638             : };
     639             : 
     640        5824 : class EffectFormatter : public DetailFormatterBase
     641             : {
     642             : public:
     643             :     explicit            EffectFormatter(
     644             :                             ObjectFormatterData& rData,
     645             :                             const AutoFormatEntry* pAutoFormatEntry );
     646             : 
     647             :     /** Converts effect formatting to the passed property set. */
     648             :     void                convertFormatting(
     649             :                             ShapePropertyMap& rPropMap,
     650             :                             const ModelRef< Shape >& rxShapeProp,
     651             :                             sal_Int32 nSeriesIdx ) const;
     652             : };
     653             : 
     654        5824 : class TextFormatter : public DetailFormatterBase
     655             : {
     656             : public:
     657             :     explicit            TextFormatter(
     658             :                             ObjectFormatterData& rData,
     659             :                             const AutoTextEntry* pAutoTextEntry,
     660             :                             const ModelRef< TextBody >& rxGlobalTextProp );
     661             : 
     662             :     /** Converts text formatting to the passed property set. */
     663             :     void                convertFormatting(
     664             :                             PropertySet& rPropSet,
     665             :                             const TextCharacterProperties* pTextProps );
     666             :     /** Converts text formatting to the passed property set. */
     667             :     void                convertFormatting(
     668             :                             PropertySet& rPropSet,
     669             :                             const ModelRef< TextBody >& rxTextProp );
     670             : 
     671             : private:
     672             :     TextCharacterPropertiesPtr mxAutoText;  /// Automatic text properties.
     673             : };
     674             : 
     675             : /** Formatter for a specific object type. */
     676        5824 : class ObjectTypeFormatter
     677             : {
     678             : public:
     679             :     explicit            ObjectTypeFormatter(
     680             :                             ObjectFormatterData& rData,
     681             :                             const ObjectTypeFormatEntry& rEntry,
     682             :                             const ChartSpaceModel& rChartSpace,
     683             :                             const ObjectType eObjType );
     684             : 
     685             :     /** Sets frame formatting properties to the passed property set. */
     686             :     void                convertFrameFormatting(
     687             :                             PropertySet& rPropSet,
     688             :                             const ModelRef< Shape >& rxShapeProp,
     689             :                             const PictureOptionsModel* pPicOptions,
     690             :                             sal_Int32 nSeriesIdx );
     691             : 
     692             :     /** Sets text formatting properties to the passed property set. */
     693             :     void                convertTextFormatting(
     694             :                             PropertySet& rPropSet,
     695             :                             const ModelRef< TextBody >& rxTextProp );
     696             : 
     697             :     /** Sets frame/text formatting properties to the passed property set. */
     698             :     void                convertFormatting(
     699             :                             PropertySet& rPropSet,
     700             :                             const ModelRef< Shape >& rxShapeProp,
     701             :                             const ModelRef< TextBody >& rxTextProp );
     702             : 
     703             :     /** Sets text formatting properties to the passed property set. */
     704             :     void                convertTextFormatting(
     705             :                             PropertySet& rPropSet,
     706             :                             const TextCharacterProperties& rTextProps );
     707             : 
     708             :     /** Sets automatic fill properties to the passed property set. */
     709             :     void                convertAutomaticFill(
     710             :                             PropertySet& rPropSet,
     711             :                             sal_Int32 nSeriesIdx );
     712             : 
     713             : private:
     714             :     LineFormatter       maLineFormatter;    /// Converter for line formatting.
     715             :     FillFormatter       maFillFormatter;    /// Converter for fill formatting.
     716             :     EffectFormatter     maEffectFormatter;  /// Converter for effect formatting.
     717             :     TextFormatter       maTextFormatter;    /// Converter for text formatting.
     718             :     ModelObjectHelper&  mrModelObjHelper;   /// Helper for named drawing formatting.
     719             :     const ObjectTypeFormatEntry& mrEntry;   /// Additional settings.
     720             : };
     721             : 
     722         224 : struct ObjectFormatterData
     723             : {
     724             :     typedef RefMap< ObjectType, ObjectTypeFormatter > ObjectTypeFormatterMap;
     725             : 
     726             :     const XmlFilterBase& mrFilter;              /// Base filter object.
     727             :     ObjectTypeFormatterMap maTypeFormatters;    /// Formatters for all types of objects in a chart.
     728             :     ModelObjectHelper   maModelObjHelper;       /// Helper for named drawing formatting (dashes, gradients, bitmaps).
     729             :     Reference< XNumberFormats > mxNumFmts;      /// Number formats collection of container document.
     730             :     Reference< XNumberFormatTypes > mxNumTypes; /// Number format types collection of container document.
     731             :     Locale              maEnUsLocale;           /// Locale struct containing en-US.
     732             :     Locale              maFromLocale;           /// Empty locale struct.
     733             :     sal_Int32           mnMaxSeriesIdx;         /// Maximum series index used for color cycling/fading.
     734             : 
     735             :     explicit            ObjectFormatterData(
     736             :                             const XmlFilterBase& rFilter,
     737             :                             const Reference< XChartDocument >& rxChartDoc,
     738             :                             const ChartSpaceModel& rChartSpace );
     739             : 
     740             :     ObjectTypeFormatter* getTypeFormatter( ObjectType eObjType );
     741             : };
     742             : 
     743       17472 : DetailFormatterBase::DetailFormatterBase( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) :
     744             :     mrData( rData ),
     745       17472 :     mnPhClr( -1 )
     746             : {
     747       17472 :     if( pAutoFormatEntry )
     748             :     {
     749        6308 :         if( pAutoFormatEntry->mpPattern )
     750             :         {
     751             :             // prepare multi-color pattern
     752        4620 :             for( const AutoFormatPatternEntry* pPatternEntry = pAutoFormatEntry->mpPattern; pPatternEntry->mnColorToken != XML_TOKEN_INVALID; ++pPatternEntry )
     753        3960 :                 maColorPattern.push_back( getSchemeColor( pPatternEntry->mnColorToken, pPatternEntry->mnModToken, pPatternEntry->mnModValue ) );
     754             :         }
     755        5648 :         else if( pAutoFormatEntry->mnColorToken != XML_TOKEN_INVALID )
     756             :         {
     757             :             // prepare color or single-color pattern (color fading)
     758        3892 :             mnPhClr = getSchemeColor( pAutoFormatEntry->mnColorToken, pAutoFormatEntry->mnModToken, pAutoFormatEntry->mnModValue );
     759        3892 :             if( pAutoFormatEntry->mbFadedColor )
     760          12 :                 maColorPattern.push_back( mnPhClr );
     761             :         }
     762             :     }
     763       17472 : }
     764             : 
     765        5824 : DetailFormatterBase::DetailFormatterBase( ObjectFormatterData& rData, const AutoTextEntry* pAutoTextEntry ) :
     766             :     mrData( rData ),
     767        5824 :     mnPhClr( -1 )
     768             : {
     769        5824 :     if( pAutoTextEntry && (pAutoTextEntry->mnColorToken != XML_TOKEN_INVALID) )
     770        1792 :         mnPhClr = getSchemeColor( pAutoTextEntry->mnColorToken, XML_TOKEN_INVALID, 0 );
     771        5824 : }
     772             : 
     773        5394 : sal_Int32 DetailFormatterBase::getPhColor( sal_Int32 nSeriesIdx ) const
     774             : {
     775        5394 :     if( maColorPattern.empty() || (mrData.mnMaxSeriesIdx < 0) || (nSeriesIdx < 0) )
     776        4514 :         return mnPhClr;
     777             : 
     778             :     /*  Apply tint/shade depending on the cycle index. The colors of leading
     779             :         series are darkened (color shade), the colors of trailing series are
     780             :         lightened (color tint). Shade/tint is applied in an exclusive range of
     781             :         -70% to 70%.
     782             : 
     783             :         Example 1: 3 data series using single-color shading with accent color 1
     784             :         (e.g. automatic chart style #3). Shade/tint is applied per series.
     785             :         Shade/tint changes in steps of 140%/(<series_count+1) = 140%/4 = 35%,
     786             :         starting at -70%:
     787             :             Step 1: -70% -> Not used.
     788             :             Step 2: -35% -> Series 1 has 35% shade of accent color 1.
     789             :             Step 3:   0% -> Series 2 has pure accent color 1.
     790             :             Step 4:  35% -> Series 3 has 35% tint of accent color 1.
     791             :             Step 5:  70% -> Not used.
     792             : 
     793             :         Example 2: 20 data series using accent color pattern (e.g. automatic
     794             :         chart style #2). Each color cycle has a size of 6 series (accent colors
     795             :         1 to 6). Shade/tint is applied per color cycle.
     796             :             Cycle #1: Series 1...6 are based on accent colors 1 to 6.
     797             :             Cycle #2: Series 7...12 are based on accent colors 1 to 6.
     798             :             Cycle #3: Series 13...18 are based on accent colors 1 to 6.
     799             :             Cycle #4: Series 19...20 are based on accent colors 1 to 2.
     800             :         Shade/tint changes in steps of 140%/(cycle_count+1) = 140%/5 = 28%,
     801             :         starting at -70%:
     802             :             Step 1: -70% -> Not used.
     803             :             Step 2: -42% -> Cycle #1 has 42% shade of accent colors 1...6
     804             :             step 3: -14% -> Cycle #2 has 14% shade of accent colors 1...6
     805             :             step 4:  14% -> Cycle #3 has 14% tint of accent colors 1...6
     806             :             step 5:  42% -> Cycle #4 has 42% tint of accent colors 1...6
     807             :             step 6:  70% -> Not used.
     808             :      */
     809         880 :     sal_Int32 nPhClr = maColorPattern[ static_cast< size_t >( nSeriesIdx % maColorPattern.size() ) ];
     810         880 :     size_t nCycleIdx = static_cast< size_t >( nSeriesIdx / maColorPattern.size() );
     811         880 :     size_t nMaxCycleIdx = static_cast< size_t >( mrData.mnMaxSeriesIdx / maColorPattern.size() );
     812         880 :     double fShadeTint = static_cast< double >( nCycleIdx + 1 ) / (nMaxCycleIdx + 2) * 1.4 - 0.7;
     813         880 :     if( fShadeTint != 0.0 )
     814             :     {
     815          68 :         Color aColor;
     816          68 :         aColor.setSrgbClr( nPhClr );
     817          68 :         aColor.addChartTintTransformation( fShadeTint );
     818          68 :         nPhClr = aColor.getColor( mrData.mrFilter.getGraphicHelper() );
     819             :     }
     820             : 
     821         880 :     return nPhClr;
     822             : }
     823             : 
     824        9644 : sal_Int32 DetailFormatterBase::getSchemeColor( sal_Int32 nColorToken, sal_Int32 nModToken, sal_Int32 nModValue ) const
     825             : {
     826        9644 :     Color aColor;
     827        9644 :     aColor.setSchemeClr( nColorToken );
     828        9644 :     if( nModToken != XML_TOKEN_INVALID )
     829        1872 :         aColor.addTransformation( nModToken, nModValue );
     830        9644 :     return aColor.getColor( mrData.mrFilter.getGraphicHelper() );
     831             : }
     832             : 
     833        5824 : LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) :
     834        5824 :     DetailFormatterBase( rData, pAutoFormatEntry )
     835             : {
     836        5824 :     if( pAutoFormatEntry )
     837             :     {
     838        4256 :         mxAutoLine.reset( new LineProperties );
     839        4256 :         mxAutoLine->maLineFill.moFillType = XML_noFill;
     840        4256 :         if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
     841        4256 :             if( const LineProperties* pLineProps = pTheme->getLineStyle( pAutoFormatEntry->mnThemedIdx ) )
     842        3148 :                 *mxAutoLine = *pLineProps;
     843             :         // change line width according to chart auto style
     844        4256 :         if( mxAutoLine->moLineWidth.has() )
     845        3148 :             mxAutoLine->moLineWidth = mxAutoLine->moLineWidth.get() * pAutoFormatEntry->mnRelLineWidth / 100;
     846             :     }
     847        5824 : }
     848             : 
     849        2092 : void LineFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx )
     850             : {
     851        2092 :     LineProperties aLineProps;
     852        2092 :     if( mxAutoLine.get() )
     853        1840 :         aLineProps.assignUsed( *mxAutoLine );
     854        2092 :     if( rxShapeProp.is() )
     855        1262 :         aLineProps.assignUsed( rxShapeProp->getLineProperties() );
     856        2092 :     aLineProps.pushToPropMap( rPropMap, mrData.mrFilter.getGraphicHelper(), getPhColor( nSeriesIdx ) );
     857        2092 : }
     858             : 
     859        5824 : FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, const ObjectType eObjType ) :
     860        5824 :     DetailFormatterBase( rData, pAutoFormatEntry )
     861             : {
     862        5824 :     if( pAutoFormatEntry )
     863             :     {
     864        2012 :         mxAutoFill.reset( new FillProperties );
     865        2012 :         if( eObjType != OBJECTTYPE_CHARTSPACE )
     866        1788 :             mxAutoFill->moFillType = XML_noFill;
     867        2012 :         if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
     868        2012 :             if( const FillProperties* pFillProps = pTheme->getFillStyle( pAutoFormatEntry->mnThemedIdx ) )
     869        1044 :                 *mxAutoFill = *pFillProps;
     870             :     }
     871        5824 : }
     872             : 
     873        1510 : void FillFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx )
     874             : {
     875        1510 :     FillProperties aFillProps;
     876        1510 :     if( mxAutoFill.get() )
     877        1412 :         aFillProps.assignUsed( *mxAutoFill );
     878        1510 :     if( rxShapeProp.is() )
     879         768 :         aFillProps.assignUsed( rxShapeProp->getFillProperties() );
     880        1510 :     if( pPicOptions )
     881         468 :         lclConvertPictureOptions( aFillProps, *pPicOptions );
     882        1510 :     aFillProps.pushToPropMap( rPropMap, mrData.mrFilter.getGraphicHelper(), 0, getPhColor( nSeriesIdx ) );
     883        1510 : }
     884             : 
     885        5824 : EffectFormatter::EffectFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) :
     886        5824 :     DetailFormatterBase( rData, pAutoFormatEntry )
     887             : {
     888        5824 : }
     889             : //TODO :
     890        2306 : void EffectFormatter::convertFormatting( ShapePropertyMap& /*rPropMap*/, const ModelRef< Shape >& /*rxShapeProp*/, sal_Int32 /*nSeriesIdx*/ ) const
     891             : {
     892        2306 : }
     893             : 
     894             : namespace {
     895             : 
     896        3110 : const TextCharacterProperties* lclGetTextProperties( const ModelRef< TextBody >& rxTextProp )
     897             : {
     898        3484 :     return (rxTextProp.is() && !rxTextProp->getParagraphs().empty()) ?
     899        3484 :         &rxTextProp->getParagraphs().front()->getProperties().getTextCharacterProperties() : 0;
     900             : }
     901             : 
     902             : } // namespace
     903             : 
     904        5824 : TextFormatter::TextFormatter( ObjectFormatterData& rData, const AutoTextEntry* pAutoTextEntry, const ModelRef< TextBody >& rxGlobalTextProp ) :
     905        5824 :     DetailFormatterBase( rData, pAutoTextEntry )
     906             : {
     907        5824 :     if( pAutoTextEntry )
     908             :     {
     909        1792 :         mxAutoText.reset( new TextCharacterProperties );
     910        1792 :         if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
     911        1792 :             if( const TextCharacterProperties* pTextProps = pTheme->getFontStyle( pAutoTextEntry->mnThemedFont ) )
     912        1664 :                 *mxAutoText = *pTextProps;
     913        1792 :         sal_Int32 nTextColor = getPhColor( -1 );
     914        1792 :         if( nTextColor >= 0 )
     915        1664 :             mxAutoText->maCharColor.setSrgbClr( nTextColor );
     916        1792 :         mxAutoText->moHeight = pAutoTextEntry->mnDefFontSize;
     917        1792 :         mxAutoText->moBold = pAutoTextEntry->mbBold;
     918             : 
     919        1792 :         if( const TextCharacterProperties* pTextProps = lclGetTextProperties( rxGlobalTextProp ) )
     920             :         {
     921         288 :             mxAutoText->assignUsed( *pTextProps );
     922         288 :             if( pTextProps->moHeight.has() )
     923         112 :                 mxAutoText->moHeight = pTextProps->moHeight.get() * pAutoTextEntry->mnRelFontSize / 100;
     924             :         }
     925             :     }
     926        5824 : }
     927             : 
     928        1402 : void TextFormatter::convertFormatting( PropertySet& rPropSet, const TextCharacterProperties* pTextProps )
     929             : {
     930        1402 :     TextCharacterProperties aTextProps;
     931        1402 :     if( mxAutoText.get() )
     932        1402 :         aTextProps.assignUsed( *mxAutoText );
     933        1402 :     if( pTextProps )
     934         170 :         aTextProps.assignUsed( *pTextProps );
     935        1402 :     aTextProps.pushToPropSet( rPropSet, mrData.mrFilter );
     936        1402 : }
     937             : 
     938        1318 : void TextFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp )
     939             : {
     940        1318 :     convertFormatting( rPropSet, lclGetTextProperties( rxTextProp ) );
     941        1318 : }
     942             : 
     943        5824 : ObjectTypeFormatter::ObjectTypeFormatter( ObjectFormatterData& rData, const ObjectTypeFormatEntry& rEntry, const ChartSpaceModel& rChartSpace, const ObjectType eObjType ) :
     944             :     maLineFormatter(   rData, lclGetAutoFormatEntry( rEntry.mpAutoLines,   rChartSpace.mnStyle ) ),
     945             :     maFillFormatter(   rData, lclGetAutoFormatEntry( rEntry.mpAutoFills,   rChartSpace.mnStyle ), eObjType ),
     946             :     maEffectFormatter( rData, lclGetAutoFormatEntry( rEntry.mpAutoEffects, rChartSpace.mnStyle ) ),
     947             :     maTextFormatter(   rData, lclGetAutoTextEntry(   rEntry.mpAutoTexts,   rChartSpace.mnStyle ), rChartSpace.mxTextProp ),
     948             :     mrModelObjHelper( rData.maModelObjHelper ),
     949        5824 :     mrEntry( rEntry )
     950             : {
     951        5824 : }
     952             : 
     953        2092 : void ObjectTypeFormatter::convertFrameFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel* pPicOptions, sal_Int32 nSeriesIdx )
     954             : {
     955        2092 :     ShapePropertyMap aPropMap( mrModelObjHelper, *mrEntry.mpPropInfo );
     956        2092 :     maLineFormatter.convertFormatting( aPropMap, rxShapeProp, nSeriesIdx );
     957        2092 :     if( mrEntry.mbIsFrame )
     958        1296 :         maFillFormatter.convertFormatting( aPropMap, rxShapeProp, pPicOptions, nSeriesIdx );
     959        2092 :     maEffectFormatter.convertFormatting( aPropMap, rxShapeProp, nSeriesIdx );
     960        2092 :     rPropSet.setProperties( aPropMap );
     961        2092 : }
     962             : 
     963        1318 : void ObjectTypeFormatter::convertTextFormatting( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp )
     964             : {
     965        1318 :     maTextFormatter.convertFormatting( rPropSet, rxTextProp );
     966        1318 : }
     967             : 
     968         662 : void ObjectTypeFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const ModelRef< TextBody >& rxTextProp )
     969             : {
     970         662 :     convertFrameFormatting( rPropSet, rxShapeProp, 0, -1 );
     971         662 :     convertTextFormatting( rPropSet, rxTextProp );
     972         662 : }
     973             : 
     974          84 : void ObjectTypeFormatter::convertTextFormatting( PropertySet& rPropSet, const TextCharacterProperties& rTextProps )
     975             : {
     976          84 :     maTextFormatter.convertFormatting( rPropSet, &rTextProps );
     977          84 : }
     978             : 
     979         214 : void ObjectTypeFormatter::convertAutomaticFill( PropertySet& rPropSet, sal_Int32 nSeriesIdx )
     980             : {
     981         214 :     ShapePropertyMap aPropMap( mrModelObjHelper, *mrEntry.mpPropInfo );
     982         428 :     ModelRef< Shape > xShapeProp;
     983         214 :     maFillFormatter.convertFormatting( aPropMap, xShapeProp, 0, nSeriesIdx );
     984         214 :     maEffectFormatter.convertFormatting( aPropMap, xShapeProp, nSeriesIdx );
     985         428 :     rPropSet.setProperties( aPropMap );
     986         214 : }
     987             : 
     988         224 : ObjectFormatterData::ObjectFormatterData( const XmlFilterBase& rFilter, const Reference< XChartDocument >& rxChartDoc, const ChartSpaceModel& rChartSpace ) :
     989             :     mrFilter( rFilter ),
     990             :     maModelObjHelper( Reference< XMultiServiceFactory >( rxChartDoc, UNO_QUERY ) ),
     991             :     maEnUsLocale( "en", "US", OUString() ),
     992         224 :     mnMaxSeriesIdx( -1 )
     993             : {
     994         224 :     const ObjectTypeFormatEntry* pEntryEnd = STATIC_ARRAY_END( spObjTypeFormatEntries );
     995        6048 :     for( const ObjectTypeFormatEntry* pEntry = spObjTypeFormatEntries; pEntry != pEntryEnd; ++pEntry )
     996        5824 :         maTypeFormatters[ pEntry->meObjType ].reset( new ObjectTypeFormatter( *this, *pEntry, rChartSpace, pEntry->meObjType ) );
     997             : 
     998             :     try
     999             :     {
    1000         224 :         Reference< XNumberFormatsSupplier > xNumFmtsSupp( rxChartDoc, UNO_QUERY_THROW );
    1001         224 :         mxNumFmts = xNumFmtsSupp->getNumberFormats();
    1002         224 :         mxNumTypes.set( mxNumFmts, UNO_QUERY );
    1003             :     }
    1004           0 :     catch( Exception& )
    1005             :     {
    1006             :     }
    1007             :     OSL_ENSURE( mxNumFmts.is() && mxNumTypes.is(), "ObjectFormatterData::ObjectFormatterData - cannot get number formats" );
    1008         224 : }
    1009             : 
    1010        3046 : ObjectTypeFormatter* ObjectFormatterData::getTypeFormatter( ObjectType eObjType )
    1011             : {
    1012             :     OSL_ENSURE( maTypeFormatters.has( eObjType ), "ObjectFormatterData::getTypeFormatter - unknown object type" );
    1013        3046 :     return maTypeFormatters.get( eObjType ).get();
    1014             : }
    1015             : 
    1016         224 : ObjectFormatter::ObjectFormatter( const XmlFilterBase& rFilter, const Reference< XChartDocument >& rxChartDoc, const ChartSpaceModel& rChartSpace ) :
    1017         224 :     mxData( new ObjectFormatterData( rFilter, rxChartDoc, rChartSpace ) )
    1018             : {
    1019         224 : }
    1020             : 
    1021         224 : ObjectFormatter::~ObjectFormatter()
    1022             : {
    1023         224 : }
    1024             : 
    1025         316 : void ObjectFormatter::setMaxSeriesIndex( sal_Int32 nMaxSeriesIdx )
    1026             : {
    1027         316 :     mxData->mnMaxSeriesIdx = nMaxSeriesIdx;
    1028         316 : }
    1029             : 
    1030          48 : sal_Int32 ObjectFormatter::getMaxSeriesIndex() const
    1031             : {
    1032          48 :     return mxData->mnMaxSeriesIdx;
    1033             : }
    1034             : 
    1035         962 : void ObjectFormatter::convertFrameFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, ObjectType eObjType, sal_Int32 nSeriesIdx )
    1036             : {
    1037         962 :     if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
    1038         962 :         pFormat->convertFrameFormatting( rPropSet, rxShapeProp, 0, nSeriesIdx );
    1039         962 : }
    1040             : 
    1041         468 : void ObjectFormatter::convertFrameFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const PictureOptionsModel& rPicOptions, ObjectType eObjType, sal_Int32 nSeriesIdx )
    1042             : {
    1043         468 :     if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
    1044         468 :         pFormat->convertFrameFormatting( rPropSet, rxShapeProp, &rPicOptions, nSeriesIdx );
    1045         468 : }
    1046             : 
    1047         656 : void ObjectFormatter::convertTextFormatting( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp, ObjectType eObjType )
    1048             : {
    1049         656 :     if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
    1050         656 :         pFormat->convertTextFormatting( rPropSet, rxTextProp );
    1051         656 : }
    1052             : 
    1053         662 : void ObjectFormatter::convertFormatting( PropertySet& rPropSet, const ModelRef< Shape >& rxShapeProp, const ModelRef< TextBody >& rxTextProp, ObjectType eObjType )
    1054             : {
    1055         662 :     if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
    1056         662 :         pFormat->convertFormatting( rPropSet, rxShapeProp, rxTextProp );
    1057         662 : }
    1058             : 
    1059          84 : void ObjectFormatter::convertTextFormatting( PropertySet& rPropSet, const TextCharacterProperties& rTextProps, ObjectType eObjType )
    1060             : {
    1061          84 :     if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
    1062          84 :         pFormat->convertTextFormatting( rPropSet, rTextProps );
    1063          84 : }
    1064             : 
    1065        1188 : void ObjectFormatter::convertTextRotation( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp, bool bSupportsStacked )
    1066             : {
    1067        1188 :     if( rxTextProp.is() )
    1068             :     {
    1069         130 :         bool bStacked = false;
    1070         130 :         if( bSupportsStacked )
    1071             :         {
    1072         100 :             sal_Int32 nVert = rxTextProp->getTextProperties().moVert.get( XML_horz );
    1073         100 :             bStacked = (nVert == XML_wordArtVert) || (nVert == XML_wordArtVertRtl);
    1074         100 :             rPropSet.setProperty( PROP_StackCharacters, bStacked );
    1075             :         }
    1076             : 
    1077             :         /*  Chart2 expects rotation angle as double value in range of [0,360).
    1078             :             OOXML counts clockwise, Chart2 counts counterclockwise. */
    1079         130 :         double fAngle = static_cast< double >( bStacked ? 0 : rxTextProp->getTextProperties().moRotation.get( 0 ) );
    1080             :         // MS Office UI allows values only in range of [-90,90].
    1081         130 :         if ( fAngle <= -5400000.0 || fAngle >= 5400000.0 )
    1082             :         {
    1083          32 :             fAngle = 0.0;
    1084             :         }
    1085         130 :         fAngle = getDoubleIntervalValue< double >( -fAngle / 60000.0, 0.0, 360.0 );
    1086         130 :         rPropSet.setProperty( PROP_TextRotation, fAngle );
    1087             :     }
    1088        1188 : }
    1089             : 
    1090         876 : void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFormat& rNumberFormat, bool bAxis, bool bShowPercent )
    1091             : {
    1092         876 :     if( mxData->mxNumFmts.is() )
    1093             :     {
    1094         876 :         const bool bGeneral = rNumberFormat.maFormatCode.equalsIgnoreAsciiCase("general");
    1095         876 :         const bool bPercent = !bAxis && bShowPercent && !rNumberFormat.mbSourceLinked;
    1096         876 :         sal_Int32 nPropId = bPercent ? PROP_PercentageNumberFormat : PROP_NumberFormat;
    1097         876 :         OUString sFormatCode(rNumberFormat.maFormatCode);
    1098         876 :         if (bPercent && bGeneral)
    1099           2 :             sFormatCode = OUString("0%");
    1100             :         try
    1101             :         {
    1102         638 :             sal_Int32 nIndex = bGeneral && !bPercent ?
    1103         636 :                 mxData->mxNumTypes->getStandardIndex( mxData->maFromLocale ) :
    1104        1512 :                 mxData->mxNumFmts->addNewConverted( sFormatCode, mxData->maEnUsLocale, mxData->maFromLocale );
    1105         728 :             if( nIndex >= 0 )
    1106         728 :                 rPropSet.setProperty( nPropId, nIndex );
    1107             :         }
    1108         148 :         catch( Exception& )
    1109             :         {
    1110             :             OSL_FAIL( OStringBuffer( "ObjectFormatter::convertNumberFormat - cannot create number format '" ).
    1111             :                 append( OUStringToOString( rNumberFormat.maFormatCode, osl_getThreadTextEncoding() ) ).append( '\'' ).getStr() );
    1112             :         }
    1113             : 
    1114             :         // Setting "LinkNumberFormatToSource" does not really work, at least not for axis :-/
    1115         876 :         if (!bAxis)
    1116         618 :             rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.mbSourceLinked));
    1117             :         else
    1118         258 :             rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.maFormatCode.isEmpty()));
    1119             :     }
    1120         876 : }
    1121             : 
    1122         214 : void ObjectFormatter::convertAutomaticFill( PropertySet& rPropSet, ObjectType eObjType, sal_Int32 nSeriesIdx )
    1123             : {
    1124         214 :     if( ObjectTypeFormatter* pFormat = mxData->getTypeFormatter( eObjType ) )
    1125         214 :         pFormat->convertAutomaticFill( rPropSet, nSeriesIdx );
    1126         214 : }
    1127             : 
    1128           0 : bool ObjectFormatter::isAutomaticFill( const ModelRef< Shape >& rxShapeProp )
    1129             : {
    1130           0 :     return !rxShapeProp || !rxShapeProp->getFillProperties().moFillType.has();
    1131             : }
    1132             : 
    1133             : } // namespace chart
    1134             : } // namespace drawingml
    1135         408 : } // namespace oox
    1136             : 
    1137             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10