24#include <com/sun/star/text/XTextTable.hpp>
25#include <com/sun/star/text/XTextSection.hpp>
28#include <rtl/ustrbuf.hxx>
91struct SwXMLTableColumnCmpWidth_Impl
102class SwXMLTableColumns_Impl :
public o3tl::sorted_vector<std::unique_ptr<SwXMLTableColumn_Impl>, o3tl::less_uniqueptr_to<SwXMLTableColumn_Impl> > {
129#if OSL_DEBUG_LEVEL > 0
130 sal_uInt32 nEndCPos = 0
U;
132 const size_t nLines = rLines.
size();
133 for(
size_t nLine=0
U; nLine<nLines; ++nLine )
137 const size_t nBoxes = rBoxes.size();
139 sal_uInt32 nCPos = 0
U;
140 for(
size_t nBox=0
U; nBox<nBoxes; ++nBox )
144 if( nBox < nBoxes-1U ||
m_nWidth==0 )
147 std::unique_ptr<SwXMLTableColumn_Impl> pCol(
150 m_aCols.insert( std::move(pCol) );
152 if( nBox==nBoxes-1U )
155 "parent width will be lost" );
161#if OSL_DEBUG_LEVEL > 0
162 sal_uInt32 nCheckPos =
166 nEndCPos = nCheckPos;
170#if OSL_DEBUG_LEVEL > 0
172 OSL_ENSURE(
m_aCols.find(&aCol) !=
m_aCols.end(),
"couldn't find last column" );
175 "rows have different total widths" );
194 ::std::optional<OUString>
AddRow(
SwFrameFormat& rFrameFormat, std::u16string_view rNamePrefix, sal_uInt32 nLine );
196 sal_uInt32 nCol, sal_uInt32 nRow,
bool bTop );
200 std::u16string_view rNamePrefix,
211 if( !pFrameSize && !pBrush && !pRowSplit && !pHasTextChangesOnly )
218 SwXMLFrameFormats_Impl::iterator
i;
232 pTestFrameSize = pItem;
258 pTestRowSplit = pItem;
268 if( !pHasTextChangesOnly )
271 pTestHasTextChangesOnly = pItem;
275 if( pHasTextChangesOnly )
284 if( pBrush && (*pBrush != *pTestBrush) )
290 if( pHasTextChangesOnly && (!pHasTextChangesOnly->GetValue() != !pTestHasTextChangesOnly->GetValue()) )
294 auto const oName(
m_rFormatMap.find(pTestFormat)->second);
301 OUString
const name(OUString::Concat(rNamePrefix) +
"." + OUString::number(nLine+1));
305 return ::std::optional<OUString>(
name);
310 sal_uInt32 nCol, sal_uInt32 nRow,
bool bTop )
316 return OUString::Concat(rNamePrefix) +
"." + sTmp + OUString::number(nRow + 1);
318 return OUString::Concat(rNamePrefix)
319 +
"." + OUString::number(nCol + 1)
320 +
"." + OUString::number(nRow + 1);
324 std::u16string_view rNamePrefix,
325 sal_uInt32 nCol, sal_uInt32 nRow,
bool bTop )
339 if( !pVertOrient && !pBrush && !pBox && !pNumFormat && !pFrameDir && !pAttCnt )
351 SwXMLFrameFormats_Impl::iterator
i;
367 pTestVertOrient = pItem;
407 pTestNumFormat = pItem;
422 pTestFrameDir = pItem;
450 if( pBrush && ( *pBrush != *pTestBrush ) )
453 if( pBox && ( *pBox != *pTestBox ) )
459 if( pFrameDir && pFrameDir->GetValue() != pTestFrameDir->GetValue() )
462 if( pAttCnt && ( *pAttCnt != *pTestAttCnt ) )
466 auto const oName(
m_rFormatMap.find(pTestFormat)->second);
477 return ::std::optional<OUString>(
name);
508 inline void SetBaseSection(
const Reference < XTextSection >& rBase );
516 const Reference < XTextSection >& rBaseSection )
528 bool bEncoded =
false;
540 OUStringBuffer sValue;
546 sValue.makeStringAndClear() );
550 sValue.append(
static_cast<sal_Int32
>(rCol.
GetRelWidth()) );
551 sValue.append(
'*' );
553 sValue.makeStringAndClear() );
565 sal_uInt32 nAbsWidth, sal_uInt32 nBaseWidth,
566 std::u16string_view rNamePrefix,
582 const SwXMLTableColumns_Impl& rCols = pLines->
GetColumns();
583 sal_uInt32 nCPos = 0
U;
584 const size_t nColumns = rCols.size();
585 for(
size_t nColumn=0
U; nColumn<nColumns; ++nColumn )
589 sal_uInt32 nOldCPos = nCPos;
590 nCPos = pColumn->
GetPos();
592 sal_uInt32 nWidth = nCPos - nOldCPos;
608 sal_uInt32 nColAbsWidth = nWidth;
611 nColAbsWidth *= nAbsWidth;
612 nColAbsWidth += (nBaseWidth/2UL);
613 nColAbsWidth /= nBaseWidth;
619 if( it != rExpCols.
end() )
629 pColumn->
SetStyleName( OUString::Concat(rNamePrefix) +
"." + sTmp );
634 OUString::Concat(rNamePrefix) +
"." + OUString::number(nColumn + 1U) );
637 rExpCols.
insert( pColumn );
643 const size_t nLines = rLines.
size();
644 for(
size_t nLine=0
U; nLine<nLines; ++nLine )
649 if (
auto oNew = rExpRows.
AddRow(*pFrameFormat, rNamePrefix, nLine))
655 const size_t nBoxes = rBoxes.size();
657 sal_uInt32 nCPos = 0
U;
659 for(
size_t nBox=0
U; nBox<nBoxes; nBox++ )
663 if( nBox < nBoxes-1U )
669 const size_t nOldCol = nCol;
671 SwXMLTableColumns_Impl::const_iterator it = pLines->
GetColumns().find( &aCol );
672 OSL_ENSURE( it != pLines->
GetColumns().end(),
"couldn't find column" );
679 if (
auto oNew = rExpCells.
AddCell(*pFrameFormat2, rNamePrefix, nOldCol, nLine,
691 Reference < XText > xText( xCell, UNO_QUERY );
694 Reference<XPropertySet> xCellPropertySet( xCell,
696 Any aAny = xCellPropertySet->getPropertyValue(
"TextSection");
697 Reference < XTextSection > xTextSection;
698 aAny >>= xTextSection;
702 const bool bExportContent = bool(
getExportFlags() & SvXMLExportFlags::CONTENT );
703 if ( !bExportContent )
711 OSL_FAIL(
"here should be a XCell");
717 nAbsWidth, nBaseWidth,
719 nOldCol, nLine, bTop ),
720 rExpCols, rExpRows, rExpCells,
732 auto const it(rFormats.find(&rTableNd));
733 assert(it != rFormats.end());
746 sal_uInt32 nBaseWidth = 0;
750 || HoriOrientation::FULL == eTabHoriOri;
753 nBaseWidth = nAbsWidth;
767 pTableFormat->
GetName(), aExpCols, aExpRows, aExpCells,
783 auto const it(rTableInfo.
GetBoxFormats().find(pFrameFormat));
787 assert(!it->second->isEmpty());
796 OUString::number(nRowSpan) );
802 OUString::number(nColSpan) );
816 Reference<XText> xText( xCell, UNO_QUERY );
819 const OUString sCellFormula = xCell->getFormula();
823 if (!sCellFormula.isEmpty())
825 const OUString sQValue =
833 Reference<XPropertySet> xCellPropertySet(xCell,
835 if (xCellPropertySet.is())
837 sal_Int32 nNumberFormat = 0;
838 Any aAny = xCellPropertySet->getPropertyValue(
"NumberFormat");
839 aAny >>= nNumberFormat;
847 else if ( (-1 != nNumberFormat) && !xText->getString().isEmpty() )
853 *
this, nNumberFormat, xCell->getValue() );
858 aAny = xCellPropertySet->getPropertyValue(
"IsProtected");
859 if (*o3tl::doAccess<bool>(aAny))
867 aAny = xCellPropertySet->getPropertyValue(
"TextSection");
868 Reference < XTextSection > xTextSection;
869 aAny >>= xTextSection;
885 OSL_FAIL(
"here should be a XCell");
922 assert(!it->second->isEmpty());
930 const size_t nBoxes = rBoxes.size();
932 sal_uInt32 nCPos = 0
U;
934 for(
size_t nBox=0
U; nBox<nBoxes; ++nBox )
939 const sal_Int32 nRowSpan = pBox->
getRowSpan();
950 assert(!it->second->isEmpty());
960 if( nBox < nBoxes-1U )
966 const size_t nOldCol = nCol;
968 SwXMLTableColumns_Impl::const_iterator it = rLines.
GetColumns().find( &aCol );
969 OSL_ENSURE( it != rLines.
GetColumns().end(),
"couldn't find column" );
973 if ( nCol < nOldCol )
975 OSL_FAIL(
"table and/or table information seems to be corrupted." );
981 const sal_uInt32 nColSpan = nCol - nOldCol + 1U;
984 ExportTableBox( *pBox, nColSpan,
static_cast< sal_uInt32
>(nRowSpan), rTableInfo );
986 for(
size_t i=nOldCol;
i<nCol; ++
i )
1000 sal_uInt32 nHeaderRows )
1003 "SwXMLExport::ExportTableLines: table columns infos missing" );
1009 for( nInfoPos=0; nInfoPos <
m_pTableLines->size(); nInfoPos++ )
1018 "SwXMLExport::ExportTableLines: table columns info missing" );
1019 OSL_ENSURE( 0==nInfoPos,
1020 "SwXMLExport::ExportTableLines: table columns infos are unsorted" );
1024 SwXMLTableLinesCache_Impl::iterator it =
m_pTableLines->begin();
1025 advance( it, nInfoPos );
1032 const SwXMLTableColumns_Impl& rCols = pLines->
GetColumns();
1033 size_t nColumn = 0
U;
1034 const size_t nColumns = rCols.size();
1035 sal_Int32 nColRep = 1;
1041 (nColumn < nColumns) ? rCols[nColumn].
get() :
nullptr;
1055 OUString::number(nColRep) );
1064 pColumn = pNextColumn;
1068 const size_t nLines = rLines.
size();
1070 if( nHeaderRows > 0 )
1075 OSL_ENSURE( nHeaderRows <= nLines,
"more headers then lines?" );
1076 for(
size_t nLine = 0
U; nLine < nHeaderRows; ++nLine )
1080 for(
size_t nLine = nHeaderRows; nLine < nLines; ++nLine )
1112 if (pTableFormat && !pTableFormat->
GetName().isEmpty())
1122 OUString sStyleName;
1130 if (
auto pSwDdeTable =
dynamic_cast<const SwDDETable*
>( &rTable) )
1133 const SwDDEFieldType* pDDEFieldType = pSwDdeTable->GetDDEFieldType();
1140 const OUString& sCmd = pDDEFieldType->
GetCmd();
1141 sal_Int32 nIdx{ 0 };
1150 if (pDDEFieldType->
GetType() == SfxLinkUpdateMode::ALWAYS)
1162 auto const it(rFormats.find(&rTableNd));
1163 assert(it != rFormats.end());
1182 for (
SwTableBox* pBox : pLine->GetTabBoxes())
1184 if (pBox->getRowSpan() <= 0)
1186 if (pBox->GetSttNd())
1201 const Reference < XTextContent > & rTextContent,
1202 bool bAutoStyles,
bool _bProgress )
1207 Reference < XTextTable > xTextTable( rTextContent, UNO_QUERY );
1208 OSL_ENSURE( xTextTable.is(),
"text table missing" );
1209 if( xTextTable.is() )
1215 OSL_ENSURE( pFormat,
"table format missing" );
1217 OSL_ENSURE( pTable,
"table missing" );
1219 OSL_ENSURE( pTableNd,
"table node missing" );
1227 const bool bExportStyles = bool(
GetExport().getExportFlags() & SvXMLExportFlags::STYLES );
constexpr sal_uInt32 getSwDefaultTextFormat()
The number formatter's default locale's @ Text format.
sal_uInt32 GetValue() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
constexpr tools::Long Width() const
const SvXMLNamespaceMap & GetNamespaceMap() const
rtl::Reference< XMLTextParagraphExport > const & GetTextParagraphExport()
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
SvXMLExportFlags getExportFlags() const
SvtSaveOptions::ODFSaneDefaultVersion getSaneDefaultVersion() const
OUString EncodeStyleName(const OUString &rName, bool *pEncoded=nullptr) const
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
tools::Long GetHeight() const
const Size & GetSize() const
OUString const & GetCmd() const
SfxLinkUpdateMode GetType() const
virtual OUString GetName() const override
Only in derived classes.
bool IsInHeaderFooter(const SwNode &) const
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
void Width(tools::Long nNew)
Starts a section of nodes in the document model.
static void FillProgName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
SwTableBox is one table cell in the document model.
sal_Int32 getRowSpan() const
SwFrameFormat * GetFrameFormat()
SwTableLines & GetTabLines()
const SwStartNode * GetSttNd() const
SwTableLine is one table row in the document model.
SwFrameFormat * GetFrameFormat()
SwTableBoxes & GetTabBoxes()
bool hasSoftPageBreak() const
const SwTable & GetTable() const
SwTable is one table in the document model, containing rows (which contain cells).
SwTableNode * GetTableNode() const
const OUString & GetTableStyleName() const
Return the table style name of this table.
SwTableLines & GetTabLines()
SwTableFormat * GetFrameFormat()
static SwTable * FindTable(SwFrameFormat const *const pFormat)
sal_uInt16 GetRowsToRepeat() const
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
sal_uInt32 GetWidthOpt() const
void SetWidthOpt(sal_uInt32 nWidth, bool bRel)
sal_uInt32 GetPos() const
static sal_uInt32 GetBoxWidth(const SwTableBox *pBox)
static rtl::Reference< SwXCell > CreateXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, SwTable *pTable=nullptr)
std::unique_ptr< SwXMLTableLinesCache_Impl > m_pTableLines
void ExportTableAutoStyles(const SwTableNode &rTableNd)
const SvXMLUnitConverter & GetTwipUnitConverter() const
void ExportTableFormat(const SwFrameFormat &rFormat, sal_uInt32 nAbsWidth)
void ExportTableColumnStyle(const SwXMLTableColumn_Impl &rCol)
void ExportTableBox(const SwTableBox &rBox, sal_uInt32 nColSpan, sal_uInt32 nRowSpan, SwXMLTableInfo_Impl &rTableInfo)
bool IsShowProgress() const
void ExportTable(const SwTableNode &rTableNd)
void ExportFormat(const SwFormat &rFormat, enum ::xmloff::token::XMLTokenEnum eClass, ::std::optional< OUString > const oStyleName)
void ExportTableLinesAutoStyles(const SwTableLines &rLines, sal_uInt32 nAbsWidth, sal_uInt32 nBaseWidth, std::u16string_view rNamePrefix, SwXMLTableColumnsSortByWidth_Impl &rExpCols, SwXMLTableFrameFormatsSort_Impl &rExpRows, SwXMLTableFrameFormatsSort_Impl &rExpCells, SwXMLTableInfo_Impl &rTableInfo, bool bTop=false)
void ExportTableLines(const SwTableLines &rLines, SwXMLTableInfo_Impl &rTableInfo, sal_uInt32 nHeaderRows=0)
void ExportTableLine(const SwTableLine &rLine, const SwXMLTableLines_Impl &rLines, SwXMLTableInfo_Impl &rTableInfo)
void SetRelWidth(sal_uInt32 nSet)
const OUString & GetStyleName() const
void SetStyleName(const OUString &rName)
SwXMLTableColumn_Impl(sal_uInt32 nPosition)
sal_uInt32 GetRelWidth() const
sal_uInt16 GetPrefix() const
The namespace (table or loext) that should be used for the elements.
bool IsBaseSectionValid() const
void SetBaseSection(const Reference< XTextSection > &rBase)
SwXMLTextParagraphExport::FormatMap const & m_rLineFormats
const SwTable * GetTable() const
const Reference< XTextSection > & GetBaseSection() const
SwXMLTextParagraphExport::FormatMap const & m_rBoxFormats
SwXMLTextParagraphExport::FormatMap const & GetBoxFormats() const
const SwFrameFormat * GetTableFormat() const
SwXMLTextParagraphExport::FormatMap const & GetLineFormats() const
Reference< XTextSection > m_xBaseSection
SwXMLTableInfo_Impl(const SwTable *pTable, sal_uInt16 nPrefix, SwXMLTextParagraphExport::FormatMap const &rLineFormats, SwXMLTextParagraphExport::FormatMap const &rBoxFormats)
const SwTableLines * m_pLines
SwXMLTableLines_Impl(const SwTableLines &rLines)
sal_uInt32 GetWidth() const
const SwXMLTableColumns_Impl & GetColumns() const
SwXMLTableColumns_Impl m_aCols
const SwTableLines * GetLines() const
void CollectTableLinesAutoStyles(const SwTableLines &rLines, SwFrameFormat &rFormat, bool bProgress)
::std::unordered_map< SwTableNode const *, ::std::pair< FormatMap, FormatMap > > m_TableFormats
::std::unordered_map< SwFrameFormat const *, ::std::optional< OUString > > FormatMap
std::vector< const SwTableNode * > maTableNodes
virtual void exportTable(const css::uno::Reference< css::text::XTextContent > &rTextContent, bool bAutoStyles, bool bProgress) override
virtual void exportTableAutoStyles() override
SwFrameFormat * GetFrameFormat()
SvXMLExport & GetExport()
bool isAutoStylesCollected() const
void exportText(const css::uno::Reference< css::text::XText > &rText, bool bIsProgress=false, bool bExportParagraph=true, TextPNS eExtensionNS=TextPNS::ODF)
std::vector< Value >::const_iterator const_iterator
const_iterator find(const Value &x) const
const_iterator end() const
std::pair< const_iterator, bool > insert(Value &&x)
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN)
constexpr TypedWhichId< SwFormatRowSplit > RES_ROW_SPLIT(122)
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(98)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
const sal_Unicode cTokenSeparator
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
XML_TABLE_COLUMN_PROPERTIES
XML_NUMBER_COLUMNS_SPANNED
XML_NUMBER_COLUMNS_REPEATED
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
void sw_GetTableBoxColStr(sal_uInt16 nCol, OUString &rNm)
std::vector< SwTableBox * > SwTableBoxes
std::vector< SwXMLTableLines_Impl * > SwXMLTableLinesCache_Impl
constexpr sal_uInt16 XML_NAMESPACE_TEXT
constexpr sal_uInt16 XML_NAMESPACE_TABLE
constexpr sal_uInt16 XML_NAMESPACE_OOOW
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
constexpr sal_uInt16 XML_NAMESPACE_STYLE
vector< SwFrameFormat * > SwXMLFrameFormats_Impl
static OUString lcl_xmltble_appendBoxPrefix(std::u16string_view rNamePrefix, sal_uInt32 nCol, sal_uInt32 nRow, bool bTop)