diff options
author | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2011-01-06 12:32:39 +0100 |
---|---|---|
committer | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2011-01-06 12:32:39 +0100 |
commit | 1ed3654a1c0acf899fbe93352b93979f17103528 (patch) | |
tree | 13735a742e021d41a308fd60f3b1e782a823ecd7 /oox/source | |
parent | b156d957d5029e80483bfe0da9279243a6fbf439 (diff) |
dr78: #i96587# oox - import BIFF2-BIFF5 cell notes
Diffstat (limited to 'oox/source')
-rw-r--r-- | oox/source/dump/biffdumper.cxx | 3 | ||||
-rw-r--r-- | oox/source/xls/commentsbuffer.cxx | 59 | ||||
-rw-r--r-- | oox/source/xls/defnamesbuffer.cxx | 4 | ||||
-rwxr-xr-x | oox/source/xls/drawingmanager.cxx | 3 | ||||
-rw-r--r-- | oox/source/xls/richstring.cxx | 17 | ||||
-rw-r--r-- | oox/source/xls/worksheetfragment.cxx | 11 |
6 files changed, 81 insertions, 16 deletions
diff --git a/oox/source/dump/biffdumper.cxx b/oox/source/dump/biffdumper.cxx index 8b3127d0b5e7..3e9e1d77d5c2 100644 --- a/oox/source/dump/biffdumper.cxx +++ b/oox/source/dump/biffdumper.cxx @@ -2523,7 +2523,8 @@ void WorkbookStreamObject::implDumpRecordBody() } else { - sal_uInt16 nTextLen = ::std::min( dumpDec< sal_uInt16 >( "text-len" ), static_cast< sal_uInt16 >( rStrm.getRemaining() ) ); + sal_uInt16 nTextLen = dumpDec< sal_uInt16 >( "text-len" ); + nTextLen = ::std::min( nTextLen, static_cast< sal_uInt16 >( rStrm.getRemaining() ) ); writeStringItem( "note-text", rStrm.readCharArrayUC( nTextLen, getBiffData().getTextEncoding(), true ) ); } break; diff --git a/oox/source/xls/commentsbuffer.cxx b/oox/source/xls/commentsbuffer.cxx index 612568ed0b51..f0d4eb63611c 100644 --- a/oox/source/xls/commentsbuffer.cxx +++ b/oox/source/xls/commentsbuffer.cxx @@ -34,6 +34,7 @@ #include "oox/helper/recordinputstream.hxx" #include "oox/vml/vmlshape.hxx" #include "oox/xls/addressconverter.hxx" +#include "oox/xls/biffinputstream.hxx" #include "oox/xls/drawingfragment.hxx" using ::rtl::OUString; @@ -82,6 +83,39 @@ void Comment::importComment( RecordInputStream& rStrm ) getAddressConverter().convertToCellRangeUnchecked( maModel.maRange, aBinRange, getSheetIndex() ); } +void Comment::importNote( BiffInputStream& rStrm ) +{ + BinAddress aBinAddr; + sal_uInt16 nTotalLen; + rStrm >> aBinAddr >> nTotalLen; + // cell range will be checked while inserting the comment into the document + getAddressConverter().convertToCellRangeUnchecked( maModel.maRange, BinRange( aBinAddr ), getSheetIndex() ); + RichStringRef xNoteText = createText(); + + sal_uInt16 nPartLen = ::std::min( nTotalLen, static_cast< sal_uInt16 >( rStrm.getRemaining() ) ); + xNoteText->importCharArray( rStrm, nPartLen, getTextEncoding() ); + + nTotalLen = nTotalLen - nPartLen; // operator-=() gives compiler warning + while( (nTotalLen > 0) && (rStrm.getNextRecId() == BIFF_ID_NOTE) && rStrm.startNextRecord() ) + { + rStrm >> aBinAddr >> nPartLen; + OSL_ENSURE( aBinAddr.mnRow == 0xFFFF, "Comment::importNote - missing continuation NOTE record" ); + if( aBinAddr.mnRow == 0xFFFF ) + { + OSL_ENSURE( nPartLen <= nTotalLen, "Comment::importNote - string too long" ); + // call to RichString::importCharArray() appends new text portion + xNoteText->importCharArray( rStrm, nPartLen, getTextEncoding() ); + nTotalLen = nTotalLen - ::std::min( nTotalLen, nPartLen ); + } + else + { + // seems to be a new note, rewind record, so worksheet fragment loop will find it + rStrm.rewindRecord(); + nTotalLen = 0; + } + } +} + RichStringRef Comment::createText() { maModel.mxText.reset( new RichString( *this ) ); @@ -107,14 +141,25 @@ void Comment::finalizeImport() Reference< XSheetAnnotationShapeSupplier > xAnnoShapeSupp( xAnno, UNO_QUERY_THROW ); Reference< XShape > xAnnoShape( xAnnoShapeSupp->getAnnotationShape(), UNO_SET_THROW ); // convert shape formatting - if( const ::oox::vml::ShapeBase* pNoteShape = getVmlDrawing().getNoteShape( aNotePos ) ) + switch( getFilterType() ) { - // position and formatting - pNoteShape->convertFormatting( xAnnoShape ); - // visibility - const ::oox::vml::ShapeModel::ShapeClientDataPtr& rxClientData = pNoteShape->getShapeModel().mxClientData; - bool bVisible = rxClientData.get() && rxClientData->mbVisible; - xAnno->setIsVisible( bVisible ); + case FILTER_OOX: + if( const ::oox::vml::ShapeBase* pNoteShape = getVmlDrawing().getNoteShape( aNotePos ) ) + { + // position and formatting + pNoteShape->convertFormatting( xAnnoShape ); + // visibility + const ::oox::vml::ShapeModel::ShapeClientDataPtr& rxClientData = pNoteShape->getShapeModel().mxClientData; + bool bVisible = rxClientData.get() && rxClientData->mbVisible; + xAnno->setIsVisible( bVisible ); + } + break; + case FILTER_BIFF: + // notes are always hidden and unformatted in BIFF3-BIFF5 + xAnno->setIsVisible( sal_False ); + break; + case FILTER_UNKNOWN: + break; } // insert text and convert text formatting maModel.mxText->finalizeImport(); diff --git a/oox/source/xls/defnamesbuffer.cxx b/oox/source/xls/defnamesbuffer.cxx index a02375e2b869..3c1a9169f004 100644 --- a/oox/source/xls/defnamesbuffer.cxx +++ b/oox/source/xls/defnamesbuffer.cxx @@ -491,6 +491,10 @@ void DefinedName::createNameObject() if( /*maModel.mbHidden ||*/ maModel.mbFunction ) return; + // skip BIFF names without stream position (e.g. BIFF3-BIFF4 internal 3D references) + if( (getFilterType() == FILTER_BIFF) && !mxBiffStrm.get() ) + return; + // convert original name to final Calc name if( maModel.mbVBName ) maCalcName = maModel.maName; diff --git a/oox/source/xls/drawingmanager.cxx b/oox/source/xls/drawingmanager.cxx index 16e5ceddd27d..0ef734aa86a0 100755 --- a/oox/source/xls/drawingmanager.cxx +++ b/oox/source/xls/drawingmanager.cxx @@ -891,7 +891,8 @@ void BiffDrawingBase::importObj( BiffInputStream& rStrm ) xDrawingObj = BiffDrawingObjectBase::importObjBiff4( *this, rStrm ); break; case BIFF5: - case BIFF8: +// TODO: add BIFF8 when DFF is supported +// case BIFF8: xDrawingObj = BiffDrawingObjectBase::importObjBiff5( *this, rStrm ); break; default:; diff --git a/oox/source/xls/richstring.cxx b/oox/source/xls/richstring.cxx index c967ce60fa3d..f7aad994c3d5 100644 --- a/oox/source/xls/richstring.cxx +++ b/oox/source/xls/richstring.cxx @@ -416,7 +416,12 @@ void RichString::importString( RecordInputStream& rStrm, bool bRich ) } } -void RichString::importByteString( BiffInputStream& rStrm, rtl_TextEncoding eDefaultTextEnc, BiffStringFlags nFlags ) +void RichString::importCharArray( BiffInputStream& rStrm, sal_uInt16 nChars, rtl_TextEncoding eTextEnc ) +{ + createPortion()->setText( rStrm.readCharArrayUC( nChars, eTextEnc ) ); +} + +void RichString::importByteString( BiffInputStream& rStrm, rtl_TextEncoding eTextEnc, BiffStringFlags nFlags ) { OSL_ENSURE( !getFlag( nFlags, BIFF_STR_KEEPFONTS ), "RichString::importString - keep fonts not implemented" ); OSL_ENSURE( !getFlag( nFlags, static_cast< BiffStringFlags >( ~(BIFF_STR_8BITLENGTH | BIFF_STR_EXTRAFONTS) ) ), "RichString::importByteString - unknown flag" ); @@ -428,11 +433,11 @@ void RichString::importByteString( BiffInputStream& rStrm, rtl_TextEncoding eDef { FontPortionModelList aPortions; aPortions.importPortions( rStrm, false ); - createFontPortions( aBaseText, eDefaultTextEnc, aPortions ); + createFontPortions( aBaseText, eTextEnc, aPortions ); } else { - createPortion()->setText( OStringToOUString( aBaseText, eDefaultTextEnc ) ); + createPortion()->setText( OStringToOUString( aBaseText, eTextEnc ) ); } } @@ -525,7 +530,7 @@ RichStringPhoneticRef RichString::createPhonetic() return xPhonetic; } -void RichString::createFontPortions( const OString& rText, rtl_TextEncoding eDefaultTextEnc, FontPortionModelList& rPortions ) +void RichString::createFontPortions( const OString& rText, rtl_TextEncoding eTextEnc, FontPortionModelList& rPortions ) { maFontPortions.clear(); sal_Int32 nStrLen = rText.getLength(); @@ -545,8 +550,8 @@ void RichString::createFontPortions( const OString& rText, rtl_TextEncoding eDef { // convert byte string to unicode string, using current font encoding FontRef xFont = getStyles().getFont( aIt->mnFontId ); - rtl_TextEncoding eTextEnc = xFont.get() ? xFont->getFontEncoding() : eDefaultTextEnc; - OUString aUniStr = OStringToOUString( rText.copy( aIt->mnPos, nPortionLen ), eTextEnc ); + rtl_TextEncoding eFontEnc = xFont.get() ? xFont->getFontEncoding() : eTextEnc; + OUString aUniStr = OStringToOUString( rText.copy( aIt->mnPos, nPortionLen ), eFontEnc ); // create string portion RichStringPortionRef xPortion = createPortion(); xPortion->setText( aUniStr ); diff --git a/oox/source/xls/worksheetfragment.cxx b/oox/source/xls/worksheetfragment.cxx index 9a8fa57f68cb..cd017cab9cf6 100644 --- a/oox/source/xls/worksheetfragment.cxx +++ b/oox/source/xls/worksheetfragment.cxx @@ -823,6 +823,7 @@ bool BiffWorksheetFragment::importFragment() case BIFF_ID_COLUMNDEFAULT: importColumnDefault(); break; case BIFF_ID_COLWIDTH: importColWidth(); break; case BIFF2_ID_DEFROWHEIGHT: importDefRowHeight(); break; + case BIFF_ID_NOTE: importNote(); break; case BIFF2_ID_WINDOW2: rSheetViewSett.importWindow2( mrStrm ); break; } break; @@ -833,6 +834,7 @@ bool BiffWorksheetFragment::importFragment() case BIFF_ID_DEFCOLWIDTH: importDefColWidth(); break; case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight(); break; case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; + case BIFF_ID_NOTE: importNote(); break; case BIFF_ID_OBJ: rDrawing.importObj( mrStrm ); break; case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; case BIFF_ID_SAVERECALC: rWorkbookSett.importSaveRecalc( mrStrm ); break; @@ -849,6 +851,7 @@ bool BiffWorksheetFragment::importFragment() case BIFF_ID_COLINFO: importColInfo(); break; case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight(); break; case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; + case BIFF_ID_NOTE: importNote(); break; case BIFF_ID_OBJ: rDrawing.importObj( mrStrm ); break; case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( mrStrm ); break; @@ -867,6 +870,7 @@ bool BiffWorksheetFragment::importFragment() case BIFF3_ID_DEFROWHEIGHT: importDefRowHeight(); break; case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break; case BIFF_ID_MERGEDCELLS: importMergedCells(); break; // #i62300# also in BIFF5 + case BIFF_ID_NOTE: importNote(); break; case BIFF_ID_OBJ: rDrawing.importObj( mrStrm ); break; case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( mrStrm ); break; @@ -894,7 +898,7 @@ bool BiffWorksheetFragment::importFragment() case BIFF_ID_HYPERLINK: importHyperlink(); break; case BIFF_ID_LABELRANGES: importLabelRanges(); break; case BIFF_ID_MERGEDCELLS: importMergedCells(); break; -// case BIFF_ID_OBJ: rDrawing.importObj( mrStrm ); break; + case BIFF_ID_OBJ: rDrawing.importObj( mrStrm ); break; case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break; case BIFF_ID_PAGESETUP: rPageSett.importPageSetup( mrStrm ); break; case BIFF_ID_PHONETICPR: rWorksheetSett.importPhoneticPr( mrStrm ); break; @@ -1149,6 +1153,11 @@ void BiffWorksheetFragment::importMergedCells() setMergedRange( *aIt ); } +void BiffWorksheetFragment::importNote() +{ + getComments().createComment()->importNote( mrStrm ); +} + void BiffWorksheetFragment::importPageBreaks( bool bRowBreak ) { PageBreakModel aModel; |