diff options
26 files changed, 591 insertions, 302 deletions
diff --git a/oox/inc/oox/helper/attributelist.hxx b/oox/inc/oox/helper/attributelist.hxx index 89981160b699..631d7ec4b66e 100644 --- a/oox/inc/oox/helper/attributelist.hxx +++ b/oox/inc/oox/helper/attributelist.hxx @@ -37,27 +37,12 @@ namespace oox { // ============================================================================ -/** Provides access to attribute values of an element. - - Wraps a com.sun.star.xml.sax.XFastAttributeList object. Provides - convenience functions that convert the string value of an attribute to - various other data types. +/** Static helpers for conversion of strings to attribute values of various + different data types. */ -class AttributeList +class AttributeConversion { public: - explicit AttributeList( - const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ); - - /** Returns the wrapped com.sun.star.xml.sax.XFastAttributeList object. */ - inline ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList > - getFastAttributeList() const { return mxAttribs; } - - /** Returns true, if the specified attribute is present. */ - bool hasAttribute( sal_Int32 nElement ) const; - - // static string conversion ----------------------------------------------- - /** Returns the decoded string value. All characters in the format '_xHHHH_' (H being a hexadecimal digit), will be decoded. */ static ::rtl::OUString decodeXString( const ::rtl::OUString& rValue ); @@ -82,95 +67,117 @@ public: /** Returns the 64-bit signed integer value from the passed string (hexadecimal). */ static sal_Int64 decodeHyperHex( const ::rtl::OUString& rValue ); +}; + +// ============================================================================ + +/** Provides access to attribute values of an element. + + Wraps a com.sun.star.xml.sax.XFastAttributeList object. Provides + convenience functions that convert the string value of an attribute to + various other data types. + */ +class AttributeList +{ +public: + explicit AttributeList( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ); + + /** Returns the wrapped com.sun.star.xml.sax.XFastAttributeList object. */ + inline ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList > + getFastAttributeList() const { return mxAttribs; } + + /** Returns true, if the specified attribute is present. */ + bool hasAttribute( sal_Int32 nAttrToken ) const; // optional return values ------------------------------------------------- /** Returns the token identifier of the value of the specified attribute. */ - OptValue< sal_Int32 > getToken( sal_Int32 nElement ) const; + OptValue< sal_Int32 > getToken( sal_Int32 nAttrToken ) const; /** Returns the string value of the specified attribute. */ - OptValue< ::rtl::OUString > getString( sal_Int32 nElement ) const; + OptValue< ::rtl::OUString > getString( sal_Int32 nAttrToken ) const; /** Returns the string value of the specified attribute. All characters in the format '_xHHHH_' (H being a hexadecimal digit), will be decoded. */ - OptValue< ::rtl::OUString > getXString( sal_Int32 nElement ) const; + OptValue< ::rtl::OUString > getXString( sal_Int32 nAttrToken ) const; /** Returns the double value of the specified attribute. */ - OptValue< double > getDouble( sal_Int32 nElement ) const; + OptValue< double > getDouble( sal_Int32 nAttrToken ) const; /** Returns the 32-bit signed integer value of the specified attribute (decimal). */ - OptValue< sal_Int32 > getInteger( sal_Int32 nElement ) const; + OptValue< sal_Int32 > getInteger( sal_Int32 nAttrToken ) const; /** Returns the 32-bit unsigned integer value of the specified attribute (decimal). */ - OptValue< sal_uInt32 > getUnsigned( sal_Int32 nElement ) const; + OptValue< sal_uInt32 > getUnsigned( sal_Int32 nAttrToken ) const; /** Returns the 64-bit signed integer value of the specified attribute (decimal). */ - OptValue< sal_Int64 > getHyper( sal_Int32 nElement ) const; + OptValue< sal_Int64 > getHyper( sal_Int32 nAttrToken ) const; /** Returns the 32-bit signed integer value of the specified attribute (hexadecimal). */ - OptValue< sal_Int32 > getIntegerHex( sal_Int32 nElement ) const; + OptValue< sal_Int32 > getIntegerHex( sal_Int32 nAttrToken ) const; /** Returns the 32-bit unsigned integer value of the specified attribute (hexadecimal). */ - OptValue< sal_uInt32 > getUnsignedHex( sal_Int32 nElement ) const; + OptValue< sal_uInt32 > getUnsignedHex( sal_Int32 nAttrToken ) const; /** Returns the 64-bit signed integer value of the specified attribute (hexadecimal). */ - OptValue< sal_Int64 > getHyperHex( sal_Int32 nElement ) const; + OptValue< sal_Int64 > getHyperHex( sal_Int32 nAttrToken ) const; /** Returns the boolean value of the specified attribute. */ - OptValue< bool > getBool( sal_Int32 nElement ) const; + OptValue< bool > getBool( sal_Int32 nAttrToken ) const; /** Returns the date/time value of the specified attribute. */ - OptValue< ::com::sun::star::util::DateTime > getDateTime( sal_Int32 nElement ) const; + OptValue< ::com::sun::star::util::DateTime > getDateTime( sal_Int32 nAttrToken ) const; // defaulted return values ------------------------------------------------ /** Returns the token identifier of the value of the specified attribute, or the passed default identifier if the attribute is missing. */ - sal_Int32 getToken( sal_Int32 nElement, sal_Int32 nDefault ) const; + sal_Int32 getToken( sal_Int32 nAttrToken, sal_Int32 nDefault ) const; /** Returns the string value of the specified attribute, or the passed default string if the attribute is missing. */ - ::rtl::OUString getString( sal_Int32 nElement, const ::rtl::OUString& rDefault ) const; + ::rtl::OUString getString( sal_Int32 nAttrToken, const ::rtl::OUString& rDefault ) const; /** Returns the decoded string value of the specified attribute, or the passed default string if the attribute is missing. */ - ::rtl::OUString getXString( sal_Int32 nElement, const ::rtl::OUString& rDefault ) const; + ::rtl::OUString getXString( sal_Int32 nAttrToken, const ::rtl::OUString& rDefault ) const; /** Returns the double value of the specified attribute, or the passed default value if the attribute is missing or not convertible to a double. */ - double getDouble( sal_Int32 nElement, double fDefault ) const; + double getDouble( sal_Int32 nAttrToken, double fDefault ) const; /** Returns the 32-bit signed integer value of the specified attribute, or the passed default value if the attribute is missing or not convertible to integer. */ - sal_Int32 getInteger( sal_Int32 nElement, sal_Int32 nDefault ) const; + sal_Int32 getInteger( sal_Int32 nAttrToken, sal_Int32 nDefault ) const; /** Returns the 32-bit unsigned integer value of the specified attribute, or the passed default value if the attribute is missing or not convertible to unsigned. */ - sal_uInt32 getUnsigned( sal_Int32 nElement, sal_uInt32 nDefault ) const; + sal_uInt32 getUnsigned( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const; /** Returns the 64-bit signed integer value of the specified attribute, or the passed default value if the attribute is missing or not convertible to integer. */ - sal_Int64 getHyper( sal_Int32 nElement, sal_Int64 nDefault ) const; + sal_Int64 getHyper( sal_Int32 nAttrToken, sal_Int64 nDefault ) const; /** Returns the 32-bit signed integer value of the specified attribute (hexadecimal), or the passed default value if the attribute is missing or not convertible. */ - sal_Int32 getIntegerHex( sal_Int32 nElement, sal_Int32 nDefault ) const; + sal_Int32 getIntegerHex( sal_Int32 nAttrToken, sal_Int32 nDefault ) const; /** Returns the 32-bit unsigned integer value of the specified attribute (hexadecimal), or the passed default value if the attribute is missing or not convertible. */ - sal_uInt32 getUnsignedHex( sal_Int32 nElement, sal_uInt32 nDefault ) const; + sal_uInt32 getUnsignedHex( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const; /** Returns the 64-bit signed integer value of the specified attribute (hexadecimal), or the passed default value if the attribute is missing or not convertible. */ - sal_Int64 getHyperHex( sal_Int32 nElement, sal_Int64 nDefault ) const; + sal_Int64 getHyperHex( sal_Int32 nAttrToken, sal_Int64 nDefault ) const; /** Returns the boolean value of the specified attribute, or the passed default value if the attribute is missing or not convertible to bool. */ - bool getBool( sal_Int32 nElement, bool bDefault ) const; + bool getBool( sal_Int32 nAttrToken, bool bDefault ) const; /** Returns the date/time value of the specified attribute, or the default value if the attribute is missing or not convertible to a date/time value. */ - ::com::sun::star::util::DateTime getDateTime( sal_Int32 nElement, const ::com::sun::star::util::DateTime& rDefault ) const; + ::com::sun::star::util::DateTime getDateTime( sal_Int32 nAttrToken, const ::com::sun::star::util::DateTime& rDefault ) const; private: ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList > diff --git a/oox/inc/oox/vml/vmldrawing.hxx b/oox/inc/oox/vml/vmldrawing.hxx index 1af14903793b..c8b2d54aeb02 100644 --- a/oox/inc/oox/vml/vmldrawing.hxx +++ b/oox/inc/oox/vml/vmldrawing.hxx @@ -36,6 +36,7 @@ namespace com { namespace sun { namespace star { namespace awt { struct Rectangle; } namespace awt { class XControlModel; } namespace drawing { class XDrawPage; } + namespace drawing { class XShape; } } } } namespace oox { namespace core { class XmlFilterBase; } } @@ -123,7 +124,8 @@ public: /** Final processing after import of the fragment. */ void finalizeFragmentImport(); - /** Creates and inserts all UNO shapes into the passed container. */ + /** Creates and inserts all UNO shapes into the passed container. The virtual + function notifyShapeInserted() will be called for each new shape. */ void convertAndInsert() const; /** Returns the registered info structure for an OLE object, if extant. */ @@ -146,6 +148,12 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, const ShapeClientData& rClientData ) const; + /** Derived classes may want to know that a shape has been inserted. Will + be called from the convertAndInsert() implementation. */ + virtual void notifyShapeInserted( + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape, + const ::com::sun::star::awt::Rectangle& rShapeRect ); + protected: /** Derived classes may create a specialized form control helper object. */ virtual ::oox::ole::AxControlHelper* createControlHelper() const; diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index 18eaa7513fc5..7c770df28477 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -83,7 +83,7 @@ struct ShapeTypeModel class ShapeType { public: - explicit ShapeType( const Drawing& rDrawing ); + explicit ShapeType( Drawing& rDrawing ); virtual ~ShapeType(); /** Returns read/write access to the shape template model structure. */ @@ -109,7 +109,7 @@ private: ::com::sun::star::awt::Rectangle getRelRectangle() const; protected: - const Drawing& mrDrawing; /// The VML drawing page that contains this shape. + Drawing& mrDrawing; /// The VML drawing page that contains this shape. ShapeTypeModel maTypeModel; /// The model structure containing shape type data. }; @@ -180,7 +180,7 @@ public: const ShapeParentAnchor* pParentAnchor = 0 ) const; protected: - explicit ShapeBase( const Drawing& rDrawing ); + explicit ShapeBase( Drawing& rDrawing ); /** Derived classes create the corresponding XShape and insert it into the passed container. */ virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > @@ -207,7 +207,7 @@ protected: class SimpleShape : public ShapeBase { public: - explicit SimpleShape( const Drawing& rDrawing, const ::rtl::OUString& rService ); + explicit SimpleShape( Drawing& rDrawing, const ::rtl::OUString& rService ); protected: /** Creates the corresponding XShape and inserts it into the passed container. */ @@ -226,7 +226,7 @@ private: class RectangleShape : public SimpleShape { public: - explicit RectangleShape( const Drawing& rDrawing ); + explicit RectangleShape( Drawing& rDrawing ); }; // ============================================================================ @@ -235,7 +235,7 @@ public: class EllipseShape : public SimpleShape { public: - explicit EllipseShape( const Drawing& rDrawing ); + explicit EllipseShape( Drawing& rDrawing ); }; // ============================================================================ @@ -244,7 +244,7 @@ public: class PolyLineShape : public SimpleShape { public: - explicit PolyLineShape( const Drawing& rDrawing ); + explicit PolyLineShape( Drawing& rDrawing ); protected: /** Creates the corresponding XShape and inserts it into the passed container. */ @@ -260,7 +260,7 @@ protected: class CustomShape : public SimpleShape { public: - explicit CustomShape( const Drawing& rDrawing ); + explicit CustomShape( Drawing& rDrawing ); protected: /** Creates the corresponding XShape and inserts it into the passed container. */ @@ -277,7 +277,7 @@ protected: class ComplexShape : public CustomShape { public: - explicit ComplexShape( const Drawing& rDrawing ); + explicit ComplexShape( Drawing& rDrawing ); protected: /** Creates the corresponding XShape and inserts it into the passed container. */ @@ -293,7 +293,7 @@ protected: class GroupShape : public ShapeBase { public: - explicit GroupShape( const Drawing& rDrawing ); + explicit GroupShape( Drawing& rDrawing ); virtual ~GroupShape(); /** Returns read/write access to the container of child shapes and templates. */ diff --git a/oox/inc/oox/vml/vmlshapecontainer.hxx b/oox/inc/oox/vml/vmlshapecontainer.hxx index d2682c89fd6c..a878fda2b74c 100644 --- a/oox/inc/oox/vml/vmlshapecontainer.hxx +++ b/oox/inc/oox/vml/vmlshapecontainer.hxx @@ -56,7 +56,7 @@ struct ShapeParentAnchor class ShapeContainer { public: - explicit ShapeContainer( const Drawing& rDrawing ); + explicit ShapeContainer( Drawing& rDrawing ); ~ShapeContainer(); /** Creates and returns a new shape template object. */ @@ -101,7 +101,7 @@ private: typedef RefMap< ::rtl::OUString, ShapeType > ShapeTypeMap; typedef RefMap< ::rtl::OUString, ShapeBase > ShapeMap; - const Drawing& mrDrawing; /// The VML drawing page that contains this shape. + Drawing& mrDrawing; /// The VML drawing page that contains this shape. ShapeTypeVector maTypes; /// All shape templates. ShapeVector maShapes; /// All shape definitions. ShapeTypeMap maTypesById; /// All shape templates mapped by identifier. diff --git a/oox/inc/oox/xls/biffhelper.hxx b/oox/inc/oox/xls/biffhelper.hxx index f425b983ada2..062e72030663 100644 --- a/oox/inc/oox/xls/biffhelper.hxx +++ b/oox/inc/oox/xls/biffhelper.hxx @@ -151,6 +151,7 @@ const sal_Int32 OOBIN_ID_NUMFMT = 0x002C; const sal_Int32 OOBIN_ID_NUMFMTS = 0x0267; const sal_Int32 OOBIN_ID_OLEOBJECT = 0x027F; const sal_Int32 OOBIN_ID_OLEOBJECTS = 0x027E; +const sal_Int32 OOBIN_ID_OLESIZE = 0x0225; const sal_Int32 OOBIN_ID_PAGEMARGINS = 0x01DC; const sal_Int32 OOBIN_ID_PAGESETUP = 0x01DE; const sal_Int32 OOBIN_ID_PANE = 0x0097; @@ -421,6 +422,7 @@ const sal_uInt16 BIFF2_ID_NUMBER = 0x0003; const sal_uInt16 BIFF3_ID_NUMBER = 0x0203; const sal_uInt16 BIFF_ID_OBJ = 0x005D; const sal_uInt16 BIFF_ID_OBJECTPROTECT = 0x0063; +const sal_uInt16 BIFF_ID_OLESIZE = 0x00DE; const sal_uInt16 BIFF_ID_PAGELAYOUTVIEW = 0x088B; const sal_uInt16 BIFF_ID_PAGESETUP = 0x00A1; const sal_uInt16 BIFF_ID_PALETTE = 0x0092; diff --git a/oox/inc/oox/xls/drawingfragment.hxx b/oox/inc/oox/xls/drawingfragment.hxx index 22fddd373a86..66d716220b8a 100644 --- a/oox/inc/oox/xls/drawingfragment.hxx +++ b/oox/inc/oox/xls/drawingfragment.hxx @@ -177,6 +177,11 @@ public: virtual void convertControlClientData( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel, const ::oox::vml::ShapeClientData& rClientData ) const; + + /** Updates the bounding box covering all shapes of this drawing. */ + virtual void notifyShapeInserted( + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape, + const ::com::sun::star::awt::Rectangle& rShapeRect ); }; // ============================================================================ diff --git a/oox/inc/oox/xls/viewsettings.hxx b/oox/inc/oox/xls/viewsettings.hxx index 9715644cd54c..1f82aedeef91 100644 --- a/oox/inc/oox/xls/viewsettings.hxx +++ b/oox/inc/oox/xls/viewsettings.hxx @@ -179,15 +179,24 @@ public: /** Imports the workbookView element containing workbook view settings. */ void importWorkbookView( const AttributeList& rAttribs ); + /** Imports the oleSize element containing the visible size of the workbook. */ + void importOleSize( const AttributeList& rAttribs ); /** Imports the WORKBOOKVIEW record containing workbook view settings. */ void importWorkbookView( RecordInputStream& rStrm ); + /** Imports the OLESIZE record containing the visible size of the workbook. */ + void importOleSize( RecordInputStream& rStrm ); /** Imports the WINDOW1 record containing workbook view settings. */ void importWindow1( BiffInputStream& rStrm ); + /** Imports the OLESIZE record containing the visible size of the workbook. */ + void importOleSize( BiffInputStream& rStrm ); /** Stores converted view settings for a specific worksheet. */ void setSheetViewSettings( sal_Int16 nSheet, const SheetViewModelRef& rxSheetView, const ::com::sun::star::uno::Any& rProperties ); + /** Stores the used area for a specific worksheet. */ + void setSheetUsedArea( + const ::com::sun::star::table::CellRangeAddress& rUsedArea ); /** Converts all imported document view settings. */ void finalizeImport(); @@ -199,13 +208,18 @@ private: WorkbookViewModel& createWorkbookView(); private: - typedef RefVector< WorkbookViewModel > WorkbookViewModelVec; - typedef RefMap< sal_Int16, SheetViewModel > SheetViewModelMap; - typedef ::std::map< sal_Int16, ::com::sun::star::uno::Any > SheetPropertiesMap; + typedef RefVector< WorkbookViewModel > WorkbookViewModelVec; + typedef RefMap< sal_Int16, SheetViewModel > SheetViewModelMap; + typedef ::std::map< sal_Int16, ::com::sun::star::uno::Any > SheetPropertiesMap; + typedef ::std::map< sal_Int16, ::com::sun::star::table::CellRangeAddress > SheetUsedAreaMap; WorkbookViewModelVec maBookViews; /// Workbook view models. SheetViewModelMap maSheetViews; /// Active view model for each sheet. SheetPropertiesMap maSheetProps; /// Converted property sequences for each sheet. + SheetUsedAreaMap maSheetUsedAreas; /// Used area (cell range) of every sheet. + ::com::sun::star::table::CellRangeAddress + maOleSize; /// Visible area if this is an embedded OLE object. + bool mbValidOleSize; /// True = imported OLE size is a valid cell range. }; // ============================================================================ diff --git a/oox/inc/oox/xls/workbooksettings.hxx b/oox/inc/oox/xls/workbooksettings.hxx index d0f4ca17e73e..8ba322103955 100644 --- a/oox/inc/oox/xls/workbooksettings.hxx +++ b/oox/inc/oox/xls/workbooksettings.hxx @@ -109,8 +109,6 @@ public: /** Sets the save external linked values flag, e.g. from the WSBOOL record. */ void setSaveExtLinkValues( bool bSaveExtLinks ); - /** Imports the FILESHARING record. */ - void importFileSharing( BiffInputStream& rStrm ); /** Imports the BOOKBOOL record. */ void importBookBool( BiffInputStream& rStrm ); /** Imports the CALCCOUNT record. */ @@ -123,6 +121,8 @@ public: void importDateMode( BiffInputStream& rStrm ); /** Imports the DELTA record. */ void importDelta( BiffInputStream& rStrm ); + /** Imports the FILESHARING record. */ + void importFileSharing( BiffInputStream& rStrm ); /** Imports the HIDEOBJ record. */ void importHideObj( BiffInputStream& rStrm ); /** Imports the ITERATION record. */ diff --git a/oox/inc/oox/xls/worksheethelper.hxx b/oox/inc/oox/xls/worksheethelper.hxx index 4fdd827ff648..632d7027403f 100644 --- a/oox/inc/oox/xls/worksheethelper.hxx +++ b/oox/inc/oox/xls/worksheethelper.hxx @@ -35,6 +35,7 @@ namespace com { namespace sun { namespace star { namespace awt { struct Point; } + namespace awt { struct Rectangle; } namespace awt { struct Size; } namespace util { struct DateTime; } namespace drawing { class XDrawPage; } @@ -355,8 +356,6 @@ public: /** Changes the current sheet type. */ void setSheetType( WorksheetType eSheetType ); - /** Sets the dimension (used area) of the sheet. */ - void setDimension( const ::com::sun::star::table::CellRangeAddress& rRange ); /** Stores the cell formatting data of the current cell. */ void setCellFormat( const CellModel& rModel ); /** Merges the cells in the passed cell range. */ @@ -380,6 +379,14 @@ public: /** Sets the path to the legacy VML drawing fragment of this sheet. */ void setVmlDrawingPath( const ::rtl::OUString& rVmlDrawingPath ); + /** Extends the used area of this sheet by the passed cell position. */ + void extendUsedArea( const ::com::sun::star::table::CellAddress& rAddress ); + /** Extends the used area of this sheet by the passed cell range. */ + void extendUsedArea( const ::com::sun::star::table::CellRangeAddress& rRange ); + /** Extends the shape bounding box by the position and size of the passed rectangle. */ + void extendShapeBoundingBox( + const ::com::sun::star::awt::Rectangle& rShapeRect ); + /** Sets base width for all columns (without padding pixels). This value is only used, if width has not been set with setDefaultColumnWidth(). */ void setBaseColumnWidth( sal_Int32 nWidth ); diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx index da7daa9a058e..70b970cc3063 100644 --- a/oox/source/docprop/docprophandler.cxx +++ b/oox/source/docprop/docprophandler.cxx @@ -618,7 +618,7 @@ void SAL_CALL OOXMLDocPropHandler::characters( const ::rtl::OUString& aChars ) case XML_bstr|NMSP_VT: case XML_lpstr|NMSP_VT: case XML_lpwstr|NMSP_VT: - AddCustomProperty( uno::makeAny( AttributeList::decodeXString( aChars ) ) ); // the property has string type + AddCustomProperty( uno::makeAny( AttributeConversion::decodeXString( aChars ) ) ); // the property has string type break; case XML_date|NMSP_VT: diff --git a/oox/source/dump/biffdumper.cxx b/oox/source/dump/biffdumper.cxx index 21aa341107fa..50f249520aad 100644 --- a/oox/source/dump/biffdumper.cxx +++ b/oox/source/dump/biffdumper.cxx @@ -2477,6 +2477,11 @@ void WorkbookStreamObject::implDumpRecordBody() dumpObjRec(); break; + case BIFF_ID_OLESIZE: + dumpUnused( 2 ); + dumpRange( "visible-range", false ); + break; + case BIFF_ID_PAGELAYOUTVIEW: dumpFrHeader( true, true ); dumpDec< sal_uInt16 >( "scaling", "CONV-PERCENT" ); diff --git a/oox/source/dump/xlsbdumper.cxx b/oox/source/dump/xlsbdumper.cxx index a9674951225b..ef8e9e84fd3a 100644 --- a/oox/source/dump/xlsbdumper.cxx +++ b/oox/source/dump/xlsbdumper.cxx @@ -1632,6 +1632,10 @@ void RecordStreamObject::implDumpRecordBody() } break; + case OOBIN_ID_OLESIZE: + dumpRange( "visible-range" ); + break; + case OOBIN_ID_PAGEMARGINS: dumpDec< double >( "left-margin" ); dumpDec< double >( "right-margin" ); diff --git a/oox/source/dump/xlsbdumper.ini b/oox/source/dump/xlsbdumper.ini index d8bc97ddb6bc..f2ac3b49b4d6 100644 --- a/oox/source/dump/xlsbdumper.ini +++ b/oox/source/dump/xlsbdumper.ini @@ -216,7 +216,7 @@ multilist=RECORD-NAMES 0x0208=VOLTYPETP,VOLTYPETP_END,VOLTYPESTP,VOLTYPETR,,VOLTYPE_ERROR,, 0x0210=CALCCHAIN,CALCCHAIN_END,,,,,,SHEETPROTECTION 0x0218=,PHONETICPR,,,,,, - 0x0220=,,,,,,DRAWING,LEGACYDRAWING + 0x0220=,,,,,OLESIZE,DRAWING,LEGACYDRAWING 0x0230=,,PICTURE,,CFCOLOR,INDEXEDCOLORS,INDEXEDCOLORS_END, 0x0238=,MRUCOLORS,MRUCOLORS_END,,COLOR,DATAVALIDATIONS,DATAVALIDATIONS_END, diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index 4e121497c452..5479fae46f82 100644 --- a/oox/source/helper/attributelist.cxx +++ b/oox/source/helper/attributelist.cxx @@ -72,22 +72,9 @@ sal_Unicode lclGetXChar( const sal_Unicode*& rpcStr, const sal_Unicode* pcEnd ) } // namespace -// ============================================================================ - -AttributeList::AttributeList( const Reference< XFastAttributeList >& rxAttribs ) : - mxAttribs( rxAttribs ) -{ - OSL_ENSURE( mxAttribs.is(), "AttributeList::AttributeList - missing attribute list interface" ); -} - -bool AttributeList::hasAttribute( sal_Int32 nElement ) const -{ - return mxAttribs->hasAttribute( nElement ); -} - -// static string conversion ----------------------------------------------- +// ---------------------------------------------------------------------------- -OUString AttributeList::decodeXString( const OUString& rValue ) +OUString AttributeConversion::decodeXString( const OUString& rValue ) { // string shorter than one encoded character - no need to decode if( rValue.getLength() < XSTRING_ENCCHAR_LEN ) @@ -100,127 +87,146 @@ OUString AttributeList::decodeXString( const OUString& rValue ) return aBuffer.makeStringAndClear(); } -double AttributeList::decodeDouble( const OUString& rValue ) +double AttributeConversion::decodeDouble( const OUString& rValue ) { return rValue.toDouble(); } -sal_Int32 AttributeList::decodeInteger( const OUString& rValue ) +sal_Int32 AttributeConversion::decodeInteger( const OUString& rValue ) { return rValue.toInt32(); } -sal_uInt32 AttributeList::decodeUnsigned( const OUString& rValue ) +sal_uInt32 AttributeConversion::decodeUnsigned( const OUString& rValue ) { return getLimitedValue< sal_uInt32, sal_Int64 >( rValue.toInt64(), 0, SAL_MAX_UINT32 ); } -sal_Int64 AttributeList::decodeHyper( const OUString& rValue ) +sal_Int64 AttributeConversion::decodeHyper( const OUString& rValue ) { return rValue.toInt64(); } -sal_Int32 AttributeList::decodeIntegerHex( const OUString& rValue ) +sal_Int32 AttributeConversion::decodeIntegerHex( const OUString& rValue ) { return rValue.toInt32( 16 ); } -sal_uInt32 AttributeList::decodeUnsignedHex( const OUString& rValue ) +sal_uInt32 AttributeConversion::decodeUnsignedHex( const OUString& rValue ) { return getLimitedValue< sal_uInt32, sal_Int64 >( rValue.toInt64( 16 ), 0, SAL_MAX_UINT32 ); } -sal_Int64 AttributeList::decodeHyperHex( const OUString& rValue ) +sal_Int64 AttributeConversion::decodeHyperHex( const OUString& rValue ) { return rValue.toInt64( 16 ); } +// ============================================================================ + +AttributeList::AttributeList( const Reference< XFastAttributeList >& rxAttribs ) : + mxAttribs( rxAttribs ) +{ + OSL_ENSURE( mxAttribs.is(), "AttributeList::AttributeList - missing attribute list interface" ); +} + +bool AttributeList::hasAttribute( sal_Int32 nAttrToken ) const +{ + return mxAttribs->hasAttribute( nAttrToken ); +} + // optional return values ----------------------------------------------------- -OptValue< sal_Int32 > AttributeList::getToken( sal_Int32 nElement ) const +OptValue< sal_Int32 > AttributeList::getToken( sal_Int32 nAttrToken ) const { - sal_Int32 nToken = mxAttribs->getOptionalValueToken( nElement, XML_TOKEN_INVALID ); + sal_Int32 nToken = mxAttribs->getOptionalValueToken( nAttrToken, XML_TOKEN_INVALID ); return OptValue< sal_Int32 >( nToken != XML_TOKEN_INVALID, nToken ); } -OptValue< OUString > AttributeList::getString( sal_Int32 nElement ) const +OptValue< OUString > AttributeList::getString( sal_Int32 nAttrToken ) const { - return OptValue< OUString >( mxAttribs->hasAttribute( nElement ), mxAttribs->getOptionalValue( nElement ) ); + // check if the attribute exists (empty string may be different to missing attribute) + if( mxAttribs->hasAttribute( nAttrToken ) ) + return OptValue< OUString >( mxAttribs->getOptionalValue( nAttrToken ) ); + return OptValue< OUString >(); } -OptValue< OUString > AttributeList::getXString( sal_Int32 nElement ) const +OptValue< OUString > AttributeList::getXString( sal_Int32 nAttrToken ) const { - return OptValue< OUString >( mxAttribs->hasAttribute( nElement ), decodeXString( mxAttribs->getOptionalValue( nElement ) ) ); + // check if the attribute exists (empty string may be different to missing attribute) + if( mxAttribs->hasAttribute( nAttrToken ) ) + return OptValue< OUString >( AttributeConversion::decodeXString( mxAttribs->getOptionalValue( nAttrToken ) ) ); + return OptValue< OUString >(); } -OptValue< double > AttributeList::getDouble( sal_Int32 nElement ) const +OptValue< double > AttributeList::getDouble( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< double >( bValid, bValid ? decodeDouble( aValue ) : 0.0 ); + return OptValue< double >( bValid, bValid ? AttributeConversion::decodeDouble( aValue ) : 0.0 ); } -OptValue< sal_Int32 > AttributeList::getInteger( sal_Int32 nElement ) const +OptValue< sal_Int32 > AttributeList::getInteger( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_Int32 >( bValid, bValid ? decodeInteger( aValue ) : 0 ); + return OptValue< sal_Int32 >( bValid, bValid ? AttributeConversion::decodeInteger( aValue ) : 0 ); } -OptValue< sal_uInt32 > AttributeList::getUnsigned( sal_Int32 nElement ) const +OptValue< sal_uInt32 > AttributeList::getUnsigned( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_uInt32 >( bValid, decodeUnsigned( aValue ) ); + return OptValue< sal_uInt32 >( bValid, AttributeConversion::decodeUnsigned( aValue ) ); } -OptValue< sal_Int64 > AttributeList::getHyper( sal_Int32 nElement ) const +OptValue< sal_Int64 > AttributeList::getHyper( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_Int64 >( bValid, bValid ? decodeHyper( aValue ) : 0 ); + return OptValue< sal_Int64 >( bValid, bValid ? AttributeConversion::decodeHyper( aValue ) : 0 ); } -OptValue< sal_Int32 > AttributeList::getIntegerHex( sal_Int32 nElement ) const +OptValue< sal_Int32 > AttributeList::getIntegerHex( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_Int32 >( bValid, bValid ? decodeIntegerHex( aValue ) : 0 ); + return OptValue< sal_Int32 >( bValid, bValid ? AttributeConversion::decodeIntegerHex( aValue ) : 0 ); } -OptValue< sal_uInt32 > AttributeList::getUnsignedHex( sal_Int32 nElement ) const +OptValue< sal_uInt32 > AttributeList::getUnsignedHex( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_uInt32 >( bValid, bValid ? decodeUnsignedHex( aValue ) : 0 ); + return OptValue< sal_uInt32 >( bValid, bValid ? AttributeConversion::decodeUnsignedHex( aValue ) : 0 ); } -OptValue< sal_Int64 > AttributeList::getHyperHex( sal_Int32 nElement ) const +OptValue< sal_Int64 > AttributeList::getHyperHex( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); bool bValid = aValue.getLength() > 0; - return OptValue< sal_Int64 >( bValid, bValid ? decodeHyperHex( aValue ) : 0 ); + return OptValue< sal_Int64 >( bValid, bValid ? AttributeConversion::decodeHyperHex( aValue ) : 0 ); } -OptValue< bool > AttributeList::getBool( sal_Int32 nElement ) const +OptValue< bool > AttributeList::getBool( sal_Int32 nAttrToken ) const { // boolean attributes may be "t", "f", "true", "false", "on", "off", "1", or "0" - switch( getToken( nElement, -1 ) ) + switch( getToken( nAttrToken, XML_TOKEN_INVALID ) ) { - case XML_t: return OptValue< bool >( true, true ); // used in VML - case XML_true: return OptValue< bool >( true, true ); - case XML_on: return OptValue< bool >( true, true ); - case XML_f: return OptValue< bool >( true, false ); // used in VML - case XML_false: return OptValue< bool >( true, false ); - case XML_off: return OptValue< bool >( true, false ); + case XML_t: return OptValue< bool >( true ); // used in VML + case XML_true: return OptValue< bool >( true ); + case XML_on: return OptValue< bool >( true ); + case XML_f: return OptValue< bool >( false ); // used in VML + case XML_false: return OptValue< bool >( false ); + case XML_off: return OptValue< bool >( false ); } - OptValue< sal_Int32 > onValue = getInteger( nElement ); + OptValue< sal_Int32 > onValue = getInteger( nAttrToken ); return OptValue< bool >( onValue.has(), onValue.get() != 0 ); } -OptValue< DateTime > AttributeList::getDateTime( sal_Int32 nElement ) const +OptValue< DateTime > AttributeList::getDateTime( sal_Int32 nAttrToken ) const { - OUString aValue = mxAttribs->getOptionalValue( nElement ); + OUString aValue = mxAttribs->getOptionalValue( nAttrToken ); DateTime aDateTime; bool bValid = (aValue.getLength() == 19) && (aValue[ 4 ] == '-') && (aValue[ 7 ] == '-') && (aValue[ 10 ] == 'T') && (aValue[ 13 ] == ':') && (aValue[ 16 ] == ':'); @@ -238,16 +244,16 @@ OptValue< DateTime > AttributeList::getDateTime( sal_Int32 nElement ) const // defaulted return values ---------------------------------------------------- -sal_Int32 AttributeList::getToken( sal_Int32 nElement, sal_Int32 nDefault ) const +sal_Int32 AttributeList::getToken( sal_Int32 nAttrToken, sal_Int32 nDefault ) const { - return mxAttribs->getOptionalValueToken( nElement, nDefault ); + return mxAttribs->getOptionalValueToken( nAttrToken, nDefault ); } -OUString AttributeList::getString( sal_Int32 nElement, const OUString& rDefault ) const +OUString AttributeList::getString( sal_Int32 nAttrToken, const OUString& rDefault ) const { try { - return mxAttribs->getValue( nElement ); + return mxAttribs->getValue( nAttrToken ); } catch( Exception& ) { @@ -255,54 +261,54 @@ OUString AttributeList::getString( sal_Int32 nElement, const OUString& rDefault return rDefault; } -OUString AttributeList::getXString( sal_Int32 nElement, const OUString& rDefault ) const +OUString AttributeList::getXString( sal_Int32 nAttrToken, const OUString& rDefault ) const { - return getXString( nElement ).get( rDefault ); + return getXString( nAttrToken ).get( rDefault ); } -double AttributeList::getDouble( sal_Int32 nElement, double fDefault ) const +double AttributeList::getDouble( sal_Int32 nAttrToken, double fDefault ) const { - return getDouble( nElement ).get( fDefault ); + return getDouble( nAttrToken ).get( fDefault ); } -sal_Int32 AttributeList::getInteger( sal_Int32 nElement, sal_Int32 nDefault ) const +sal_Int32 AttributeList::getInteger( sal_Int32 nAttrToken, sal_Int32 nDefault ) const { - return getInteger( nElement ).get( nDefault ); + return getInteger( nAttrToken ).get( nDefault ); } -sal_uInt32 AttributeList::getUnsigned( sal_Int32 nElement, sal_uInt32 nDefault ) const +sal_uInt32 AttributeList::getUnsigned( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const { - return getUnsigned( nElement ).get( nDefault ); + return getUnsigned( nAttrToken ).get( nDefault ); } -sal_Int64 AttributeList::getHyper( sal_Int32 nElement, sal_Int64 nDefault ) const +sal_Int64 AttributeList::getHyper( sal_Int32 nAttrToken, sal_Int64 nDefault ) const { - return getHyper( nElement ).get( nDefault ); + return getHyper( nAttrToken ).get( nDefault ); } -sal_Int32 AttributeList::getIntegerHex( sal_Int32 nElement, sal_Int32 nDefault ) const +sal_Int32 AttributeList::getIntegerHex( sal_Int32 nAttrToken, sal_Int32 nDefault ) const { - return getIntegerHex( nElement ).get( nDefault ); + return getIntegerHex( nAttrToken ).get( nDefault ); } -sal_uInt32 AttributeList::getUnsignedHex( sal_Int32 nElement, sal_uInt32 nDefault ) const +sal_uInt32 AttributeList::getUnsignedHex( sal_Int32 nAttrToken, sal_uInt32 nDefault ) const { - return getUnsignedHex( nElement ).get( nDefault ); + return getUnsignedHex( nAttrToken ).get( nDefault ); } -sal_Int64 AttributeList::getHyperHex( sal_Int32 nElement, sal_Int64 nDefault ) const +sal_Int64 AttributeList::getHyperHex( sal_Int32 nAttrToken, sal_Int64 nDefault ) const { - return getHyperHex( nElement ).get( nDefault ); + return getHyperHex( nAttrToken ).get( nDefault ); } -bool AttributeList::getBool( sal_Int32 nElement, bool bDefault ) const +bool AttributeList::getBool( sal_Int32 nAttrToken, bool bDefault ) const { - return getBool( nElement ).get( bDefault ); + return getBool( nAttrToken ).get( bDefault ); } -DateTime AttributeList::getDateTime( sal_Int32 nElement, const DateTime& rDefault ) const +DateTime AttributeList::getDateTime( sal_Int32 nAttrToken, const DateTime& rDefault ) const { - return getDateTime( nElement ).get( rDefault ); + return getDateTime( nAttrToken ).get( rDefault ); } // ============================================================================ diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 96baaab4bb36..4a94f9849bd2 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -427,11 +427,11 @@ void AxFontDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue { switch( nPropId ) { - case XML_FontName: maFontName = rValue; break; - case XML_FontEffects: mnFontEffects = AttributeList::decodeUnsigned( rValue ); break; - case XML_FontHeight: mnFontHeight = AttributeList::decodeInteger( rValue ); break; - case XML_FontCharSet: mnFontCharSet = AttributeList::decodeInteger( rValue ); break; - case XML_ParagraphAlign: mnHorAlign = AttributeList::decodeInteger( rValue ); break; + case XML_FontName: maFontName = rValue; break; + case XML_FontEffects: mnFontEffects = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_FontHeight: mnFontHeight = AttributeConversion::decodeInteger( rValue ); break; + case XML_FontCharSet: mnFontCharSet = AttributeConversion::decodeInteger( rValue ); break; + case XML_ParagraphAlign: mnHorAlign = AttributeConversion::decodeInteger( rValue ); break; default: AxControlModelBase::importProperty( nPropId, rValue ); } } @@ -508,12 +508,12 @@ void AxCommandButtonModel::importProperty( sal_Int32 nPropId, const OUString& rV { switch( nPropId ) { - case XML_Caption: maCaption = rValue; break; - case XML_ForeColor: mnTextColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_BackColor: mnBackColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_VariousPropertyBits: mnFlags = AttributeList::decodeUnsigned( rValue ); break; - case XML_PicturePosition: mnPicturePos = AttributeList::decodeUnsigned( rValue ); break; - case XML_TakeFocusOnClick: mbFocusOnClick = AttributeList::decodeInteger( rValue ) != 0; break; + case XML_Caption: maCaption = rValue; break; + case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_PicturePosition: mnPicturePos = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_TakeFocusOnClick: mbFocusOnClick = AttributeConversion::decodeInteger( rValue ) != 0; break; default: AxFontDataModel::importProperty( nPropId, rValue ); } } @@ -580,12 +580,12 @@ void AxLabelModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) switch( nPropId ) { case XML_Caption: maCaption = rValue; break; - case XML_ForeColor: mnTextColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_BackColor: mnBackColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_VariousPropertyBits: mnFlags = AttributeList::decodeUnsigned( rValue ); break; - case XML_BorderColor: mnBorderColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_BorderStyle: mnBorderStyle = AttributeList::decodeInteger( rValue ); break; - case XML_SpecialEffect: mnSpecialEffect = AttributeList::decodeInteger( rValue ); break; + case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break; + case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break; default: AxFontDataModel::importProperty( nPropId, rValue ); } } @@ -645,14 +645,14 @@ void AxImageModel::importProperty( sal_Int32 nPropId, const OUString& rValue ) { switch( nPropId ) { - case XML_BackColor: mnBackColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_VariousPropertyBits: mnFlags = AttributeList::decodeUnsigned( rValue ); break; - case XML_BorderColor: mnBorderColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_BorderStyle: mnBorderStyle = AttributeList::decodeInteger( rValue ); break; - case XML_SpecialEffect: mnSpecialEffect = AttributeList::decodeInteger( rValue ); break; - case XML_SizeMode: mnPicSizeMode = AttributeList::decodeInteger( rValue ); break; - case XML_PictureAlignment: mnPicAlign = AttributeList::decodeInteger( rValue ); break; - case XML_PictureTiling: mbPicTiling = AttributeList::decodeInteger( rValue ) != 0; break; + case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break; + case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break; + case XML_SizeMode: mnPicSizeMode = AttributeConversion::decodeInteger( rValue ); break; + case XML_PictureAlignment: mnPicAlign = AttributeConversion::decodeInteger( rValue ); break; + case XML_PictureTiling: mbPicTiling = AttributeConversion::decodeInteger( rValue ) != 0; break; default: AxControlModelBase::importProperty( nPropId, rValue ); } } @@ -726,24 +726,24 @@ void AxMorphDataModel::importProperty( sal_Int32 nPropId, const OUString& rValue { switch( nPropId ) { - case XML_Caption: maCaption = rValue; break; - case XML_Value: maValue = rValue; break; - case XML_GroupName: maGroupName = rValue; break; - case XML_ForeColor: mnTextColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_BackColor: mnBackColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_VariousPropertyBits: mnFlags = AttributeList::decodeUnsigned( rValue ); break; - case XML_PicturePosition: mnPicturePos = AttributeList::decodeUnsigned( rValue ); break; - case XML_BorderColor: mnBorderColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_BorderStyle: mnBorderStyle = AttributeList::decodeInteger( rValue ); break; - case XML_SpecialEffect: mnSpecialEffect = AttributeList::decodeInteger( rValue ); break; - case XML_DisplayStyle: mnDisplayStyle = AttributeList::decodeInteger( rValue ); break; - case XML_MultiSelect: mnMultiSelect = AttributeList::decodeInteger( rValue ); break; - case XML_ScrollBars: mnScrollBars = AttributeList::decodeInteger( rValue ); break; - case XML_MatchEntry: mnMatchEntry = AttributeList::decodeInteger( rValue ); break; - case XML_ShowDropButtonWhen: mnShowDropButton = AttributeList::decodeInteger( rValue ); break; - case XML_MaxLength: mnMaxLength = AttributeList::decodeInteger( rValue ); break; - case XML_PasswordChar: mnPasswordChar = AttributeList::decodeInteger( rValue ); break; - case XML_ListRows: mnListRows = AttributeList::decodeInteger( rValue ); break; + case XML_Caption: maCaption = rValue; break; + case XML_Value: maValue = rValue; break; + case XML_GroupName: maGroupName = rValue; break; + case XML_ForeColor: mnTextColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_PicturePosition: mnPicturePos = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BorderColor: mnBorderColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BorderStyle: mnBorderStyle = AttributeConversion::decodeInteger( rValue ); break; + case XML_SpecialEffect: mnSpecialEffect = AttributeConversion::decodeInteger( rValue ); break; + case XML_DisplayStyle: mnDisplayStyle = AttributeConversion::decodeInteger( rValue ); break; + case XML_MultiSelect: mnMultiSelect = AttributeConversion::decodeInteger( rValue ); break; + case XML_ScrollBars: mnScrollBars = AttributeConversion::decodeInteger( rValue ); break; + case XML_MatchEntry: mnMatchEntry = AttributeConversion::decodeInteger( rValue ); break; + case XML_ShowDropButtonWhen: mnShowDropButton = AttributeConversion::decodeInteger( rValue );break; + case XML_MaxLength: mnMaxLength = AttributeConversion::decodeInteger( rValue ); break; + case XML_PasswordChar: mnPasswordChar = AttributeConversion::decodeInteger( rValue ); break; + case XML_ListRows: mnListRows = AttributeConversion::decodeInteger( rValue ); break; default: AxFontDataModel::importProperty( nPropId, rValue ); } } @@ -979,15 +979,15 @@ void AxSpinButtonModel::importProperty( sal_Int32 nPropId, const OUString& rValu { switch( nPropId ) { - case XML_ForeColor: mnArrowColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_BackColor: mnBackColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_VariousPropertyBits: mnFlags = AttributeList::decodeUnsigned( rValue ); break; - case XML_Orientation: mnOrientation = AttributeList::decodeInteger( rValue ); break; - case XML_Min: mnMin = AttributeList::decodeInteger( rValue ); break; - case XML_Max: mnMax = AttributeList::decodeInteger( rValue ); break; - case XML_Position: mnPosition = AttributeList::decodeInteger( rValue ); break; - case XML_SmallChange: mnSmallChange = AttributeList::decodeInteger( rValue ); break; - case XML_Delay: mnDelay = AttributeList::decodeInteger( rValue ); break; + case XML_ForeColor: mnArrowColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_Orientation: mnOrientation = AttributeConversion::decodeInteger( rValue ); break; + case XML_Min: mnMin = AttributeConversion::decodeInteger( rValue ); break; + case XML_Max: mnMax = AttributeConversion::decodeInteger( rValue ); break; + case XML_Position: mnPosition = AttributeConversion::decodeInteger( rValue ); break; + case XML_SmallChange: mnSmallChange = AttributeConversion::decodeInteger( rValue ); break; + case XML_Delay: mnDelay = AttributeConversion::decodeInteger( rValue ); break; default: AxControlModelBase::importProperty( nPropId, rValue ); } } @@ -1057,17 +1057,17 @@ void AxScrollBarModel::importProperty( sal_Int32 nPropId, const OUString& rValue { switch( nPropId ) { - case XML_ForeColor: mnArrowColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_BackColor: mnBackColor = AttributeList::decodeUnsigned( rValue ); break; - case XML_VariousPropertyBits: mnFlags = AttributeList::decodeUnsigned( rValue ); break; - case XML_Orientation: mnOrientation = AttributeList::decodeInteger( rValue ); break; - case XML_ProportionalThumb: mnPropThumb = AttributeList::decodeInteger( rValue ); break; - case XML_Min: mnMin = AttributeList::decodeInteger( rValue ); break; - case XML_Max: mnMax = AttributeList::decodeInteger( rValue ); break; - case XML_Position: mnPosition = AttributeList::decodeInteger( rValue ); break; - case XML_SmallChange: mnSmallChange = AttributeList::decodeInteger( rValue ); break; - case XML_LargeChange: mnLargeChange = AttributeList::decodeInteger( rValue ); break; - case XML_Delay: mnDelay = AttributeList::decodeInteger( rValue ); break; + case XML_ForeColor: mnArrowColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_BackColor: mnBackColor = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_VariousPropertyBits: mnFlags = AttributeConversion::decodeUnsigned( rValue ); break; + case XML_Orientation: mnOrientation = AttributeConversion::decodeInteger( rValue ); break; + case XML_ProportionalThumb: mnPropThumb = AttributeConversion::decodeInteger( rValue ); break; + case XML_Min: mnMin = AttributeConversion::decodeInteger( rValue ); break; + case XML_Max: mnMax = AttributeConversion::decodeInteger( rValue ); break; + case XML_Position: mnPosition = AttributeConversion::decodeInteger( rValue ); break; + case XML_SmallChange: mnSmallChange = AttributeConversion::decodeInteger( rValue ); break; + case XML_LargeChange: mnLargeChange = AttributeConversion::decodeInteger( rValue ); break; + case XML_Delay: mnDelay = AttributeConversion::decodeInteger( rValue ); break; default: AxControlModelBase::importProperty( nPropId, rValue ); } } diff --git a/oox/source/vml/vmldrawing.cxx b/oox/source/vml/vmldrawing.cxx index 9c1bb761532a..21e313288dfa 100644 --- a/oox/source/vml/vmldrawing.cxx +++ b/oox/source/vml/vmldrawing.cxx @@ -39,6 +39,7 @@ using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::awt::Rectangle; using ::com::sun::star::awt::XControlModel; using ::com::sun::star::drawing::XDrawPage; +using ::com::sun::star::drawing::XShape; using ::com::sun::star::drawing::XShapes; using ::oox::core::XmlFilterBase; @@ -158,6 +159,10 @@ void Drawing::convertControlClientData( const Reference< XControlModel >& /*rxCt { } +void Drawing::notifyShapeInserted( const Reference< XShape >& /*rxShape*/, const Rectangle& /*rShapeRect*/ ) +{ +} + ::oox::ole::AxControlHelper* Drawing::createControlHelper() const { return new ::oox::ole::AxEmbeddedControlHelper( mrFilter, mxDrawPage ); diff --git a/oox/source/vml/vmldrawingfragment.cxx b/oox/source/vml/vmldrawingfragment.cxx index aae5b5c40556..333df72bbaf7 100644 --- a/oox/source/vml/vmldrawingfragment.cxx +++ b/oox/source/vml/vmldrawingfragment.cxx @@ -50,6 +50,7 @@ DrawingFragment::DrawingFragment( XmlFilterBase& rFilter, const OUString& rFragm Reference< XInputStream > DrawingFragment::openFragmentStream() const { + // #i104719# create an input stream that preprocesses the VML data return new InputStream( FragmentHandler2::openFragmentStream() ); } diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 014f1edf4c45..6a9bd1cbc94b 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -165,7 +165,7 @@ void ShapeTypeModel::assignUsed( const ShapeTypeModel& rSource ) // ---------------------------------------------------------------------------- -ShapeType::ShapeType( const Drawing& rDrawing ) : +ShapeType::ShapeType( Drawing& rDrawing ) : mrDrawing( rDrawing ) { } @@ -237,7 +237,7 @@ ShapeClientData& ShapeModel::createClientData() // ---------------------------------------------------------------------------- -ShapeBase::ShapeBase( const Drawing& rDrawing ) : +ShapeBase::ShapeBase( Drawing& rDrawing ) : ShapeType( rDrawing ) { } @@ -270,7 +270,14 @@ Reference< XShape > ShapeBase::convertAndInsert( const Reference< XShapes >& rxS Rectangle aShapeRect = calcShapeRectangle( pParentAnchor ); // convert the shape, if the calculated rectangle is not empty if( ((aShapeRect.Width > 0) || (aShapeRect.Height > 0)) && rxShapes.is() ) + { xShape = implConvertAndInsert( rxShapes, aShapeRect ); + /* Notify the drawing that a new shape has been inserted (but not + for children of group shapes). For convenience, pass the + rectangle that contains position and size of the shape. */ + if( !pParentAnchor && xShape.is() ) + mrDrawing.notifyShapeInserted( xShape, aShapeRect ); + } } return xShape; } @@ -316,7 +323,7 @@ void ShapeBase::convertShapeProperties( const Reference< XShape >& rxShape ) con // ============================================================================ -SimpleShape::SimpleShape( const Drawing& rDrawing, const OUString& rService ) : +SimpleShape::SimpleShape( Drawing& rDrawing, const OUString& rService ) : ShapeBase( rDrawing ), maService( rService ) { @@ -331,21 +338,21 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes // ============================================================================ -RectangleShape::RectangleShape( const Drawing& rDrawing ) : +RectangleShape::RectangleShape( Drawing& rDrawing ) : SimpleShape( rDrawing, CREATE_OUSTRING( "com.sun.star.drawing.RectangleShape" ) ) { } // ============================================================================ -EllipseShape::EllipseShape( const Drawing& rDrawing ) : +EllipseShape::EllipseShape( Drawing& rDrawing ) : SimpleShape( rDrawing, CREATE_OUSTRING( "com.sun.star.drawing.EllipseShape" ) ) { } // ============================================================================ -PolyLineShape::PolyLineShape( const Drawing& rDrawing ) : +PolyLineShape::PolyLineShape( Drawing& rDrawing ) : SimpleShape( rDrawing, CREATE_OUSTRING( "com.sun.star.drawing.PolyLineShape" ) ) { } @@ -370,7 +377,7 @@ Reference< XShape > PolyLineShape::implConvertAndInsert( const Reference< XShape // ============================================================================ -CustomShape::CustomShape( const Drawing& rDrawing ) : +CustomShape::CustomShape( Drawing& rDrawing ) : SimpleShape( rDrawing, CREATE_OUSTRING( "com.sun.star.drawing.CustomShape" ) ) { } @@ -395,7 +402,7 @@ Reference< XShape > CustomShape::implConvertAndInsert( const Reference< XShapes // ============================================================================ -ComplexShape::ComplexShape( const Drawing& rDrawing ) : +ComplexShape::ComplexShape( Drawing& rDrawing ) : CustomShape( rDrawing ) { } @@ -485,7 +492,7 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes // ============================================================================ -GroupShape::GroupShape( const Drawing& rDrawing ) : +GroupShape::GroupShape( Drawing& rDrawing ) : ShapeBase( rDrawing ), mxChildren( new ShapeContainer( rDrawing ) ) { diff --git a/oox/source/vml/vmlshapecontainer.cxx b/oox/source/vml/vmlshapecontainer.cxx index 6b1711f3c0f9..1968cd567acd 100644 --- a/oox/source/vml/vmlshapecontainer.cxx +++ b/oox/source/vml/vmlshapecontainer.cxx @@ -61,7 +61,7 @@ void lclMapShapesById( RefMap< OUString, ShapeType >& orMap, const RefVector< Sh // ============================================================================ -ShapeContainer::ShapeContainer( const Drawing& rDrawing ) : +ShapeContainer::ShapeContainer( Drawing& rDrawing ) : mrDrawing( rDrawing ) { } 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/sheetdatacontext.cxx b/oox/source/xls/sheetdatacontext.cxx index be5644554d6d..9b501c64e359 100644 --- a/oox/source/xls/sheetdatacontext.cxx +++ b/oox/source/xls/sheetdatacontext.cxx @@ -368,6 +368,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 ) @@ -400,6 +404,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 ) @@ -705,6 +713,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/viewsettings.cxx b/oox/source/xls/viewsettings.cxx index 69af326c2471..c5a9442dbace 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 e61820a2e620..ef62990605f9 100644 --- a/oox/source/xls/workbookfragment.cxx +++ b/oox/source/xls/workbookfragment.cxx @@ -101,6 +101,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; @@ -152,6 +153,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; @@ -551,6 +553,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; @@ -573,6 +576,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; diff --git a/oox/source/xls/workbooksettings.cxx b/oox/source/xls/workbooksettings.cxx index 1277b0879e7a..a4b59d86b865 100644 --- a/oox/source/xls/workbooksettings.cxx +++ b/oox/source/xls/workbooksettings.cxx @@ -191,23 +191,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 +224,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() ); diff --git a/oox/source/xls/worksheetfragment.cxx b/oox/source/xls/worksheetfragment.cxx index ff42c6afb704..6849503308b6 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 ) @@ -1055,15 +1065,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 e28df89cd7b3..ff0fa515ddc0 100644 --- a/oox/source/xls/worksheethelper.cxx +++ b/oox/source/xls/worksheethelper.cxx @@ -88,6 +88,7 @@ using ::com::sun::star::util::XMergeable; using ::com::sun::star::util::XNumberFormatsSupplier; using ::com::sun::star::util::XNumberFormatTypes; using ::com::sun::star::awt::Point; +using ::com::sun::star::awt::Rectangle; using ::com::sun::star::awt::Size; using ::com::sun::star::drawing::XDrawPage; using ::com::sun::star::drawing::XDrawPageSupplier; @@ -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 ) @@ -875,6 +930,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 @@ -949,13 +1036,13 @@ 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 { OOX_LOADSAVE_TIMER( CONVERTCOLUMNFORMAT ); - 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 ) ); @@ -966,7 +1053,7 @@ void WorksheetData::convertColumnFormat( sal_Int32 nFirstCol, sal_Int32 nLastCol void WorksheetData::convertRowFormat( sal_Int32 nFirstRow, sal_Int32 nLastRow, sal_Int32 nXfId ) const { OOX_LOADSAVE_TIMER( CONVERTROWFORMAT ); - 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 ) ); @@ -982,7 +1069,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() @@ -1004,6 +1091,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 @@ -1167,7 +1255,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 ); } @@ -1353,13 +1441,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 ); @@ -1368,7 +1456,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 ); @@ -1411,6 +1499,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; @@ -1557,14 +1665,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 ); @@ -1865,11 +1973,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 ); @@ -2012,6 +2115,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 ); |