1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <hintids.hxx>
#include <vcl/svapp.hxx>
#include <svtools/htmlout.hxx>
#include <svtools/htmltokn.h>
#include <svtools/htmlkywd.hxx>
#include <svtools/HtmlWriter.hxx>
#include <editeng/ulspitem.hxx>
#include <editeng/lrspitem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/boxitem.hxx>
#include <fmtornt.hxx>
#include <frmfmt.hxx>
#include <fmtfsize.hxx>
#include <fmtsrnd.hxx>
#include <frmatr.hxx>
#include <doc.hxx>
#include <IDocumentLayoutAccess.hxx>
#include <pam.hxx>
#include <ndtxt.hxx>
#include <swrect.hxx>
#include <cellatr.hxx>
#include <poolfmt.hxx>
#include <swtable.hxx>
#include <htmltbl.hxx>
#include "htmlnum.hxx"
#include "wrthtml.hxx"
#include <wrtswtbl.hxx>
#ifdef DBG_UTIL
#include <viewsh.hxx>
#include <viewopt.hxx>
#endif
#include <rtl/strbuf.hxx>
#include <sal/types.h>
#include <osl/diagnose.h>
#define MAX_DEPTH (3)
using namespace ::com::sun::star;
namespace {
class SwHTMLWrtTable : public SwWriteTable
{
static void Pixelize( sal_uInt16& rValue );
void PixelizeBorders();
void OutTableCell( SwHTMLWriter& rWrt, const SwWriteTableCell *pCell,
bool bOutVAlign ) const;
void OutTableCells( SwHTMLWriter& rWrt,
const SwWriteTableCells& rCells,
const SvxBrushItem *pBrushItem ) const;
virtual bool ShouldExpandSub( const SwTableBox *pBox,
bool bExpandedBefore, sal_uInt16 nDepth ) const override;
static bool HasTabBackground( const SwTableLine& rLine,
bool bTop, bool bBottom, bool bLeft, bool bRight );
static bool HasTabBackground( const SwTableBox& rBox,
bool bTop, bool bBottom, bool bLeft, bool bRight );
public:
SwHTMLWrtTable( const SwTableLines& rLines, tools::Long nWidth, sal_uInt32 nBWidth,
bool bRel, sal_uInt16 nLeftSub, sal_uInt16 nRightSub,
sal_uInt16 nNumOfRowsToRepeat );
explicit SwHTMLWrtTable( const SwHTMLTableLayout *pLayoutInfo );
void Write( SwHTMLWriter& rWrt, sal_Int16 eAlign=text::HoriOrientation::NONE,
bool bTHead=false, const SwFrameFormat *pFrameFormat=nullptr,
const OUString *pCaption=nullptr, bool bTopCaption=false,
sal_uInt16 nHSpace=0, sal_uInt16 nVSpace=0 ) const;
};
}
SwHTMLWrtTable::SwHTMLWrtTable( const SwTableLines& rLines, tools::Long nWidth,
sal_uInt32 nBWidth, bool bRel,
sal_uInt16 nLSub, sal_uInt16 nRSub,
sal_uInt16 nNumOfRowsToRepeat )
: SwWriteTable(nullptr, rLines, nWidth, nBWidth, bRel, MAX_DEPTH, nLSub, nRSub, nNumOfRowsToRepeat)
{
PixelizeBorders();
}
SwHTMLWrtTable::SwHTMLWrtTable( const SwHTMLTableLayout *pLayoutInfo )
: SwWriteTable(nullptr, pLayoutInfo)
{
// Adjust some Twip values to pixel limits
if( m_bCollectBorderWidth )
PixelizeBorders();
}
void SwHTMLWrtTable::Pixelize( sal_uInt16& rValue )
{
if( rValue && Application::GetDefaultDevice() )
{
Size aSz( rValue, 0 );
aSz = Application::GetDefaultDevice()->LogicToPixel( aSz, MapMode(MapUnit::MapTwip) );
if( !aSz.Width() )
aSz.setWidth( 1 );
aSz = Application::GetDefaultDevice()->PixelToLogic( aSz, MapMode(MapUnit::MapTwip) );
rValue = o3tl::narrowing<sal_uInt16>(aSz.Width());
}
}
void SwHTMLWrtTable::PixelizeBorders()
{
Pixelize( m_nBorder );
Pixelize( m_nCellSpacing );
Pixelize( m_nCellPadding );
}
bool SwHTMLWrtTable::HasTabBackground( const SwTableBox& rBox,
bool bTop, bool bBottom, bool bLeft, bool bRight )
{
OSL_ENSURE( bTop || bBottom || bLeft || bRight,
"HasTabBackground: cannot be called" );
bool bRet = false;
if( rBox.GetSttNd() )
{
std::unique_ptr<SvxBrushItem> aBrushItem =
rBox.GetFrameFormat()->makeBackgroundBrushItem();
/// The table box has a background, if its background color is not "no fill"/
/// "auto fill" or it has a background graphic.
bRet = aBrushItem->GetColor() != COL_TRANSPARENT ||
!aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic();
}
else
{
const SwTableLines& rLines = rBox.GetTabLines();
const SwTableLines::size_type nCount = rLines.size();
bool bLeftRight = bLeft || bRight;
for( SwTableLines::size_type i=0; !bRet && i<nCount; ++i )
{
bool bT = bTop && 0 == i;
bool bB = bBottom && nCount-1 == i;
if( bT || bB || bLeftRight )
bRet = HasTabBackground( *rLines[i], bT, bB, bLeft, bRight);
}
}
return bRet;
}
bool SwHTMLWrtTable::HasTabBackground( const SwTableLine& rLine,
bool bTop, bool bBottom, bool bLeft, bool bRight )
{
OSL_ENSURE( bTop || bBottom || bLeft || bRight,
"HasTabBackground: cannot be called" );
std::unique_ptr<SvxBrushItem> aBrushItem = rLine.GetFrameFormat()->makeBackgroundBrushItem();
/// The table line has a background, if its background color is not "no fill"/
/// "auto fill" or it has a background graphic.
bool bRet = aBrushItem->GetColor() != COL_TRANSPARENT ||
!aBrushItem->GetGraphicLink().isEmpty() || aBrushItem->GetGraphic();
if( !bRet )
{
const SwTableBoxes& rBoxes = rLine.GetTabBoxes();
const SwTableBoxes::size_type nCount = rBoxes.size();
bool bTopBottom = bTop || bBottom;
for( SwTableBoxes::size_type i=0; !bRet && i<nCount; ++i )
{
bool bL = bLeft && 0 == i;
bool bR = bRight && nCount-1 == i;
if( bTopBottom || bL || bR )
bRet = HasTabBackground( *rBoxes[i], bTop, bBottom, bL, bR );
}
}
return bRet;
}
static bool lcl_TableLine_HasTabBorders( const SwTableLine* pLine, bool *pBorders );
static bool lcl_TableBox_HasTabBorders( const SwTableBox* pBox, bool *pBorders )
{
if( *pBorders )
return false;
if( !pBox->GetSttNd() )
{
for( const auto& rpLine : pBox->GetTabLines() )
{
if ( lcl_TableLine_HasTabBorders( rpLine, pBorders ) )
break;
}
}
else
{
const SvxBoxItem& rBoxItem =
pBox->GetFrameFormat()->GetFormatAttr( RES_BOX );
*pBorders = rBoxItem.GetTop() || rBoxItem.GetBottom() ||
rBoxItem.GetLeft() || rBoxItem.GetRight();
}
return !*pBorders;
}
static bool lcl_TableLine_HasTabBorders( const SwTableLine* pLine, bool *pBorders )
{
if( *pBorders )
return false;
for( const auto& rpBox : pLine->GetTabBoxes() )
{
if ( lcl_TableBox_HasTabBorders( rpBox, pBorders ) )
break;
}
return !*pBorders;
}
bool SwHTMLWrtTable::ShouldExpandSub( const SwTableBox *pBox,
bool bExpandedBefore,
sal_uInt16 nDepth ) const
{
bool bExpand = !pBox->GetSttNd() && nDepth>0;
if( bExpand && bExpandedBefore )
{
// MIB 30.6.97: If a box was already expanded, another one is only
// expanded when it has a border.
bool bBorders = false;
lcl_TableBox_HasTabBorders( pBox, &bBorders );
if( !bBorders )
bBorders = HasTabBackground( *pBox, true, true, true, true );
bExpand = bBorders;
}
return bExpand;
}
// Write a box as single cell
void SwHTMLWrtTable::OutTableCell( SwHTMLWriter& rWrt,
const SwWriteTableCell *pCell,
bool bOutVAlign ) const
{
const SwTableBox *pBox = pCell->GetBox();
sal_uInt16 nRow = pCell->GetRow();
sal_uInt16 nCol = pCell->GetCol();
sal_uInt16 nRowSpan = pCell->GetRowSpan();
sal_uInt16 nColSpan = pCell->GetColSpan();
if ( !nRowSpan )
return;
const SwStartNode* pSttNd = pBox->GetSttNd();
bool bHead = false;
if( pSttNd )
{
SwNodeOffset nNdPos = pSttNd->GetIndex()+1;
// determine the type of cell (TD/TH)
SwNode* pNd;
while( !( pNd = rWrt.m_pDoc->GetNodes()[nNdPos])->IsEndNode() )
{
if( pNd->IsTextNode() )
{
// The only paragraphs relevant for the distinction are those
// where the style is one of the two table related styles
// or inherits from one of these.
const SwFormat *pFormat = &static_cast<SwTextNode*>(pNd)->GetAnyFormatColl();
sal_uInt16 nPoolId = pFormat->GetPoolFormatId();
while( !pFormat->IsDefault() &&
RES_POOLCOLL_TABLE_HDLN!=nPoolId &&
RES_POOLCOLL_TABLE!=nPoolId )
{
pFormat = pFormat->DerivedFrom();
nPoolId = pFormat->GetPoolFormatId();
}
if( !pFormat->IsDefault() )
{
bHead = (RES_POOLCOLL_TABLE_HDLN==nPoolId);
break;
}
}
nNdPos++;
}
}
rWrt.OutNewLine(); // <TH>/<TD> in new line
OStringBuffer sOut;
sOut.append('<');
OString aTag(bHead ? OOO_STRING_SVTOOLS_HTML_tableheader : OOO_STRING_SVTOOLS_HTML_tabledata);
sOut.append(rWrt.GetNamespace() + aTag);
// output ROW- and COLSPAN
if( nRowSpan>1 )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_rowspan
"=\"" + OString::number(nRowSpan) + "\"");
}
if( nColSpan > 1 )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_colspan
"=\"" + OString::number(nColSpan) + "\"");
}
tools::Long nWidth = 0;
bool bOutWidth = true;
sal_uInt32 nPercentWidth = SAL_MAX_UINT32;
if( m_bLayoutExport )
{
if( pCell->HasPercentWidthOpt() )
{
nPercentWidth = pCell->GetWidthOpt();
}
else
{
nWidth = pCell->GetWidthOpt();
if( !nWidth )
bOutWidth = false;
}
}
else
{
if( HasRelWidths() )
nPercentWidth = GetPercentWidth(nCol, nColSpan);
else
nWidth = GetAbsWidth( nCol, nColSpan );
}
if (rWrt.mbReqIF)
// ReqIF implies strict XHTML: no width for <td>.
bOutWidth = false;
tools::Long nHeight = pCell->GetHeight() > 0
? GetAbsHeight( pCell->GetHeight(), nRow, nRowSpan )
: 0;
Size aPixelSz( nWidth, nHeight );
// output WIDTH (Argh: only for Netscape)
if( (aPixelSz.Width() || aPixelSz.Height()) && Application::GetDefaultDevice() )
{
Size aOldSz( aPixelSz );
aPixelSz = Application::GetDefaultDevice()->LogicToPixel( aPixelSz,
MapMode(MapUnit::MapTwip) );
if( aOldSz.Width() && !aPixelSz.Width() )
aPixelSz.setWidth( 1 );
if( aOldSz.Height() && !aPixelSz.Height() )
aPixelSz.setHeight( 1 );
}
// output WIDTH: from layout or calculated
if( bOutWidth )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_width "=\"");
if( nPercentWidth != SAL_MAX_UINT32 )
{
sOut.append(static_cast<sal_Int32>(nPercentWidth)).append('%');
}
else
{
sOut.append(static_cast<sal_Int32>(aPixelSz.Width()));
}
sOut.append("\"");
}
if (rWrt.mbReqIF)
{
// ReqIF implies strict XHTML: no height for <td>.
nHeight = 0;
}
if( nHeight )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_height
"=\"" + OString::number(aPixelSz.Height()) + "\"");
}
const SfxItemSet& rItemSet = pBox->GetFrameFormat()->GetAttrSet();
// ALIGN is only outputted at the paragraphs from now on
// output VALIGN
if( bOutVAlign )
{
sal_Int16 eVertOri = pCell->GetVertOri();
if( text::VertOrientation::TOP==eVertOri || text::VertOrientation::BOTTOM==eVertOri )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_valign
"=\"").append(text::VertOrientation::TOP==eVertOri ?
OOO_STRING_SVTOOLS_HTML_VA_top :
OOO_STRING_SVTOOLS_HTML_VA_bottom)
.append("\"");
}
}
rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
rWrt.m_bTextAttr = false;
rWrt.m_bOutOpts = true;
const SvxBrushItem *pBrushItem = rItemSet.GetItemIfSet( RES_BACKGROUND, false );
if( !pBrushItem )
pBrushItem = pCell->GetBackground();
if( pBrushItem )
{
// output background
if (!rWrt.mbReqIF)
// Avoid non-CSS version in the ReqIF case.
rWrt.OutBackground( pBrushItem, false );
if (!rWrt.m_bCfgOutStyles)
pBrushItem = nullptr;
}
// tdf#132739 with rWrt.m_bCfgOutStyles of true bundle the brush item css
// properties into the same "style" tag as the borders so there is only one
// style tag
rWrt.OutCSS1_TableCellBordersAndBG(*pBox->GetFrameFormat(), pBrushItem);
sal_uInt32 nNumFormat = 0;
double nValue = 0.0;
bool bNumFormat = false, bValue = false;
if( const SwTableBoxNumFormat* pItem = rItemSet.GetItemIfSet( RES_BOXATR_FORMAT, false ) )
{
nNumFormat = pItem->GetValue();
bNumFormat = true;
}
if( const SwTableBoxValue* pItem = rItemSet.GetItemIfSet( RES_BOXATR_VALUE, false ) )
{
nValue = pItem->GetValue();
bValue = true;
if( !bNumFormat )
nNumFormat = pBox->GetFrameFormat()->GetTableBoxNumFormat().GetValue();
}
if( bNumFormat || bValue )
{
sOut.append(HTMLOutFuncs::CreateTableDataOptionsValNum(bValue, nValue,
nNumFormat, *rWrt.m_pDoc->GetNumberFormatter()));
}
sOut.append('>');
rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
rWrt.m_bLFPossible = true;
rWrt.IncIndentLevel(); // indent the content of <TD>...</TD>
if( pSttNd )
{
HTMLSaveData aSaveData( rWrt, pSttNd->GetIndex()+1,
pSttNd->EndOfSectionIndex() );
rWrt.Out_SwDoc( rWrt.m_pCurrentPam.get() );
}
else
{
sal_uInt16 nTWidth;
sal_uInt32 nBWidth;
sal_uInt16 nLSub, nRSub;
if( HasRelWidths() )
{
nTWidth = 100;
nBWidth = GetRawWidth( nCol, nColSpan );
nLSub = 0;
nRSub = 0;
}
else
{
nTWidth = GetAbsWidth( nCol, nColSpan );
nBWidth = nTWidth;
nLSub = GetLeftSpace( nCol );
nRSub = GetRightSpace( nCol, nColSpan );
}
SwHTMLWrtTable aTableWrt( pBox->GetTabLines(), nTWidth,
nBWidth, HasRelWidths(), nLSub, nRSub, /*nNumOfRowsToRepeat*/0 );
aTableWrt.Write( rWrt );
}
rWrt.DecIndentLevel(); // indent the content of <TD>...</TD>
if( rWrt.m_bLFPossible )
rWrt.OutNewLine();
aTag = bHead ? OOO_STRING_SVTOOLS_HTML_tableheader : OOO_STRING_SVTOOLS_HTML_tabledata;
HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + aTag), false);
rWrt.m_bLFPossible = true;
}
// output a line as lines
void SwHTMLWrtTable::OutTableCells( SwHTMLWriter& rWrt,
const SwWriteTableCells& rCells,
const SvxBrushItem *pBrushItem ) const
{
// If the line contains more the one cell and all cells have the same
// alignment, then output the VALIGN at the line instead of the cell.
sal_Int16 eRowVertOri = text::VertOrientation::NONE;
if( rCells.size() > 1 )
{
for (SwWriteTableCells::size_type nCell = 0; nCell < rCells.size(); ++nCell)
{
sal_Int16 eCellVertOri = rCells[nCell]->GetVertOri();
if( 0==nCell )
{
eRowVertOri = eCellVertOri;
}
else if( eRowVertOri != eCellVertOri )
{
eRowVertOri = text::VertOrientation::NONE;
break;
}
}
}
rWrt.OutNewLine(); // <TR> in new line
rWrt.Strm().WriteChar( '<' ).WriteOString( OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_tablerow) );
if( pBrushItem )
{
if (!rWrt.mbXHTML)
{
rWrt.OutBackground(pBrushItem, false);
}
rWrt.m_bTextAttr = false;
rWrt.m_bOutOpts = true;
if (rWrt.m_bCfgOutStyles || rWrt.mbXHTML)
OutCSS1_TableBGStyleOpt( rWrt, *pBrushItem );
}
if( text::VertOrientation::TOP==eRowVertOri || text::VertOrientation::BOTTOM==eRowVertOri )
{
OStringBuffer sOut;
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_valign
"=\"").append(text::VertOrientation::TOP==eRowVertOri ? OOO_STRING_SVTOOLS_HTML_VA_top : OOO_STRING_SVTOOLS_HTML_VA_bottom)
.append("\"");
rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
}
rWrt.Strm().WriteChar( '>' );
rWrt.IncIndentLevel(); // indent content of <TR>...</TR>
for (const auto &rpCell : rCells)
{
OutTableCell(rWrt, rpCell.get(), text::VertOrientation::NONE == eRowVertOri);
}
rWrt.DecIndentLevel(); // indent content of <TR>...</TR>
rWrt.OutNewLine(); // </TR> in new line
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_tablerow), false );
}
void SwHTMLWrtTable::Write( SwHTMLWriter& rWrt, sal_Int16 eAlign,
bool bTHead, const SwFrameFormat *pFrameFormat,
const OUString *pCaption, bool bTopCaption,
sal_uInt16 nHSpace, sal_uInt16 nVSpace ) const
{
// determine value of RULES
bool bRowsHaveBorder = false;
bool bRowsHaveBorderOnly = true;
SwWriteTableRow *pRow = m_aRows[0].get();
for( SwWriteTableRows::size_type nRow=1; nRow < m_aRows.size(); ++nRow )
{
SwWriteTableRow *pNextRow = m_aRows[nRow].get();
bool bBorder = ( pRow->m_bBottomBorder || pNextRow->m_bTopBorder );
bRowsHaveBorder |= bBorder;
bRowsHaveBorderOnly &= bBorder;
sal_uInt16 nBorder2 = pRow->m_bBottomBorder ? pRow->m_nBottomBorder : USHRT_MAX;
if( pNextRow->m_bTopBorder && pNextRow->m_nTopBorder < nBorder2 )
nBorder2 = pNextRow->m_nTopBorder;
pRow->m_bBottomBorder = bBorder;
pRow->m_nBottomBorder = nBorder2;
pNextRow->m_bTopBorder = bBorder;
pNextRow->m_nTopBorder = nBorder2;
pRow = pNextRow;
}
bool bColsHaveBorder = false;
bool bColsHaveBorderOnly = true;
SwWriteTableCol *pCol = m_aCols[0].get();
for( SwWriteTableCols::size_type nCol=1; nCol<m_aCols.size(); ++nCol )
{
SwWriteTableCol *pNextCol = m_aCols[nCol].get();
bool bBorder = ( pCol->m_bRightBorder || pNextCol->m_bLeftBorder );
bColsHaveBorder |= bBorder;
bColsHaveBorderOnly &= bBorder;
pCol->m_bRightBorder = bBorder;
pNextCol->m_bLeftBorder = bBorder;
pCol = pNextCol;
}
// close previous numbering, etc
rWrt.ChangeParaToken( HtmlTokenId::NONE );
if( rWrt.m_bLFPossible )
rWrt.OutNewLine(); // <TABLE> in new line
OStringBuffer sOut;
sOut.append('<').append(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_table);
const SvxFrameDirection nOldDirection = rWrt.m_nDirection;
if( pFrameFormat )
rWrt.m_nDirection = rWrt.GetHTMLDirection( pFrameFormat->GetAttrSet() );
if( rWrt.m_bOutFlyFrame || nOldDirection != rWrt.m_nDirection )
{
rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
rWrt.OutDirection( rWrt.m_nDirection );
}
// output ALIGN=
if( text::HoriOrientation::RIGHT == eAlign )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_align
"=\"" OOO_STRING_SVTOOLS_HTML_AL_right "\"");
}
else if( text::HoriOrientation::CENTER == eAlign )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_align
"=\"" OOO_STRING_SVTOOLS_HTML_AL_center "\"");
}
else if( text::HoriOrientation::LEFT == eAlign )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_align
"=\"" OOO_STRING_SVTOOLS_HTML_AL_left "\"");
}
// output WIDTH: from layout or calculated
if( m_nTabWidth )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_width "=\"");
if( HasRelWidths() )
sOut.append(static_cast<sal_Int32>(m_nTabWidth)).append('%');
else if( Application::GetDefaultDevice() )
{
sal_Int32 nPixWidth = Application::GetDefaultDevice()->LogicToPixel(
Size(m_nTabWidth,0), MapMode(MapUnit::MapTwip) ).Width();
if( !nPixWidth )
nPixWidth = 1;
sOut.append(nPixWidth);
}
else
{
OSL_ENSURE( Application::GetDefaultDevice(), "no Application-Window!?" );
sOut.append("100%");
}
sOut.append("\"");
}
if( (nHSpace || nVSpace) && Application::GetDefaultDevice() && !rWrt.mbReqIF)
{
Size aPixelSpc =
Application::GetDefaultDevice()->LogicToPixel( Size(nHSpace,nVSpace),
MapMode(MapUnit::MapTwip) );
if( !aPixelSpc.Width() && nHSpace )
aPixelSpc.setWidth( 1 );
if( !aPixelSpc.Height() && nVSpace )
aPixelSpc.setHeight( 1 );
if( aPixelSpc.Width() )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_hspace
"=\"" + OString::number(aPixelSpc.Width()) + "\"");
}
if( aPixelSpc.Height() )
{
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_vspace
"=\"" + OString::number(aPixelSpc.Height()) + "\"");
}
}
// output CELLPADDING: from layout or calculated
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_cellpadding
"=\"" + OString::number(SwHTMLWriter::ToPixel(m_nCellPadding,false)) + "\"");
// output CELLSPACING: from layout or calculated
sOut.append(" " OOO_STRING_SVTOOLS_HTML_O_cellspacing
"=\"" + OString::number(SwHTMLWriter::ToPixel(m_nCellSpacing,false)) + "\"");
rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
// output background
if( pFrameFormat )
{
if (!rWrt.mbXHTML)
{
rWrt.OutBackground(pFrameFormat->GetAttrSet(), false);
}
if (rWrt.m_bCfgOutStyles || rWrt.mbXHTML)
{
rWrt.OutCSS1_TableFrameFormatOptions( *pFrameFormat );
}
}
sOut.append('>');
rWrt.Strm().WriteOString( sOut.makeStringAndClear() );
rWrt.IncIndentLevel(); // indent content of table
// output caption
if( pCaption && !pCaption->isEmpty() )
{
rWrt.OutNewLine(); // <CAPTION> in new line
OStringBuffer sOutStr(OOO_STRING_SVTOOLS_HTML_caption);
sOutStr.append(" " OOO_STRING_SVTOOLS_HTML_O_align "=\"")
.append(bTopCaption ? OOO_STRING_SVTOOLS_HTML_VA_top : OOO_STRING_SVTOOLS_HTML_VA_bottom)
.append("\"");
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + sOutStr) );
HTMLOutFuncs::Out_String( rWrt.Strm(), *pCaption );
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_caption), false );
}
const SwWriteTableCols::size_type nCols = m_aCols.size();
// output <COLGRP>/<COL>: If exporting via layout only when during import
// some were there, otherwise always.
bool bColGroups = (bColsHaveBorder && !bColsHaveBorderOnly);
if( m_bColTags )
{
if( bColGroups )
{
rWrt.OutNewLine(); // <COLGRP> in new line
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup) );
rWrt.IncIndentLevel(); // indent content of <COLGRP>
}
for( SwWriteTableCols::size_type nCol=0; nCol<nCols; ++nCol )
{
rWrt.OutNewLine(); // </COL> in new line
const SwWriteTableCol *pColumn = m_aCols[nCol].get();
HtmlWriter html(rWrt.Strm(), rWrt.maNamespace);
html.start(OOO_STRING_SVTOOLS_HTML_col);
sal_uInt32 nWidth;
bool bRel;
if( m_bLayoutExport )
{
bRel = pColumn->HasRelWidthOpt();
nWidth = pColumn->GetWidthOpt();
}
else
{
bRel = HasRelWidths();
nWidth = bRel ? GetRelWidth(nCol,1) : GetAbsWidth(nCol,1);
}
if( bRel )
html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, OStringConcatenation(OString::number(nWidth) + "*"));
else
html.attribute(OOO_STRING_SVTOOLS_HTML_O_width, OString::number(SwHTMLWriter::ToPixel(nWidth,false)));
html.end();
if( bColGroups && pColumn->m_bRightBorder && nCol<nCols-1 )
{
rWrt.DecIndentLevel(); // indent content of <COLGRP>
rWrt.OutNewLine(); // </COLGRP> in new line
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup),
false );
rWrt.OutNewLine(); // <COLGRP> in new line
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup) );
rWrt.IncIndentLevel(); // indent content of <COLGRP>
}
}
if( bColGroups )
{
rWrt.DecIndentLevel(); // indent content of <COLGRP>
rWrt.OutNewLine(); // </COLGRP> in new line
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_colgroup),
false );
}
}
// output the lines as table lines
// Output <TBODY>?
bool bTSections = (bRowsHaveBorder && !bRowsHaveBorderOnly);
bool bTBody = bTSections;
// If sections must be outputted, then a THEAD around the first line only
// can be outputted if there is a line below the cell.
if( bTHead &&
(bTSections || bColGroups) &&
m_nHeadEndRow<m_aRows.size()-1 && !m_aRows[m_nHeadEndRow]->m_bBottomBorder )
bTHead = false;
// Output <TBODY> only if <THEAD> is outputted.
bTSections |= bTHead;
if( bTSections )
{
rWrt.OutNewLine(); // <THEAD>/<TDATA> in new line
OString aTag = bTHead ? OOO_STRING_SVTOOLS_HTML_thead : OOO_STRING_SVTOOLS_HTML_tbody;
HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + aTag));
rWrt.IncIndentLevel(); // indent content of <THEAD>/<TDATA>
}
for( SwWriteTableRows::size_type nRow = 0; nRow < m_aRows.size(); ++nRow )
{
const SwWriteTableRow *pRow2 = m_aRows[nRow].get();
OutTableCells( rWrt, pRow2->GetCells(), pRow2->GetBackground() );
if( !m_nCellSpacing && nRow < m_aRows.size()-1 && pRow2->m_bBottomBorder &&
pRow2->m_nBottomBorder > SvxBorderLineWidth::Thin )
{
for( auto nCnt = (pRow2->m_nBottomBorder / SvxBorderLineWidth::Thin) - 1; nCnt; --nCnt )
{
rWrt.OutNewLine();
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_tablerow ));
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_tablerow),
false );
}
}
if( ( (bTHead && nRow==m_nHeadEndRow) ||
(bTBody && pRow2->m_bBottomBorder) ) &&
nRow < m_aRows.size()-1 )
{
rWrt.DecIndentLevel(); // indent content of <THEAD>/<TDATA>
rWrt.OutNewLine(); // </THEAD>/</TDATA> in new line
OString aTag = bTHead ? OOO_STRING_SVTOOLS_HTML_thead : OOO_STRING_SVTOOLS_HTML_tbody;
HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + aTag), false);
rWrt.OutNewLine(); // <THEAD>/<TDATA> in new line
if( bTHead && nRow==m_nHeadEndRow )
bTHead = false;
aTag = bTHead ? OOO_STRING_SVTOOLS_HTML_thead : OOO_STRING_SVTOOLS_HTML_tbody;
HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + aTag));
rWrt.IncIndentLevel(); // indent content of <THEAD>/<TDATA>
}
}
if( bTSections )
{
rWrt.DecIndentLevel(); // indent content of <THEAD>/<TDATA>
rWrt.OutNewLine(); // </THEAD>/</TDATA> in new line
OString aTag = bTHead ? OOO_STRING_SVTOOLS_HTML_thead : OOO_STRING_SVTOOLS_HTML_tbody;
HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + aTag), false);
}
rWrt.DecIndentLevel(); // indent content of <TABLE>
rWrt.OutNewLine(); // </TABLE> in new line
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_table), false );
rWrt.m_nDirection = nOldDirection;
}
Writer& OutHTML_SwTableNode( Writer& rWrt, SwTableNode & rNode,
const SwFrameFormat *pFlyFrameFormat,
const OUString *pCaption, bool bTopCaption )
{
SwTable& rTable = rNode.GetTable();
SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
rHTMLWrt.m_bOutTable = true;
// The horizontal alignment of the frame (if exists) has priority.
// NONE means that no horizontal alignment was outputted.
sal_Int16 eFlyHoriOri = text::HoriOrientation::NONE;
css::text::WrapTextMode eSurround = css::text::WrapTextMode_NONE;
sal_uInt8 nFlyPercentWidth = 0;
tools::Long nFlyWidth = 0;
sal_uInt16 nFlyHSpace = 0;
sal_uInt16 nFlyVSpace = 0;
if( pFlyFrameFormat )
{
eSurround = pFlyFrameFormat->GetSurround().GetSurround();
const SwFormatFrameSize& rFrameSize = pFlyFrameFormat->GetFrameSize();
nFlyPercentWidth = rFrameSize.GetWidthPercent();
nFlyWidth = rFrameSize.GetSize().Width();
eFlyHoriOri = pFlyFrameFormat->GetHoriOrient().GetHoriOrient();
if( text::HoriOrientation::NONE == eFlyHoriOri )
eFlyHoriOri = text::HoriOrientation::LEFT;
const SvxLRSpaceItem& rLRSpace = pFlyFrameFormat->GetLRSpace();
nFlyHSpace = static_cast< sal_uInt16 >((rLRSpace.GetLeft() + rLRSpace.GetRight()) / 2);
const SvxULSpaceItem& rULSpace = pFlyFrameFormat->GetULSpace();
nFlyVSpace = (rULSpace.GetUpper() + rULSpace.GetLower()) / 2;
}
// maybe open a FORM
bool bPreserveForm = false;
if( !rHTMLWrt.m_bPreserveForm )
{
rHTMLWrt.OutForm( true, &rNode );
bPreserveForm = rHTMLWrt.mxFormComps.is();
rHTMLWrt.m_bPreserveForm = bPreserveForm;
}
SwFrameFormat *pFormat = rTable.GetFrameFormat();
const SwFormatFrameSize& rFrameSize = pFormat->GetFrameSize();
tools::Long nWidth = rFrameSize.GetSize().Width();
sal_uInt8 nPercentWidth = rFrameSize.GetWidthPercent();
sal_uInt16 nBaseWidth = o3tl::narrowing<sal_uInt16>(nWidth);
sal_Int16 eTabHoriOri = pFormat->GetHoriOrient().GetHoriOrient();
// text::HoriOrientation::NONE and text::HoriOrientation::FULL tables need relative widths
sal_uInt16 nNewDefListLvl = 0;
bool bRelWidths = false;
bool bCheckDefList = false;
switch( eTabHoriOri )
{
case text::HoriOrientation::FULL:
// Tables with automatic alignment become tables with 100% width.
bRelWidths = true;
nWidth = 100;
eTabHoriOri = text::HoriOrientation::LEFT;
break;
case text::HoriOrientation::NONE:
{
const SvxLRSpaceItem& aLRItem = pFormat->GetLRSpace();
if( aLRItem.GetRight() )
{
// The table width is defined on the basis of the left and
// right margin. Therefore we try to define the actual
// width of the table. If that's not possible we transform
// it to a table with width 100%.
nWidth = pFormat->FindLayoutRect(true).Width();
if( !nWidth )
{
bRelWidths = true;
nWidth = 100;
}
}
else if( nPercentWidth )
{
// Without a right border the %-width is maintained.
nWidth = nPercentWidth;
bRelWidths = true;
}
else
{
// Without a right margin also an absolute width is maintained.
// We still try to define the actual width via the layout.
tools::Long nRealWidth = pFormat->FindLayoutRect(true).Width();
if( nRealWidth )
nWidth = nRealWidth;
}
bCheckDefList = true;
}
break;
case text::HoriOrientation::LEFT_AND_WIDTH:
eTabHoriOri = text::HoriOrientation::LEFT;
bCheckDefList = true;
[[fallthrough]];
default:
// In all other case it's possible to use directly an absolute
// or relative width.
if( nPercentWidth )
{
bRelWidths = true;
nWidth = nPercentWidth;
}
break;
}
if( bCheckDefList )
{
OSL_ENSURE( !rHTMLWrt.GetNumInfo().GetNumRule() ||
rHTMLWrt.GetNextNumInfo(),
"NumInfo for next paragraph is missing!" );
const SvxLRSpaceItem& aLRItem = pFormat->GetLRSpace();
if( aLRItem.GetLeft() > 0 && rHTMLWrt.m_nDefListMargin > 0 &&
( !rHTMLWrt.GetNumInfo().GetNumRule() ||
( rHTMLWrt.GetNextNumInfo() &&
(rHTMLWrt.GetNextNumInfo()->IsRestart() ||
rHTMLWrt.GetNumInfo().GetNumRule() !=
rHTMLWrt.GetNextNumInfo()->GetNumRule()) ) ) )
{
// If the paragraph before the table is not numbered or the
// paragraph after the table starts with a new numbering or with
// a different rule, we can maintain the indentation with a DL.
// Otherwise we keep the indentation of the numbering.
nNewDefListLvl = static_cast< sal_uInt16 >(
(aLRItem.GetLeft() + (rHTMLWrt.m_nDefListMargin/2)) /
rHTMLWrt.m_nDefListMargin );
}
}
if( !pFlyFrameFormat && nNewDefListLvl != rHTMLWrt.m_nDefListLvl )
rHTMLWrt.OutAndSetDefList( nNewDefListLvl );
if( nNewDefListLvl )
{
if( rHTMLWrt.m_bLFPossible )
rHTMLWrt.OutNewLine();
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_dd) );
}
// eFlyHoriOri and eTabHoriOri now only contain the values of
// LEFT/CENTER and RIGHT!
if( eFlyHoriOri!=text::HoriOrientation::NONE )
{
eTabHoriOri = eFlyHoriOri;
// MIB 4.7.97: If the table has a relative width, then the width is
// adjusted to the width of the frame, therefore we export its width.
// If fixed width, the table width is relevant. Whoever puts tables with
// relative width <100% into frames is to blame when the result looks bad.
if( bRelWidths )
{
nWidth = nFlyPercentWidth ? nFlyPercentWidth : nFlyWidth;
bRelWidths = nFlyPercentWidth > 0;
}
}
sal_Int16 eDivHoriOri = text::HoriOrientation::NONE;
switch( eTabHoriOri )
{
case text::HoriOrientation::LEFT:
// If a left-aligned table has no right sided flow, then we don't need
// an ALIGN=LEFT in the table.
if( eSurround==css::text::WrapTextMode_NONE || eSurround==css::text::WrapTextMode_LEFT )
eTabHoriOri = text::HoriOrientation::NONE;
break;
case text::HoriOrientation::RIGHT:
// Something like that also applies to right-aligned tables,
// here we use a <DIV ALIGN=RIGHT> instead.
if( eSurround==css::text::WrapTextMode_NONE || eSurround==css::text::WrapTextMode_RIGHT )
{
eDivHoriOri = text::HoriOrientation::RIGHT;
eTabHoriOri = text::HoriOrientation::NONE;
}
break;
case text::HoriOrientation::CENTER:
// Almost nobody understands ALIGN=CENTER, therefore we abstain
// from it and use a <CENTER>.
eDivHoriOri = text::HoriOrientation::CENTER;
eTabHoriOri = text::HoriOrientation::NONE;
break;
default:
;
}
if( text::HoriOrientation::NONE==eTabHoriOri )
nFlyHSpace = nFlyVSpace = 0;
if( !pFormat->GetName().isEmpty() )
rHTMLWrt.OutImplicitMark( pFormat->GetName(), "table" );
if( text::HoriOrientation::NONE!=eDivHoriOri )
{
if( rHTMLWrt.m_bLFPossible )
rHTMLWrt.OutNewLine(); // <CENTER> in new line
if( text::HoriOrientation::CENTER==eDivHoriOri )
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rHTMLWrt.GetNamespace() + OOO_STRING_SVTOOLS_HTML_center) );
else
{
OStringLiteral sOut = OOO_STRING_SVTOOLS_HTML_division
" " OOO_STRING_SVTOOLS_HTML_O_align "=\""
OOO_STRING_SVTOOLS_HTML_AL_right "\"";
HTMLOutFuncs::Out_AsciiTag( rWrt.Strm(), OStringConcatenation(rHTMLWrt.GetNamespace() + sOut) );
}
rHTMLWrt.IncIndentLevel(); // indent content of <CENTER>
rHTMLWrt.m_bLFPossible = true;
}
// If the table isn't in a frame, then you always can output a LF.
if( text::HoriOrientation::NONE==eTabHoriOri )
rHTMLWrt.m_bLFPossible = true;
const SwHTMLTableLayout *pLayout = rTable.GetHTMLTableLayout();
#ifdef DBG_UTIL
{
SwViewShell *pSh = rWrt.m_pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
if ( pSh && pSh->GetViewOptions()->IsTest1() )
pLayout = nullptr;
}
#endif
if( pLayout && pLayout->IsExportable() )
{
SwHTMLWrtTable aTableWrt( pLayout );
aTableWrt.Write( rHTMLWrt, eTabHoriOri, rTable.GetRowsToRepeat() > 0,
pFormat, pCaption, bTopCaption,
nFlyHSpace, nFlyVSpace );
}
else
{
SwHTMLWrtTable aTableWrt( rTable.GetTabLines(), nWidth,
nBaseWidth, bRelWidths, 0, 0, rTable.GetRowsToRepeat() );
aTableWrt.Write( rHTMLWrt, eTabHoriOri, rTable.GetRowsToRepeat() > 0,
pFormat, pCaption, bTopCaption,
nFlyHSpace, nFlyVSpace );
}
// If the table wasn't in a frame, then you always can output a LF.
if( text::HoriOrientation::NONE==eTabHoriOri )
rHTMLWrt.m_bLFPossible = true;
if( text::HoriOrientation::NONE!=eDivHoriOri )
{
rHTMLWrt.DecIndentLevel(); // indent content of <CENTER>
rHTMLWrt.OutNewLine(); // </CENTER> in new line
OString aTag = text::HoriOrientation::CENTER == eDivHoriOri
? OOO_STRING_SVTOOLS_HTML_center
: OOO_STRING_SVTOOLS_HTML_division;
HTMLOutFuncs::Out_AsciiTag(rWrt.Strm(), OStringConcatenation(rHTMLWrt.GetNamespace() + aTag), false);
rHTMLWrt.m_bLFPossible = true;
}
// move Pam behind the table
rHTMLWrt.m_pCurrentPam->GetPoint()->nNode = *rNode.EndOfSectionNode();
if( bPreserveForm )
{
rHTMLWrt.m_bPreserveForm = false;
rHTMLWrt.OutForm( false );
}
rHTMLWrt.m_bOutTable = false;
if( rHTMLWrt.GetNextNumInfo() &&
!rHTMLWrt.GetNextNumInfo()->IsRestart() &&
rHTMLWrt.GetNextNumInfo()->GetNumRule() ==
rHTMLWrt.GetNumInfo().GetNumRule() )
{
// If the paragraph after the table is numbered with the same rule as the
// one before, then the NumInfo of the next paragraph holds the level of
// paragraph before the table. Therefore NumInfo must be fetched again
// to maybe close the Num list.
rHTMLWrt.ClearNextNumInfo();
rHTMLWrt.FillNextNumInfo();
OutHTML_NumberBulletListEnd( rHTMLWrt, *rHTMLWrt.GetNextNumInfo() );
}
return rWrt;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|