diff options
author | Daniel Vogelheim <dvo@openoffice.org> | 2000-11-16 10:21:54 +0000 |
---|---|---|
committer | Daniel Vogelheim <dvo@openoffice.org> | 2000-11-16 10:21:54 +0000 |
commit | cfc62f2605ff3eb4f46f79691f7e52ddab29e04d (patch) | |
tree | 4c3b3890d15a7a5b95146de3bbc2abaf8d9050d1 | |
parent | ff4f5d730aa7c9814db5dcedd8546c1546f3755c (diff) |
- added: XML im- and export of formulas, values, and data styles in StarWriter tables
-rw-r--r-- | sw/source/filter/xml/xmlexp.cxx | 8 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlexp.hxx | 7 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlfmt.cxx | 79 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlfmte.cxx | 35 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltble.cxx | 110 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltbli.cxx | 104 | ||||
-rw-r--r-- | sw/source/filter/xml/xmltbli.hxx | 8 |
7 files changed, 315 insertions, 36 deletions
diff --git a/sw/source/filter/xml/xmlexp.cxx b/sw/source/filter/xml/xmlexp.cxx index 0658b3a67e80..3b2de960809f 100644 --- a/sw/source/filter/xml/xmlexp.cxx +++ b/sw/source/filter/xml/xmlexp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlexp.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mib $ $Date: 2000-11-13 08:44:24 $ + * last change: $Author: dvo $ $Date: 2000-11-16 11:21:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -175,7 +175,9 @@ SwXMLExport::SwXMLExport( const Reference< XModel >& rModel, SwPaM& rPaM, pTableLines( 0 ), bExportWholeDoc( bExpWholeDoc ), bExportFirstTableOnly( bExpFirstTableOnly ), - bShowProgress( bShowProg ) + bShowProgress( bShowProg ), + sNumberFormat(RTL_CONSTASCII_USTRINGPARAM("NumberFormat")), + sCell(RTL_CONSTASCII_USTRINGPARAM("Cell")) { const SfxPoolItem* pItem; const SfxItemPool& rPool = pDoc->GetAttrPool(); diff --git a/sw/source/filter/xml/xmlexp.hxx b/sw/source/filter/xml/xmlexp.hxx index 477820c894f9..8953f230d865 100644 --- a/sw/source/filter/xml/xmlexp.hxx +++ b/sw/source/filter/xml/xmlexp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlexp.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mib $ $Date: 2000-11-13 08:44:24 $ + * last change: $Author: dvo $ $Date: 2000-11-16 11:21:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -161,6 +161,9 @@ class SwXMLExport : public SvXMLExport void SetCurPaM( SwPaM& rPaM, sal_Bool bWhole, sal_Bool bTabOnly ); #endif + const ::rtl::OUString sNumberFormat; + const ::rtl::OUString sCell; + protected: virtual XMLTextParagraphExport* CreateTextParagraphExport(); diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx index 3bb0ad431612..2c66db0e39d9 100644 --- a/sw/source/filter/xml/xmlfmt.cxx +++ b/sw/source/filter/xml/xmlfmt.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlfmt.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: mib $ $Date: 2000-11-07 14:05:53 $ + * last change: $Author: dvo $ $Date: 2000-11-16 11:21:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -162,6 +162,10 @@ #ifndef _XMLTBLI_HXX #include "xmltbli.hxx" #endif +#ifndef _CELLATR_HXX +#include "cellatr.hxx" +#endif + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -567,8 +571,11 @@ class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext OUString sMasterPageName; SfxItemSet *pItemSet; + OUString sDataStyleName; + sal_Bool bHasMasterPageName : 1; sal_Bool bPageDescConnected : 1; + sal_Bool bDataStyleIsResolved; SvXMLImportContext *CreateItemSetContext( sal_uInt16 nPrefix, @@ -610,17 +617,35 @@ public: sal_Bool IsPageDescConnected() const { return bPageDescConnected; } void ConnectPageDesc(); + + sal_Bool ResolveDataStyleName(); }; void SwXMLItemSetStyleContext_Impl::SetAttribute( sal_uInt16 nPrefixKey, const OUString& rLocalName, const OUString& rValue ) { - if( XML_NAMESPACE_STYLE == nPrefixKey && - rLocalName.compareToAscii( sXML_master_page_name ) == 0 ) + if( XML_NAMESPACE_STYLE == nPrefixKey ) { - sMasterPageName = rValue; - bHasMasterPageName = sal_True; + if (rLocalName.compareToAscii( sXML_master_page_name ) == 0) + { + sMasterPageName = rValue; + bHasMasterPageName = sal_True; + } + else if (rLocalName.equalsAsciiL( sXML_data_style_name, + sizeof(sXML_data_style_name)-1 )) + { + // if we have a valid data style name + if (rValue.getLength() > 0) + { + sDataStyleName = rValue; + bDataStyleIsResolved = sal_False; // needs to be resolved + } + } + else + { + SvXMLStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue ); + } } else { @@ -685,7 +710,9 @@ SwXMLItemSetStyleContext_Impl::SwXMLItemSetStyleContext_Impl( SwXMLImport& rImpo SvXMLStyleContext( rImport, nPrfx, rLName, xAttrList ), pItemSet( 0 ), bHasMasterPageName( sal_False ), - bPageDescConnected( sal_False ) + bPageDescConnected( sal_False ), + sDataStyleName(), + bDataStyleIsResolved( sal_True ) { SetFamily( nFamily ); } @@ -771,6 +798,36 @@ void SwXMLItemSetStyleContext_Impl::ConnectPageDesc() } } +sal_Bool SwXMLItemSetStyleContext_Impl::ResolveDataStyleName() +{ + sal_Bool bTmp = bDataStyleIsResolved; + + // resolve, if not already done + if (! bDataStyleIsResolved) + { + // get the format key + sal_Int32 nFormat = + GetImport().GetTextImport()->GetDataStyleKey(sDataStyleName); + + // if the key is valid, insert Item into ItemSet + DBG_ASSERT(NULL != pItemSet, "need ItemSet"); + if ((NULL != pItemSet) && (-1 != nFormat)) + { + SwTblBoxNumFormat aNumFormatItem(nFormat); + pItemSet->Put(aNumFormatItem); + } + + // now resolved + bDataStyleIsResolved = sal_True; + return sal_True; + } + else + { + // was already resolved; nothing to do + return sal_False; + } +} + // --------------------------------------------------------------------- // class SwXMLStylesContext_Impl : public SvXMLStylesContext @@ -1070,6 +1127,14 @@ sal_Bool SwXMLImport::FindAutomaticStyle( !pStyle->IsPageDescConnected() ) pStyle->ConnectPageDesc(); (*ppItemSet) = pStyle->GetItemSet(); + + // resolve data style name late + if( XML_STYLE_FAMILY_TABLE_CELL == pStyle->GetFamily() && + pStyle->ResolveDataStyleName() ) + { + (*ppItemSet) = pStyle->GetItemSet(); + } + } if( pParent ) diff --git a/sw/source/filter/xml/xmlfmte.cxx b/sw/source/filter/xml/xmlfmte.cxx index 557fdd92495f..e22ae0346190 100644 --- a/sw/source/filter/xml/xmlfmte.cxx +++ b/sw/source/filter/xml/xmlfmte.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlfmte.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: mib $ $Date: 2000-11-07 14:05:53 $ + * last change: $Author: dvo $ $Date: 2000-11-16 11:21:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -216,6 +216,10 @@ #include "unostyle.hxx" #endif +#ifndef _CELLATR_HXX +#include "cellatr.hxx" +#endif + using namespace rtl; using namespace ::com::sun::star; @@ -269,6 +273,30 @@ void SwXMLExport::ExportFmt( const SwFmt& rFmt, const char *pFamily ) } } + if( sXML_table_cell == pStr ) + { + DBG_ASSERT(RES_FRMFMT == rFmt.Which(), "only frame format"); + + const SfxPoolItem *pItem; + if( SFX_ITEM_SET == + rFmt.GetAttrSet().GetItemState( RES_BOXATR_FORMAT, + sal_False, &pItem ) ) + { + sal_Int32 nFormat = (sal_Int32) + ((const SwTblBoxNumFormat *)pItem)->GetValue(); + + if (-1 != nFormat) + { + // if we have a format, register and then export + // (Careful: here we assume that data styles will be + // written after cell styles) + addDataStyle(nFormat); + AddAttribute( XML_NAMESPACE_STYLE, sXML_data_style_name, + getDataStyleName(nFormat) ); + } + } + } + { SvXMLElementExport aElem( *this, XML_NAMESPACE_STYLE, sXML_style, sal_True, sal_True ); @@ -425,6 +453,9 @@ void SwXMLExport::_ExportAutoStyles() GetTextParagraphExport()->exportTextAutoStyles(); GetPageExport()->exportAutoStyles(); + + // we rely on data styles being written after cell styles in the + // ExportFmt() method; so be careful when changing order. exportAutoDataStyles(); } diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx index 84abf4b98ab3..571c1d77ddcb 100644 --- a/sw/source/filter/xml/xmltble.cxx +++ b/sw/source/filter/xml/xmltble.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltble.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mib $ $Date: 2000-11-07 14:05:53 $ + * last change: $Author: dvo $ $Date: 2000-11-16 11:21:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,6 +75,10 @@ #include <com/sun/star/text/XTextTable.hpp> #endif +#ifndef _COM_SUN_STAR_TABLE_XCELL_HPP_ +#include <com/sun/star/table/XCell.hpp> +#endif + #ifndef _XMLOFF_XMLNMSPE_HXX #include <xmloff/xmlnmspe.hxx> #endif @@ -87,9 +91,16 @@ #include <xmloff/xmluconv.hxx> #endif +#ifndef XMLOFF_NUMEHELP_HXX +#include <xmloff/numehelp.hxx> +#endif + #ifndef _CNTRSRT_HXX #include <svtools/cntnrsrt.hxx> #endif +#ifndef _ZFORLIST_HXX +#include <svtools/zforlist.hxx> +#endif #ifndef _SVX_BRSHITEM_HXX #include <svx/brshitem.hxx> @@ -119,6 +130,9 @@ #ifndef _FMTORNT_HXX #include "fmtornt.hxx" #endif +#ifndef _CELLATR_HXX +#include "cellatr.hxx" +#endif #ifndef _UNOOBJ_HXX #include "unoobj.hxx" @@ -134,13 +148,15 @@ #include "xmlexp.hxx" #endif + using namespace ::rtl; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::text; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; +using ::com::sun::star::table::XCell; -Reference < XText > lcl_xml_CreateTableBoxText( +Reference < XTextRange > lcl_xml_CreateTableBoxTextRange( const SwStartNode& rBoxSttNd ) { SwPaM aPaM( *rBoxSttNd.EndOfSectionNode() ); @@ -152,7 +168,7 @@ Reference < XText > lcl_xml_CreateTableBoxText( Reference < XTextRange > xTextRange = CreateTextRangeFromPosition( aPaM.GetDoc(), *aPaM.GetPoint(), aPaM.GetMark() ); - return xTextRange->getText(); + return xTextRange; } class SwXMLTableColumn_Impl : public SwWriteTableCol @@ -416,6 +432,7 @@ sal_Bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt, const SwFmtVertOrient *pVertOrient = 0; const SvxBrushItem *pBrush = 0; const SvxBoxItem *pBox = 0; + sal_uInt32 nNumFormat = 0; // compare number formats by their number const SfxItemSet& rItemSet = rFrmFmt.GetAttrSet(); const SfxPoolItem *pItem; @@ -429,6 +446,10 @@ sal_Bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt, if( SFX_ITEM_SET == rItemSet.GetItemState( RES_BOX, sal_False, &pItem ) ) pBox = (const SvxBoxItem *)pItem; + if ( SFX_ITEM_SET == rItemSet.GetItemState( RES_BOXATR_FORMAT, + sal_False, &pItem ) ) + nNumFormat = ((const SwTblBoxNumFormat *)pItem)->GetValue(); + // empty styles have not to be exported if( !pVertOrient && !pBrush && !pBox ) return sal_False; @@ -443,6 +464,7 @@ sal_Bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt, const SwFmtVertOrient *pTestVertOrient = 0; const SvxBrushItem *pTestBrush = 0; const SvxBoxItem *pTestBox = 0; + sal_uInt32 nTestNumFormat = 0; const SwFrmFmt *pTestFmt = GetObject(i); const SfxItemSet& rTestSet = pTestFmt->GetAttrSet(); if( SFX_ITEM_SET == rTestSet.GetItemState( RES_VERT_ORIENT, sal_False, @@ -486,6 +508,10 @@ sal_Bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt, continue; } + if ( SFX_ITEM_SET == rTestSet.GetItemState( RES_BOXATR_FORMAT, + sal_False, &pItem ) ) + nTestNumFormat = ((const SwTblBoxNumFormat *)pItem)->GetValue(); + if( pVertOrient && pVertOrient->GetVertOrient() != pTestVertOrient->GetVertOrient() ) continue; @@ -496,6 +522,10 @@ sal_Bool SwXMLTableFrmFmtsSort_Impl::AddCell( SwFrmFmt& rFrmFmt, if( pBox && !pBox->equalsXML( *pTestBox ) ) continue; + // compare formats based on value (rather than presentation) + if( nNumFormat != nTestNumFormat ) + continue; + // found! const String& rFmtName = pTestFmt->GetName(); rFrmFmt.SetName( rFmtName ); @@ -676,7 +706,7 @@ void SwXMLExport::ExportTableLinesAutoStyles( const SwTableLines& rLines, ExportFmt( *pFrmFmt, sXML_table_cell ); GetTextParagraphExport()->collectTextAutoStyles( - lcl_xml_CreateTableBoxText( *pBoxSttNd ) ); + lcl_xml_CreateTableBoxTextRange( *pBoxSttNd )->getText() ); } else { @@ -758,18 +788,76 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox, sal_uInt16 nColSpan ) } { - SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, - sXML_table_cell, sal_True, sal_True ); if( pBoxSttNd ) { - GetTextParagraphExport()->exportText( - lcl_xml_CreateTableBoxText( *pBoxSttNd ) ); + // start node -> normal cell + + // get cell range for table + Reference<XTextRange> xRange( + lcl_xml_CreateTableBoxTextRange( *pBoxSttNd ) ); + + // get formula + Reference<XPropertySet> xRangePropertySet(xRange, UNO_QUERY); + Any aAny = xRangePropertySet->getPropertyValue(sCell); + Reference<XCell> xCell; + aAny >>= xCell; + if (xCell.is()) + { + OUString sCellFormula = xCell->getFormula(); + + // if this cell has a formula, export it + // (with value and number format) + if (sCellFormula.getLength()>0) + { + // formula + AddAttribute(XML_NAMESPACE_TABLE, sXML_formula, + sCellFormula); + } + + // value and format (if NumberFormat != -1) + Reference<XPropertySet> xCellPropertySet(xCell, + UNO_QUERY); + if (xCellPropertySet.is()) + { + sal_Int32 nNumberFormat; + aAny = xCellPropertySet->getPropertyValue(sNumberFormat); + aAny >>= nNumberFormat; + + if (NUMBERFORMAT_TEXT == nNumberFormat) + { + // text format + AddAttributeASCII( XML_NAMESPACE_TEXT, + sXML_value_type, sXML_text ); + } + else if (-1 != nNumberFormat) + { + // number format key: + XMLNumberFormatAttributesExportHelper:: + SetNumberFormatAttributes( + *this, nNumberFormat, xCell->getValue(), + XML_NAMESPACE_TABLE, sal_True); + } + // else: invalid key; ignore + } + } + + // export cell element + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, + sXML_table_cell, sal_True, sal_True ); + + // export cell content + GetTextParagraphExport()->exportText( xRange->getText() ); } else { + // no start node -> merged cells: export subtable in cell SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, - sXML_sub_table, sal_True, sal_True ); - ExportTableLines( rBox.GetTabLines() ); + sXML_table_cell, sal_True, sal_True ); + { + SvXMLElementExport aElem( *this, XML_NAMESPACE_TABLE, + sXML_sub_table, sal_True, sal_True ); + ExportTableLines( rBox.GetTabLines() ); + } } } } diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index cdfd12884aea..76ec5917f663 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltbli.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: mib $ $Date: 2000-11-08 09:39:53 $ + * last change: $Author: dvo $ $Date: 2000-11-16 11:21:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,6 +104,10 @@ #include <xmloff/families.hxx> #endif +#ifndef _XMLOFF_XMLUCONV_HXX +#include <xmloff/xmluconv.hxx> +#endif + #ifndef _POOLFMT_HXX #include "poolfmt.hxx" #endif @@ -134,6 +138,10 @@ #ifndef _UNOCRSR_HXX #include "unocrsr.hxx" #endif +#ifndef _CELLATR_HXX +#include "cellatr.hxx" +#endif + #ifndef _XMLIMP_HXX #include "xmlimp.hxx" @@ -189,6 +197,9 @@ class SwXMLTableCell_Impl { OUString aStyleName; + OUString sFormula; // cell formula; valid if length > 0 + double dValue; // formula value + SvXMLImportContextRef xSubTable; const SwStartNode *pStartNode; @@ -208,7 +219,8 @@ public: inline void Set( const OUString& rStyleName, sal_uInt32 nRSpan, sal_uInt32 nCSpan, - const SwStartNode *pStNd, SwXMLTableContext *pTable ); + const SwStartNode *pStNd, SwXMLTableContext *pTable, + OUString* pFormula = NULL, double dVal = 0.0 ); sal_Bool IsUsed() const { return pStartNode!=0 || xSubTable.Is() || bProtected;} @@ -217,6 +229,8 @@ public: void SetRowSpan( sal_uInt32 nSet ) { nRowSpan = nSet; } sal_uInt32 GetColSpan() const { return nColSpan; } const OUString& GetStyleName() const { return aStyleName; } + const OUString& GetFormula() const { return sFormula; } + double GetValue() const { return dValue; } const SwStartNode *GetStartNode() const { return pStartNode; } inline void SetStartNode( const SwStartNode *pSttNd ); @@ -229,13 +243,22 @@ public: inline void SwXMLTableCell_Impl::Set( const OUString& rStyleName, sal_uInt32 nRSpan, sal_uInt32 nCSpan, const SwStartNode *pStNd, - SwXMLTableContext *pTable ) + SwXMLTableContext *pTable, + OUString* pFormula, + double dVal) { aStyleName = rStyleName; nRowSpan = nRSpan; nColSpan = nCSpan; pStartNode = pStNd; xSubTable = pTable; + dValue = dVal; + + // set formula, if valid + if (pFormula != NULL) + { + sFormula = *pFormula; + } } inline void SwXMLTableCell_Impl::SetStartNode( const SwStartNode *pSttNd ) @@ -348,9 +371,12 @@ void SwXMLTableRow_Impl::Dispose() class SwXMLTableCellContext_Impl : public SvXMLImportContext { OUString aStyleName; + OUString sFormula; SvXMLImportContextRef xMyTable; + double fValue; + sal_uInt32 nRowSpan; sal_uInt32 nColSpan; @@ -389,7 +415,9 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl( nRowSpan( 1UL ), nColSpan( 1UL ), bHasTextContent( sal_False ), - bHasTableContent( sal_False ) + bHasTableContent( sal_False ), + sFormula(), + fValue(0.0) { sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; for( sal_Int16 i=0; i < nAttrCount; i++ ) @@ -419,6 +447,48 @@ SwXMLTableCellContext_Impl::SwXMLTableCellContext_Impl( if( nRowSpan < 1UL ) nRowSpan = 1UL; } + else if (aLocalName.equalsAsciiL(sXML_formula, + sizeof(sXML_formula)-1)) + { + sFormula = rValue; + } + else if (aLocalName.equalsAsciiL(sXML_value, + sizeof(sXML_value)-1)) + { + double fTmp; + if (SvXMLUnitConverter::convertNumber(fTmp, rValue)) + { + fValue = fTmp; + } + } + else if (aLocalName.equalsAsciiL(sXML_time_value, + sizeof(sXML_time_value)-1)) + { + double fTmp; + if (SvXMLUnitConverter::convertTime(fTmp, rValue)) + { + fValue = fTmp; + } + } + else if (aLocalName.equalsAsciiL(sXML_date_value, + sizeof(sXML_date_value)-1)) + { + double fTmp; + if (GetImport().GetMM100UnitConverter().convertDateTime(fTmp, + rValue)) + { + fValue = fTmp; + } + } + else if (aLocalName.equalsAsciiL(sXML_boolean_value, + sizeof(sXML_boolean_value)-1)) + { + sal_Bool bTmp; + if (SvXMLUnitConverter::convertBool(bTmp, rValue)) + { + fValue = (bTmp ? 1.0 : 0.0); + } + } } } } @@ -432,7 +502,8 @@ inline void SwXMLTableCellContext_Impl::InsertContentIfNotThere() if( !HasContent() ) { GetTable()->InsertCell( aStyleName, nRowSpan, nColSpan, - GetTable()->InsertTableSection() ); + GetTable()->InsertTableSection(), + NULL, &sFormula, fValue); bHasTextContent = sal_True; } } @@ -1022,7 +1093,9 @@ sal_Int32 SwXMLTableContext::GetColumnWidth( sal_uInt32 nCol, void SwXMLTableContext::InsertCell( const OUString& rStyleName, sal_uInt32 nRowSpan, sal_uInt32 nColSpan, const SwStartNode *pStartNode, - SwXMLTableContext *pTable ) + SwXMLTableContext *pTable, + OUString* pFormula, + double fValue) { ASSERT( nCurCol < GetColumnCount(), "SwXMLTableContext::InsertCell: row is full" ); @@ -1097,7 +1170,7 @@ void SwXMLTableContext::InsertCell( const OUString& rStyleName, for( i=nColSpan; i>0UL; i-- ) for( j=nRowSpan; j>0UL; j-- ) GetCell( nRowsReq-j, nColsReq-i ) - ->Set( rStyleName, j, i, pStartNode, pTable ); + ->Set( rStyleName, j, i, pStartNode, pTable, pFormula, fValue); // Set current col to the next (free) column nCurCol = nColsReq; @@ -1387,6 +1460,21 @@ SwTableBox *SwXMLTableContext::MakeTableBox( pFrmFmt->SetAttr( *pAutoItemSet ); } + if( pCell->GetStartNode() ) + { + const OUString& rFormula = pCell->GetFormula(); + if (rFormula.getLength() > 0) + { + // formula cell: insert formula if valid + SwTblBoxFormula aFormulaItem( rFormula ); + pFrmFmt->SetAttr( aFormulaItem ); + } + + // always insert value, even if default + SwTblBoxValue aValueItem( pCell->GetValue() ); + pFrmFmt->SetAttr( aValueItem ); + } + pFrmFmt->SetAttr( SwFmtFrmSize( ATT_VAR_SIZE, nColWidth ) ); return pBox; diff --git a/sw/source/filter/xml/xmltbli.hxx b/sw/source/filter/xml/xmltbli.hxx index 7aaa4da5800c..815f4dcf52d8 100644 --- a/sw/source/filter/xml/xmltbli.hxx +++ b/sw/source/filter/xml/xmltbli.hxx @@ -2,9 +2,9 @@ * * $RCSfile: xmltbli.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mib $ $Date: 2000-11-07 14:05:53 $ + * last change: $Author: dvo $ $Date: 2000-11-16 11:21:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -179,7 +179,9 @@ public: void InsertCell( const ::rtl::OUString& rStyleName, sal_uInt32 nRowSpan=1U, sal_uInt32 nColSpan=1U, const SwStartNode *pStNd=0, - SwXMLTableContext *pTable=0 ); + SwXMLTableContext *pTable=0, + ::rtl::OUString *pFormula=0, + double fValue=0.0); void InsertRow( const ::rtl::OUString& rStyleName, sal_Bool bInHead ); void FinishRow(); |