1ca5ec200SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3ca5ec200SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4ca5ec200SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5ca5ec200SAndrew Rist  * distributed with this work for additional information
6ca5ec200SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7ca5ec200SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8ca5ec200SAndrew Rist  * "License"); you may not use this file except in compliance
9ca5ec200SAndrew Rist  * with the License.  You may obtain a copy of the License at
10ca5ec200SAndrew Rist  *
11ca5ec200SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12ca5ec200SAndrew Rist  *
13ca5ec200SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14ca5ec200SAndrew Rist  * software distributed under the License is distributed on an
15ca5ec200SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ca5ec200SAndrew Rist  * KIND, either express or implied.  See the License for the
17ca5ec200SAndrew Rist  * specific language governing permissions and limitations
18ca5ec200SAndrew Rist  * under the License.
19ca5ec200SAndrew Rist  *
20ca5ec200SAndrew Rist  *************************************************************/
21ca5ec200SAndrew Rist 
22ca5ec200SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "oox/drawingml/table/tableproperties.hxx"
25cdf0e10cSrcweir #include "oox/drawingml/drawingmltypes.hxx"
26cdf0e10cSrcweir #include <com/sun/star/table/XTable.hpp>
27cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
28cdf0e10cSrcweir #include <com/sun/star/beans/XMultiPropertySet.hpp>
29cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30cdf0e10cSrcweir #include <com/sun/star/table/XMergeableCellRange.hpp>
31cdf0e10cSrcweir #include <com/sun/star/table/BorderLine.hpp>
32cdf0e10cSrcweir #include "oox/core/xmlfilterbase.hxx"
33cdf0e10cSrcweir #include "oox/helper/propertyset.hxx"
34cdf0e10cSrcweir 
35*506e6541SZhe Wang 
36cdf0e10cSrcweir using rtl::OUString;
37cdf0e10cSrcweir using namespace ::oox::core;
38cdf0e10cSrcweir using namespace ::com::sun::star;
39cdf0e10cSrcweir using namespace ::com::sun::star::uno;
40cdf0e10cSrcweir using namespace ::com::sun::star::beans;
41cdf0e10cSrcweir using namespace ::com::sun::star::table;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 
44cdf0e10cSrcweir namespace oox { namespace drawingml { namespace table {
45cdf0e10cSrcweir 
TableProperties()46cdf0e10cSrcweir TableProperties::TableProperties()
47cdf0e10cSrcweir : mbRtl( sal_False )
48cdf0e10cSrcweir , mbFirstRow( sal_False )
49cdf0e10cSrcweir , mbFirstCol( sal_False )
50cdf0e10cSrcweir , mbLastRow( sal_False )
51cdf0e10cSrcweir , mbLastCol( sal_False )
52cdf0e10cSrcweir , mbBandRow( sal_False )
53cdf0e10cSrcweir , mbBandCol( sal_False )
54cdf0e10cSrcweir {
55cdf0e10cSrcweir }
~TableProperties()56cdf0e10cSrcweir TableProperties::~TableProperties()
57cdf0e10cSrcweir {
58cdf0e10cSrcweir }
59cdf0e10cSrcweir 
apply(const TablePropertiesPtr &)60cdf0e10cSrcweir void TableProperties::apply( const TablePropertiesPtr& /* rSourceTableProperties */ )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
CreateTableRows(uno::Reference<XTableRows> xTableRows,const std::vector<TableRow> & rvTableRows)64cdf0e10cSrcweir void CreateTableRows( uno::Reference< XTableRows > xTableRows, const std::vector< TableRow >& rvTableRows )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 	if ( rvTableRows.size() > 1 )
67cdf0e10cSrcweir 		xTableRows->insertByIndex( 0, rvTableRows.size() - 1 );
68cdf0e10cSrcweir 	std::vector< TableRow >::const_iterator aTableRowIter( rvTableRows.begin() );
69cdf0e10cSrcweir 	uno::Reference< container::XIndexAccess > xIndexAccess( xTableRows, UNO_QUERY_THROW );
70cdf0e10cSrcweir 	for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ )
71cdf0e10cSrcweir 	{
72cdf0e10cSrcweir 		static const rtl::OUString	sHeight( RTL_CONSTASCII_USTRINGPARAM ( "Height" ) );
73cdf0e10cSrcweir 		Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW );
74cdf0e10cSrcweir 		xPropSet->setPropertyValue( sHeight, Any( static_cast< sal_Int32 >( aTableRowIter->getHeight() / 360 ) ) );
75cdf0e10cSrcweir 		aTableRowIter++;
76cdf0e10cSrcweir 	}
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
CreateTableColumns(Reference<XTableColumns> xTableColumns,const std::vector<sal_Int32> & rvTableGrid)79cdf0e10cSrcweir void CreateTableColumns( Reference< XTableColumns > xTableColumns, const std::vector< sal_Int32 >& rvTableGrid )
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	if ( rvTableGrid.size() > 1 )
82cdf0e10cSrcweir 		xTableColumns->insertByIndex( 0, rvTableGrid.size() - 1 );
83cdf0e10cSrcweir 	std::vector< sal_Int32 >::const_iterator aTableGridIter( rvTableGrid.begin() );
84cdf0e10cSrcweir 	uno::Reference< container::XIndexAccess > xIndexAccess( xTableColumns, UNO_QUERY_THROW );
85cdf0e10cSrcweir 	for ( sal_Int32 n = 0; n < xIndexAccess->getCount(); n++ )
86cdf0e10cSrcweir 	{
87cdf0e10cSrcweir 		static const rtl::OUString	sWidth( RTL_CONSTASCII_USTRINGPARAM ( "Width" ) );
88cdf0e10cSrcweir 		Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW );
89cdf0e10cSrcweir 		xPropSet->setPropertyValue( sWidth, Any( static_cast< sal_Int32 >( *aTableGridIter++ / 360 ) ) );
90cdf0e10cSrcweir 	}
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
MergeCells(const uno::Reference<XTable> & xTable,sal_Int32 nCol,sal_Int32 nRow,sal_Int32 nColSpan,sal_Int32 nRowSpan)93cdf0e10cSrcweir void MergeCells( const uno::Reference< XTable >& xTable, sal_Int32 nCol, sal_Int32 nRow, sal_Int32 nColSpan, sal_Int32 nRowSpan )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir    if( xTable.is() ) try
96cdf0e10cSrcweir    {
97cdf0e10cSrcweir        Reference< XMergeableCellRange > xRange( xTable->createCursorByRange( xTable->getCellRangeByPosition( nCol, nRow,nCol + nColSpan - 1, nRow + nRowSpan - 1 ) ), UNO_QUERY_THROW );
98cdf0e10cSrcweir        if( xRange->isMergeable() )
99cdf0e10cSrcweir                xRange->merge();
100cdf0e10cSrcweir    }
101cdf0e10cSrcweir    catch( Exception& )
102cdf0e10cSrcweir    {
103cdf0e10cSrcweir    }
104cdf0e10cSrcweir }
105cdf0e10cSrcweir 
106cdf0e10cSrcweir static TableStyle* pDefaultTableStyle = new TableStyle();
107cdf0e10cSrcweir 
108*506e6541SZhe Wang //for pptx just has table style id
SetTableStyleProperties(TableStyle * & pTableStyle,const sal_Int32 & tblFillClr,const sal_Int32 & tblTextClr,const sal_Int32 & lineBdrClr)109*506e6541SZhe Wang static void SetTableStyleProperties(TableStyle* &pTableStyle , const sal_Int32& tblFillClr,const sal_Int32& tblTextClr, const sal_Int32& lineBdrClr)
110*506e6541SZhe Wang {
111*506e6541SZhe Wang 	//whole table fill style and color
112*506e6541SZhe Wang 	oox::drawingml::FillPropertiesPtr pWholeTabFillProperties( new oox::drawingml::FillProperties );
113*506e6541SZhe Wang 	pWholeTabFillProperties->moFillType.set(XML_solidFill);
114*506e6541SZhe Wang 	pWholeTabFillProperties->maFillColor.setSchemeClr(tblFillClr);
115*506e6541SZhe Wang 	pWholeTabFillProperties->maFillColor.addTransformation(XML_tint,20000);
116*506e6541SZhe Wang 	pTableStyle->getWholeTbl().getFillProperties() = pWholeTabFillProperties;
117*506e6541SZhe Wang 	//whole table text color
118*506e6541SZhe Wang 	::oox::drawingml::Color tableTextColor;
119*506e6541SZhe Wang 	tableTextColor.setSchemeClr(tblTextClr);
120*506e6541SZhe Wang 	pTableStyle->getWholeTbl().getTextColor() = tableTextColor;
121*506e6541SZhe Wang 	//whole table line border
122*506e6541SZhe Wang 	oox::drawingml::LinePropertiesPtr pLeftBorder( new oox::drawingml::LineProperties);
123*506e6541SZhe Wang 	pLeftBorder->moLineWidth = 12700;
124*506e6541SZhe Wang 	pLeftBorder->moPresetDash = XML_sng;
125*506e6541SZhe Wang 	pLeftBorder->maLineFill.moFillType.set(XML_solidFill);
126*506e6541SZhe Wang 	pLeftBorder->maLineFill.maFillColor.setSchemeClr(lineBdrClr);
127*506e6541SZhe Wang 	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_left,pLeftBorder));
128*506e6541SZhe Wang 	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_right,pLeftBorder));
129*506e6541SZhe Wang 	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top,pLeftBorder));
130*506e6541SZhe Wang 	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom,pLeftBorder));
131*506e6541SZhe Wang 	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideH,pLeftBorder));
132*506e6541SZhe Wang 	pTableStyle->getWholeTbl().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_insideV,pLeftBorder));
133*506e6541SZhe Wang 
134*506e6541SZhe Wang 	//Band1H style
135*506e6541SZhe Wang 	oox::drawingml::FillPropertiesPtr pBand1HFillProperties( new oox::drawingml::FillProperties );
136*506e6541SZhe Wang 	pBand1HFillProperties->moFillType.set(XML_solidFill);
137*506e6541SZhe Wang 	pBand1HFillProperties->maFillColor.setSchemeClr(tblFillClr);
138*506e6541SZhe Wang 	pBand1HFillProperties->maFillColor.addTransformation(XML_tint,40000);
139*506e6541SZhe Wang 	pTableStyle->getBand1H().getFillProperties() = pBand1HFillProperties;
140*506e6541SZhe Wang 
141*506e6541SZhe Wang 	//Band1V style
142*506e6541SZhe Wang 	pTableStyle->getBand1V().getFillProperties() = pBand1HFillProperties;
143*506e6541SZhe Wang 
144*506e6541SZhe Wang     //tet bold for 1st row/last row/column
145*506e6541SZhe Wang 	::boost::optional< sal_Bool > textBoldStyle(sal_True);
146*506e6541SZhe Wang 	pTableStyle->getFirstRow().getTextBoldStyle() = textBoldStyle;
147*506e6541SZhe Wang 	pTableStyle->getLastRow().getTextBoldStyle() = textBoldStyle;
148*506e6541SZhe Wang 	pTableStyle->getFirstCol().getTextBoldStyle() = textBoldStyle;
149*506e6541SZhe Wang 	pTableStyle->getLastCol().getTextBoldStyle() = textBoldStyle;
150*506e6541SZhe Wang }
151*506e6541SZhe Wang 
CreateTableStyle(TableStyle * & pTableStyle,const OUString & styleId)152*506e6541SZhe Wang  sal_Bool CreateTableStyle(TableStyle* &pTableStyle , const OUString& styleId)
153*506e6541SZhe Wang {
154*506e6541SZhe Wang 	sal_Bool createdTblStyle = sal_False;
155*506e6541SZhe Wang 	if(!styleId.compareToAscii("{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}")){           //Medium Style 2 Accenat 1
156*506e6541SZhe Wang 		pTableStyle = new TableStyle();
157*506e6541SZhe Wang 		createdTblStyle = sal_True;
158*506e6541SZhe Wang         //first row style
159*506e6541SZhe Wang         //fill color and type
160*506e6541SZhe Wang 		oox::drawingml::FillPropertiesPtr pFstRowFillProperties( new oox::drawingml::FillProperties );
161*506e6541SZhe Wang 		pFstRowFillProperties->moFillType.set(XML_solidFill);
162*506e6541SZhe Wang 		pFstRowFillProperties->maFillColor.setSchemeClr(XML_accent1);
163*506e6541SZhe Wang 		pTableStyle->getFirstRow().getFillProperties() = pFstRowFillProperties;
164*506e6541SZhe Wang 		//text color
165*506e6541SZhe Wang 		::oox::drawingml::Color fstRowTextColor;
166*506e6541SZhe Wang 		fstRowTextColor.setSchemeClr(XML_lt1);
167*506e6541SZhe Wang 		pTableStyle->getFirstRow().getTextColor() = fstRowTextColor;
168*506e6541SZhe Wang 		//bottom line border
169*506e6541SZhe Wang 		oox::drawingml::LinePropertiesPtr pFstBottomBorder( new oox::drawingml::LineProperties);
170*506e6541SZhe Wang 		pFstBottomBorder->moLineWidth = 38100;
171*506e6541SZhe Wang 		pFstBottomBorder->moPresetDash = XML_sng;
172*506e6541SZhe Wang 		pFstBottomBorder->maLineFill.moFillType.set(XML_solidFill);
173*506e6541SZhe Wang 		pFstBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1);
174*506e6541SZhe Wang 		pTableStyle->getFirstRow().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom,pFstBottomBorder));
175*506e6541SZhe Wang 
176*506e6541SZhe Wang         //last row style
177*506e6541SZhe Wang 		pTableStyle->getLastRow().getFillProperties() = pFstRowFillProperties;
178*506e6541SZhe Wang 		pTableStyle->getLastRow().getTextColor() = fstRowTextColor;
179*506e6541SZhe Wang 		pTableStyle->getLastRow().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top,pFstBottomBorder));
180*506e6541SZhe Wang 
181*506e6541SZhe Wang 		//first column style
182*506e6541SZhe Wang 		pTableStyle->getFirstRow().getFillProperties() = pFstRowFillProperties;
183*506e6541SZhe Wang 		pTableStyle->getFirstRow().getTextColor() = fstRowTextColor;
184*506e6541SZhe Wang 
185*506e6541SZhe Wang 		//last column style
186*506e6541SZhe Wang 		pTableStyle->getLastCol().getFillProperties() = pFstRowFillProperties;
187*506e6541SZhe Wang 		pTableStyle->getLastCol().getTextColor() = fstRowTextColor;
188*506e6541SZhe Wang 
189*506e6541SZhe Wang 		SetTableStyleProperties(pTableStyle, XML_accent1, XML_dk1, XML_lt1);
190*506e6541SZhe Wang 	}
191*506e6541SZhe Wang 	else if (!styleId.compareToAscii("{21E4AEA4-8DFA-4A89-87EB-49C32662AFE0}"))         //Medium Style 2 Accent 2
192*506e6541SZhe Wang 	{
193*506e6541SZhe Wang 		pTableStyle = new TableStyle();
194*506e6541SZhe Wang 		createdTblStyle = sal_True;
195*506e6541SZhe Wang 		oox::drawingml::FillPropertiesPtr pFstRowFillProperties( new oox::drawingml::FillProperties );
196*506e6541SZhe Wang 		pFstRowFillProperties->moFillType.set(XML_solidFill);
197*506e6541SZhe Wang 		pFstRowFillProperties->maFillColor.setSchemeClr(XML_accent2);
198*506e6541SZhe Wang 		pTableStyle->getFirstRow().getFillProperties() = pFstRowFillProperties;
199*506e6541SZhe Wang 
200*506e6541SZhe Wang 		::oox::drawingml::Color fstRowTextColor;
201*506e6541SZhe Wang 		fstRowTextColor.setSchemeClr(XML_lt1);
202*506e6541SZhe Wang 		pTableStyle->getFirstRow().getTextColor() = fstRowTextColor;
203*506e6541SZhe Wang 
204*506e6541SZhe Wang 		oox::drawingml::LinePropertiesPtr pFstBottomBorder( new oox::drawingml::LineProperties);
205*506e6541SZhe Wang 		pFstBottomBorder->moLineWidth = 38100;
206*506e6541SZhe Wang 		pFstBottomBorder->moPresetDash = XML_sng;
207*506e6541SZhe Wang 		pFstBottomBorder->maLineFill.moFillType.set(XML_solidFill);
208*506e6541SZhe Wang 		pFstBottomBorder->maLineFill.maFillColor.setSchemeClr(XML_lt1);
209*506e6541SZhe Wang 		pTableStyle->getFirstRow().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_bottom,pFstBottomBorder));
210*506e6541SZhe Wang 
211*506e6541SZhe Wang 		pTableStyle->getLastRow().getFillProperties() = pFstRowFillProperties;
212*506e6541SZhe Wang 		pTableStyle->getLastRow().getTextColor() = fstRowTextColor;
213*506e6541SZhe Wang 		pTableStyle->getLastRow().getLineBorders().insert(std::pair<sal_Int32, ::oox::drawingml::LinePropertiesPtr>(XML_top,pFstBottomBorder));
214*506e6541SZhe Wang 
215*506e6541SZhe Wang 		pTableStyle->getFirstCol().getFillProperties() = pFstRowFillProperties;
216*506e6541SZhe Wang 		pTableStyle->getFirstCol().getTextColor() = fstRowTextColor;
217*506e6541SZhe Wang 
218*506e6541SZhe Wang 		pTableStyle->getLastCol().getFillProperties() = pFstRowFillProperties;
219*506e6541SZhe Wang 		pTableStyle->getLastCol().getTextColor() = fstRowTextColor;
220*506e6541SZhe Wang 
221*506e6541SZhe Wang 		SetTableStyleProperties(pTableStyle, XML_accent2, XML_dk1, XML_lt1);
222*506e6541SZhe Wang 	}
223*506e6541SZhe Wang 	else if (!styleId.compareToAscii("{C4B1156A-380E-4F78-BDF5-A606A8083BF9}"))         //Medium Style 4 Accent 4
224*506e6541SZhe Wang 	{
225*506e6541SZhe Wang 		pTableStyle = new TableStyle();
226*506e6541SZhe Wang 		createdTblStyle = sal_True;
227*506e6541SZhe Wang 		SetTableStyleProperties(pTableStyle, XML_accent4, XML_dk1, XML_accent4);
228*506e6541SZhe Wang 	}
229*506e6541SZhe Wang 
230*506e6541SZhe Wang 	return createdTblStyle;
231*506e6541SZhe Wang }
232*506e6541SZhe Wang //end
233*506e6541SZhe Wang 
getUsedTableStyle(const::oox::core::XmlFilterBase & rFilterBase,sal_Bool & isCreateTabStyle)234*506e6541SZhe Wang const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase, sal_Bool &isCreateTabStyle )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir 	::oox::core::XmlFilterBase& rBase( const_cast< ::oox::core::XmlFilterBase& >( rFilterBase ) );
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 	TableStyle* pTableStyle = NULL;
239cdf0e10cSrcweir 	if ( mpTableStyle )
240cdf0e10cSrcweir 		pTableStyle = &*mpTableStyle;
241cdf0e10cSrcweir 	else if ( rBase.getTableStyles() )
242cdf0e10cSrcweir 	{
243cdf0e10cSrcweir 		const std::vector< TableStyle >& rTableStyles( rBase.getTableStyles()->getTableStyles() );
244cdf0e10cSrcweir 		const rtl::OUString aStyleId( getStyleId().getLength() ? getStyleId() : rBase.getTableStyles()->getDefaultStyleId() );
245cdf0e10cSrcweir 		std::vector< TableStyle >::const_iterator aIter( rTableStyles.begin() );
246cdf0e10cSrcweir 		while( aIter != rTableStyles.end() )
247cdf0e10cSrcweir 		{
248cdf0e10cSrcweir 			if ( const_cast< TableStyle& >( *aIter ).getStyleId() == aStyleId )
249cdf0e10cSrcweir 			{
250cdf0e10cSrcweir 				pTableStyle = &const_cast< TableStyle& >( *aIter );
251cdf0e10cSrcweir 				break;	// we get the correct style
252cdf0e10cSrcweir 			}
253cdf0e10cSrcweir 			aIter++;
254cdf0e10cSrcweir 		}
255*506e6541SZhe Wang 		//if the pptx just has table style id, but no table style content, we will create the table style ourselves
256*506e6541SZhe Wang 		if ( !pTableStyle )
257*506e6541SZhe Wang 		{
258*506e6541SZhe Wang 			isCreateTabStyle = CreateTableStyle(pTableStyle , aStyleId);
259*506e6541SZhe Wang 		}
260cdf0e10cSrcweir 	}
261cdf0e10cSrcweir 	if ( !pTableStyle )
262cdf0e10cSrcweir 		pTableStyle = pDefaultTableStyle;
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	return *pTableStyle;
265cdf0e10cSrcweir }
266cdf0e10cSrcweir 
pushToPropSet(const::oox::core::XmlFilterBase & rFilterBase,const Reference<XPropertySet> & xPropSet,TextListStylePtr pMasterTextListStyle)267cdf0e10cSrcweir void TableProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase,
268cdf0e10cSrcweir 	const Reference < XPropertySet >& xPropSet, TextListStylePtr pMasterTextListStyle )
269cdf0e10cSrcweir {
270cdf0e10cSrcweir 	TableStyleListPtr( const_cast< ::oox::core::XmlFilterBase& >( rFilterBase ).getTableStyles() );
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	uno::Reference< XColumnRowRange > xColumnRowRange(
273cdf0e10cSrcweir  		xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ), uno::UNO_QUERY_THROW );
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	CreateTableColumns( xColumnRowRange->getColumns(), mvTableGrid );
276cdf0e10cSrcweir 	CreateTableRows( xColumnRowRange->getRows(), mvTableRows );
277cdf0e10cSrcweir 
278*506e6541SZhe Wang 	sal_Bool mbOwnTblStyle = sal_False;
279*506e6541SZhe Wang 	const TableStyle& rTableStyle( getUsedTableStyle( rFilterBase, mbOwnTblStyle ) );
280cdf0e10cSrcweir 	sal_Int32 nRow = 0;
281cdf0e10cSrcweir 	std::vector< TableRow >::iterator aTableRowIter( mvTableRows.begin() );
282cdf0e10cSrcweir 	while( aTableRowIter != mvTableRows.end() )
283cdf0e10cSrcweir 	{
284cdf0e10cSrcweir 		sal_Int32 nColumn = 0;
285cdf0e10cSrcweir 		std::vector< TableCell >::iterator aTableCellIter( aTableRowIter->getTableCells().begin() );
286cdf0e10cSrcweir 		while( aTableCellIter != aTableRowIter->getTableCells().end() )
287cdf0e10cSrcweir 		{
288cdf0e10cSrcweir 			TableCell& rTableCell( *aTableCellIter );
289cdf0e10cSrcweir 			if ( !rTableCell.getvMerge() && !rTableCell.gethMerge() )
290cdf0e10cSrcweir 			{
291cdf0e10cSrcweir 				uno::Reference< XTable > xTable( xColumnRowRange, uno::UNO_QUERY_THROW );
292cdf0e10cSrcweir 				if ( ( rTableCell.getRowSpan() > 1 ) || ( rTableCell.getGridSpan() > 1 ) )
293cdf0e10cSrcweir 					MergeCells( xTable, nColumn, nRow, rTableCell.getGridSpan(), rTableCell.getRowSpan() );
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 				Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW );
296cdf0e10cSrcweir 				rTableCell.pushToXCell( rFilterBase, pMasterTextListStyle, xCellRange->getCellByPosition( nColumn, nRow ), *this, rTableStyle,
297cdf0e10cSrcweir 					nColumn, aTableRowIter->getTableCells().size(), nRow, mvTableRows.size() );
298cdf0e10cSrcweir 			}
299cdf0e10cSrcweir 			nColumn++;
300cdf0e10cSrcweir 			aTableCellIter++;
301cdf0e10cSrcweir 		}
302cdf0e10cSrcweir 		nRow++;
303cdf0e10cSrcweir 		aTableRowIter++;
304cdf0e10cSrcweir 	}
305*506e6541SZhe Wang 
306*506e6541SZhe Wang 	if(mbOwnTblStyle == sal_True)
307*506e6541SZhe Wang 	{
308*506e6541SZhe Wang 		TableStyle* pTableStyle = (TableStyle*)&rTableStyle;
309*506e6541SZhe Wang 		if(pTableStyle != NULL)
310*506e6541SZhe Wang 		{
311*506e6541SZhe Wang 			delete pTableStyle;
312*506e6541SZhe Wang 			pTableStyle = NULL;
313*506e6541SZhe Wang 		}
314*506e6541SZhe Wang 		mbOwnTblStyle = sal_False;
315*506e6541SZhe Wang 	}
316cdf0e10cSrcweir }
317cdf0e10cSrcweir 
318cdf0e10cSrcweir } } }
319