tableproperties.cxx (ca5ec200) tableproperties.cxx (506e6541)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 18 unchanged lines hidden (view full) ---

27#include <com/sun/star/container/XNameContainer.hpp>
28#include <com/sun/star/beans/XMultiPropertySet.hpp>
29#include <com/sun/star/lang/XMultiServiceFactory.hpp>
30#include <com/sun/star/table/XMergeableCellRange.hpp>
31#include <com/sun/star/table/BorderLine.hpp>
32#include "oox/core/xmlfilterbase.hxx"
33#include "oox/helper/propertyset.hxx"
34
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 18 unchanged lines hidden (view full) ---

27#include <com/sun/star/container/XNameContainer.hpp>
28#include <com/sun/star/beans/XMultiPropertySet.hpp>
29#include <com/sun/star/lang/XMultiServiceFactory.hpp>
30#include <com/sun/star/table/XMergeableCellRange.hpp>
31#include <com/sun/star/table/BorderLine.hpp>
32#include "oox/core/xmlfilterbase.hxx"
33#include "oox/helper/propertyset.hxx"
34
35
35using rtl::OUString;
36using namespace ::oox::core;
37using namespace ::com::sun::star;
38using namespace ::com::sun::star::uno;
39using namespace ::com::sun::star::beans;
40using namespace ::com::sun::star::table;
41
42

--- 56 unchanged lines hidden (view full) ---

99 }
100 catch( Exception& )
101 {
102 }
103}
104
105static TableStyle* pDefaultTableStyle = new TableStyle();
106
36using rtl::OUString;
37using namespace ::oox::core;
38using namespace ::com::sun::star;
39using namespace ::com::sun::star::uno;
40using namespace ::com::sun::star::beans;
41using namespace ::com::sun::star::table;
42
43

--- 56 unchanged lines hidden (view full) ---

100 }
101 catch( Exception& )
102 {
103 }
104}
105
106static TableStyle* pDefaultTableStyle = new TableStyle();
107
107const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase )
108//for pptx just has table style id
109static 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
234const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilterBase& rFilterBase, sal_Bool &isCreateTabStyle )
108{
109 ::oox::core::XmlFilterBase& rBase( const_cast< ::oox::core::XmlFilterBase& >( rFilterBase ) );
110
111 TableStyle* pTableStyle = NULL;
112 if ( mpTableStyle )
113 pTableStyle = &*mpTableStyle;
114 else if ( rBase.getTableStyles() )
115 {

--- 4 unchanged lines hidden (view full) ---

120 {
121 if ( const_cast< TableStyle& >( *aIter ).getStyleId() == aStyleId )
122 {
123 pTableStyle = &const_cast< TableStyle& >( *aIter );
124 break; // we get the correct style
125 }
126 aIter++;
127 }
235{
236 ::oox::core::XmlFilterBase& rBase( const_cast< ::oox::core::XmlFilterBase& >( rFilterBase ) );
237
238 TableStyle* pTableStyle = NULL;
239 if ( mpTableStyle )
240 pTableStyle = &*mpTableStyle;
241 else if ( rBase.getTableStyles() )
242 {

--- 4 unchanged lines hidden (view full) ---

247 {
248 if ( const_cast< TableStyle& >( *aIter ).getStyleId() == aStyleId )
249 {
250 pTableStyle = &const_cast< TableStyle& >( *aIter );
251 break; // we get the correct style
252 }
253 aIter++;
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 }
129 if ( !pTableStyle )
130 pTableStyle = pDefaultTableStyle;
131
132 return *pTableStyle;
133}
134
135void TableProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase,
136 const Reference < XPropertySet >& xPropSet, TextListStylePtr pMasterTextListStyle )
137{
138 TableStyleListPtr( const_cast< ::oox::core::XmlFilterBase& >( rFilterBase ).getTableStyles() );
139
140 uno::Reference< XColumnRowRange > xColumnRowRange(
141 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ), uno::UNO_QUERY_THROW );
142
143 CreateTableColumns( xColumnRowRange->getColumns(), mvTableGrid );
144 CreateTableRows( xColumnRowRange->getRows(), mvTableRows );
145
260 }
261 if ( !pTableStyle )
262 pTableStyle = pDefaultTableStyle;
263
264 return *pTableStyle;
265}
266
267void TableProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase,
268 const Reference < XPropertySet >& xPropSet, TextListStylePtr pMasterTextListStyle )
269{
270 TableStyleListPtr( const_cast< ::oox::core::XmlFilterBase& >( rFilterBase ).getTableStyles() );
271
272 uno::Reference< XColumnRowRange > xColumnRowRange(
273 xPropSet->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ) ), uno::UNO_QUERY_THROW );
274
275 CreateTableColumns( xColumnRowRange->getColumns(), mvTableGrid );
276 CreateTableRows( xColumnRowRange->getRows(), mvTableRows );
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;
148 std::vector< TableRow >::iterator aTableRowIter( mvTableRows.begin() );
149 while( aTableRowIter != mvTableRows.end() )
150 {
151 sal_Int32 nColumn = 0;
152 std::vector< TableCell >::iterator aTableCellIter( aTableRowIter->getTableCells().begin() );
153 while( aTableCellIter != aTableRowIter->getTableCells().end() )
154 {

--- 9 unchanged lines hidden (view full) ---

164 nColumn, aTableRowIter->getTableCells().size(), nRow, mvTableRows.size() );
165 }
166 nColumn++;
167 aTableCellIter++;
168 }
169 nRow++;
170 aTableRowIter++;
171 }
280 sal_Int32 nRow = 0;
281 std::vector< TableRow >::iterator aTableRowIter( mvTableRows.begin() );
282 while( aTableRowIter != mvTableRows.end() )
283 {
284 sal_Int32 nColumn = 0;
285 std::vector< TableCell >::iterator aTableCellIter( aTableRowIter->getTableCells().begin() );
286 while( aTableCellIter != aTableRowIter->getTableCells().end() )
287 {

--- 9 unchanged lines hidden (view full) ---

297 nColumn, aTableRowIter->getTableCells().size(), nRow, mvTableRows.size() );
298 }
299 nColumn++;
300 aTableCellIter++;
301 }
302 nRow++;
303 aTableRowIter++;
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}
173
174} } }
316}
317
318} } }