diff options
Diffstat (limited to 'sw/source/filter/ww8/wrtww8.cxx')
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 256 |
1 files changed, 153 insertions, 103 deletions
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index dd6dd6d0d0e7..f6fb18aa0c63 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -1914,28 +1914,29 @@ void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTa } } -static sal_uInt16 lcl_TCFlags(const SwTableBox * pBox) +static sal_uInt16 lcl_TCFlags(const SwTableBox * pBox, long nRowSpan) { sal_uInt16 nFlags = 0; - long nRowSpan = pBox->getRowSpan(); - if (nRowSpan > 1) nFlags |= (3 << 5); else if (nRowSpan < 0) nFlags |= (1 << 5); - const SwFrmFmt * pFmt = pBox->GetFrmFmt(); - switch (pFmt->GetVertOrient().GetVertOrient()) + if (pBox != NULL) { - case text::VertOrientation::CENTER: - nFlags |= (1 << 7); - break; - case text::VertOrientation::BOTTOM: - nFlags |= (2 << 7); - break; - default: - break; + const SwFrmFmt * pFmt = pBox->GetFrmFmt(); + switch (pFmt->GetVertOrient().GetVertOrient()) + { + case text::VertOrientation::CENTER: + nFlags |= (1 << 7); + break; + case text::VertOrientation::BOTTOM: + nFlags |= (2 << 7); + break; + default: + break; + } } return nFlags; @@ -2093,9 +2094,6 @@ void WW8AttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { - const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); - const SwTableLine * pTabLine = pTabBox->GetUpper(); - const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes(); const SwTable * pTable = pTableTextNodeInfoInner->getTable(); if ( pTable->GetRowsToRepeat() > pTableTextNodeInfoInner->getRow() ) @@ -2107,10 +2105,10 @@ void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t m_rWW8Export.pO->Insert( 1, m_rWW8Export.pO->Count() ); } + ww8::TableBoxVectorPtr pTableBoxes = + pTableTextNodeInfoInner->getTableBoxesOfRow(); // number of cell written - sal_uInt32 nBoxes = rTabBoxes.Count(); - if ( nBoxes > 32 ) - nBoxes = 32; + sal_uInt32 nBoxes = pTableBoxes->size(); // sprm header m_rWW8Export.InsUInt16( NS_sprm::LN_TDefTable ); @@ -2161,86 +2159,71 @@ void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t } } - sal_uInt32 n = 0; - m_rWW8Export.InsUInt16( nTblOffset ); + m_rWW8Export.InsUInt16( nTblOffset ); - std::vector<SwTwips> gridCols = GetGridCols( pTableTextNodeInfoInner ); - for ( std::vector<SwTwips>::const_iterator it = gridCols.begin(), end = gridCols.end(); it != end; ++it ) - { - m_rWW8Export.InsUInt16( static_cast<USHORT>( *it ) + nTblOffset ); - } + ww8::GridColsPtr pGridCols = GetGridCols( pTableTextNodeInfoInner ); + for ( ww8::GridCols::const_iterator it = pGridCols->begin(), + end = pGridCols->end(); it != end; ++it ) + { + m_rWW8Export.InsUInt16( static_cast<USHORT>( *it ) + nTblOffset ); + } + + /* TCs */ + ww8::RowSpansPtr pRowSpans = pTableTextNodeInfoInner->getRowSpansOfRow(); + ww8::RowSpans::const_iterator aItRowSpans = pRowSpans->begin(); + ww8::TableBoxVector::const_iterator aIt; + ww8::TableBoxVector::const_iterator aItEnd = pTableBoxes->end(); + +#ifdef DEBUG + size_t nRowSpans = pRowSpans->size(); + size_t nTableBoxes = pTableBoxes->size(); + (void) nRowSpans; + (void) nTableBoxes; +#endif - /* TCs */ - for ( n = 0; n < nBoxes; n++ ) + for( aIt = pTableBoxes->begin(); aIt != aItEnd; ++aIt, ++aItRowSpans) { #ifdef DEBUG sal_uInt16 npOCount = m_rWW8Export.pO->Count(); #endif - SwTableBox * pTabBox1 = rTabBoxes[n]; - const SwFrmFmt & rBoxFmt = *(pTabBox1->GetFrmFmt()); + const SwTableBox * pTabBox1 = *aIt; + const SwFrmFmt * pBoxFmt = NULL; + if (pTabBox1 != NULL) + pBoxFmt = pTabBox1->GetFrmFmt(); + if ( m_rWW8Export.bWrtWW8 ) { - sal_uInt16 nFlags = lcl_TCFlags(pTabBox1); - m_rWW8Export.InsUInt16( nFlags ); + sal_uInt16 nFlags = + lcl_TCFlags(pTabBox1, *aItRowSpans); + m_rWW8Export.InsUInt16( nFlags ); } static BYTE aNullBytes[] = { 0x0, 0x0 }; m_rWW8Export.pO->Insert( aNullBytes, 2, m_rWW8Export.pO->Count() ); // dummy - m_rWW8Export.Out_SwFmtTableBox( *m_rWW8Export.pO, rBoxFmt.GetBox() ); // 8/16 Byte + if (pBoxFmt != NULL) + { + const SvxBoxItem & rBoxItem = pBoxFmt->GetBox(); + + m_rWW8Export.Out_SwFmtTableBox( *m_rWW8Export.pO, &rBoxItem ); // 8/16 Byte + } + else + m_rWW8Export.Out_SwFmtTableBox( *m_rWW8Export.pO, NULL); // 8/16 Byte #ifdef DEBUG ::std::clog << "<tclength>" << m_rWW8Export.pO->Count() - npOCount << "</tclength>" - << ::std::endl; + << ::std::endl; #endif } } -std::vector<SwTwips> AttributeOutputBase::GetGridCols( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +ww8::GridColsPtr AttributeOutputBase::GetGridCols( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { - std::vector<SwTwips> gridCols; - - const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); - const SwTableLine * pTabLine = pTabBox->GetUpper(); - const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes(); - const SwTable *pTable = pTableTextNodeInfoInner->getTable( ); - - // number of cell written - sal_uInt32 nBoxes = rTabBoxes.Count(); - if ( nBoxes > 32 ) - nBoxes = 32; - - const SwFrmFmt *pFmt = pTable->GetFrmFmt(); - ASSERT(pFmt,"Impossible"); - if (!pFmt) - return gridCols; - - const SwFmtFrmSize &rSize = pFmt->GetFrmSize(); - unsigned long nTblSz = static_cast<unsigned long>(rSize.GetWidth()); - - sal_uInt32 nPageSize = 0; - bool bRelBoxSize = false; - - GetTablePageSize( pTableTextNodeInfoInner, nPageSize, bRelBoxSize ); - - SwTwips nSz = 0; - for ( sal_uInt32 n = 0; n < nBoxes; n++ ) - { - const SwFrmFmt* pBoxFmt = rTabBoxes[ n ]->GetFrmFmt(); - const SwFmtFrmSize& rLSz = pBoxFmt->GetFrmSize(); - nSz += rLSz.GetWidth(); - SwTwips nCalc = nSz; - if ( bRelBoxSize ) - nCalc = ( nCalc * nPageSize ) / nTblSz; - - gridCols.push_back( nCalc ); - } - - return gridCols; + return pTableTextNodeInfoInner->getGridColsOfRow(*this); } -void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner, sal_uInt32& rPageSize, bool& rRelBoxSize ) +void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner * pTableTextNodeInfoInner, sal_uInt32& rPageSize, bool& rRelBoxSize ) { sal_uInt32 nPageSize = 0; @@ -2455,18 +2438,7 @@ void MSWordExportBase::WriteText() } else { - ::std::clog << "<already-done><which>" << dbg_out(*pNd) - << "</which><nodes>" << ::std::endl; - - SwNodeDeque::const_iterator aEnd = aNodeDeque.end(); - - for (SwNodeDeque::const_iterator aIt = aNodeDeque.begin(); - aIt != aEnd; aIt++) - { - ::std::clog << dbg_out(**aIt) << ::std::endl; - } - - ::std::clog << "</nodes></already-done>" << ::std::endl; + ::std::clog << "<already-done>" << dbg_out(*pNd) << "</already-done>" << ::std::endl; } #endif @@ -2522,6 +2494,10 @@ void MSWordExportBase::WriteText() AppendSection( pAktPageDesc, pParentFmt, nRstLnNum ); } } + else if ( pNd->IsStartNode() ) + { + OutputStartNode( *pNd->GetStartNode() ); + } else if ( pNd->IsEndNode() ) { OutputEndNode( *pNd->GetEndNode() ); @@ -3684,6 +3660,30 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // leeren + sal_uInt32 nShadowsBefore = pNodeInfoInner->getShadowsBefore(); + if (nShadowsBefore > 0) + { + ww8::WW8TableNodeInfoInner::Pointer_t + pTmpNodeInfoInner(new ww8::WW8TableNodeInfoInner(NULL)); + + pTmpNodeInfoInner->setDepth(pNodeInfoInner->getDepth()); + pTmpNodeInfoInner->setEndOfCell(true); + + for (sal_uInt32 n = 0; n < nShadowsBefore; ++n) + { + m_rWW8Export.WriteCR(pTmpNodeInfoInner); + + m_rWW8Export.pO->Insert( (BYTE*)&nStyle, 2, + m_rWW8Export.pO->Count() ); // Style # + TableInfoCell(pTmpNodeInfoInner); + m_rWW8Export.pPapPlc->AppendFkpEntry + ( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), + m_rWW8Export.pO->GetData() ); + + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // leeren + } + } + if (pNodeInfoInner->isEndOfCell()) { #ifdef DEBUG @@ -3699,6 +3699,28 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // leeren } + sal_uInt32 nShadowsAfter = pNodeInfoInner->getShadowsAfter(); + if (nShadowsAfter > 0) + { + ww8::WW8TableNodeInfoInner::Pointer_t + pTmpNodeInfoInner(new ww8::WW8TableNodeInfoInner(NULL)); + + pTmpNodeInfoInner->setDepth(pNodeInfoInner->getDepth()); + pTmpNodeInfoInner->setEndOfCell(true); + + for (sal_uInt32 n = 0; n < nShadowsAfter; ++n) + { + m_rWW8Export.WriteCR(pTmpNodeInfoInner); + + m_rWW8Export.pO->Insert( (BYTE*)&nStyle, 2, m_rWW8Export.pO->Count() ); // Style # + TableInfoCell(pTmpNodeInfoInner); + m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), + m_rWW8Export.pO->GetData() ); + + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // leeren + } + } + if (pNodeInfoInner->isEndOfLine()) { #ifdef DEBUG @@ -3719,34 +3741,62 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer #endif } -void MSWordExportBase::OutputEndNode( const SwEndNode &rNode ) +void MSWordExportBase::OutputStartNode( const SwStartNode & rNode) { #ifdef DEBUG - ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(&rNode) << ::std::endl; + ::std::clog << "<OutWW8_SwStartNode>" << dbg_out(&rNode) << ::std::endl; #endif - ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = mpTableInfo->getTableNodeInfo( &rNode ); + ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = + mpTableInfo->getTableNodeInfo( &rNode ); - if (pNodeInfo) + if (pNodeInfo.get() != NULL) { - if (pNodeInfo.get() != NULL) - { #ifdef DEBUG - ::std::clog << pNodeInfo->toString() << ::std::endl; + ::std::clog << pNodeInfo->toString() << ::std::endl; #endif - const ww8::WW8TableNodeInfo::Inners_t aInners = pNodeInfo->getInners(); - ww8::WW8TableNodeInfo::Inners_t::const_iterator aIt(aInners.begin()); - ww8::WW8TableNodeInfo::Inners_t::const_iterator aEnd(aInners.end()); - while (aIt != aEnd) - { - ww8::WW8TableNodeInfoInner::Pointer_t pInner = aIt->second; - AttrOutput().TableNodeInfoInner(pInner); - aIt++; - } + const ww8::WW8TableNodeInfo::Inners_t aInners = pNodeInfo->getInners(); + ww8::WW8TableNodeInfo::Inners_t::const_reverse_iterator aIt(aInners.rbegin()); + ww8::WW8TableNodeInfo::Inners_t::const_reverse_iterator aEnd(aInners.rend()); + while (aIt != aEnd) + { + ww8::WW8TableNodeInfoInner::Pointer_t pInner = aIt->second; + + AttrOutput().TableNodeInfoInner(pInner); + aIt++; } } #ifdef DEBUG + ::std::clog << "</OutWW8_SwStartNode>" << ::std::endl; +#endif +} + +void MSWordExportBase::OutputEndNode( const SwEndNode &rNode ) +{ +#ifdef DEBUG + ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(&rNode) << ::std::endl; +#endif + + ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = mpTableInfo->getTableNodeInfo( &rNode ); + + if (pNodeInfo.get() != NULL) + { +#ifdef DEBUG + ::std::clog << pNodeInfo->toString() << ::std::endl; +#endif + + const ww8::WW8TableNodeInfo::Inners_t aInners = pNodeInfo->getInners(); + ww8::WW8TableNodeInfo::Inners_t::const_iterator aIt(aInners.begin()); + ww8::WW8TableNodeInfo::Inners_t::const_iterator aEnd(aInners.end()); + while (aIt != aEnd) + { + ww8::WW8TableNodeInfoInner::Pointer_t pInner = aIt->second; + AttrOutput().TableNodeInfoInner(pInner); + aIt++; + } + } +#ifdef DEBUG ::std::clog << "</OutWW8_SwEndNode>" << ::std::endl; #endif } |