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