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