update dev300-m57
[ooovba.git] / applied_patches / 0433-chart-subtitle-xls-export.diff
blob88f04bb3b76c280f7cf5a520f77a818d5f5d4656
1 --- sc/source/filter/excel/xechart.cxx
2 +++ sc/source/filter/excel/xechart.cxx
3 @@ -36,6 +36,7 @@
4 #include <com/sun/star/i18n/XBreakIterator.hpp>
5 #include <com/sun/star/i18n/ScriptType.hpp>
6 #include <com/sun/star/drawing/FillStyle.hpp>
7 +#include <com/sun/star/chart/XChartDocument.hpp>
8 #include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
9 #include <com/sun/star/chart/ChartAxisPosition.hpp>
10 #include <com/sun/star/chart/DataLabelPlacement.hpp>
11 @@ -876,6 +877,13 @@ void XclExpChSourceLink::ConvertNumFmt(
15 +void XclExpChSourceLink::AppendString( const String& rStr )
17 + if (!mxString.is())
18 + return;
19 + XclExpStringHelper::AppendString( *mxString, GetRoot(), rStr );
22 void XclExpChSourceLink::Save( XclExpStream& rStrm )
24 // CHFORMATRUNS record
25 @@ -977,7 +985,7 @@ void XclExpChText::SetRotation( sal_uInt
26 ::insert_value( maData.mnFlags, XclTools::GetXclOrientFromRot( nRotation ), 8, 3 );
29 -void XclExpChText::ConvertTitle( Reference< XTitle > xTitle, sal_uInt16 nTarget )
30 +void XclExpChText::ConvertTitle( Reference< XTitle > xTitle, sal_uInt16 nTarget, const String* pSubTitle )
32 switch( nTarget )
34 @@ -991,6 +999,14 @@ void XclExpChText::ConvertTitle( Referen
35 // string sequence
36 mxSrcLink.reset( new XclExpChSourceLink( GetChRoot(), EXC_CHSRCLINK_TITLE ) );
37 sal_uInt16 nFontIdx = mxSrcLink->ConvertStringSequence( xTitle->getText() );
38 + if (pSubTitle)
39 + {
40 + // append subtitle as the 2nd line of the title.
41 + String aSubTitle = String::CreateFromAscii("\n");
42 + aSubTitle.Append(*pSubTitle);
43 + mxSrcLink->AppendString(aSubTitle);
44 + }
46 ConvertFontBase( GetChRoot(), nFontIdx );
48 // rotation
49 @@ -1140,14 +1156,15 @@ void XclExpChText::WriteBody( XclExpStre
50 namespace {
52 /** Creates and returns an Excel text object from the passed title. */
53 -XclExpChTextRef lclCreateTitle( const XclExpChRoot& rRoot, Reference< XTitled > xTitled, sal_uInt16 nTarget )
54 +XclExpChTextRef lclCreateTitle( const XclExpChRoot& rRoot, Reference< XTitled > xTitled, sal_uInt16 nTarget,
55 + const String* pSubTitle = NULL )
57 Reference< XTitle > xTitle;
58 if( xTitled.is() )
59 xTitle = xTitled->getTitleObject();
61 XclExpChTextRef xText( new XclExpChText( rRoot ) );
62 - xText->ConvertTitle( xTitle, nTarget );
63 + xText->ConvertTitle( xTitle, nTarget, pSubTitle );
64 /* Do not delete the CHTEXT group for the main title. A missing CHTEXT
65 will be interpreted as auto-generated title showing the series title in
66 charts that contain exactly one data series. */
67 @@ -2742,6 +2759,23 @@ void XclExpChAxesSet::WriteBody( XclExpS
69 // The chart object ===========================================================
71 +static void lcl_getChartSubTitle(const Reference<XChartDocument>& xChartDoc,
72 + String& rSubTitle)
74 + Reference< ::com::sun::star::chart::XChartDocument > xChartDoc1(xChartDoc, UNO_QUERY);
75 + if (!xChartDoc1.is())
76 + return;
78 + Reference< XPropertySet > xProp(xChartDoc1->getSubTitle(), UNO_QUERY);
79 + if (!xProp.is())
80 + return;
82 + OUString aTitle;
83 + Any any = xProp->getPropertyValue( OUString::createFromAscii("String") );
84 + if (any >>= aTitle)
85 + rSubTitle = aTitle;
88 XclExpChChart::XclExpChChart( const XclExpRoot& rRoot,
89 Reference< XChartDocument > xChartDoc, const Size& rSize ) :
90 XclExpChGroupBase( EXC_ID_CHCHART, 16 ),
91 @@ -2780,7 +2814,10 @@ XclExpChChart::XclExpChChart( const XclE
93 // chart title
94 Reference< XTitled > xTitled( xChartDoc, UNO_QUERY );
95 - mxTitle = lclCreateTitle( GetChRoot(), xTitled, EXC_CHOBJLINK_TITLE );
96 + String aSubTitle;
97 + lcl_getChartSubTitle(xChartDoc, aSubTitle);
98 + mxTitle = lclCreateTitle( GetChRoot(), xTitled, EXC_CHOBJLINK_TITLE,
99 + aSubTitle.Len() ? &aSubTitle : NULL );
101 // diagrams (axes sets)
102 sal_uInt16 nFreeGroupIdx = mxPrimAxesSet->Convert( xDiagram, 0 );
103 --- sc/source/filter/inc/xechart.hxx.old 2009-04-06 16:41:51.000000000 +0000
104 +++ sc/source/filter/inc/xechart.hxx 2009-04-06 16:42:05.000000000 +0000
105 @@ -348,6 +348,8 @@ public:
106 /** Converts the number format from the passed property set. */
107 void ConvertNumFmt( const ScfPropertySet& rPropSet, bool bPercent );
109 + void AppendString( const String& rStr );
111 /** Returns true, if this source link contains explicit string data. */
112 inline bool HasString() const { return mxString.is() && !mxString->IsEmpty(); }
114 @@ -436,7 +438,7 @@ public:
115 virtual void SetRotation( sal_uInt16 nRotation );
117 /** Converts all text settings of the passed title text object. */
118 - void ConvertTitle( XTitleRef xTitle, sal_uInt16 nTarget );
119 + void ConvertTitle( XTitleRef xTitle, sal_uInt16 nTarget, const String* pSubTitle = NULL );
120 /** Converts all text settings of the passed legend. */
121 void ConvertLegend( const ScfPropertySet& rPropSet );
122 /** Converts all settings of the passed data point caption text object. */