LibreOffice Module oox (master) 1
tablecell.cxx
Go to the documentation of this file.
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
28#include <oox/token/properties.hxx>
29#include <oox/token/tokens.hxx>
30#include <tools/color.hxx>
31#include <com/sun/star/table/BorderLineStyle.hpp>
32#include <com/sun/star/table/BorderLine2.hpp>
33#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
34#include <com/sun/star/text/XText.hpp>
35#include <com/sun/star/text/WritingMode.hpp>
36
37using namespace ::oox::core;
38using namespace ::com::sun::star;
39using namespace ::com::sun::star::uno;
40using namespace ::com::sun::star::beans;
41using ::com::sun::star::table::BorderLine2;
42
43namespace oox::drawingml::table {
44
46: mpTextBody( std::make_shared<TextBody>() )
47, mnRowSpan ( 1 )
48, mnGridSpan( 1 )
49, mbhMerge( false )
50, mbvMerge( false )
51, mnMarL( 91440 )
52, mnMarR( 91440 )
53, mnMarT( 45720 )
54, mnMarB( 45720 )
55, mnVertToken( XML_horz )
56, mnAnchorToken( XML_t )
57, mbAnchorCtr( false )
58, mnHorzOverflowToken( XML_clip )
59{
60}
61
62static void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase,
63 Reference< XPropertySet > const & rxPropSet, oox::drawingml::LineProperties const & rLineProperties,
64 sal_Int32 nPropId )
65{
66 BorderLine2 aBorderLine;
67 if ( rLineProperties.maLineFill.moFillType.has_value() && rLineProperties.maLineFill.moFillType.value() != XML_noFill )
68 {
69 Color aColor = rLineProperties.maLineFill.getBestSolidColor();
70 aBorderLine.Color = sal_Int32(aColor.getColor( rFilterBase.getGraphicHelper() ));
71 aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 4 );
72 aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 4 );
73 aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 2 );
74 aBorderLine.LineDistance = 0;
75 }
76 else
77 {
78 aBorderLine.Color = sal_Int32( COL_AUTO );
79 aBorderLine.OuterLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 4 );
80 aBorderLine.InnerLineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 4 );
81 aBorderLine.LineWidth = static_cast< sal_Int16 >( GetCoordinate( rLineProperties.moLineWidth.value_or( 0 ) ) / 2 );
82 aBorderLine.LineDistance = 0;
83 }
84
85 if ( rLineProperties.moPresetDash.has_value() )
86 {
87 switch ( rLineProperties.moPresetDash.value() )
88 {
89 case XML_dot:
90 case XML_sysDot:
91 aBorderLine.LineStyle = ::table::BorderLineStyle::DOTTED;
92 break;
93 case XML_dash:
94 case XML_lgDash:
95 case XML_sysDash:
96 aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED;
97 break;
98 case XML_dashDot:
99 case XML_lgDashDot:
100 case XML_sysDashDot:
101 aBorderLine.LineStyle = ::table::BorderLineStyle::DASH_DOT;
102 break;
103 case XML_lgDashDotDot:
104 case XML_sysDashDotDot:
105 aBorderLine.LineStyle = ::table::BorderLineStyle::DASH_DOT_DOT;
106 break;
107 case XML_solid:
108 aBorderLine.LineStyle = ::table::BorderLineStyle::SOLID;
109 break;
110 default:
111 aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED;
112 break;
113 }
114 }
115 else if ( !rLineProperties.maCustomDash.empty() )
116 {
117 aBorderLine.LineStyle = ::table::BorderLineStyle::DASHED;
118 }
119 else
120 {
121 aBorderLine.LineStyle = ::table::BorderLineStyle::NONE;
122 }
123
124 PropertySet aPropSet( rxPropSet );
125 aPropSet.setProperty( nPropId, aBorderLine );
126}
127
128static void applyBorder( const ::oox::core::XmlFilterBase& rFilterBase, TableStylePart& rTableStylePart, sal_Int32 nLineType, oox::drawingml::LineProperties& rLineProperties )
129{
130 std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >& rPartLineBorders( rTableStylePart.getLineBorders() );
131 ::oox::drawingml::ShapeStyleRef& rLineStyleRef = rTableStylePart.getStyleRefs()[ nLineType ];
132 std::map < sal_Int32, ::oox::drawingml::LinePropertiesPtr >::const_iterator aIter( rPartLineBorders.find( nLineType ) );
133 if ( ( aIter != rPartLineBorders.end() ) && aIter->second )
134 rLineProperties.assignUsed( *aIter->second );
135 else if (rLineStyleRef.mnThemedIdx != 0)
136 {
137 if (const Theme* pTheme = rFilterBase.getCurrentTheme())
138 {
139 rLineProperties.assignUsed( *pTheme->getLineStyle(rLineStyleRef.mnThemedIdx) );
140 ::Color nPhClr = rLineStyleRef.maPhClr.getColor( rFilterBase.getGraphicHelper() );
141 rLineProperties.maLineFill.maFillColor.setSrgbClr( nPhClr );
142 }
143 }
144}
145
146static void applyTableStylePart( const ::oox::core::XmlFilterBase& rFilterBase,
147 oox::drawingml::FillProperties& rFillProperties,
148 TextCharacterProperties& aTextCharProps,
150 oox::drawingml::LineProperties& rRightBorder,
152 oox::drawingml::LineProperties& rBottomBorder,
153 oox::drawingml::LineProperties& rInsideHBorder,
154 oox::drawingml::LineProperties& rInsideVBorder,
155 oox::drawingml::LineProperties& rTopLeftToBottomRightBorder,
156 oox::drawingml::LineProperties& rBottomLeftToTopRightBorder,
157 TableStylePart& rTableStylePart,
158 bool bIsWholeTable = false,
159 sal_Int32 nCol = 0,
160 sal_Int32 nMaxCol = 0,
161 sal_Int32 nRow = 0,
162 sal_Int32 nMaxRow = 0)
163{
164 ::oox::drawingml::FillPropertiesPtr& rPartFillPropertiesPtr( rTableStylePart.getFillProperties() );
165 if ( rPartFillPropertiesPtr )
166 rFillProperties.assignUsed( *rPartFillPropertiesPtr );
167 else
168 {
169 ::oox::drawingml::ShapeStyleRef& rFillStyleRef = rTableStylePart.getStyleRefs()[ XML_fillRef ];
170 const Theme* pTheme = rFilterBase.getCurrentTheme();
171 if (pTheme && rFillStyleRef.mnThemedIdx != 0 )
172 {
173 rFillProperties.assignUsed( *pTheme->getFillStyle( rFillStyleRef.mnThemedIdx ) );
174 ::Color nPhClr = rFillStyleRef.maPhClr.getColor( rFilterBase.getGraphicHelper() );
175 rFillProperties.maFillColor.setSrgbClr( nPhClr );
176 }
177 }
178
179 // Left, right, top and bottom side of the whole table should be mean outer frame of the whole table.
180 // Without this check it means left top right and bottom of whole cells of whole table.
181 if (bIsWholeTable)
182 {
183 if (nCol == 0)
184 applyBorder( rFilterBase, rTableStylePart, XML_left, rLeftBorder );
185 if (nCol == nMaxCol)
186 applyBorder( rFilterBase, rTableStylePart, XML_right, rRightBorder );
187 if (nRow == 0)
188 applyBorder( rFilterBase, rTableStylePart, XML_top, rTopBorder );
189 if (nRow == nMaxRow)
190 applyBorder( rFilterBase, rTableStylePart, XML_bottom, rBottomBorder );
191
192 applyBorder( rFilterBase, rTableStylePart, XML_insideH, rInsideHBorder );
193 applyBorder( rFilterBase, rTableStylePart, XML_insideV, rInsideVBorder );
194 applyBorder( rFilterBase, rTableStylePart, XML_tl2br, rTopLeftToBottomRightBorder );
195 applyBorder( rFilterBase, rTableStylePart, XML_tr2bl, rBottomLeftToTopRightBorder );
196 }
197 else
198 {
199 applyBorder( rFilterBase, rTableStylePart, XML_left, rLeftBorder );
200 applyBorder( rFilterBase, rTableStylePart, XML_right, rRightBorder );
201 applyBorder( rFilterBase, rTableStylePart, XML_top, rTopBorder );
202 applyBorder( rFilterBase, rTableStylePart, XML_bottom, rBottomBorder );
203 applyBorder( rFilterBase, rTableStylePart, XML_tl2br, rTopLeftToBottomRightBorder );
204 applyBorder( rFilterBase, rTableStylePart, XML_tr2bl, rBottomLeftToTopRightBorder );
205 applyBorder( rFilterBase, rTableStylePart, XML_insideH, rInsideHBorder );
206 applyBorder( rFilterBase, rTableStylePart, XML_insideV, rInsideVBorder );
207 }
208
209 aTextCharProps.maLatinFont = rTableStylePart.getLatinFont();
210 aTextCharProps.maAsianFont = rTableStylePart.getAsianFont();
211 aTextCharProps.maComplexFont = rTableStylePart.getComplexFont();
212 aTextCharProps.maSymbolFont = rTableStylePart.getSymbolFont();
213 if ( rTableStylePart.getTextColor().isUsed() )
214 {
215 aTextCharProps.maFillProperties.maFillColor = rTableStylePart.getTextColor();
216 aTextCharProps.maFillProperties.moFillType = XML_solidFill;
217 }
218 if( rTableStylePart.getTextBoldStyle() )
219 aTextCharProps.moBold = *rTableStylePart.getTextBoldStyle();
220 if( rTableStylePart.getTextItalicStyle() )
221 aTextCharProps.moItalic = *rTableStylePart.getTextItalicStyle();
222}
223
224static void applyTableCellProperties( const Reference < css::table::XCell >& rxCell, const TableCell& rTableCell )
225{
226 Reference< XPropertySet > xPropSet( rxCell, UNO_QUERY_THROW );
227 xPropSet->setPropertyValue( "TextUpperDistance", Any( static_cast< sal_Int32 >( rTableCell.getTopMargin() / 360 ) ) );
228 xPropSet->setPropertyValue( "TextRightDistance", Any( static_cast< sal_Int32 >( rTableCell.getRightMargin() / 360 ) ) );
229 xPropSet->setPropertyValue( "TextLeftDistance", Any( static_cast< sal_Int32 >( rTableCell.getLeftMargin() / 360 ) ) );
230 xPropSet->setPropertyValue( "TextLowerDistance", Any( static_cast< sal_Int32 >( rTableCell.getBottomMargin() / 360 ) ) );
231
232 drawing::TextVerticalAdjust eVA;
233 switch( rTableCell.getAnchorToken() )
234 {
235 case XML_ctr: eVA = drawing::TextVerticalAdjust_CENTER; break;
236 case XML_b: eVA = drawing::TextVerticalAdjust_BOTTOM; break;
237 case XML_just:
238 case XML_dist:
239 default:
240 case XML_t: eVA = drawing::TextVerticalAdjust_TOP; break;
241 }
242 xPropSet->setPropertyValue( "TextVerticalAdjust", Any( eVA ) );
243}
244
245void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, const ::oox::drawingml::TextListStylePtr& pMasterTextListStyle,
246 const css::uno::Reference < css::table::XCell >& rxCell, const TableProperties& rTableProperties,
247 const TableStyle& rTableStyle, sal_Int32 nColumn, sal_Int32 nMaxColumn, sal_Int32 nRow, sal_Int32 nMaxRow )
248{
249 TableStyle& rTable( const_cast< TableStyle& >( rTableStyle ) );
250 TableProperties& rProperties( const_cast< TableProperties& >( rTableProperties ) );
251
252 Reference< text::XText > xText( rxCell, UNO_QUERY_THROW );
253 Reference< text::XTextCursor > xAt = xText->createTextCursor();
254
255 applyTableCellProperties( rxCell, *this );
256 TextCharacterProperties aTextStyleProps;
257 xAt->gotoStart( true );
258 xAt->gotoEnd( true );
259
260 Reference< XPropertySet > xPropSet( rxCell, UNO_QUERY_THROW );
261 oox::drawingml::FillProperties aFillProperties;
262 oox::drawingml::LineProperties aLinePropertiesLeft;
263 oox::drawingml::LineProperties aLinePropertiesRight;
264 oox::drawingml::LineProperties aLinePropertiesTop;
265 oox::drawingml::LineProperties aLinePropertiesBottom;
266 oox::drawingml::LineProperties aLinePropertiesInsideH;
267 oox::drawingml::LineProperties aLinePropertiesInsideV;
268 oox::drawingml::LineProperties aLinePropertiesTopLeftToBottomRight;
269 oox::drawingml::LineProperties aLinePropertiesBottomLeftToTopRight;
270
271 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
272 aLinePropertiesLeft,
273 aLinePropertiesRight,
274 aLinePropertiesTop,
275 aLinePropertiesBottom,
276 aLinePropertiesInsideH,
277 aLinePropertiesInsideV,
278 aLinePropertiesTopLeftToBottomRight,
279 aLinePropertiesBottomLeftToTopRight,
280 rTable.getWholeTbl(),
281 true,
282 nColumn,
283 nMaxColumn,
284 nRow,
285 nMaxRow );
286
287 if ( rProperties.isFirstRow() && ( nRow == 0 ) )
288 {
289 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
290 aLinePropertiesLeft,
291 aLinePropertiesRight,
292 aLinePropertiesTop,
293 aLinePropertiesBottom,
294 aLinePropertiesInsideH,
295 aLinePropertiesInsideV,
296 aLinePropertiesTopLeftToBottomRight,
297 aLinePropertiesBottomLeftToTopRight,
298 rTable.getFirstRow() );
299 }
300 if ( rProperties.isLastRow() && ( nRow == nMaxRow ) )
301 {
302 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
303 aLinePropertiesLeft,
304 aLinePropertiesRight,
305 aLinePropertiesTop,
306 aLinePropertiesBottom,
307 aLinePropertiesInsideH,
308 aLinePropertiesInsideV,
309 aLinePropertiesTopLeftToBottomRight,
310 aLinePropertiesBottomLeftToTopRight,
311 rTable.getLastRow() );
312 }
313 if ( rProperties.isFirstCol() && ( nColumn == 0 ) )
314 {
315 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
316 aLinePropertiesLeft,
317 aLinePropertiesRight,
318 aLinePropertiesTop,
319 aLinePropertiesBottom,
320 aLinePropertiesInsideH,
321 aLinePropertiesInsideV,
322 aLinePropertiesTopLeftToBottomRight,
323 aLinePropertiesBottomLeftToTopRight,
324 rTable.getFirstCol() );
325 }
326 if ( rProperties.isLastCol() && ( nColumn == nMaxColumn ) )
327 {
328 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
329 aLinePropertiesLeft,
330 aLinePropertiesRight,
331 aLinePropertiesTop,
332 aLinePropertiesBottom,
333 aLinePropertiesInsideH,
334 aLinePropertiesInsideV,
335 aLinePropertiesTopLeftToBottomRight,
336 aLinePropertiesBottomLeftToTopRight,
337 rTable.getLastCol() );
338 }
339 if ( rProperties.isBandRow() )
340 {
341 if ( ( !rProperties.isFirstRow() || ( nRow != 0 ) ) &&
342 ( !rProperties.isLastRow() || ( nRow != nMaxRow ) ) &&
343 ( !rProperties.isFirstCol() || ( nColumn != 0 ) ) &&
344 ( !rProperties.isLastCol() || ( nColumn != nMaxColumn ) ) )
345 {
346 sal_Int32 nBand = nRow;
347 if ( rProperties.isFirstRow() )
348 nBand++;
349 if ( nBand & 1 )
350 {
351 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
352 aLinePropertiesLeft,
353 aLinePropertiesRight,
354 aLinePropertiesTop,
355 aLinePropertiesBottom,
356 aLinePropertiesInsideH,
357 aLinePropertiesInsideV,
358 aLinePropertiesTopLeftToBottomRight,
359 aLinePropertiesBottomLeftToTopRight,
360 rTable.getBand2H() );
361 }
362 else
363 {
364 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
365 aLinePropertiesLeft,
366 aLinePropertiesRight,
367 aLinePropertiesTop,
368 aLinePropertiesBottom,
369 aLinePropertiesInsideH,
370 aLinePropertiesInsideV,
371 aLinePropertiesTopLeftToBottomRight,
372 aLinePropertiesBottomLeftToTopRight,
373 rTable.getBand1H() );
374 }
375 }
376 }
377 if ( ( nRow == 0 ) && ( nColumn == 0 ) )
378 {
379 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
380 aLinePropertiesLeft,
381 aLinePropertiesRight,
382 aLinePropertiesTop,
383 aLinePropertiesBottom,
384 aLinePropertiesInsideH,
385 aLinePropertiesInsideV,
386 aLinePropertiesTopLeftToBottomRight,
387 aLinePropertiesBottomLeftToTopRight,
388 rTable.getNwCell() );
389 }
390 if ( ( nRow == nMaxRow ) && ( nColumn == 0 ) )
391 {
392 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
393 aLinePropertiesLeft,
394 aLinePropertiesRight,
395 aLinePropertiesTop,
396 aLinePropertiesBottom,
397 aLinePropertiesInsideH,
398 aLinePropertiesInsideV,
399 aLinePropertiesTopLeftToBottomRight,
400 aLinePropertiesBottomLeftToTopRight,
401 rTable.getSwCell() );
402 }
403 if ( ( nRow == 0 ) && ( nColumn == nMaxColumn ) )
404 {
405 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
406 aLinePropertiesLeft,
407 aLinePropertiesRight,
408 aLinePropertiesTop,
409 aLinePropertiesBottom,
410 aLinePropertiesInsideH,
411 aLinePropertiesInsideV,
412 aLinePropertiesTopLeftToBottomRight,
413 aLinePropertiesBottomLeftToTopRight,
414 rTable.getNeCell() );
415 }
416 if ( ( nRow == nMaxRow ) && ( nColumn == nMaxColumn ) )
417 {
418 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
419 aLinePropertiesLeft,
420 aLinePropertiesRight,
421 aLinePropertiesTop,
422 aLinePropertiesBottom,
423 aLinePropertiesInsideH,
424 aLinePropertiesInsideV,
425 aLinePropertiesTopLeftToBottomRight,
426 aLinePropertiesBottomLeftToTopRight,
427 rTable.getSeCell() );
428 }
429 if ( rProperties.isBandCol() )
430 {
431 if ( ( !rProperties.isFirstRow() || ( nRow != 0 ) ) &&
432 ( !rProperties.isLastRow() || ( nRow != nMaxRow ) ) &&
433 ( !rProperties.isFirstCol() || ( nColumn != 0 ) ) &&
434 ( !rProperties.isLastCol() || ( nColumn != nMaxColumn ) ) )
435 {
436 sal_Int32 nBand = nColumn;
437 if ( rProperties.isFirstCol() )
438 nBand++;
439 if ( nBand & 1 )
440 {
441 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
442 aLinePropertiesLeft,
443 aLinePropertiesRight,
444 aLinePropertiesTop,
445 aLinePropertiesBottom,
446 aLinePropertiesInsideH,
447 aLinePropertiesInsideV,
448 aLinePropertiesTopLeftToBottomRight,
449 aLinePropertiesBottomLeftToTopRight,
450 rTable.getBand2V() );
451 }
452 else
453 {
454 applyTableStylePart( rFilterBase, aFillProperties, aTextStyleProps,
455 aLinePropertiesLeft,
456 aLinePropertiesRight,
457 aLinePropertiesTop,
458 aLinePropertiesBottom,
459 aLinePropertiesInsideH,
460 aLinePropertiesInsideV,
461 aLinePropertiesTopLeftToBottomRight,
462 aLinePropertiesBottomLeftToTopRight,
463 rTable.getBand1V() );
464 }
465 }
466 }
467 aLinePropertiesLeft.assignUsed( maLinePropertiesLeft );
468 aLinePropertiesRight.assignUsed( maLinePropertiesRight );
469 aLinePropertiesTop.assignUsed( maLinePropertiesTop );
470 aLinePropertiesBottom.assignUsed( maLinePropertiesBottom );
471 aLinePropertiesInsideH.assignUsed( maLinePropertiesInsideH );
472 aLinePropertiesInsideV.assignUsed( maLinePropertiesInsideV );
473 aLinePropertiesTopLeftToBottomRight.assignUsed( maLinePropertiesTopLeftToBottomRight );
474 aLinePropertiesBottomLeftToTopRight.assignUsed( maLinePropertiesBottomLeftToTopRight );
475
476 applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesLeft, PROP_LeftBorder );
477 applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesRight, PROP_RightBorder );
478 applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesTop, PROP_TopBorder );
479 applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesBottom, PROP_BottomBorder );
480 applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesTopLeftToBottomRight, PROP_DiagonalTLBR );
481 applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesBottomLeftToTopRight, PROP_DiagonalBLTR );
482
483 // Convert insideH to Top and Bottom, InsideV to Left and Right. Exclude the outer borders.
484 if(nRow != 0)
485 {
486 aLinePropertiesInsideH.assignUsed( aLinePropertiesTop );
487 applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideH, PROP_TopBorder );
488 }
489 if(nRow != nMaxRow)
490 {
491 aLinePropertiesInsideH.assignUsed( aLinePropertiesBottom );
492 applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideH, PROP_BottomBorder );
493 }
494 if(nColumn != 0)
495 {
496 aLinePropertiesInsideV.assignUsed( aLinePropertiesLeft );
497 applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideV, PROP_LeftBorder );
498 }
499 if(nColumn != nMaxColumn)
500 {
501 aLinePropertiesInsideV.assignUsed( aLinePropertiesRight );
502 applyLineAttributes( rFilterBase, xPropSet, aLinePropertiesInsideV, PROP_RightBorder );
503 }
504
505 if (rProperties.getBgColor().isUsed() && !maFillProperties.maFillColor.isUsed() && maFillProperties.moFillType.value() == XML_noFill)
506 {
507 maFillProperties.moFillType = XML_solidFill;
509 }
510
511 aFillProperties.assignUsed( maFillProperties );
512 ShapePropertyMap aPropMap( rFilterBase.getModelObjectHelper() );
513
514 Color aBgColor;
516 std::shared_ptr< ::oox::drawingml::FillProperties >& rBackgroundFillPropertiesPtr( rTable.getBackgroundFillProperties() );
517 ::oox::drawingml::ShapeStyleRef& rBackgroundFillStyle( rTable.getBackgroundFillStyleRef() );
518 if (rBackgroundFillPropertiesPtr)
519 aBgColor = rBackgroundFillPropertiesPtr->getBestSolidColor();
520 else if (rBackgroundFillStyle.mnThemedIdx != 0)
521 {
522 if (const Theme* pTheme = rFilterBase.getCurrentTheme())
523 {
524 aBgColor = pTheme->getFillStyle(rBackgroundFillStyle.mnThemedIdx)->getBestSolidColor();
525 nPhClr = rBackgroundFillStyle.maPhClr.getColor(rFilterBase.getGraphicHelper());
526 }
527 }
528 if (aBgColor.isUsed())
529 {
530 const Color& rCellColor = aFillProperties.getBestSolidColor();
531 const double fTransparency = rCellColor.isUsed() ? 0.01 * rCellColor.getTransparency() : 1.0;
532 ::Color nBgColor( aBgColor.getColor(rFilterBase.getGraphicHelper(), nPhClr) );
533 ::Color nCellColor( rCellColor.getColor(rFilterBase.getGraphicHelper()) );
534 ::Color aResult( basegfx::interpolate(nBgColor.getBColor(), nCellColor.getBColor(), 1.0 - fTransparency) );
535 aFillProperties.maFillColor.clearTransformations();
536 aFillProperties.maFillColor.setSrgbClr(sal_Int32(aResult.GetRGBColor()));
537 aFillProperties.moFillType = XML_solidFill;
538 }
539 if (!aFillProperties.moFillType.has_value())
540 aFillProperties.moFillType = XML_noFill;
541
542 // TODO: phClr?
543 aFillProperties.pushToPropMap( aPropMap, rFilterBase.getGraphicHelper() );
544 PropertySet( xPropSet ).setProperties( aPropMap );
545
546 if ( getVertToken() == XML_eaVert )
547 {
548 xPropSet->setPropertyValue("TextWritingMode", Any(css::text::WritingMode_TB_RL));
549 }
550
551 getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, pMasterTextListStyle );
552
553 if (getVertToken() == XML_vert)
554 xPropSet->setPropertyValue("RotateAngle", Any(short(27000)));
555 else if (getVertToken() == XML_vert270)
556 xPropSet->setPropertyValue("RotateAngle", Any(short(9000)));
557}
558
559}
560
561/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Color GetRGBColor() const
basegfx::BColor getBColor() const
A wrapper for a UNO property set.
Definition: propertyset.hxx:58
void setProperties(const css::uno::Sequence< OUString > &rPropNames, const css::uno::Sequence< css::uno::Any > &rValues)
Puts the passed properties into the property set.
bool setProperty(sal_Int32 nPropId, const Type &rValue)
Puts the passed value into the property set.
sal_Int16 getTransparency() const
Returns the transparency of the color (0 = opaque, 100 = full transparent).
Definition: color.cxx:708
void clearTransformations()
Removes all color transformations.
Definition: color.cxx:362
bool isUsed() const
Returns true, if the color is initialized.
Definition: color.hxx:87
::Color getColor(const GraphicHelper &rGraphicHelper, ::Color nPhClr=API_RGB_TRANSPARENT) const
Returns the final RGB color value.
Definition: color.cxx:531
void setSrgbClr(sal_Int32 nRgb)
Sets an RGB value (hexadecimal RRGGBB) from the a:srgbClr element.
Definition: color.cxx:260
const FillProperties * getFillStyle(sal_Int32 nIndex) const
Returns the fill properties of the passed one-based themed style index.
Definition: theme.cxx:43
oox::drawingml::FillProperties maFillProperties
Definition: tablecell.hxx:90
const oox::drawingml::TextBodyPtr & getTextBody() const
Definition: tablecell.hxx:68
sal_Int32 getTopMargin() const
Definition: tablecell.hxx:56
oox::drawingml::LineProperties maLinePropertiesTopLeftToBottomRight
Definition: tablecell.hxx:87
oox::drawingml::LineProperties maLinePropertiesBottomLeftToTopRight
Definition: tablecell.hxx:88
sal_Int32 getBottomMargin() const
Definition: tablecell.hxx:58
sal_Int32 getLeftMargin() const
Definition: tablecell.hxx:52
sal_Int32 getVertToken() const
Definition: tablecell.hxx:60
sal_Int32 getRightMargin() const
Definition: tablecell.hxx:54
oox::drawingml::LineProperties maLinePropertiesInsideV
Definition: tablecell.hxx:86
oox::drawingml::LineProperties maLinePropertiesLeft
Definition: tablecell.hxx:81
void pushToXCell(const ::oox::core::XmlFilterBase &rFilterBase, const ::oox::drawingml::TextListStylePtr &pMasterTextListStyle, const css::uno::Reference< css::table::XCell > &rxCell, const TableProperties &rTableProperties, const TableStyle &rTable, sal_Int32 nColumn, sal_Int32 nMaxColumn, sal_Int32 nRow, sal_Int32 nMaxRow)
Definition: tablecell.cxx:245
oox::drawingml::LineProperties maLinePropertiesTop
Definition: tablecell.hxx:83
oox::drawingml::LineProperties maLinePropertiesRight
Definition: tablecell.hxx:82
oox::drawingml::LineProperties maLinePropertiesBottom
Definition: tablecell.hxx:84
sal_Int32 getAnchorToken() const
Definition: tablecell.hxx:62
oox::drawingml::LineProperties maLinePropertiesInsideH
Definition: tablecell.hxx:85
::oox::drawingml::TextFont & getSymbolFont()
::oox::drawingml::ShapeStyleRefMap & getStyleRefs()
::oox::drawingml::TextFont & getComplexFont()
::std::optional< bool > & getTextBoldStyle()
::oox::drawingml::TextFont & getLatinFont()
::std::optional< bool > & getTextItalicStyle()
::oox::drawingml::Color & getTextColor()
::oox::drawingml::FillPropertiesPtr & getFillProperties()
::oox::drawingml::TextFont & getAsianFont()
std::map< sal_Int32, ::oox::drawingml::LinePropertiesPtr > & getLineBorders()
::oox::drawingml::ShapeStyleRef & getBackgroundFillStyleRef()
Definition: tablestyle.hxx:38
TableStylePart & getWholeTbl()
Definition: tablestyle.hxx:42
::oox::drawingml::FillPropertiesPtr & getBackgroundFillProperties()
Definition: tablestyle.hxx:40
TableStylePart & getFirstCol()
Definition: tablestyle.hxx:48
TableStylePart & getFirstRow()
Definition: tablestyle.hxx:52
constexpr ::Color COL_AUTO(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
B2DTuple interpolate(const B2DTuple &rOld1, const B2DTuple &rOld2, double t)
std::shared_ptr< T > make_shared(Args &&... args)
static void applyLineAttributes(const ::oox::core::XmlFilterBase &rFilterBase, Reference< XPropertySet > const &rxPropSet, oox::drawingml::LineProperties const &rLineProperties, sal_Int32 nPropId)
Definition: tablecell.cxx:62
static void applyBorder(const ::oox::core::XmlFilterBase &rFilterBase, TableStylePart &rTableStylePart, sal_Int32 nLineType, oox::drawingml::LineProperties &rLineProperties)
Definition: tablecell.cxx:128
static void applyTableCellProperties(const Reference< css::table::XCell > &rxCell, const TableCell &rTableCell)
Definition: tablecell.cxx:224
static void applyTableStylePart(const ::oox::core::XmlFilterBase &rFilterBase, oox::drawingml::FillProperties &rFillProperties, TextCharacterProperties &aTextCharProps, oox::drawingml::LineProperties &rLeftBorder, oox::drawingml::LineProperties &rRightBorder, oox::drawingml::LineProperties &rTopBorder, oox::drawingml::LineProperties &rBottomBorder, oox::drawingml::LineProperties &rInsideHBorder, oox::drawingml::LineProperties &rInsideVBorder, oox::drawingml::LineProperties &rTopLeftToBottomRightBorder, oox::drawingml::LineProperties &rBottomLeftToTopRightBorder, TableStylePart &rTableStylePart, bool bIsWholeTable=false, sal_Int32 nCol=0, sal_Int32 nMaxCol=0, sal_Int32 nRow=0, sal_Int32 nMaxRow=0)
Definition: tablecell.cxx:146
sal_Int32 GetCoordinate(sal_Int32 nValue)
converts EMUs into 1/100th mmm
std::shared_ptr< FillProperties > FillPropertiesPtr
std::shared_ptr< TextListStyle > TextListStylePtr
const ::Color API_RGB_TRANSPARENT(ColorTransparency, 0xffffffff)
Transparent color for API calls.
void pushToPropMap(ShapePropertyMap &rPropMap, const GraphicHelper &rGraphicHelper, sal_Int32 nShapeRotation=0, ::Color nPhClr=API_RGB_TRANSPARENT, sal_Int16 nPhClrTheme=-1, bool bFlipH=false, bool bFlipV=false, bool bIsCustomShape=false) const
Writes the properties to the passed property map.
void assignUsed(const FillProperties &rSourceProps)
Properties for bitmap fills.
Color getBestSolidColor() const
Tries to resolve current settings to a solid color, e.g.
Color maFillColor
Fill type (OOXML token).
std::optional< sal_Int32 > moFillType
void assignUsed(const LineProperties &rSourceProps)
Line joint type (OOXML token).
FillProperties maLineFill
End line arrow style.
std::optional< sal_Int32 > moLineWidth
User-defined line dash style.
std::optional< sal_Int32 > moPresetDash
Line width (EMUs).
DashStopVector maCustomDash
Line fill (solid, gradient, ...).
sal_Int32 mnRowSpan