LCOV - code coverage report
Current view: top level - oox/source/drawingml/chart - objectformatter.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 235 0.0 %
Date: 2014-04-14 Functions: 0 47 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10