summaryrefslogtreecommitdiff
path: root/oox/source/xls
diff options
context:
space:
mode:
Diffstat (limited to 'oox/source/xls')
-rw-r--r--oox/source/xls/chartsheetfragment.cxx1
-rw-r--r--oox/source/xls/drawingfragment.cxx17
-rw-r--r--oox/source/xls/formulabase.cxx5
-rw-r--r--oox/source/xls/pagesettings.cxx2
-rw-r--r--oox/source/xls/sheetdatacontext.cxx11
-rw-r--r--oox/source/xls/stylesbuffer.cxx2
-rw-r--r--oox/source/xls/viewsettings.cxx72
-rw-r--r--oox/source/xls/workbookfragment.cxx8
-rw-r--r--oox/source/xls/workbooksettings.cxx60
-rw-r--r--oox/source/xls/worksheetfragment.cxx36
-rw-r--r--oox/source/xls/worksheethelper.cxx208
-rw-r--r--oox/source/xls/worksheetsettings.cxx14
12 files changed, 344 insertions, 92 deletions
diff --git a/oox/source/xls/chartsheetfragment.cxx b/oox/source/xls/chartsheetfragment.cxx
index 4980312900fd..287518584cc3 100644
--- a/oox/source/xls/chartsheetfragment.cxx
+++ b/oox/source/xls/chartsheetfragment.cxx
@@ -263,6 +263,7 @@ bool BiffChartsheetFragment::importFragment()
case BIFF8: switch( nRecId )
{
+ case BIFF_ID_CODENAME: rWorksheetSett.importCodeName( mrStrm ); break;
case BIFF_ID_HCENTER: rPageSett.importHorCenter( mrStrm ); break;
case BIFF_ID_OBJECTPROTECT: rWorksheetSett.importObjectProtect( mrStrm ); break;
case BIFF_ID_PICTURE: rPageSett.importPicture( mrStrm ); break;
diff --git a/oox/source/xls/drawingfragment.cxx b/oox/source/xls/drawingfragment.cxx
index 28687ba92da7..172530692923 100644
--- a/oox/source/xls/drawingfragment.cxx
+++ b/oox/source/xls/drawingfragment.cxx
@@ -62,6 +62,7 @@ using ::com::sun::star::form::binding::XBindableValue;
using ::com::sun::star::form::binding::XListEntrySink;
using ::com::sun::star::form::binding::XListEntrySource;
using ::com::sun::star::form::binding::XValueBinding;
+using ::com::sun::star::drawing::XShape;
using ::com::sun::star::table::CellAddress;
using ::com::sun::star::table::CellRangeAddress;
using ::oox::core::ContextHandlerRef;
@@ -508,9 +509,13 @@ void OoxDrawingFragment::onEndElement( const OUString& rChars )
case XDR_TOKEN( twoCellAnchor ):
if( mxDrawPage.is() && mxShape.get() && mxAnchor.get() && mxAnchor->isValidAnchor() )
{
- Rectangle aLoc = mxAnchor->calcEmuLocation( maEmuSheetSize );
- if( (aLoc.X >= 0) && (aLoc.Y >= 0) && (aLoc.Width >= 0) && (aLoc.Height >= 0) )
- mxShape->addShape( getOoxFilter(), &getTheme(), mxDrawPage, &aLoc );
+ Rectangle aShapeRect = mxAnchor->calcEmuLocation( maEmuSheetSize );
+ if( (aShapeRect.X >= 0) && (aShapeRect.Y >= 0) && (aShapeRect.Width >= 0) && (aShapeRect.Height >= 0) )
+ {
+ mxShape->addShape( getOoxFilter(), &getTheme(), mxDrawPage, &aShapeRect );
+ // collect all shape positions in the WorksheetHelper base class
+ extendShapeBoundingBox( aShapeRect );
+ }
}
mxShape.reset();
mxAnchor.reset();
@@ -648,6 +653,12 @@ void VmlDrawing::convertControlClientData( const Reference< XControlModel >& rxC
}
}
+void VmlDrawing::notifyShapeInserted( const Reference< XShape >& /*rxShape*/, const Rectangle& rShapeRect )
+{
+ // collect all shape positions in the WorksheetHelper base class
+ extendShapeBoundingBox( rShapeRect );
+}
+
// ============================================================================
OoxVmlDrawingFragment::OoxVmlDrawingFragment( const WorksheetHelper& rHelper, const OUString& rFragmentPath ) :
diff --git a/oox/source/xls/formulabase.cxx b/oox/source/xls/formulabase.cxx
index b2e5ba0ee931..ea353bb48558 100644
--- a/oox/source/xls/formulabase.cxx
+++ b/oox/source/xls/formulabase.cxx
@@ -1262,6 +1262,11 @@ bool OpCodeProviderImpl::initFuncOpCode( FunctionInfo& orFuncInfo, const ApiToke
maParserMap.push_back( aEntry );
}
}
+ else
+ {
+ // ignore entries for functions unknown by Calc *and* by Excel
+ bIsValid = orFuncInfo.maOoxFuncName.getLength() == 0;
+ }
}
else if( orFuncInfo.mnBiffFuncId == BIFF_FUNC_EXTERNCALL )
{
diff --git a/oox/source/xls/pagesettings.cxx b/oox/source/xls/pagesettings.cxx
index c0b1011fdbcc..0a5ce05a37df 100644
--- a/oox/source/xls/pagesettings.cxx
+++ b/oox/source/xls/pagesettings.cxx
@@ -440,7 +440,7 @@ void PageSettings::importPictureData( const Relations& rRelations, const OUStrin
{
OUString aPicturePath = rRelations.getFragmentPathFromRelId( rRelId );
if( aPicturePath.getLength() > 0 )
- maModel.maGraphicUrl = getBaseFilter().importEmbeddedGraphicObject( aPicturePath );
+ maModel.maGraphicUrl = getBaseFilter().getGraphicHelper().importEmbeddedGraphicObject( aPicturePath );
}
// ============================================================================
diff --git a/oox/source/xls/sheetdatacontext.cxx b/oox/source/xls/sheetdatacontext.cxx
index 43c2f1b0b654..05e4c5bfe767 100644
--- a/oox/source/xls/sheetdatacontext.cxx
+++ b/oox/source/xls/sheetdatacontext.cxx
@@ -364,6 +364,10 @@ void OoxSheetDataContext::importCell( const AttributeList& rAttribs )
maCurrCell.mnXfId = rAttribs.getInteger( XML_s, -1 );
maCurrCell.mbShowPhonetic = rAttribs.getBool( XML_ph, false );
mxInlineStr.reset();
+
+ // update used area of the sheet
+ if( maCurrCell.mxCell.is() )
+ extendUsedArea( maCurrCell.maAddress );
}
void OoxSheetDataContext::importFormula( const AttributeList& rAttribs )
@@ -396,6 +400,10 @@ void OoxSheetDataContext::importCellHeader( RecordInputStream& rStrm, CellType e
maCurrCell.mxCell = getCell( maCurrPos, &maCurrCell.maAddress );
maCurrCell.mnXfId = extractValue< sal_Int32 >( nXfId, 0, 24 );
maCurrCell.mbShowPhonetic = getFlag( nXfId, OOBIN_CELL_SHOWPHONETIC );
+
+ // update used area of the sheet
+ if( maCurrCell.mxCell.is() )
+ extendUsedArea( maCurrCell.maAddress );
}
void OoxSheetDataContext::importCellBool( RecordInputStream& rStrm, CellType eCellType )
@@ -701,6 +709,9 @@ void BiffSheetDataContext::setCurrCell( const BinAddress& rAddr )
{
maCurrCell.reset();
maCurrCell.mxCell = getCell( rAddr, &maCurrCell.maAddress );
+ // update used area of the sheet
+ if( maCurrCell.mxCell.is() )
+ extendUsedArea( maCurrCell.maAddress );
}
void BiffSheetDataContext::importXfId( bool bBiff2 )
diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx
index b9a11b5104ea..5a149961c0e2 100644
--- a/oox/source/xls/stylesbuffer.cxx
+++ b/oox/source/xls/stylesbuffer.cxx
@@ -306,7 +306,7 @@ sal_Int32 lclReadRgbColor( BinaryInputStream& rStrm )
// ============================================================================
ExcelGraphicHelper::ExcelGraphicHelper( const WorkbookHelper& rHelper ) :
- GraphicHelper( rHelper.getGlobalFactory(), rHelper.getBaseFilter().getTargetFrame() ),
+ GraphicHelper( rHelper.getGlobalFactory(), rHelper.getBaseFilter().getTargetFrame(), rHelper.getBaseFilter().getStorage() ),
WorkbookHelper( rHelper )
{
}
diff --git a/oox/source/xls/viewsettings.cxx b/oox/source/xls/viewsettings.cxx
index 3d88e64dbb12..05dfa7bf9f96 100644
--- a/oox/source/xls/viewsettings.cxx
+++ b/oox/source/xls/viewsettings.cxx
@@ -26,11 +26,14 @@
************************************************************************/
#include "oox/xls/viewsettings.hxx"
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/awt/Size.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/document/XViewDataSupplier.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
+#include <comphelper/mediadescriptor.hxx>
#include "properties.hxx"
#include "oox/helper/attributelist.hxx"
#include "oox/helper/containerhelper.hxx"
@@ -38,22 +41,26 @@
#include "oox/helper/propertyset.hxx"
#include "oox/helper/recordinputstream.hxx"
#include "oox/core/filterbase.hxx"
+#include "oox/xls/addressconverter.hxx"
#include "oox/xls/biffinputstream.hxx"
#include "oox/xls/unitconverter.hxx"
#include "oox/xls/workbooksettings.hxx"
#include "oox/xls/worksheetbuffer.hxx"
using ::rtl::OUString;
-using ::com::sun::star::uno::Any;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::uno::Exception;
-using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::awt::Point;
+using ::com::sun::star::awt::Size;
using ::com::sun::star::container::XNameContainer;
using ::com::sun::star::container::XIndexContainer;
using ::com::sun::star::container::XIndexAccess;
using ::com::sun::star::document::XViewDataSupplier;
using ::com::sun::star::table::CellAddress;
+using ::com::sun::star::table::CellRangeAddress;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::oox::core::FilterBase;
namespace oox {
@@ -622,7 +629,8 @@ WorkbookViewModel::WorkbookViewModel() :
// ----------------------------------------------------------------------------
ViewSettings::ViewSettings( const WorkbookHelper& rHelper ) :
- WorkbookHelper( rHelper )
+ WorkbookHelper( rHelper ),
+ mbValidOleSize( false )
{
}
@@ -643,6 +651,12 @@ void ViewSettings::importWorkbookView( const AttributeList& rAttribs )
rModel.mbMinimized = rAttribs.getBool( XML_minimized, false );
}
+void ViewSettings::importOleSize( const AttributeList& rAttribs )
+{
+ OUString aRange = rAttribs.getString( XML_ref, OUString() );
+ mbValidOleSize = getAddressConverter().convertToCellRange( maOleSize, aRange, 0, true, false );
+}
+
void ViewSettings::importWorkbookView( RecordInputStream& rStrm )
{
WorkbookViewModel& rModel = createWorkbookView();
@@ -655,6 +669,13 @@ void ViewSettings::importWorkbookView( RecordInputStream& rStrm )
rModel.mbMinimized = getFlag( nFlags, OOBIN_WBVIEW_MINIMIZED );
}
+void ViewSettings::importOleSize( RecordInputStream& rStrm )
+{
+ BinRange aBinRange;
+ rStrm >> aBinRange;
+ mbValidOleSize = getAddressConverter().convertToCellRange( maOleSize, aBinRange, 0, true, false );
+}
+
void ViewSettings::importWindow1( BiffInputStream& rStrm )
{
sal_uInt16 nWinX, nWinY, nWinWidth, nWinHeight;
@@ -691,12 +712,25 @@ void ViewSettings::importWindow1( BiffInputStream& rStrm )
}
}
+void ViewSettings::importOleSize( BiffInputStream& rStrm )
+{
+ rStrm.skip( 2 );
+ BinRange aBinRange;
+ aBinRange.read( rStrm, false );
+ mbValidOleSize = getAddressConverter().convertToCellRange( maOleSize, aBinRange, 0, true, false );
+}
+
void ViewSettings::setSheetViewSettings( sal_Int16 nSheet, const SheetViewModelRef& rxSheetView, const Any& rProperties )
{
maSheetViews[ nSheet ] = rxSheetView;
maSheetProps[ nSheet ] = rProperties;
}
+void ViewSettings::setSheetUsedArea( const CellRangeAddress& rUsedArea )
+{
+ maSheetUsedAreas[ rUsedArea.Sheet ] = rUsedArea;
+}
+
void ViewSettings::finalizeImport()
{
const WorksheetBuffer& rWorksheets = getWorksheets();
@@ -751,6 +785,31 @@ void ViewSettings::finalizeImport()
{
OSL_ENSURE( false, "ViewSettings::finalizeImport - cannot create document view settings" );
}
+
+ /* Set visible area to be used if this document is an embedded OLE object.
+ #i44077# If a new OLE object is inserted from file, there is no OLESIZE
+ record in the Excel file. In this case, use the used area calculated
+ from file contents (used cells and drawing objects). */
+ maOleSize.Sheet = nActiveSheet;
+ const CellRangeAddress* pVisibleArea = mbValidOleSize ?
+ &maOleSize : ContainerHelper::getMapElement( maSheetUsedAreas, nActiveSheet );
+ if( pVisibleArea )
+ {
+ // calculate the visible area in units of 1/100 mm
+ PropertySet aRangeProp( getCellRangeFromDoc( *pVisibleArea ) );
+ Point aPos;
+ Size aSize;
+ if( aRangeProp.getProperty( aPos, PROP_Position ) && aRangeProp.getProperty( aSize, PROP_Size ) )
+ {
+ // set the visible area as sequence of long at the media descriptor
+ Sequence< sal_Int32 > aWinExtent( 4 );
+ aWinExtent[ 0 ] = aPos.X;
+ aWinExtent[ 1 ] = aPos.Y;
+ aWinExtent[ 2 ] = aPos.X + aSize.Width;
+ aWinExtent[ 3 ] = aPos.Y + aSize.Height;
+ getBaseFilter().getMediaDescriptor()[ CREATE_OUSTRING( "WinExtent" ) ] <<= aWinExtent;
+ }
+ }
}
sal_Int16 ViewSettings::getActiveCalcSheet() const
@@ -771,4 +830,3 @@ WorkbookViewModel& ViewSettings::createWorkbookView()
} // namespace xls
} // namespace oox
-
diff --git a/oox/source/xls/workbookfragment.cxx b/oox/source/xls/workbookfragment.cxx
index d64abf268008..6e43a32495be 100644
--- a/oox/source/xls/workbookfragment.cxx
+++ b/oox/source/xls/workbookfragment.cxx
@@ -105,6 +105,7 @@ ContextHandlerRef OoxWorkbookFragment::onCreateContext( sal_Int32 nElement, cons
case XLS_TOKEN( fileSharing ): getWorkbookSettings().importFileSharing( rAttribs ); break;
case XLS_TOKEN( workbookPr ): getWorkbookSettings().importWorkbookPr( rAttribs ); break;
case XLS_TOKEN( calcPr ): getWorkbookSettings().importCalcPr( rAttribs ); break;
+ case XLS_TOKEN( oleSize ): getViewSettings().importOleSize( rAttribs ); break;
}
break;
@@ -156,6 +157,7 @@ ContextHandlerRef OoxWorkbookFragment::onCreateRecordContext( sal_Int32 nRecId,
case OOBIN_ID_FILESHARING: getWorkbookSettings().importFileSharing( rStrm ); break;
case OOBIN_ID_WORKBOOKPR: getWorkbookSettings().importWorkbookPr( rStrm ); break;
case OOBIN_ID_CALCPR: getWorkbookSettings().importCalcPr( rStrm ); break;
+ case OOBIN_ID_OLESIZE: getViewSettings().importOleSize( rStrm ); break;
case OOBIN_ID_DEFINEDNAME: getDefinedNames().importDefinedName( rStrm ); break;
}
break;
@@ -565,6 +567,7 @@ bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgress
case BIFF5_ID_FONT: rStyles.importFont( mrStrm ); break;
case BIFF4_ID_FORMAT: rStyles.importFormat( mrStrm ); break;
case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( mrStrm ); break;
+ case BIFF_ID_OLESIZE: rViewSett.importOleSize( mrStrm ); break;
case BIFF_ID_PALETTE: rStyles.importPalette( mrStrm ); break;
case BIFF_ID_PIVOTCACHE: rPivotCaches.importPivotCacheRef( mrStrm ); break;
case BIFF_ID_SHEET: rWorksheets.importSheet( mrStrm ); break;
@@ -587,14 +590,15 @@ bool BiffWorkbookFragment::importGlobalsFragment( ISegmentProgressBar& rProgress
case BIFF5_ID_FONT: rStyles.importFont( mrStrm ); break;
case BIFF4_ID_FORMAT: rStyles.importFormat( mrStrm ); break;
case BIFF_ID_HIDEOBJ: rWorkbookSett.importHideObj( mrStrm ); break;
- case BIFF_ID_VBAPROJECT: bHasVbaProject = true; break;
- case BIFF_ID_VBAPROJECTEMPTY: bEmptyVbaProject = true; break;
+ case BIFF_ID_OLESIZE: rViewSett.importOleSize( mrStrm ); break;
case BIFF_ID_PALETTE: rStyles.importPalette( mrStrm ); break;
case BIFF_ID_PIVOTCACHE: rPivotCaches.importPivotCacheRef( mrStrm ); break;
case BIFF_ID_SHEET: rWorksheets.importSheet( mrStrm ); break;
case BIFF_ID_SST: rSharedStrings.importSst( mrStrm ); break;
case BIFF_ID_STYLE: rStyles.importStyle( mrStrm ); break;
case BIFF_ID_USESELFS: rWorkbookSett.importUsesElfs( mrStrm ); break;
+ case BIFF_ID_VBAPROJECT: bHasVbaProject = true; break;
+ case BIFF_ID_VBAPROJECTEMPTY: bEmptyVbaProject = true; break;
case BIFF_ID_XCT: bExtLinkRec = true; break;
case BIFF5_ID_XF: rStyles.importXf( mrStrm ); break;
}
diff --git a/oox/source/xls/workbooksettings.cxx b/oox/source/xls/workbooksettings.cxx
index 40d400da7757..51d60ebafe3b 100644
--- a/oox/source/xls/workbooksettings.cxx
+++ b/oox/source/xls/workbooksettings.cxx
@@ -26,9 +26,9 @@
************************************************************************/
#include "oox/xls/workbooksettings.hxx"
+#include <com/sun/star/sheet/XCalculatable.hpp>
#include <com/sun/star/util/Date.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
-#include <com/sun/star/sheet/XCalculatable.hpp>
#include <comphelper/mediadescriptor.hxx>
#include "properties.hxx"
#include "oox/helper/attributelist.hxx"
@@ -39,11 +39,16 @@
#include "oox/xls/unitconverter.hxx"
using ::rtl::OUString;
+using ::com::sun::star::beans::XPropertySet;
+using ::com::sun::star::sheet::XCalculatable;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::util::Date;
using ::com::sun::star::util::XNumberFormatsSupplier;
-using ::com::sun::star::sheet::XCalculatable;
+using ::comphelper::MediaDescriptor;
using ::oox::core::CodecHelper;
namespace oox {
@@ -191,23 +196,6 @@ void WorkbookSettings::setSaveExtLinkValues( bool bSaveExtLinks )
maBookSettings.mbSaveExtLinkValues = bSaveExtLinks;
}
-void WorkbookSettings::importFileSharing( BiffInputStream& rStrm )
-{
- maFileSharing.mbRecommendReadOnly = rStrm.readuInt16() != 0;
- rStrm >> maFileSharing.mnPasswordHash;
- if( getBiff() == BIFF8 )
- {
- sal_uInt16 nStrLen = rStrm.readuInt16();
- // there is no string flags field if string is empty
- if( nStrLen > 0 )
- maFileSharing.maUserName = rStrm.readUniStringBody( nStrLen );
- }
- else
- {
- maFileSharing.maUserName = rStrm.readByteStringUC( false, getTextEncoding() );
- }
-}
-
void WorkbookSettings::importBookBool( BiffInputStream& rStrm )
{
// value of 0 means save external values, value of 1 means strip external values
@@ -241,6 +229,23 @@ void WorkbookSettings::importDelta( BiffInputStream& rStrm )
rStrm >> maCalcSettings.mfIterateDelta;
}
+void WorkbookSettings::importFileSharing( BiffInputStream& rStrm )
+{
+ maFileSharing.mbRecommendReadOnly = rStrm.readuInt16() != 0;
+ rStrm >> maFileSharing.mnPasswordHash;
+ if( getBiff() == BIFF8 )
+ {
+ sal_uInt16 nStrLen = rStrm.readuInt16();
+ // there is no string flags field if string is empty
+ if( nStrLen > 0 )
+ maFileSharing.maUserName = rStrm.readUniStringBody( nStrLen );
+ }
+ else
+ {
+ maFileSharing.maUserName = rStrm.readByteStringUC( false, getTextEncoding() );
+ }
+}
+
void WorkbookSettings::importHideObj( BiffInputStream& rStrm )
{
maBookSettings.setBinObjectMode( rStrm.readuInt16() );
@@ -293,10 +298,21 @@ void WorkbookSettings::finalizeImport()
}
// write protection
- if( maFileSharing.mbRecommendReadOnly || (maFileSharing.mnPasswordHash != 0) )
+ if( maFileSharing.mbRecommendReadOnly || (maFileSharing.mnPasswordHash != 0) ) try
+ {
getBaseFilter().getMediaDescriptor()[ CREATE_OUSTRING( "ReadOnly" ) ] <<= true;
- if( maFileSharing.mnPasswordHash != 0 )
- aPropSet.setProperty( PROP_WriteProtectionPassword, static_cast< sal_Int32 >( maFileSharing.mnPasswordHash ) );
+
+ Reference< XPropertySet > xDocumentSettings( getDocumentFactory()->createInstance(
+ CREATE_OUSTRING( "com.sun.star.document.Settings" ) ), UNO_QUERY_THROW );
+ PropertySet aSettingsProp( xDocumentSettings );
+ if( maFileSharing.mbRecommendReadOnly )
+ aSettingsProp.setProperty( PROP_LoadReadonly, true );
+// if( maFileSharing.mnPasswordHash != 0 )
+// aSettingsProp.setProperty( PROP_ModifyPasswordHash, static_cast< sal_Int32 >( maFileSharing.mnPasswordHash ) );
+ }
+ catch( Exception& )
+ {
+ }
// calculation settings
Date aNullDate = getNullDate();
diff --git a/oox/source/xls/worksheetfragment.cxx b/oox/source/xls/worksheetfragment.cxx
index 14cf80a91d52..bee58fdbaff3 100644
--- a/oox/source/xls/worksheetfragment.cxx
+++ b/oox/source/xls/worksheetfragment.cxx
@@ -514,7 +514,12 @@ void OoxWorksheetFragment::importDimension( const AttributeList& rAttribs )
{
CellRangeAddress aRange;
getAddressConverter().convertToCellRangeUnchecked( aRange, rAttribs.getString( XML_ref, OUString() ), getSheetIndex() );
- setDimension( aRange );
+ /* OOXML stores the used area, if existing, or "A1" if the sheet is empty.
+ In case of "A1", the dimension at the WorksheetHelper object will not
+ be set. If the cell A1 exists, the used area will be updated while
+ importing the cell. */
+ if( (aRange.EndColumn > 0) || (aRange.EndRow > 0) )
+ extendUsedArea( aRange );
}
void OoxWorksheetFragment::importSheetFormatPr( const AttributeList& rAttribs )
@@ -619,7 +624,12 @@ void OoxWorksheetFragment::importDimension( RecordInputStream& rStrm )
aBinRange.read( rStrm );
CellRangeAddress aRange;
getAddressConverter().convertToCellRangeUnchecked( aRange, aBinRange, getSheetIndex() );
- setDimension( aRange );
+ /* BIFF12 stores the used area, if existing, or "A1" if the sheet is
+ empty. In case of "A1", the dimension at the WorksheetHelper object
+ will not be set. If the cell A1 exists, the used area will be updated
+ while importing the cell. */
+ if( (aRange.EndColumn > 0) || (aRange.EndRow > 0) )
+ extendUsedArea( aRange );
}
void OoxWorksheetFragment::importSheetFormatPr( RecordInputStream& rStrm )
@@ -1056,15 +1066,21 @@ void BiffWorksheetFragment::importDataValidation()
void BiffWorksheetFragment::importDimension()
{
+ // 32-bit row indexes in BIFF8
+ bool bInt32Rows = (mrStrm.getRecId() == BIFF3_ID_DIMENSION) && (getBiff() == BIFF8);
BinRange aBinRange;
- aBinRange.read( mrStrm, true, (mrStrm.getRecId() == BIFF3_ID_DIMENSION) && (getBiff() == BIFF8) );
- // first unused row/column index in BIFF, not last used
- if( aBinRange.maFirst.mnCol < aBinRange.maLast.mnCol ) --aBinRange.maLast.mnCol;
- if( aBinRange.maFirst.mnRow < aBinRange.maLast.mnRow ) --aBinRange.maLast.mnRow;
- // set dimension
- CellRangeAddress aRange;
- getAddressConverter().convertToCellRangeUnchecked( aRange, aBinRange, getSheetIndex() );
- setDimension( aRange );
+ aBinRange.read( mrStrm, true, bInt32Rows );
+ /* BIFF stores the used area with end column and end row increased by 1
+ (first unused column and row). */
+ if( (aBinRange.maFirst.mnCol < aBinRange.maLast.mnCol) && (aBinRange.maFirst.mnRow < aBinRange.maLast.mnRow) )
+ {
+ // reduce range to used area
+ --aBinRange.maLast.mnCol;
+ --aBinRange.maLast.mnRow;
+ CellRangeAddress aRange;
+ getAddressConverter().convertToCellRangeUnchecked( aRange, aBinRange, getSheetIndex() );
+ extendUsedArea( aRange );
+ }
}
void BiffWorksheetFragment::importHyperlink()
diff --git a/oox/source/xls/worksheethelper.cxx b/oox/source/xls/worksheethelper.cxx
index 381def644ce5..99c2d844f4b5 100644
--- a/oox/source/xls/worksheethelper.cxx
+++ b/oox/source/xls/worksheethelper.cxx
@@ -76,6 +76,7 @@
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
using ::com::sun::star::awt::Point;
+using ::com::sun::star::awt::Rectangle;
using ::com::sun::star::awt::Size;
using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::drawing::XDrawPage;
@@ -124,11 +125,11 @@ namespace xls {
namespace {
-void lclUpdateProgressBar( ISegmentProgressBarRef xProgressBar, const CellRangeAddress& rDimension, sal_Int32 nRow )
+void lclUpdateProgressBar( ISegmentProgressBarRef xProgressBar, const CellRangeAddress& rUsedArea, sal_Int32 nRow )
{
- if( xProgressBar.get() && (rDimension.StartRow <= nRow) && (nRow <= rDimension.EndRow) )
+ if( xProgressBar.get() && (rUsedArea.StartRow <= nRow) && (nRow <= rUsedArea.EndRow) )
{
- double fPosition = static_cast< double >( nRow - rDimension.StartRow + 1 ) / (rDimension.EndRow - rDimension.StartRow + 1);
+ double fPosition = static_cast< double >( nRow - rUsedArea.StartRow + 1 ) / (rUsedArea.EndRow - rUsedArea.StartRow + 1);
if( xProgressBar->getPosition() < fPosition )
xProgressBar->setPosition( fPosition );
}
@@ -370,7 +371,7 @@ public:
/** Returns the type of this sheet. */
inline WorksheetType getSheetType() const { return meSheetType; }
/** Returns the index of the current sheet. */
- inline sal_Int16 getSheetIndex() const { return mnSheet; }
+ inline sal_Int16 getSheetIndex() const { return maUsedArea.Sheet; }
/** Returns the XSpreadsheet interface of the current sheet. */
inline const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >&
getSheet() const { return mxSheet; }
@@ -394,13 +395,18 @@ public:
/** Returns the XDrawPage interface of the draw page of the current sheet. */
Reference< XDrawPage > getDrawPage() const;
+ /** Returns the size of the entire drawing page in 1/100 mm. */
+ Size getDrawPageSize() const;
- /** Returns the absolute cell position in 1/100 mm. */
+ /** Returns the absolute position of the top-left corner of the cell in 1/100 mm. */
Point getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const;
- /** Returns the cell size in 1/100 mm. */
+ /** Returns the size of the cell in 1/100 mm. */
Size getCellSize( sal_Int32 nCol, sal_Int32 nRow ) const;
- /** Returns the size of the entire drawing page in 1/100 mm. */
- Size getDrawPageSize() const;
+
+ /** Returns the address of the cell that contains the passed point in 1/100 mm. */
+ CellAddress getCellAddressFromPosition( const Point& rPosition, const CellAddress* pStartAddr = 0 ) const;
+ /** Returns the cell range address that contains the passed rectangle in 1/100 mm. */
+ CellRangeAddress getCellRangeFromRectangle( const Rectangle& rRect ) const;
/** Returns the worksheet settings object. */
inline WorksheetSettings& getWorksheetSettings() { return maSheetSett; }
@@ -419,8 +425,6 @@ public:
/** Changes the current sheet type. */
inline void setSheetType( WorksheetType eSheetType ) { meSheetType = eSheetType; }
- /** Sets the dimension (used area) of the sheet. */
- void setDimension( const CellRangeAddress& rRange );
/** Stores the cell format at the passed address. */
void setCellFormat( const CellModel& rModel );
/** Merges the cells in the passed cell range. */
@@ -436,6 +440,13 @@ public:
/** Sets the path to the legacy VML drawing fragment of this sheet. */
void setVmlDrawingPath( const OUString& rVmlDrawingPath );
+ /** Extends the used area of this sheet by the passed cell position. */
+ void extendUsedArea( const CellAddress& rAddress );
+ /** Extends the used area of this sheet by the passed cell range. */
+ void extendUsedArea( const CellRangeAddress& rRange );
+ /** Extends the shape bounding box by the position and size of the passed rectangle. */
+ void extendShapeBoundingBox( const Rectangle& rShapeRect );
+
/** Sets base width for all columns (without padding pixels). This value
is only used, if base width has not been set with setDefaultColumnWidth(). */
void setBaseColumnWidth( sal_Int32 nWidth );
@@ -536,6 +547,8 @@ private:
void finalizeDrawing();
/** Imports the drawing layer of the sheet (VML part). */
void finalizeVmlDrawing();
+ /** Extends the used cell area with the area used by drawing objects. */
+ void finalizeUsedArea();
/** Converts column properties for all columns in the sheet. */
void convertColumns();
@@ -560,7 +573,7 @@ private:
const OUString maSheetCellRanges; /// Service name for a SheetCellRanges object.
const OUString maUrlTextField; /// Service name for a URL text field.
const CellAddress& mrMaxApiPos; /// Reference to maximum Calc cell address from address converter.
- CellRangeAddress maDimension; /// Dimension (used) area of the sheet.
+ CellRangeAddress maUsedArea; /// Used area of the sheet, and sheet index of the sheet.
ColumnModel maDefColModel; /// Default column formatting.
ColumnModelMap maColModels; /// Columns sorted by first column index.
RowModel maDefRowModel; /// Default row formatting.
@@ -581,12 +594,12 @@ private:
VmlDrawingPtr mxVmlDrawing; /// Collection of all VML shapes.
OUString maDrawingPath; /// Path to DrawingML fragment.
OUString maVmlDrawingPath; /// Path to legacy VML drawing fragment.
+ Rectangle maShapeBoundingBox; /// Bounding box for all shapes from all drawings.
ISegmentProgressBarRef mxProgressBar; /// Sheet progress bar.
ISegmentProgressBarRef mxRowProgress; /// Progress bar for row/cell processing.
ISegmentProgressBarRef mxFinalProgress; /// Progress bar for finalization.
WorksheetType meSheetType; /// Type of this sheet.
Reference< XSpreadsheet > mxSheet; /// Reference to the current sheet.
- sal_Int16 mnSheet; /// Index of the current sheet.
bool mbHasDefWidth; /// True = default column width is set from defaultColWidth attribute.
};
@@ -599,6 +612,7 @@ WorksheetData::WorksheetData( const WorkbookHelper& rHelper, ISegmentProgressBar
maSheetCellRanges( CREATE_OUSTRING( "com.sun.star.sheet.SheetCellRanges" ) ),
maUrlTextField( CREATE_OUSTRING( "com.sun.star.text.TextField.URL" ) ),
mrMaxApiPos( rHelper.getAddressConverter().getMaxApiAddress() ),
+ maUsedArea( nSheet, SAL_MAX_INT32, SAL_MAX_INT32, -1, -1 ),
maSheetSett( *this ),
maSharedFmlas( *this ),
maCondFormats( *this ),
@@ -607,14 +621,11 @@ WorksheetData::WorksheetData( const WorkbookHelper& rHelper, ISegmentProgressBar
maSheetViewSett( *this ),
mxProgressBar( xProgressBar ),
meSheetType( eSheetType ),
- mnSheet( nSheet ),
mbHasDefWidth( false )
{
mxSheet = getSheetFromDoc( nSheet );
if( !mxSheet.is() )
- mnSheet = -1;
-
- maDimension.Sheet = mnSheet;
+ maUsedArea.Sheet = -1;
// default column settings (width and hidden state may be updated later)
maDefColModel.mfWidth = 8.5;
@@ -727,7 +738,7 @@ Reference< XTableColumns > WorksheetData::getColumns( sal_Int32 nFirstCol, sal_I
nLastCol = ::std::min( nLastCol, mrMaxApiPos.Column );
if( (0 <= nFirstCol) && (nFirstCol <= nLastCol) )
{
- Reference< XColumnRowRange > xRange( getCellRange( CellRangeAddress( mnSheet, nFirstCol, 0, nLastCol, 0 ) ), UNO_QUERY );
+ Reference< XColumnRowRange > xRange( getCellRange( CellRangeAddress( getSheetIndex(), nFirstCol, 0, nLastCol, 0 ) ), UNO_QUERY );
if( xRange.is() )
xColumns = xRange->getColumns();
}
@@ -740,7 +751,7 @@ Reference< XTableRows > WorksheetData::getRows( sal_Int32 nFirstRow, sal_Int32 n
nLastRow = ::std::min( nLastRow, mrMaxApiPos.Row );
if( (0 <= nFirstRow) && (nFirstRow <= nLastRow) )
{
- Reference< XColumnRowRange > xRange( getCellRange( CellRangeAddress( mnSheet, 0, nFirstRow, 0, nLastRow ) ), UNO_QUERY );
+ Reference< XColumnRowRange > xRange( getCellRange( CellRangeAddress( getSheetIndex(), 0, nFirstRow, 0, nLastRow ) ), UNO_QUERY );
if( xRange.is() )
xRows = xRange->getRows();
}
@@ -752,8 +763,7 @@ Reference< XDrawPage > WorksheetData::getDrawPage() const
Reference< XDrawPage > xDrawPage;
try
{
- Reference< XDrawPageSupplier > xDrawPageSupp( mxSheet, UNO_QUERY_THROW );
- xDrawPage = xDrawPageSupp->getDrawPage();
+ xDrawPage = Reference< XDrawPageSupplier >( mxSheet, UNO_QUERY_THROW )->getDrawPage();
}
catch( Exception& )
{
@@ -761,10 +771,18 @@ Reference< XDrawPage > WorksheetData::getDrawPage() const
return xDrawPage;
}
+Size WorksheetData::getDrawPageSize() const
+{
+ Size aSize;
+ PropertySet aRangeProp( getCellRange( CellRangeAddress( getSheetIndex(), 0, 0, mrMaxApiPos.Column, mrMaxApiPos.Row ) ) );
+ aRangeProp.getProperty( aSize, PROP_Size );
+ return aSize;
+}
+
Point WorksheetData::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const
{
Point aPoint;
- PropertySet aCellProp( getCell( CellAddress( mnSheet, nCol, nRow ) ) );
+ PropertySet aCellProp( getCell( CellAddress( getSheetIndex(), nCol, nRow ) ) );
aCellProp.getProperty( aPoint, PROP_Position );
return aPoint;
}
@@ -772,22 +790,59 @@ Point WorksheetData::getCellPosition( sal_Int32 nCol, sal_Int32 nRow ) const
Size WorksheetData::getCellSize( sal_Int32 nCol, sal_Int32 nRow ) const
{
Size aSize;
- PropertySet aCellProp( getCell( CellAddress( mnSheet, nCol, nRow ) ) );
+ PropertySet aCellProp( getCell( CellAddress( getSheetIndex(), nCol, nRow ) ) );
aCellProp.getProperty( aSize, PROP_Size );
return aSize;
}
-Size WorksheetData::getDrawPageSize() const
+CellAddress WorksheetData::getCellAddressFromPosition( const Point& rPosition, const CellAddress* pStartAddr ) const
{
- Size aSize;
- PropertySet aRangeProp( getCellRange( CellRangeAddress( mnSheet, 0, 0, mrMaxApiPos.Column, mrMaxApiPos.Row ) ) );
- aRangeProp.getProperty( aSize, PROP_Size );
- return aSize;
+ // prepare start address for search loop
+ sal_Int32 nCol = pStartAddr ? ::std::min< sal_Int32 >( pStartAddr->Column + 1, mrMaxApiPos.Column ) : 1;
+ sal_Int32 nRow = pStartAddr ? ::std::min< sal_Int32 >( pStartAddr->Row + 1, mrMaxApiPos.Row ) : 1;
+
+ /* The loop will find the column/row index of the cell right of/below
+ the cell containing the passed point, unless the point is located at
+ the top or left border of the containing cell. */
+ bool bNextCol = true;
+ bool bNextRow = true;
+ Point aCellPos;
+ do
+ {
+ aCellPos = getCellPosition( nCol, nRow );
+ if( bNextCol && ((bNextCol = (aCellPos.X < rPosition.X) && (nCol < mrMaxApiPos.Column)) == true) )
+ ++nCol;
+ if( bNextRow && ((bNextRow = (aCellPos.Y < rPosition.Y) && (nRow < mrMaxApiPos.Row)) == true) )
+ ++nRow;
+ }
+ while( bNextCol || bNextRow );
+
+ /* The cell left of/above the current search position contains the passed
+ point, unless the point is located on the top/left border of the cell,
+ or the last column/row of the sheet has been reached. */
+ if( aCellPos.X > rPosition.X ) --nCol;
+ if( aCellPos.Y > rPosition.Y ) --nRow;
+ return CellAddress( getSheetIndex(), nCol, nRow );
}
-void WorksheetData::setDimension( const CellRangeAddress& rRange )
+CellRangeAddress WorksheetData::getCellRangeFromRectangle( const Rectangle& rRect ) const
{
- maDimension = rRange;
+ CellAddress aStartAddr = getCellAddressFromPosition( Point( rRect.X, rRect.Y ) );
+ Point aBotRight( rRect.X + rRect.Width, rRect.Y + rRect.Height );
+ CellAddress aEndAddr = getCellAddressFromPosition( aBotRight );
+ bool bMultiCols = aStartAddr.Column < aEndAddr.Column;
+ bool bMultiRows = aStartAddr.Row < aEndAddr.Row;
+ if( bMultiCols || bMultiRows )
+ {
+ /* Reduce end position of the cell range to previous column or row, if
+ the rectangle ends exactly between two columns or rows. */
+ Point aEndPos = getCellPosition( aEndAddr.Column, aEndAddr.Row );
+ if( bMultiCols && (aBotRight.X <= aEndPos.X) )
+ --aEndAddr.Column;
+ if( bMultiRows && (aBotRight.Y <= aEndPos.Y) )
+ --aEndAddr.Row;
+ }
+ return CellRangeAddress( getSheetIndex(), aStartAddr.Column, aStartAddr.Row, aEndAddr.Column, aEndAddr.Row );
}
void WorksheetData::setCellFormat( const CellModel& rModel )
@@ -874,6 +929,38 @@ void WorksheetData::setVmlDrawingPath( const OUString& rVmlDrawingPath )
maVmlDrawingPath = rVmlDrawingPath;
}
+void WorksheetData::extendUsedArea( const CellAddress& rAddress )
+{
+ maUsedArea.StartColumn = ::std::min( maUsedArea.StartColumn, rAddress.Column );
+ maUsedArea.StartRow = ::std::min( maUsedArea.StartRow, rAddress.Row );
+ maUsedArea.EndColumn = ::std::max( maUsedArea.EndColumn, rAddress.Column );
+ maUsedArea.EndRow = ::std::max( maUsedArea.EndRow, rAddress.Row );
+}
+
+void WorksheetData::extendUsedArea( const CellRangeAddress& rRange )
+{
+ extendUsedArea( CellAddress( rRange.Sheet, rRange.StartColumn, rRange.StartRow ) );
+ extendUsedArea( CellAddress( rRange.Sheet, rRange.EndColumn, rRange.EndRow ) );
+}
+
+void WorksheetData::extendShapeBoundingBox( const Rectangle& rShapeRect )
+{
+ if( (maShapeBoundingBox.Width == 0) && (maShapeBoundingBox.Height == 0) )
+ {
+ // width and height of maShapeBoundingBox are assumed to be zero on first cell
+ maShapeBoundingBox = rShapeRect;
+ }
+ else
+ {
+ sal_Int32 nEndX = ::std::max( maShapeBoundingBox.X + maShapeBoundingBox.Width, rShapeRect.X + rShapeRect.Width );
+ sal_Int32 nEndY = ::std::max( maShapeBoundingBox.Y + maShapeBoundingBox.Height, rShapeRect.Y + rShapeRect.Height );
+ maShapeBoundingBox.X = ::std::min( maShapeBoundingBox.X, rShapeRect.X );
+ maShapeBoundingBox.Y = ::std::min( maShapeBoundingBox.Y, rShapeRect.Y );
+ maShapeBoundingBox.Width = nEndX - maShapeBoundingBox.X;
+ maShapeBoundingBox.Height = nEndY - maShapeBoundingBox.Y;
+ }
+}
+
void WorksheetData::setBaseColumnWidth( sal_Int32 nWidth )
{
// do not modify width, if setDefaultColumnWidth() has been used
@@ -948,12 +1035,12 @@ void WorksheetData::setRowModel( const RowModel& rModel )
if( maRowModels.empty() || !maRowModels.rbegin()->second.tryExpand( rModel ) )
maRowModels[ nFirstRow ] = rModel;
}
- lclUpdateProgressBar( mxRowProgress, maDimension, nLastRow );
+ lclUpdateProgressBar( mxRowProgress, maUsedArea, nLastRow );
}
void WorksheetData::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol, sal_Int32 nXfId ) const
{
- CellRangeAddress aRange( mnSheet, nFirstCol, 0, nLastCol, mrMaxApiPos.Row );
+ CellRangeAddress aRange( getSheetIndex(), nFirstCol, 0, nLastCol, mrMaxApiPos.Row );
if( getAddressConverter().validateCellRange( aRange, true, false ) )
{
PropertySet aPropSet( getCellRange( aRange ) );
@@ -963,7 +1050,7 @@ void WorksheetData::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol
void WorksheetData::convertRowFormat( sal_Int32 nFirstRow, sal_Int32 nLastRow, sal_Int32 nXfId ) const
{
- CellRangeAddress aRange( mnSheet, 0, nFirstRow, mrMaxApiPos.Column, nLastRow );
+ CellRangeAddress aRange( getSheetIndex(), 0, nFirstRow, mrMaxApiPos.Column, nLastRow );
if( getAddressConverter().validateCellRange( aRange, true, false ) )
{
PropertySet aPropSet( getCellRange( aRange ) );
@@ -979,7 +1066,7 @@ void WorksheetData::initializeWorksheetImport()
/* Remember current sheet index in global data, needed by some global
objects, e.g. the chart converter. */
- setCurrentSheetIndex( mnSheet );
+ setCurrentSheetIndex( getSheetIndex() );
}
void WorksheetData::finalizeWorksheetImport()
@@ -994,6 +1081,8 @@ void WorksheetData::finalizeWorksheetImport()
maCondFormats.finalizeImport();
maPageSett.finalizeImport();
maSheetViewSett.finalizeImport();
+ maSheetSett.finalizeImport();
+
lclUpdateProgressBar( mxFinalProgress, 0.5 );
convertColumns();
convertRows();
@@ -1001,6 +1090,7 @@ void WorksheetData::finalizeWorksheetImport()
finalizeDrawing();
finalizeVmlDrawing();
maComments.finalizeImport(); // after VML drawing
+ finalizeUsedArea(); // after DML and VML drawing
lclUpdateProgressBar( mxFinalProgress, 1.0 );
// reset current sheet index in global data
@@ -1162,7 +1252,7 @@ void WorksheetData::finalizeHyperlinkRanges() const
OUString aUrl = getHyperlinkUrl( *aIt );
// try to insert URL into each cell of the range
if( aUrl.getLength() > 0 )
- for( CellAddress aAddress( mnSheet, aIt->maRange.StartColumn, aIt->maRange.StartRow ); aAddress.Row <= aIt->maRange.EndRow; ++aAddress.Row )
+ for( CellAddress aAddress( getSheetIndex(), aIt->maRange.StartColumn, aIt->maRange.StartRow ); aAddress.Row <= aIt->maRange.EndRow; ++aAddress.Row )
for( aAddress.Column = aIt->maRange.StartColumn; aAddress.Column <= aIt->maRange.EndColumn; ++aAddress.Column )
insertHyperlink( aAddress, aUrl );
}
@@ -1348,13 +1438,13 @@ void WorksheetData::finalizeMergedRange( const CellRangeAddress& rRange )
xMerge->merge( sal_True );
// if merging this range worked (no overlapping merged ranges), update cell borders
- Reference< XCell > xTopLeft( getCell( CellAddress( mnSheet, rRange.StartColumn, rRange.StartRow ) ), UNO_SET_THROW );
+ Reference< XCell > xTopLeft( getCell( CellAddress( getSheetIndex(), rRange.StartColumn, rRange.StartRow ) ), UNO_SET_THROW );
PropertySet aTopLeftProp( xTopLeft );
// copy right border of top-right cell to right border of top-left cell
if( bMultiCol )
{
- PropertySet aTopRightProp( getCell( CellAddress( mnSheet, rRange.EndColumn, rRange.StartRow ) ) );
+ PropertySet aTopRightProp( getCell( CellAddress( getSheetIndex(), rRange.EndColumn, rRange.StartRow ) ) );
BorderLine aLine;
if( aTopRightProp.getProperty( aLine, PROP_RightBorder ) )
aTopLeftProp.setProperty( PROP_RightBorder, aLine );
@@ -1363,7 +1453,7 @@ void WorksheetData::finalizeMergedRange( const CellRangeAddress& rRange )
// copy bottom border of bottom-left cell to bottom border of top-left cell
if( bMultiRow )
{
- PropertySet aBottomLeftProp( getCell( CellAddress( mnSheet, rRange.StartColumn, rRange.EndRow ) ) );
+ PropertySet aBottomLeftProp( getCell( CellAddress( getSheetIndex(), rRange.StartColumn, rRange.EndRow ) ) );
BorderLine aLine;
if( aBottomLeftProp.getProperty( aLine, PROP_BottomBorder ) )
aTopLeftProp.setProperty( PROP_BottomBorder, aLine );
@@ -1403,6 +1493,26 @@ void WorksheetData::finalizeVmlDrawing()
importOoxFragment( new OoxVmlDrawingFragment( *this, maVmlDrawingPath ) );
}
+void WorksheetData::finalizeUsedArea()
+{
+ /* Extend used area of the sheet by cells covered with drawing objects.
+ Needed if the imported document is inserted as "OLE object from file"
+ and thus does not provide an OLE size property by itself. */
+ if( (maShapeBoundingBox.Width > 0) || (maShapeBoundingBox.Height > 0) )
+ extendUsedArea( getCellRangeFromRectangle( maShapeBoundingBox ) );
+
+ // if no used area is set, default to A1
+ if( maUsedArea.StartColumn > maUsedArea.EndColumn )
+ maUsedArea.StartColumn = maUsedArea.EndColumn = 0;
+ if( maUsedArea.StartRow > maUsedArea.EndRow )
+ maUsedArea.StartRow = maUsedArea.EndRow = 0;
+
+ /* Register the used area of this sheet in global view settings. The
+ global view settings will set the visible area if this document is an
+ embedded OLE object. */
+ getViewSettings().setSheetUsedArea( maUsedArea );
+}
+
void WorksheetData::convertColumns()
{
sal_Int32 nNextCol = 0;
@@ -1549,14 +1659,14 @@ void WorksheetData::groupColumnsOrRows( sal_Int32 nFirstColRow, sal_Int32 nLastC
Reference< XSheetOutline > xOutline( mxSheet, UNO_QUERY_THROW );
if( bRows )
{
- CellRangeAddress aRange( mnSheet, 0, nFirstColRow, 0, nLastColRow );
+ CellRangeAddress aRange( getSheetIndex(), 0, nFirstColRow, 0, nLastColRow );
xOutline->group( aRange, ::com::sun::star::table::TableOrientation_ROWS );
if( bCollapse )
xOutline->hideDetail( aRange );
}
else
{
- CellRangeAddress aRange( mnSheet, nFirstColRow, 0, nLastColRow, 0 );
+ CellRangeAddress aRange( getSheetIndex(), nFirstColRow, 0, nLastColRow, 0 );
xOutline->group( aRange, ::com::sun::star::table::TableOrientation_COLUMNS );
if( bCollapse )
xOutline->hideDetail( aRange );
@@ -1856,11 +1966,6 @@ void WorksheetHelper::setSheetType( WorksheetType eSheetType )
mrSheetData.setSheetType( eSheetType );
}
-void WorksheetHelper::setDimension( const CellRangeAddress& rRange )
-{
- mrSheetData.setDimension( rRange );
-}
-
void WorksheetHelper::setCellFormat( const CellModel& rModel )
{
mrSheetData.setCellFormat( rModel );
@@ -2003,6 +2108,21 @@ void WorksheetHelper::setVmlDrawingPath( const OUString& rVmlDrawingPath )
mrSheetData.setVmlDrawingPath( rVmlDrawingPath );
}
+void WorksheetHelper::extendUsedArea( const CellAddress& rAddress )
+{
+ mrSheetData.extendUsedArea( rAddress );
+}
+
+void WorksheetHelper::extendUsedArea( const CellRangeAddress& rRange )
+{
+ mrSheetData.extendUsedArea( rRange );
+}
+
+void WorksheetHelper::extendShapeBoundingBox( const Rectangle& rShapeRect )
+{
+ mrSheetData.extendShapeBoundingBox( rShapeRect );
+}
+
void WorksheetHelper::setBaseColumnWidth( sal_Int32 nWidth )
{
mrSheetData.setBaseColumnWidth( nWidth );
diff --git a/oox/source/xls/worksheetsettings.cxx b/oox/source/xls/worksheetsettings.cxx
index 6a42c38e1647..0cc9d5f17780 100644
--- a/oox/source/xls/worksheetsettings.cxx
+++ b/oox/source/xls/worksheetsettings.cxx
@@ -26,15 +26,19 @@
************************************************************************/
#include "oox/xls/worksheetsettings.hxx"
-#include <com/sun/star/util/XProtectable.hpp>
-#include "properties.hxx"
#include "oox/helper/attributelist.hxx"
#include "oox/helper/recordinputstream.hxx"
#include "oox/xls/biffinputstream.hxx"
#include "oox/xls/pagesettings.hxx"
#include "oox/xls/workbooksettings.hxx"
+#include "oox/core/filterbase.hxx"
+#include "properties.hxx"
+
+#include <com/sun/star/util/XProtectable.hpp>
using ::rtl::OUString;
+using ::com::sun::star::beans::XPropertySet;
+using ::com::sun::star::uno::Any;
using ::com::sun::star::uno::Exception;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::UNO_QUERY_THROW;
@@ -319,6 +323,12 @@ void WorksheetSettings::finalizeImport()
// VBA code name
PropertySet aPropSet( getSheet() );
aPropSet.setProperty( PROP_CodeName, maSheetSettings.maCodeName );
+
+ if (!maSheetSettings.maTabColor.isAuto())
+ {
+ sal_Int32 nColor = maSheetSettings.maTabColor.getColor(getBaseFilter().getGraphicHelper());
+ aPropSet.setProperty(PROP_TabColor, nColor);
+ }
}
// ============================================================================