View | Details | Raw Unified | Return to issue 120723
Collapse All | Expand All

(-)main/oox/inc/oox/drawingml/table/tableproperties.hxx (-1 / +1 lines)
Lines 62-68 Link Here
62
62
63
private:
63
private:
64
64
65
	const TableStyle&					getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase );
65
	const TableStyle&					getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase,  sal_Bool &isCreateTabStyle);
66
66
67
	rtl::OUString						maStyleId;				// either StyleId is available
67
	rtl::OUString						maStyleId;				// either StyleId is available
68
	boost::shared_ptr< TableStyle >		mpTableStyle;			// or the complete TableStyle
68
	boost::shared_ptr< TableStyle >		mpTableStyle;			// or the complete TableStyle
(-)main/oox/source/drawingml/table/tableproperties.cxx (-2 / +146 lines)
Lines 32-37 Link Here
32
#include "oox/core/xmlfilterbase.hxx"
32
#include "oox/core/xmlfilterbase.hxx"
33
#include "oox/helper/propertyset.hxx"
33
#include "oox/helper/propertyset.hxx"
34
34
35
35
using rtl::OUString;
36
using rtl::OUString;
36
using namespace ::oox::core;
37
using namespace ::oox::core;
37
using namespace ::com::sun::star;
38
using namespace ::com::sun::star;
Lines 104-110 Link Here
104
105
105
static TableStyle* pDefaultTableStyle = new TableStyle();
106
static TableStyle* pDefaultTableStyle = new TableStyle();
106
107
107
const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase )
108
//for pptx just has table style id
109
static void SetTableStyleProperties(TableStyle* &pTableStyle , const sal_Int32& tblFillClr,const sal_Int32& tblTextClr, const sal_Int32& lineBdrClr)
110
{	
111
	//whole table fill style and color
112
	oox::drawingml::FillPropertiesPtr pWholeTabFillProperties( new oox::drawingml::FillProperties );
113
	pWholeTabFillProperties->moFillType.set(XML_solidFill);
114
	pWholeTabFillProperties->maFillColor.setSchemeClr(tblFillClr);  
115
	pWholeTabFillProperties->maFillColor.addTransformation(XML_tint,20000);
116
	pTableStyle->getWholeTbl().getFillProperties() = pWholeTabFillProperties;
117
	//whole table text color
118
	::oox::drawingml::Color tableTextColor;
119
	tableTextColor.setSchemeClr(tblTextClr);
120
	pTableStyle->getWholeTbl().getTextColor() = tableTextColor;
121
	//whole table line border
122
	oox::drawingml::LinePropertiesPtr pLeftBorder( new oox::drawingml::LineProperties);
123
	pLeftBorder->moLineWidth = 12700;
124
	pLeftBorder->moPresetDash = XML_sng;
125
	pLeftBorder->maLineFill.moFillType.set(XML_solidFill);
126
	pLeftBorder->maLineFill.maFillColor.setSchemeClr(lineBdrClr);
127
	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left,pLeftBorder));
128
	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right,pLeftBorder));
129
	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top,pLeftBorder));
130
	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom,pLeftBorder));
131
	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH,pLeftBorder));
132
	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV,pLeftBorder));
133
134
	//Band1H style
135
	oox::drawingml::FillPropertiesPtr pBand1HFillProperties( new oox::drawingml::FillProperties );
136
	pBand1HFillProperties->moFillType.set(XML_solidFill);
137
	pBand1HFillProperties->maFillColor.setSchemeClr(tblFillClr);	
138
	pBand1HFillProperties->maFillColor.addTransformation(XML_tint,40000);
139
	pTableStyle->getBand1H().getFillProperties() = pBand1HFillProperties;
140
	
141
	//Band1V style
142
	pTableStyle->getBand1V().getFillProperties() = pBand1HFillProperties;
143
144
    //tet bold for 1st row/last row/column
145
	::boost::optional< sal_Bool > textBoldStyle(sal_True);
146
	pTableStyle->getFirstRow().getTextBoldStyle() = textBoldStyle;
147
	pTableStyle->getLastRow().getTextBoldStyle() = textBoldStyle;
148
	pTableStyle->getFirstCol().getTextBoldStyle() = textBoldStyle;
149
	pTableStyle->getLastCol().getTextBoldStyle() = textBoldStyle;
150
}
151
152
 sal_Bool CreateTableStyle(TableStyle* &pTableStyle , const OUString& styleId)
153
{	
154
	sal_Bool createdTblStyle = sal_False;
155
	if(!styleId.compareToAscii("{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}")){           //Medium Style 2 Accenat 1
156
		pTableStyle = new TableStyle();
157
		createdTblStyle = sal_True;
158
        //first row style
159
        //fill color and type
160
		oox::drawingml::FillPropertiesPtr pFstRowFillProperties( new oox::drawingml::FillProperties );
161
		pFstRowFillProperties->moFillType.set(XML_solidFill);
162
		pFstRowFillProperties->maFillColor.setSchemeClr(XML_accent1);   
163
		pTableStyle->getFirstRow().getFillProperties() = pFstRowFillProperties;
164
		//text color
165
		::oox::drawingml::Color fstRowTextColor;
166
		fstRowTextColor.setSchemeClr(XML_lt1);
167
		pTableStyle->getFirstRow().getTextColor() = fstRowTextColor;
168
		//bottom line border
169
		oox::drawingml::LinePropertiesPtr pFstBottomBorder( new oox::drawingml::LineProperties);
170
		pFstBottomBorder->moLineWidth = 38100;
171
		pFstBottomBorder->moPresetDash = XML_sng;
172
		pFstBottomBorder->maLineFill.moFillType.set(XML_solidFill);
173
		pFstBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1);
174
		pTableStyle->getFirstRow().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom,pFstBottomBorder));
175
176
        //last row style
177
		pTableStyle->getLastRow().getFillProperties() = pFstRowFillProperties;
178
		pTableStyle->getLastRow().getTextColor() = fstRowTextColor;
179
		pTableStyle->getLastRow().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top,pFstBottomBorder));
180
181
		//first column style
182
		pTableStyle->getFirstRow().getFillProperties() = pFstRowFillProperties;
183
		pTableStyle->getFirstRow().getTextColor() = fstRowTextColor;
184
185
		//last column style
186
		pTableStyle->getLastCol().getFillProperties() = pFstRowFillProperties;
187
		pTableStyle->getLastCol().getTextColor() = fstRowTextColor;
188
189
		SetTableStyleProperties(pTableStyle, XML_accent1, XML_dk1, XML_lt1);
190
	}
191
	else if (!styleId.compareToAscii("{21E4AEA4-8DFA-4A89-87EB-49C32662AFE0}"))         //Medium Style 2 Accent 2
192
	{
193
		pTableStyle = new TableStyle();
194
		createdTblStyle = sal_True;
195
		oox::drawingml::FillPropertiesPtr pFstRowFillProperties( new oox::drawingml::FillProperties );
196
		pFstRowFillProperties->moFillType.set(XML_solidFill);
197
		pFstRowFillProperties->maFillColor.setSchemeClr(XML_accent2);   
198
		pTableStyle->getFirstRow().getFillProperties() = pFstRowFillProperties;
199
200
		::oox::drawingml::Color fstRowTextColor;
201
		fstRowTextColor.setSchemeClr(XML_lt1);
202
		pTableStyle->getFirstRow().getTextColor() = fstRowTextColor;
203
		
204
		oox::drawingml::LinePropertiesPtr pFstBottomBorder( new oox::drawingml::LineProperties);
205
		pFstBottomBorder->moLineWidth = 38100;
206
		pFstBottomBorder->moPresetDash = XML_sng;
207
		pFstBottomBorder->maLineFill.moFillType.set(XML_solidFill);
208
		pFstBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1);
209
		pTableStyle->getFirstRow().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom,pFstBottomBorder));
210
211
		pTableStyle->getLastRow().getFillProperties() = pFstRowFillProperties;
212
		pTableStyle->getLastRow().getTextColor() = fstRowTextColor;
213
		pTableStyle->getLastRow().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top,pFstBottomBorder));
214
215
		pTableStyle->getFirstCol().getFillProperties() = pFstRowFillProperties;
216
		pTableStyle->getFirstCol().getTextColor() = fstRowTextColor;
217
	
218
		pTableStyle->getLastCol().getFillProperties() = pFstRowFillProperties;
219
		pTableStyle->getLastCol().getTextColor() = fstRowTextColor;		
220
221
		SetTableStyleProperties(pTableStyle, XML_accent2, XML_dk1, XML_lt1);
222
	}
223
	else if (!styleId.compareToAscii("{C4B1156A-380E-4F78-BDF5-A606A8083BF9}"))         //Medium Style 4 Accent 4
224
	{
225
		pTableStyle = new TableStyle();
226
		createdTblStyle = sal_True;
227
		SetTableStyleProperties(pTableStyle, XML_accent4, XML_dk1, XML_accent4);
228
	}
229
230
	return createdTblStyle;
231
} 
232
//end
233
234
const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase, sal_Bool &isCreateTabStyle )
108
{
235
{
109
	::oox::core::XmlFilterBase& rBase( const_cast< ::oox::core::XmlFilterBase& >( rFilterBase ) );
236
	::oox::core::XmlFilterBase& rBase( const_cast< ::oox::core::XmlFilterBase& >( rFilterBase ) );
110
237
Lines 125-130 Link Here
125
			}
252
			}
126
			aIter++;
253
			aIter++;
127
		}
254
		}
255
		//if the pptx just has table style id, but no table style content, we will create the table style ourselves
256
		if ( !pTableStyle )
257
		{
258
			isCreateTabStyle = CreateTableStyle(pTableStyle , aStyleId);
259
		}
128
	}
260
	}
129
	if ( !pTableStyle )
261
	if ( !pTableStyle )
130
		pTableStyle = pDefaultTableStyle;
262
		pTableStyle = pDefaultTableStyle;
Lines 143-149 Link Here
143
	CreateTableColumns( xColumnRowRange->getColumns(), mvTableGrid );
275
	CreateTableColumns( xColumnRowRange->getColumns(), mvTableGrid );
144
	CreateTableRows( xColumnRowRange->getRows(), mvTableRows );
276
	CreateTableRows( xColumnRowRange->getRows(), mvTableRows );
145
277
146
	const TableStyle& rTableStyle( getUsedTableStyle( rFilterBase ) );
278
	sal_Bool mbOwnTblStyle = sal_False;
279
	const TableStyle& rTableStyle( getUsedTableStyle( rFilterBase, mbOwnTblStyle ) );
147
	sal_Int32 nRow = 0;
280
	sal_Int32 nRow = 0;
148
	std::vector< TableRow >::iterator aTableRowIter( mvTableRows.begin() );
281
	std::vector< TableRow >::iterator aTableRowIter( mvTableRows.begin() );
149
	while( aTableRowIter != mvTableRows.end() )
282
	while( aTableRowIter != mvTableRows.end() )
Lines 169-174 Link Here
169
		nRow++;
302
		nRow++;
170
		aTableRowIter++;
303
		aTableRowIter++;
171
	}
304
	}
305
	
306
	if(mbOwnTblStyle == sal_True)
307
	{
308
		TableStyle* pTableStyle = (TableStyle*)&rTableStyle;
309
		if(pTableStyle != NULL)
310
		{
311
			delete pTableStyle;
312
			pTableStyle = NULL;
313
		}
314
		mbOwnTblStyle = sal_False;
315
	}
172
}
316
}
173
317
174
} } }
318
} } }

Return to issue 120723