24#include <com/sun/star/table/XTable.hpp>
25#include <com/sun/star/table/XMergeableCellRange.hpp>
37#include <editeng/editeng.hxx>
40#include <editeng/editids.hrc>
129 std::vector< RTFColumnVectorPtr >
maRows;
144: mrTableObj( rTableObj )
146, mrItemPool( rTableObj.getSdrModelFromSdrObject().GetItemPool() )
153, mpActDefault( nullptr )
154, mpDefMerge( nullptr )
155, mxTable( rTableObj.getTable() )
168 mpOutliner->Read( rStream, OUString(), EETextFormat::Rtf );
176 switch ( rInfo.eState )
178 case RtfImportState::NextToken:
181 case RtfImportState::UnknownAttr:
184 case RtfImportState::Start:
191 case RtfImportState::End:
192 if ( rInfo.aSelection.nEndPos )
194 mpActDefault =
nullptr;
196 rInfo.aSelection.nEndPara++;
200 case RtfImportState::SetAttr:
201 case RtfImportState::InsertText:
202 case RtfImportState::InsertPara:
205 SAL_WARN(
"svx.table",
"unknown ImportInfo.eState");
234 if ( xCellInfo->mnRowSpan == 0 &&
mnVMergeIdx < nSize )
237 if (xLastCell->mnRowSpan)
238 xCellInfo->mxVMergeCell = xLastCell;
240 xCellInfo->mxVMergeCell = xLastCell->mxVMergeCell;
247 if ( xCellInfo->mxVMergeCell )
250 xColumn->back()->mxVMergeCell != xCellInfo->mxVMergeCell )
251 xCellInfo->mxVMergeCell->mnRowSpan++;
254 xColumn->push_back( xCellInfo );
264 if ( aNextEdge ==
maColumnEdges.end() || nEdge != *aNextEdge )
275 sal_Int32 nColCount =
mxTable->getColumnCount();
276 Reference< XTableColumns > xCols(
mxTable->getColumns(), UNO_SET_THROW );
278 if( nColCount < nColMax )
280 xCols->insertByIndex( nColCount, nColMax - nColCount );
281 nColCount =
mxTable->getColumnCount();
284 static constexpr OUStringLiteral sWidth(
u"Width");
285 sal_Int32 nCol, nLastEdge = 0;
286 for( nCol = 0; nCol < nColCount; nCol++ )
288 Reference< XPropertySet > xSet( xCols->getByIndex( nCol ), UNO_QUERY_THROW );
291 xSet->setPropertyValue( sWidth,
Any( nWidth ) );
295 const sal_Int32 nRowCount =
mxTable->getRowCount();
298 Reference< XTableRows > xRows(
mxTable->getRows(), UNO_SET_THROW );
299 xRows->insertByIndex( nRowCount,
mnRowCnt - nRowCount );
302 for( sal_Int32 nRow = 0; nRow < static_cast<sal_Int32>(
maRows.size()); nRow++ )
307 for( sal_Int32 nIdx = 0; nCol < nColMax && nIdx < static_cast<sal_Int32>(
xColumn->size()); nIdx++ )
311 CellRef xCell(
dynamic_cast< Cell*
>(
mxTable->getCellByPosition( nCol, nRow ).get() ) );
312 if( xCell.is() && xCellInfo )
315 if( xCellInfo->maItemSet.GetItemState(
SDRATTR_TABLE_BORDER,
false,&pPoolItem)==SfxItemState::SET)
316 xCell->SetMergedItem( *pPoolItem );
323 rOutliner.
SetText( *pTextObject );
327 sal_Int32 nLastRow = nRow;
328 if ( xCellInfo->mnRowSpan )
329 nLastRow += xCellInfo->mnRowSpan - 1;
331 aEdge = std::lower_bound( aEdge,
maColumnEdges.end(), xCellInfo->mnCellX );
332 sal_Int32 nLastCol = nCol;
339 if ( nLastCol > nCol || nLastRow > nRow )
341 Reference< XMergeableCellRange > xRange(
mxTable->createCursorByRange(
mxTable->getCellRangeByPosition( nCol, nRow, nLastCol, nLastRow ) ), UNO_QUERY_THROW );
342 if( xRange->isMergeable() )
367 maRows.push_back( std::make_shared<std::vector<std::shared_ptr<RTFCellInfo>>>( ) );
429 std::shared_ptr<RTFCellDefault> pDefault(
mpInsDefault.release() );
437 pDefault->mnCellX = nSize;
498 aParser.
Read( rStream );
constexpr auto convertTwipToMm100(N n)
const Link< RtfImportInfo &, void > & GetRtfImportHdl() const
void SetRtfImportHdl(const Link< RtfImportInfo &, void > &rLink)
void SetText(const OutlinerParaObject &)
std::optional< OutlinerParaObject > CreateParaObject(sal_Int32 nStartPara=0, sal_Int32 nParaCount=EE_PARA_ALL) const
bool SetUpdateLayout(bool bUpdate)
SfxStyleSheet * GetStyleSheet() const
SdrOutliner & ImpGetDrawOutliner() const
void NbcSetOutlinerParaObjectForText(std::optional< OutlinerParaObject > pTextObject, SdrText *pText)
void SetPardMap(TypedWhichId< T > wid, TypedWhichId< T > widTrue)
void SetAttrPool(SfxItemPool *pNewPool)
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
virtual const tools::Rectangle & GetSnapRect() const override
void InsertColumnEdge(sal_Int32 nEdge)
SdrTableRTFParser(const SdrTableRTFParser &)=delete
void ProcToken(RtfImportInfo *pInfo)
void InsertCell(RtfImportInfo const *pInfo)
RTFCellDefaultVector::iterator maDefaultIterator
std::vector< RTFColumnVectorPtr > maRows
SdrTableRTFParser & operator=(const SdrTableRTFParser &)=delete
std::unique_ptr< SdrOutliner > mpOutliner
RTFCellDefault * mpActDefault
SdrTableRTFParser(SdrTableObj &rTableObj)
DECL_LINK(RTFImportHdl, RtfImportInfo &, void)
RTFColumnVectorPtr mxLastRow
RTFCellDefault * mpDefMerge
Reference< XTable > mxTable
void Read(SvStream &rStream)
std::vector< sal_Int32 > maColumnEdges
std::unique_ptr< RTFCellDefault > mpInsDefault
RTFCellDefaultVector maDefaultList
std::vector< sal_Int32 >::iterator maLastEdge
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
std::vector< std::shared_ptr< RTFCellDefault > > RTFCellDefaultVector
std::vector< RTFCellInfoPtr > RTFColumnVector
IMPL_LINK(SdrTableRTFParser, RTFImportHdl, RtfImportInfo &, rInfo, void)
void ImportAsRTF(SvStream &rStream, SdrTableObj &rObj)
std::shared_ptr< RTFCellInfo > RTFCellInfoPtr
std::shared_ptr< RTFColumnVector > RTFColumnVectorPtr
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SvParser< int > * pParser
constexpr TypedWhichId< SvxBoxItem > SDRATTR_TABLE_BORDER(SDRATTR_TABLE_FIRST+0)
std::unique_ptr< SdrOutliner > SdrMakeOutliner(OutlinerMode nOutlinerMode, SdrModel &rModel)
Create an Outliner with the engine-global default settings on the heap.
std::shared_ptr< RTFCellInfo > mxVMergeCell