diff options
Diffstat (limited to 'oox/inc/oox')
36 files changed, 652 insertions, 197 deletions
diff --git a/oox/inc/oox/core/fasttokenhandler.hxx b/oox/inc/oox/core/fasttokenhandler.hxx index 3944011507b2..45709f9da401 100644 --- a/oox/inc/oox/core/fasttokenhandler.hxx +++ b/oox/inc/oox/core/fasttokenhandler.hxx @@ -28,27 +28,41 @@ * ************************************************************************/ -#ifndef OOX_FASTTOKENHANDLER_HXX -#define OOX_FASTTOKENHANDLER_HXX +#ifndef OOX_CORE_FASTTOKENHANDLER_HXX +#define OOX_CORE_FASTTOKENHANDLER_HXX #include <com/sun/star/xml/sax/XFastTokenHandler.hpp> #include <cppuhelper/implbase1.hxx> +namespace oox { class TokenMap; } + namespace oox { +namespace core { + +// ============================================================================ +/** Wrapper implementing the com.sun.star.xml.sax.XFastTokenHandler API interface + that provides access to the tokens generated from the internal token name list. + */ class FastTokenHandler : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XFastTokenHandler > { public: explicit FastTokenHandler(); virtual ~FastTokenHandler(); - virtual ::sal_Int32 SAL_CALL getToken( const ::rtl::OUString& Identifier ) throw (::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getIdentifier( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getUTF8Identifier( ::sal_Int32 Token ) throw (::com::sun::star::uno::RuntimeException); - virtual ::sal_Int32 SAL_CALL getTokenFromUTF8( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& Identifier ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getToken( const ::rtl::OUString& rIdentifier ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getIdentifier( sal_Int32 nToken ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( sal_Int32 nToken ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getTokenFromUTF8( const ::com::sun::star::uno::Sequence< sal_Int8 >& Identifier ) throw (::com::sun::star::uno::RuntimeException); + +private: + const TokenMap& mrTokenMap; /// Reference to global token map singleton. }; -} +// ============================================================================ + +} // namespace core +} // namespace oox #endif diff --git a/oox/inc/oox/core/filterbase.hxx b/oox/inc/oox/core/filterbase.hxx index 9115c88be4e7..adfb8d6d0941 100644 --- a/oox/inc/oox/core/filterbase.hxx +++ b/oox/inc/oox/core/filterbase.hxx @@ -198,8 +198,13 @@ public: sal_Int32 convertScreenPixelX( double fPixelX ) const; /** Converts the passed value from vertical screen pixels to 1/100 mm. */ sal_Int32 convertScreenPixelY( double fPixelY ) const; + /** Returns a system color specified by the passed XML token identifier. */ - sal_Int32 getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb = -1 ) const; + sal_Int32 getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb = API_RGB_TRANSPARENT ) const; + /** Derived classes may implement to resolve a scheme color from the passed XML token identifier. */ + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + /** Derived classes may implement to resolve a palette index to an RGB color. */ + virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; /** Requests a password from the media descriptor or from the user. On success, the password will be inserted into the media descriptor. */ diff --git a/oox/inc/oox/core/xmlfilterbase.hxx b/oox/inc/oox/core/xmlfilterbase.hxx index d1b79dc116d8..510b00ea81fc 100644 --- a/oox/inc/oox/core/xmlfilterbase.hxx +++ b/oox/inc/oox/core/xmlfilterbase.hxx @@ -87,9 +87,6 @@ public: virtual const ::oox::drawingml::Theme* getCurrentTheme() const = 0; - /** Has to be implemented by each filter to resolve scheme colors. */ - virtual sal_Int32 getSchemeClr( sal_Int32 nColorSchemeToken ) const = 0; - /** Has to be implemented by each filter to return the collection of VML shapes. */ virtual ::oox::vml::Drawing* getVmlDrawing() = 0; diff --git a/oox/inc/oox/drawingml/color.hxx b/oox/inc/oox/drawingml/color.hxx index 91fddf0be69f..b1de124adad5 100644 --- a/oox/inc/oox/drawingml/color.hxx +++ b/oox/inc/oox/drawingml/color.hxx @@ -34,10 +34,11 @@ #include <vector> #include <boost/shared_ptr.hpp> #include <sal/types.h> +#include <rtl/instance.hxx> +#include <rtl/ustring.hxx> +#include "oox/helper/helper.hxx" -namespace oox { namespace core { - class XmlFilterBase; -} } +namespace oox { namespace core { class FilterBase; } } namespace oox { namespace drawingml { @@ -50,6 +51,11 @@ public: Color(); ~Color(); + /** Returns the RGB value for the passed DrawingML color token, or nDefaultRgb on error. */ + static sal_Int32 getDmlPresetColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ); + /** Returns the RGB value for the passed VML color token, or nDefaultRgb on error. */ + static sal_Int32 getVmlPresetColor( sal_Int32 nToken, sal_Int32 nDefaultRgb ); + /** Sets the color to unused state. */ void setUnused(); /** Sets an RGB value (hexadecimal RRGGBB) from the a:srgbClr element. */ @@ -64,6 +70,8 @@ public: void setSchemeClr( sal_Int32 nToken ); /** Sets a system color from the a:sysClr element. */ void setSysClr( sal_Int32 nToken, sal_Int32 nLastRgb ); + /** Sets a palette color index. */ + void setPaletteClr( sal_Int32 nPaletteIdx ); /** Inserts the passed color transformation. */ void addTransformation( sal_Int32 nElement, sal_Int32 nValue = -1 ); @@ -71,17 +79,21 @@ public: void addChartTintTransformation( double fTint ); /** Inserts Excel specific color tint (-1.0...0.0 = shade, 0.0...1.0 = tint). */ void addExcelTintTransformation( double fTint ); + /** Removes all color transformations. */ + void clearTransformations(); + /** Removes transparence from the color. */ + void clearTransparence(); /** Overwrites this color with the passed color, if it is used. */ inline void assignIfUsed( const Color& rColor ) { if( rColor.isUsed() ) *this = rColor; } - /** Removes transparence from the color. */ - void clearTransparence(); /** Returns true, if the color is initialized. */ bool isUsed() const { return meMode != COLOR_UNUSED; } + /** Returns true, if the color is a placeholder color in theme style lists. */ + bool isPlaceHolder() const { return meMode == COLOR_PH; } /** Returns the final RGB color value. @param nPhClr Actual color for the phClr placeholder color used in theme style lists. */ - sal_Int32 getColor( const ::oox::core::XmlFilterBase& rFilter, sal_Int32 nPhClr = -1 ) const; + sal_Int32 getColor( const ::oox::core::FilterBase& rFilter, sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Returns true, if the color has a transparence set. */ bool hasTransparence() const; @@ -89,6 +101,9 @@ public: sal_Int16 getTransparence() const; private: + /** Internal helper for getColor(). */ + void setResolvedRgb( sal_Int32 nRgb ) const; + /** Converts the color components to RGB values. */ void toRgb() const; /** Converts the color components to CRGB values (gamma corrected percentage). */ @@ -104,8 +119,9 @@ private: COLOR_CRGB, /// Relative RGB (r/g/b: 0...100000). COLOR_HSL, /// HSL (hue: 0...21600000, sat/lum: 0...100000). COLOR_SCHEME, /// Color from scheme. - COLOR_PH, /// Placeholder color in theme style lists. + COLOR_PALETTE, /// Color from application defined palette. COLOR_SYSTEM, /// Color from system palette. + COLOR_PH, /// Placeholder color in theme style lists. COLOR_FINAL /// Finalized RGB color. }; @@ -120,7 +136,7 @@ private: mutable ColorMode meMode; /// Current color mode. mutable TransformVec maTransforms; /// Color transformations. - mutable sal_Int32 mnC1; /// Red, red%, hue, scheme token, system token, or final RGB. + mutable sal_Int32 mnC1; /// Red, red%, hue, scheme token, palette index, system token, or final RGB. mutable sal_Int32 mnC2; /// Green, green%, saturation, or system default RGB. mutable sal_Int32 mnC3; /// Blue, blue%, or luminance. sal_Int32 mnAlpha; /// Alpha value (color opacity). diff --git a/oox/inc/oox/drawingml/customshapeproperties.hxx b/oox/inc/oox/drawingml/customshapeproperties.hxx index 17a308a6331c..9857a75e4836 100644 --- a/oox/inc/oox/drawingml/customshapeproperties.hxx +++ b/oox/inc/oox/drawingml/customshapeproperties.hxx @@ -72,7 +72,7 @@ public: virtual ~CustomShapeProperties(); void apply( const CustomShapePropertiesPtr& ); - void pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase, + void pushToPropSet( const ::oox::core::FilterBase& rFilterBase, const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > & xShape) const; diff --git a/oox/inc/oox/drawingml/drawingmltypes.hxx b/oox/inc/oox/drawingml/drawingmltypes.hxx index fbec84c4b81c..41365f8df086 100644 --- a/oox/inc/oox/drawingml/drawingmltypes.hxx +++ b/oox/inc/oox/drawingml/drawingmltypes.hxx @@ -43,6 +43,14 @@ namespace drawingml { // ============================================================================ +const sal_Int32 PER_PERCENT = 1000; +const sal_Int32 MAX_PERCENT = 100 * PER_PERCENT; + +const sal_Int32 PER_DEGREE = 60000; +const sal_Int32 MAX_DEGREE = 360 * PER_DEGREE; + +// ============================================================================ + struct LineProperties; typedef ::boost::shared_ptr< LineProperties > LinePropertiesPtr; diff --git a/oox/inc/oox/drawingml/fillproperties.hxx b/oox/inc/oox/drawingml/fillproperties.hxx index 9190b87e0e53..9504da617083 100644 --- a/oox/inc/oox/drawingml/fillproperties.hxx +++ b/oox/inc/oox/drawingml/fillproperties.hxx @@ -159,18 +159,20 @@ struct FillProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const FillPropertyIds& rPropIds, - const ::oox::core::XmlFilterBase& rFilter, + const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, - sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const; + const FillPropertyIds& rPropIds = DEFAULT_IDS, + sal_Int32 nShapeRotation = 0, + sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Writes the properties to the passed property set. */ void pushToPropSet( PropertySet& rPropSet, - const FillPropertyIds& rPropIds, - const ::oox::core::XmlFilterBase& rFilter, + const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, - sal_Int32 nShapeRotation, sal_Int32 nPhClr ) const; + const FillPropertyIds& rPropIds = DEFAULT_IDS, + sal_Int32 nShapeRotation = 0, + sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; // ============================================================================ @@ -185,14 +187,14 @@ struct GraphicProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const ::oox::core::XmlFilterBase& rFilter, - sal_Int32 nPhClr ) const; + const ::oox::core::FilterBase& rFilter, + sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Writes the properties to the passed property set. */ void pushToPropSet( PropertySet& rPropSet, - const ::oox::core::XmlFilterBase& rFilter, - sal_Int32 nPhClr ) const; + const ::oox::core::FilterBase& rFilter, + sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; // ============================================================================ diff --git a/oox/inc/oox/drawingml/lineproperties.hxx b/oox/inc/oox/drawingml/lineproperties.hxx index 2aa9ac7fedeb..db337c520092 100644 --- a/oox/inc/oox/drawingml/lineproperties.hxx +++ b/oox/inc/oox/drawingml/lineproperties.hxx @@ -86,11 +86,16 @@ struct LineArrowProperties struct LineProperties { + typedef ::std::pair< sal_Int32, sal_Int32 > DashStop; + typedef ::std::vector< DashStop > DashStopVector; + LineArrowProperties maStartArrow; /// Start line arrow style. LineArrowProperties maEndArrow; /// End line arrow style. FillProperties maLineFill; /// Line fill (solid, gradient, ...). + DashStopVector maCustomDash; /// User-defined line dash style. OptValue< sal_Int32 > moLineWidth; /// Line width (EMUs). OptValue< sal_Int32 > moPresetDash; /// Preset dash (OOXML token). + OptValue< sal_Int32 > moLineCompound; /// Line compound type (OOXML token). OptValue< sal_Int32 > moLineCap; /// Line cap (OOXML token). OptValue< sal_Int32 > moLineJoint; /// Line joint type (OOXML token). @@ -102,18 +107,18 @@ struct LineProperties /** Writes the properties to the passed property map. */ void pushToPropMap( PropertyMap& rPropMap, - const LinePropertyIds& rPropIds, - const ::oox::core::XmlFilterBase& rFilter, + const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, - sal_Int32 nPhClr ) const; + const LinePropertyIds& rPropIds = DEFAULT_IDS, + sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; /** Writes the properties to the passed property map. */ void pushToPropSet( PropertySet& rPropSet, - const LinePropertyIds& rPropIds, - const ::oox::core::XmlFilterBase& rFilter, + const ::oox::core::FilterBase& rFilter, ModelObjectHelper& rModelObjHelper, - sal_Int32 nPhClr ) const; + const LinePropertyIds& rPropIds = DEFAULT_IDS, + sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; }; // ============================================================================ diff --git a/oox/inc/oox/helper/containerhelper.hxx b/oox/inc/oox/helper/containerhelper.hxx index be3736e92a47..8186d537faee 100644 --- a/oox/inc/oox/helper/containerhelper.hxx +++ b/oox/inc/oox/helper/containerhelper.hxx @@ -91,7 +91,7 @@ public: template< typename FunctorType > inline void forEach( const FunctorType& rFunctor ) const { - ::std::for_each( this->begin(), this->end(), Functor< FunctorType >( rFunctor ) ); + ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( rFunctor ) ); } /** Calls the passed member function of ObjType on every contained object. */ @@ -115,13 +115,30 @@ public: forEach( ::boost::bind( pFunc, _1, aParam1, aParam2 ) ); } + /** Searches for an element by using the passed functor that takes a + constant reference of the object type (const ObjType&). */ + template< typename FunctorType > + inline value_type findIf( const FunctorType& rFunctor ) const + { + typename container_type::const_iterator aIt = ::std::find_if( this->begin(), this->end(), FindFunctor< FunctorType >( rFunctor ) ); + return (aIt == this->end()) ? value_type() : *aIt; + } + private: template< typename FunctorType > - struct Functor + struct ForEachFunctor + { + const FunctorType& mrFunctor; + inline explicit ForEachFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} + inline void operator()( const value_type& rxValue ) const { if( rxValue.get() ) mrFunctor( *rxValue ); } + }; + + template< typename FunctorType > + struct FindFunctor { const FunctorType& mrFunctor; - inline explicit Functor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rValue ) const { mrFunctor( *rValue ); } + inline explicit FindFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} + inline bool operator()( const value_type& rxValue ) const { return rxValue.get() && mrFunctor( *rxValue ); } }; inline const value_type* getRef( sal_Int32 nIndex ) const @@ -170,7 +187,7 @@ public: template< typename FunctorType > inline void forEach( const FunctorType& rFunctor ) const { - ::std::for_each( this->begin(), this->end(), Functor< FunctorType >( rFunctor ) ); + ::std::for_each( this->begin(), this->end(), ForEachFunctor< FunctorType >( rFunctor ) ); } /** Calls the passed member function of ObjType on every contained object. */ @@ -196,11 +213,11 @@ public: private: template< typename FunctorType > - struct Functor + struct ForEachFunctor { const FunctorType& mrFunctor; - inline explicit Functor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} - inline void operator()( const value_type& rValue ) const { mrFunctor( *rValue.second ); } + inline explicit ForEachFunctor( const FunctorType& rFunctor ) : mrFunctor( rFunctor ) {} + inline void operator()( const value_type& rValue ) const { if( rValue.second.get() ) mrFunctor( *rValue.second ); } }; inline const mapped_type* getRef( key_type nKey ) const diff --git a/oox/inc/oox/helper/helper.hxx b/oox/inc/oox/helper/helper.hxx index d6e2286fd8ac..f08f807da2a2 100644 --- a/oox/inc/oox/helper/helper.hxx +++ b/oox/inc/oox/helper/helper.hxx @@ -104,7 +104,8 @@ inline ReturnType getLimitedValue( Type nValue, Type nMin, Type nMax ) template< typename ReturnType, typename Type > inline ReturnType getIntervalValue( Type nValue, Type nBegin, Type nEnd ) { - BOOST_STATIC_ASSERT( ::std::numeric_limits< Type >::is_integer ); +// this BOOST_STATIC_ASSERT fails with suncc +// BOOST_STATIC_ASSERT( ::std::numeric_limits< Type >::is_integer ); Type nInterval = nEnd - nBegin; Type nCount = (nValue < nBegin) ? -((nBegin - nValue - 1) / nInterval + 1) : ((nValue - nBegin) / nInterval); return static_cast< ReturnType >( nValue - nCount * nInterval ); diff --git a/oox/inc/oox/helper/propertymap.hxx b/oox/inc/oox/helper/propertymap.hxx index a3e84c4b73fe..58a769adbb48 100644 --- a/oox/inc/oox/helper/propertymap.hxx +++ b/oox/inc/oox/helper/propertymap.hxx @@ -44,13 +44,7 @@ namespace com { namespace sun { namespace star { namespace beans { namespace oox { -// ============================================================================ - -/** A vector that contains all predefined property names used in the filters. */ -struct PropertyNamesList : public ::std::vector< ::rtl::OUString > -{ - explicit PropertyNamesList(); -}; +struct PropertyList; // ============================================================================ @@ -66,6 +60,9 @@ typedef ::std::map< sal_Int32, ::com::sun::star::uno::Any > PropertyMapBase; class PropertyMap : public PropertyMapBase { public: + explicit PropertyMap(); + ~PropertyMap(); + /** Returns the name of the passed property identifier. */ static const ::rtl::OUString& getPropertyName( sal_Int32 nPropId ); @@ -94,6 +91,9 @@ public: /** Creates and fills a new instance supporting the XPropertySet interface. */ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > makePropertySet() const; + +private: + const PropertyList* mpPropNames; }; // ============================================================================ diff --git a/oox/inc/oox/ole/axcontrolhelper.hxx b/oox/inc/oox/ole/axcontrolhelper.hxx index 392a24a2704e..713cbcae362e 100644 --- a/oox/inc/oox/ole/axcontrolhelper.hxx +++ b/oox/inc/oox/ole/axcontrolhelper.hxx @@ -83,8 +83,6 @@ protected: /** Derived classes returns the UNO form of the current context. Called exactly once. */ virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > createControlForm() const = 0; - /** Derived classes may implement to resolve a palette index to an RGB color. */ - virtual sal_Int32 getPaletteColor( sal_uInt16 nPaletteIdx ) const; private: const ::oox::core::FilterBase& mrFilter; diff --git a/oox/inc/oox/ppt/pptimport.hxx b/oox/inc/oox/ppt/pptimport.hxx index d865e48c2569..d6c1d899ac35 100644 --- a/oox/inc/oox/ppt/pptimport.hxx +++ b/oox/inc/oox/ppt/pptimport.hxx @@ -56,10 +56,9 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual const ::oox::drawingml::Theme* getCurrentTheme() const; - - virtual sal_Int32 getSchemeClr( sal_Int32 nColorSchemeToken ) const; + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + virtual const ::oox::drawingml::Theme* getCurrentTheme() const; virtual ::oox::vml::Drawing* getVmlDrawing(); virtual const oox::drawingml::table::TableStyleListPtr getTableStyles(); virtual ::oox::drawingml::chart::ChartConverter& getChartConverter(); diff --git a/oox/inc/oox/token/propertylist.hxx b/oox/inc/oox/token/propertylist.hxx new file mode 100644 index 000000000000..abc776c348f6 --- /dev/null +++ b/oox/inc/oox/token/propertylist.hxx @@ -0,0 +1,53 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: propertylist.hxx,v $ + * $Revision: 1.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_TOKEN_PROPERTYLIST_HXX +#define OOX_TOKEN_PROPERTYLIST_HXX + +#include <vector> +#include <rtl/ustring.hxx> + +namespace oox { + +// ============================================================================ + +/** A vector that contains all predefined property names used in the filters. */ +struct PropertyList : public ::std::vector< ::rtl::OUString > +{ + explicit PropertyList(); + ~PropertyList(); +}; + +// ============================================================================ + +} // namespace oox + +#endif + diff --git a/oox/inc/oox/token/tokenmap.hxx b/oox/inc/oox/token/tokenmap.hxx new file mode 100644 index 000000000000..e4dd0be121ce --- /dev/null +++ b/oox/inc/oox/token/tokenmap.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: fasttokenhandler.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_TOKEN_TOKENMAP_HXX +#define OOX_TOKEN_TOKENMAP_HXX + +#include <vector> +#include <rtl/instance.hxx> +#include <rtl/ustring.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +namespace oox { + +// ============================================================================ + +class TokenMap +{ +public: + explicit TokenMap(); + ~TokenMap(); + + /** Returns the Unicode name of the passed token identifier. */ + ::rtl::OUString getUnicodeTokenName( sal_Int32 nToken ) const; + + /** Returns the token identifier for the passed Unicode token name. */ + sal_Int32 getTokenFromUnicode( const ::rtl::OUString& rUnicodeName ) const; + + /** Returns the UTF8 name of the passed token identifier as byte sequence. */ + ::com::sun::star::uno::Sequence< sal_Int8 > + getUtf8TokenName( sal_Int32 nToken ) const; + + /** Returns the token identifier for the passed UTF8 token name. */ + sal_Int32 getTokenFromUtf8( + const ::com::sun::star::uno::Sequence< sal_Int8 >& rUtf8Name ) const; + +private: + struct TokenName + { + ::rtl::OUString maUniName; + ::com::sun::star::uno::Sequence< sal_Int8 > maUtf8Name; + }; + typedef ::std::vector< TokenName > TokenNameVector; + + TokenNameVector maTokenNames; + +}; + +// ============================================================================ + +struct StaticTokenMap : public ::rtl::Static< TokenMap, StaticTokenMap > {}; + +// ============================================================================ + +} // namespace oox + +#endif + diff --git a/oox/inc/oox/vml/vmldrawing.hxx b/oox/inc/oox/vml/vmldrawing.hxx index 4be185bbcd2a..f0bd75046c37 100644 --- a/oox/inc/oox/vml/vmldrawing.hxx +++ b/oox/inc/oox/vml/vmldrawing.hxx @@ -47,6 +47,7 @@ namespace oox { namespace ole { class AxControlHelper; } } namespace oox { namespace vml { +class ShapeBase; class ShapeContainer; struct ShapeClientData; @@ -133,6 +134,9 @@ public: /** Returns the registered info structure for a form control, if extant. */ const ControlInfo* getControlInfo( const ::rtl::OUString& rShapeId ) const; + /** Derived classes may disable conversion of specific shapes. */ + virtual bool isShapeSupported( const ShapeBase& rShape ) const; + /** Derived classes may calculate the shape rectangle from a non-standard anchor information string. */ virtual bool convertShapeClientAnchor( diff --git a/oox/inc/oox/vml/vmlformatting.hxx b/oox/inc/oox/vml/vmlformatting.hxx new file mode 100644 index 000000000000..b37da4daa28c --- /dev/null +++ b/oox/inc/oox/vml/vmlformatting.hxx @@ -0,0 +1,187 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vmlformatting.hxx,v $ + * $Revision: 1.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef OOX_VML_VMLFORMATTING_HXX +#define OOX_VML_VMLFORMATTING_HXX + +#include "oox/helper/helper.hxx" + +namespace oox { class PropertyMap; } +namespace oox { namespace core { class FilterBase; } } + +namespace oox { +namespace vml { + +// ============================================================================ + +typedef ::std::pair< sal_Int32, sal_Int32 > Int32Pair; +typedef ::std::pair< double, double > DoublePair; + +// ============================================================================ + +class ConversionHelper +{ +public: + /** Returns two values contained in rValue separated by cSep. + */ + static bool separatePair( + ::rtl::OUString& orValue1, ::rtl::OUString& orValue2, + const ::rtl::OUString& rValue, sal_Unicode cSep ); + + /** Returns the boolean value from the passed string of a VML attribute. + Supported values: 'f', 't', 'false', 'true'. False for anything else. + */ + static bool decodeBool( const ::rtl::OUString& rValue ); + + /** Converts the passed VML percentage measure string to a normalized + floating-point value. + + @param rValue The VML percentage value. This is a floating-point value + with optional following '%' sign. If the '%' sign is missing, the + floating point value will be returned unmodified. If the '%' sign + is present, the value will be divided by 100. + */ + static double decodePercent( + const ::rtl::OUString& rValue, + double fDefValue ); + + /** Converts the passed VML measure string to EMU (English Metric Units). + + @param rFilter The core filter object needed to perform pixel + conversion according to the current output device. + + @param rValue The VML measure value. This is a floating-point value + with optional measure string following the value. + + @param nRefValue Reference value needed for percentage measure. + + @param bPixelX Set to true if the value is oriented horizontally (e.g. + X coordinates, widths). Set to false if the value is oriented + vertically (e.g. Y coordinates, heights). This is needed because + output devices may specify different width and height for a pixel. + + @param bDefaultAsPixel Set to true if omitted measure unit means + pixel. Set to false if omitted measure unit means EMU. + */ + static sal_Int32 decodeMeasureToEmu( + const ::oox::core::FilterBase& rFilter, + const ::rtl::OUString& rValue, + sal_Int32 nRefValue, + bool bPixelX, + bool bDefaultAsPixel ); + + /** Converts the passed VML measure string to 1/100 mm. + + @param rFilter See above. + @param rValue See above. + @param nRefValue See above. + @param bPixelX See above. + @param bDefaultAsPixel See above. + */ + static sal_Int32 decodeMeasureToHmm( + const ::oox::core::FilterBase& rFilter, + const ::rtl::OUString& rValue, + sal_Int32 nRefValue, + bool bPixelX, + bool bDefaultAsPixel ); + +private: + ConversionHelper(); + ~ConversionHelper(); +}; + +// ============================================================================ + +/** The stroke arrow model structure contains all properties for an line end arrow. */ +struct StrokeArrowModel +{ + OptValue< sal_Int32 > moArrowType; + OptValue< sal_Int32 > moArrowWidth; + OptValue< sal_Int32 > moArrowLength; + + void assignUsed( const StrokeArrowModel& rSource ); +}; + +// ============================================================================ + +/** The stroke model structure contains all shape border properties. */ +struct StrokeModel +{ + OptValue< bool > moStroked; /// Shape border line on/off. + StrokeArrowModel maStartArrow; /// Start line arrow style. + StrokeArrowModel maEndArrow; /// End line arrow style. + OptValue< ::rtl::OUString > moColor; /// Solid line color. + OptValue< double > moOpacity; /// Solid line color opacity. + OptValue< ::rtl::OUString > moWeight; /// Line width. + OptValue< ::rtl::OUString > moDashStyle; /// Line dash (predefined or manually). + OptValue< sal_Int32 > moLineStyle; /// Line style (single, double, ...). + OptValue< sal_Int32 > moEndCap; /// Type of line end cap. + OptValue< sal_Int32 > moJoinStyle; /// Type of line join. + + void assignUsed( const StrokeModel& rSource ); + + /** Writes the properties to the passed property map. */ + void pushToPropMap( + PropertyMap& rPropMap, + const ::oox::core::FilterBase& rFilter ) const; +}; + +// ============================================================================ + +/** The fill model structure contains all shape fill properties. */ +struct FillModel +{ + OptValue< bool > moFilled; /// Shape fill on/off. + OptValue< ::rtl::OUString > moColor; /// Solid fill color. + OptValue< double > moOpacity; /// Solid fill color opacity. + OptValue< ::rtl::OUString > moColor2; /// End color of gradient. + OptValue< double > moOpacity2; /// End color opycity of gradient. + OptValue< sal_Int32 > moType; /// Fill type. + OptValue< sal_Int32 > moAngle; /// Gradient rotation angle. + OptValue< double > moFocus; /// Linear gradient focus of second color. + OptValue< DoublePair > moFocusPos; /// Rectanguar gradient focus position of second color. + OptValue< DoublePair > moFocusSize; /// Rectanguar gradient focus size of second color. + OptValue< bool > moRotate; /// True = rotate gradient/bitmap with shape. + + void assignUsed( const FillModel& rSource ); + + /** Writes the properties to the passed property map. */ + void pushToPropMap( + PropertyMap& rPropMap, + const ::oox::core::FilterBase& rFilter ) const; +}; + +// ============================================================================ + +} // namespace vml +} // namespace oox + +#endif + diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index f4719f4c1d97..323e643cee50 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -34,7 +34,7 @@ #include <memory> #include <vector> #include <com/sun/star/awt/Point.hpp> -#include "oox/helper/helper.hxx" +#include "oox/vml/vmlformatting.hxx" namespace com { namespace sun { namespace star { namespace awt { struct Rectangle; } @@ -56,12 +56,10 @@ struct ShapeTypeModel { ::rtl::OUString maShapeId; /// Unique identifier of the shape. ::rtl::OUString maName; /// Name of the shape, if present. - OptValue< sal_Int32 > monShapeType; /// Builtin shape type identifier. + OptValue< sal_Int32 > moShapeType; /// Builtin shape type identifier. - OptValue< sal_Int32 > monCoordLeft; /// Left position of coordinate system for children scaling. - OptValue< sal_Int32 > monCoordTop; /// Top position of coordinate system for children scaling. - OptValue< sal_Int32 > monCoordWidth; /// Width of coordinate system for children scaling. - OptValue< sal_Int32 > monCoordHeight; /// Height of coordinate system for children scaling. + OptValue< Int32Pair > moCoordPos; /// Top-left position of coordinate system for children scaling. + OptValue< Int32Pair > moCoordSize; /// Size of coordinate system for children scaling. ::rtl::OUString maPosition; /// Position type of the shape. ::rtl::OUString maLeft; /// X position of the shape bounding box (number with unit). ::rtl::OUString maTop; /// Y position of the shape bounding box (number with unit). @@ -70,11 +68,8 @@ struct ShapeTypeModel ::rtl::OUString maMarginLeft; /// X position of the shape bounding box to shape anchor (number with unit). ::rtl::OUString maMarginTop; /// Y position of the shape bounding box to shape anchor (number with unit). - OptValue< bool > mobStroked; /// True or missing = solid border line. - OptValue< ::rtl::OUString > moStrokeColor; /// Solid border color. - - OptValue< bool > mobFilled; /// True or missing = path is filled. - OptValue< ::rtl::OUString > moFillColor; /// Solid fill color. + StrokeModel maStrokeModel; /// Border line formatting. + FillModel maFillModel; /// Shape fill formatting. OptValue< ::rtl::OUString > moGraphicPath; /// Path to a graphic for this shape. OptValue< ::rtl::OUString > moGraphicTitle; /// Title of the graphic. @@ -131,7 +126,10 @@ struct ShapeClientData ::rtl::OUString maLinkedCell; /// Link to value cell associated to the control. ::rtl::OUString maSourceRange; /// Link to cell range used as data source for the control. sal_Int32 mnObjType; /// Type of the shape. + sal_Int32 mnCol; /// Column index for spreadsheet cell note. + sal_Int32 mnRow; /// Row index for spreadsheet cell note. bool mbPrintObject; /// True = print the object. + bool mbVisible; /// True = cell note is visible. explicit ShapeClientData(); }; @@ -179,6 +177,11 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, const ShapeParentAnchor* pParentAnchor = 0 ) const; + /** Converts position and formatting into the passed existing XShape. */ + void convertFormatting( + const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape, + const ShapeParentAnchor* pParentAnchor = 0 ) const; + protected: explicit ShapeBase( const Drawing& rDrawing ); @@ -188,6 +191,11 @@ protected: const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, const ::com::sun::star::awt::Rectangle& rShapeRect ) const = 0; + /** Calculates the final shape rectangle according to the passed anchor, + if present, otherwise according to the own anchor settings. */ + ::com::sun::star::awt::Rectangle calcShapeRectangle( + const ShapeParentAnchor* pParentAnchor ) const; + /** Converts common shape properties such as formatting attributes. */ void convertShapeProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape ) const; diff --git a/oox/inc/oox/vml/vmlshapecontainer.hxx b/oox/inc/oox/vml/vmlshapecontainer.hxx index d8c9b575a6ad..caa8a1a59c6d 100644 --- a/oox/inc/oox/vml/vmlshapecontainer.hxx +++ b/oox/inc/oox/vml/vmlshapecontainer.hxx @@ -73,6 +73,7 @@ public: /** Returns true, if this contaikner does not contain any shapes. */ inline bool empty() const { return maShapes.empty(); } + /** Returns the shape template with the passed identifier. @param bDeep True = searches in all group shapes too. */ const ShapeType* getShapeTypeById( const ::rtl::OUString& rShapeId, bool bDeep ) const; @@ -80,6 +81,15 @@ public: @param bDeep True = searches in all group shapes too. */ const ShapeBase* getShapeById( const ::rtl::OUString& rShapeId, bool bDeep ) const; + /** Searches for a shape type by using the passed functor that takes a + constant reference of a ShapeType object. */ + template< typename Functor > + const ShapeType* findShapeType( const Functor& rFunctor ) const; + /** Searches for a shape by using the passed functor that takes a constant + reference of a ShapeBase object. */ + template< typename Functor > + const ShapeBase* findShape( const Functor& rFunctor ) const; + /** Returns the first shape in the collection (Word only). */ const ShapeBase* getFirstShape() const; @@ -111,6 +121,18 @@ ShapeT& ShapeContainer::createShape() return *xShape; } +template< typename Functor > +const ShapeType* ShapeContainer::findShapeType( const Functor& rFunctor ) const +{ + return maTypes.findIf( rFunctor ).get(); +} + +template< typename Functor > +const ShapeBase* ShapeContainer::findShape( const Functor& rFunctor ) const +{ + return maShapes.findIf( rFunctor ).get(); +} + // ============================================================================ } // namespace vml diff --git a/oox/inc/oox/vml/vmlshapecontext.hxx b/oox/inc/oox/vml/vmlshapecontext.hxx index 0cc0be1f963a..dbc5e1aa611d 100644 --- a/oox/inc/oox/vml/vmlshapecontext.hxx +++ b/oox/inc/oox/vml/vmlshapecontext.hxx @@ -70,7 +70,7 @@ class ShapeContextBase : public ::oox::core::ContextHandler2 { public: static ::oox::core::ContextHandlerRef - createContext( + createShapeContext( ::oox::core::ContextHandler2Helper& rParent, sal_Int32 nElement, const AttributeList& rAttribs, @@ -94,10 +94,6 @@ public: onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); private: - /** Processes the 'coordorigin' attribute. */ - void setCoordOrigin( const ::rtl::OUString& rCoordOrigin ); - /** Processes the 'coordsize' attribute. */ - void setCoordSize( const ::rtl::OUString& rCoordSize ); /** Processes the 'style' attribute. */ void setStyle( const ::rtl::OUString& rStyle ); diff --git a/oox/inc/oox/xls/biffhelper.hxx b/oox/inc/oox/xls/biffhelper.hxx index 1da2c362170f..d5be59019315 100644 --- a/oox/inc/oox/xls/biffhelper.hxx +++ b/oox/inc/oox/xls/biffhelper.hxx @@ -470,6 +470,7 @@ const sal_uInt16 BIFF_ID_STANDARDWIDTH = 0x0099; const sal_uInt16 BIFF2_ID_STRING = 0x0007; const sal_uInt16 BIFF3_ID_STRING = 0x0207; const sal_uInt16 BIFF_ID_STYLE = 0x0293; +const sal_uInt16 BIFF_ID_STYLEEXT = 0x0892; const sal_uInt16 BIFF_ID_SXEXT = 0x00DC; const sal_uInt16 BIFF_ID_TOPMARGIN = 0x0028; const sal_uInt16 BIFF_ID_TXO = 0x01B6; diff --git a/oox/inc/oox/xls/chartsheetfragment.hxx b/oox/inc/oox/xls/chartsheetfragment.hxx index d1effba29166..3e6f5d9d7a6d 100644 --- a/oox/inc/oox/xls/chartsheetfragment.hxx +++ b/oox/inc/oox/xls/chartsheetfragment.hxx @@ -45,7 +45,7 @@ public: const WorkbookHelper& rHelper, const ::rtl::OUString& rFragmentPath, ISegmentProgressBarRef xProgressBar, - sal_Int32 nSheet ); + sal_Int16 nSheet ); protected: // oox.core.ContextHandler2Helper interface ------------------------------- @@ -76,7 +76,7 @@ public: explicit BiffChartsheetFragment( const BiffWorkbookFragmentBase& rParent, ISegmentProgressBarRef xProgressBar, - sal_Int32 nSheet ); + sal_Int16 nSheet ); /** Imports the entire sheet fragment, returns true, if EOF record has been reached. */ virtual bool importFragment(); diff --git a/oox/inc/oox/xls/defnamesbuffer.hxx b/oox/inc/oox/xls/defnamesbuffer.hxx index 88e4f7272d8e..88c83c0491b3 100644 --- a/oox/inc/oox/xls/defnamesbuffer.hxx +++ b/oox/inc/oox/xls/defnamesbuffer.hxx @@ -86,17 +86,12 @@ struct DefinedNameModel class DefinedNameBase : public WorkbookHelper { public: - explicit DefinedNameBase( const WorkbookHelper& rHelper, sal_Int32 nLocalSheet ); - - /** Returns true, if this defined name is global in the document. */ - inline bool isGlobalName() const { return maModel.mnSheet < 0; } + explicit DefinedNameBase( const WorkbookHelper& rHelper ); /** Returns the original name as imported from or exported to the file. */ inline const ::rtl::OUString& getModelName() const { return maModel.maName; } /** Returns the name as used in the Calc document. */ inline const ::rtl::OUString& getCalcName() const { return maCalcName; } - /** Returns the 0-based sheet index for local names, or -1 for global names. */ - inline sal_Int32 getSheetIndex() const { return maModel.mnSheet; } /** Returns the original name as imported from or exported to the file. */ const ::rtl::OUString& getUpcaseModelName() const; @@ -105,21 +100,19 @@ public: protected: /** Imports the OOX formula string, using the passed formula context. */ - void importOoxFormula( FormulaContext& rContext ); + void importOoxFormula( FormulaContext& rContext, sal_Int16 nBaseSheet ); /** Imports the OOBIN formula, using the passed formula context. */ - void importOobFormula( FormulaContext& rContext, RecordInputStream& rStrm ); + void importOobFormula( FormulaContext& rContext, sal_Int16 nBaseSheet, RecordInputStream& rStrm ); /** Imports the BIFF formula, using the passed formula context. */ - void importBiffFormula( FormulaContext& rContext, BiffInputStream& rStrm, const sal_uInt16* pnFmlaSize = 0 ); + void importBiffFormula( FormulaContext& rContext, sal_Int16 nBaseSheet, BiffInputStream& rStrm, const sal_uInt16* pnFmlaSize = 0 ); /** Tries to convert the passed token sequence to a SingleReference or ComplexReference. */ - void setReference( const ApiTokenSequence& rTokens ); + void extractReference( const ApiTokenSequence& rTokens ); protected: DefinedNameModel maModel; /// Model data for this defined name. mutable ::rtl::OUString maUpModelName; /// Model name converted to uppercase ASCII. ::rtl::OUString maCalcName; /// Final name used in the Calc document. - -private: ::com::sun::star::uno::Any maRefAny; /// Single cell/range reference. }; @@ -128,7 +121,7 @@ private: class DefinedName : public DefinedNameBase { public: - explicit DefinedName( const WorkbookHelper& rHelper, sal_Int32 nLocalSheet ); + explicit DefinedName( const WorkbookHelper& rHelper ); /** Sets the attributes for this defined name from the passed attribute set. */ void importDefinedName( const AttributeList& rAttribs ); @@ -137,7 +130,7 @@ public: /** Imports the defined name from a DEFINEDNAME record in the passed stream. */ void importDefinedName( RecordInputStream& rStrm ); /** Imports the defined name from a DEFINEDNAME record in the passed BIFF stream. */ - void importDefinedName( BiffInputStream& rStrm ); + void importDefinedName( BiffInputStream& rStrm, sal_Int16 nCalcSheet ); /** Creates a defined name in the Calc document. */ void createNameObject(); @@ -148,9 +141,13 @@ public: inline bool isBuiltinName() const { return mcBuiltinId != OOX_DEFNAME_UNKNOWN; } /** Returns true, if this defined name is a macro function call. */ inline bool isMacroFunction() const { return maModel.mbMacro && maModel.mbFunction; } + /** Returns true, if this defined name is global in the document. */ + inline bool isGlobalName() const { return mnCalcSheet < 0; } /** Returns the token index used in API token arrays (com.sun.star.sheet.FormulaToken). */ inline sal_Int32 getTokenIndex() const { return mnTokenIndex; } + /** Returns the 0-based sheet index for local names, or -1 for global names. */ + inline sal_Int16 getLocalCalcSheet() const { return mnCalcSheet; } /** Tries to resolve the defined name to an absolute cell range. */ bool getAbsoluteRange( ::com::sun::star::table::CellRangeAddress& orRange ) const; @@ -167,6 +164,7 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XNamedRange > mxNamedRange; /// XNamedRange interface of the defined name. sal_Int32 mnTokenIndex; /// Name index used in API token array. + sal_Int16 mnCalcSheet; /// Calc sheet index for sheet-local names. sal_Unicode mcBuiltinId; /// Identifier for built-in defined names. StreamDataSeqPtr mxFormula; /// Formula data for OOBIN import. BiffStreamPosPtr mxBiffStrm; /// Cached BIFF stream for formula import. @@ -182,9 +180,9 @@ class DefinedNamesBuffer : public WorkbookHelper public: explicit DefinedNamesBuffer( const WorkbookHelper& rHelper ); - /** Sets the current sheet index for files with local defined names, e.g. - BIFF4 workspaces. All created names initially will contain this index. */ - void setLocalSheetIndex( sal_Int32 nLocalSheet ); + /** Sets the sheet index for local names (BIFF2-BIFF4 only). */ + void setLocalCalcSheet( sal_Int16 nCalcSheet ); + /** Imports a defined name from the passed attribute set. */ DefinedNameRef importDefinedName( const AttributeList& rAttribs ); /** Imports a defined name from a DEFINEDNAME record in the passed stream. */ @@ -203,7 +201,7 @@ public: @param nSheet The sheet index for local names or -1 for global names. If no local name is found, tries to find a matching global name. @return Reference to the defined name or empty reference. */ - DefinedNameRef getByModelName( const ::rtl::OUString& rModelName, sal_Int32 nSheet = -1 ) const; + DefinedNameRef getByModelName( const ::rtl::OUString& rModelName, sal_Int16 nCalcSheet = -1 ) const; private: DefinedNameRef createDefinedName(); @@ -213,8 +211,8 @@ private: typedef RefMap< sal_Int32, DefinedName > DefNameMap; DefNameVector maDefNames; /// List of all defined names in insertion order. - DefNameMap maDefNameMap; /// Maps all defined names by API token index. */ - sal_Int32 mnLocalSheet; /// Current sheet index for import of BIFF sheet-local names. + DefNameMap maDefNameMap; /// Maps all defined names by API token index. + sal_Int16 mnCalcSheet; /// Current sheet index for BIFF2-BIFF4 names (always sheet-local). }; // ============================================================================ diff --git a/oox/inc/oox/xls/drawingfragment.hxx b/oox/inc/oox/xls/drawingfragment.hxx index f1fee71e5c1c..67009f436360 100644 --- a/oox/inc/oox/xls/drawingfragment.hxx +++ b/oox/inc/oox/xls/drawingfragment.hxx @@ -170,6 +170,12 @@ class VmlDrawing : public ::oox::vml::Drawing, public WorksheetHelper public: explicit VmlDrawing( const WorksheetHelper& rHelper ); + /** Returns the drawing shape for a cell note at the specified position. */ + const ::oox::vml::ShapeBase* getNoteShape( const ::com::sun::star::table::CellAddress& rPos ) const; + + /** Filters cell note shapes. */ + virtual bool isShapeSupported( const ::oox::vml::ShapeBase& rShape ) const; + /** Calculates the shape rectangle from a cell anchor string. */ virtual bool convertShapeClientAnchor( ::com::sun::star::awt::Rectangle& orShapeRect, diff --git a/oox/inc/oox/xls/excelfilter.hxx b/oox/inc/oox/xls/excelfilter.hxx index ed6c32cdc463..28059fe30ce7 100644 --- a/oox/inc/oox/xls/excelfilter.hxx +++ b/oox/inc/oox/xls/excelfilter.hxx @@ -41,7 +41,23 @@ namespace xls { class WorkbookHelper; -class ExcelFilter : public ::oox::core::XmlFilterBase +class ExcelFilterBase +{ +protected: + explicit ExcelFilterBase(); + virtual ~ExcelFilterBase(); + + void setWorkbookHelper( WorkbookHelper& rHelper ); + WorkbookHelper& getWorkbookHelper() const; + void clearWorkbookHelper(); + +private: + WorkbookHelper* mpHelper; /// Nonowning pointer to helper base. +}; + +// ============================================================================ + +class ExcelFilter : public ::oox::core::XmlFilterBase, public ExcelFilterBase { public: explicit ExcelFilter( @@ -51,23 +67,21 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); - virtual const ::oox::drawingml::Theme* getCurrentTheme() const; - virtual sal_Int32 getSchemeClr( sal_Int32 nColorSchemeToken ) const; + virtual sal_Int32 getSchemeColor( sal_Int32 nToken ) const; + virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; + virtual const ::oox::drawingml::Theme* getCurrentTheme() const; virtual ::oox::vml::Drawing* getVmlDrawing(); virtual const ::oox::drawingml::table::TableStyleListPtr getTableStyles(); virtual ::oox::drawingml::chart::ChartConverter& getChartConverter(); private: virtual ::rtl::OUString implGetImplementationName() const; - -private: - WorkbookHelper* mpHelper; /// Nonowning pointer to helper base. }; // ============================================================================ -class ExcelBiffFilter : public ::oox::core::BinaryFilterBase +class ExcelBiffFilter : public ::oox::core::BinaryFilterBase, public ExcelFilterBase { public: explicit ExcelBiffFilter( @@ -77,6 +91,8 @@ public: virtual bool importDocument() throw(); virtual bool exportDocument() throw(); + virtual sal_Int32 getPaletteColor( sal_Int32 nPaletteIdx ) const; + private: virtual ::rtl::OUString implGetImplementationName() const; }; diff --git a/oox/inc/oox/xls/excelhandlers.hxx b/oox/inc/oox/xls/excelhandlers.hxx index 3b34a14963ec..76d0e599e502 100644 --- a/oox/inc/oox/xls/excelhandlers.hxx +++ b/oox/inc/oox/xls/excelhandlers.hxx @@ -74,7 +74,7 @@ public: ParentType& rParent, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, - sal_Int32 nSheet ); + sal_Int16 nSheet ); template< typename ParentType > explicit OoxWorksheetContextBase( ParentType& rParent ); @@ -84,7 +84,7 @@ public: template< typename ParentType > OoxWorksheetContextBase::OoxWorksheetContextBase( ParentType& rParent, - ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int32 nSheet ) : + ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int16 nSheet ) : ::oox::core::ContextHandler2( rParent ), WorksheetHelperRoot( rParent, xProgressBar, eSheetType, nSheet ) { @@ -125,7 +125,7 @@ public: const ::rtl::OUString& rFragmentPath, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, - sal_Int32 nSheet ); + sal_Int16 nSheet ); explicit OoxWorksheetFragmentBase( const WorksheetHelper& rHelper, @@ -236,7 +236,7 @@ protected: const ParentType& rParent, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, - sal_Int32 nSheet ); + sal_Int16 nSheet ); template< typename ParentType > explicit BiffWorksheetContextBase( const ParentType& rParent ); @@ -246,7 +246,7 @@ protected: template< typename ParentType > BiffWorksheetContextBase::BiffWorksheetContextBase( const ParentType& rParent, - ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int32 nSheet ) : + ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, sal_Int16 nSheet ) : BiffContextHandler( rParent ), WorksheetHelperRoot( rParent, xProgressBar, eSheetType, nSheet ) { @@ -346,7 +346,7 @@ protected: const BiffWorkbookFragmentBase& rParent, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, - sal_Int32 nSheet ); + sal_Int16 nSheet ); }; // ============================================================================ @@ -359,7 +359,7 @@ public: explicit BiffSkipWorksheetFragment( const BiffWorkbookFragmentBase& rParent, ISegmentProgressBarRef xProgressBar, - sal_Int32 nSheet ); + sal_Int16 nSheet ); virtual bool importFragment(); }; diff --git a/oox/inc/oox/xls/externallinkbuffer.hxx b/oox/inc/oox/xls/externallinkbuffer.hxx index a50170544813..a4ede4403fe3 100644 --- a/oox/inc/oox/xls/externallinkbuffer.hxx +++ b/oox/inc/oox/xls/externallinkbuffer.hxx @@ -70,9 +70,7 @@ class ExternalLink; class ExternalName : public DefinedNameBase { public: - explicit ExternalName( - const ExternalLink& rParentLink, - sal_Int32 nLocalSheet ); + explicit ExternalName( const ExternalLink& rParentLink ); /** Appends the passed value to the result set. */ template< typename Type > @@ -109,8 +107,10 @@ public: /** Returns true, if the name refers to an OLE object. */ inline bool isOleObject() const { return maExtNameModel.mbOleObj; } +#if 0 /** Returns the sheet cache index if this is a sheet-local external name. */ sal_Int32 getSheetCacheIndex() const; +#endif /** Returns the DDE item info needed by the XML formula parser. */ bool getDdeItemInfo( @@ -123,6 +123,8 @@ public: ::rtl::OUString& orDdeItem ); private: + /** Tries to convert the passed token sequence to an ExternalReference. */ + void extractExternalReference( const ApiTokenSequence& rTokens ); /** Sets the size of the result matrix. */ void setResultSize( sal_Int32 nColumns, sal_Int32 nRows ); @@ -265,14 +267,20 @@ public: /** Returns the type of the external library if this is a library link. */ FunctionLibraryType getFuncLibraryType() const; - /** Returns the internal sheet index or external sheet cache index for the passed sheet. */ - sal_Int32 getSheetIndex( sal_Int32 nTabId = 0 ) const; - /** Returns the internal sheet range or range of external sheet caches for the passed sheet range (BIFF only). */ - void getSheetRange( LinkSheetRange& orSheetRange, sal_Int32 nTabId1, sal_Int32 nTabId2 ) const; + /** Returns the internal Calc sheet index or for the passed sheet. */ + sal_Int16 getCalcSheetIndex( sal_Int32 nTabId = 0 ) const; + + /** Returns the token index of the external document. */ + sal_Int32 getDocumentLinkIndex() const; + /** Returns the external sheet cache index or for the passed sheet. */ + sal_Int32 getSheetCacheIndex( sal_Int32 nTabId = 0 ) const; /** Returns the sheet cache of the external sheet with the passed index. */ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XExternalSheetCache > - getExternalSheetCache( sal_Int32 nTabId ); + getSheetCache( sal_Int32 nTabId ) const; + + /** Returns the internal sheet range or range of external sheet caches for the passed sheet range (BIFF only). */ + void getSheetRange( LinkSheetRange& orSheetRange, sal_Int32 nTabId1, sal_Int32 nTabId2 ) const; /** Returns the external name with the passed zero-based index. */ ExternalNameRef getNameByIndex( sal_Int32 nIndex ) const; @@ -289,7 +297,8 @@ private: ExternalNameRef createExternalName(); private: - typedef ::std::vector< sal_Int32 > IndexVector; + typedef ::std::vector< sal_Int16 > Int16Vector; + typedef ::std::vector< sal_Int32 > Int32Vector; typedef RefVector< ExternalName > ExternalNameVector; ExternalLinkType meLinkType; /// Type of this link object. @@ -299,7 +308,8 @@ private: ::rtl::OUString maTargetUrl; /// Target link, DDE topic, OLE target. ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XExternalDocLink > mxDocLink; /// Interface for an external document. - IndexVector maIndexes; /// Internal sheet indexes or external sheet cache indexes. + Int16Vector maCalcSheets; /// Internal sheet indexes. + Int32Vector maSheetCaches; /// External sheet cache indexes. ExternalNameVector maExtNames; /// Defined names in external document. }; diff --git a/oox/inc/oox/xls/richstring.hxx b/oox/inc/oox/xls/richstring.hxx index 23a0801531ae..47a55e92c350 100644 --- a/oox/inc/oox/xls/richstring.hxx +++ b/oox/inc/oox/xls/richstring.hxx @@ -71,6 +71,9 @@ public: /** Final processing after import of all strings. */ void finalizeImport(); + /** Returns the text data of this portion. */ + inline const ::rtl::OUString& getText() const { return maText; } + /** Converts the portion and appends it to the passed XText. */ void convert( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >& rxText, @@ -254,6 +257,9 @@ public: /** Final processing after import of all strings. */ void finalizeImport(); + /** Returns the plain text concatenated from all string portions. */ + ::rtl::OUString getPlainText() const; + /** Converts the string and writes it into the passed XText. */ void convert( const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText >& rxText, diff --git a/oox/inc/oox/xls/stylesbuffer.hxx b/oox/inc/oox/xls/stylesbuffer.hxx index 13890aec7223..2b5b5bf3e7f7 100644 --- a/oox/inc/oox/xls/stylesbuffer.hxx +++ b/oox/inc/oox/xls/stylesbuffer.hxx @@ -38,6 +38,7 @@ #include <com/sun/star/table/CellVertJustify.hpp> #include <com/sun/star/table/TableBorder.hpp> #include "oox/helper/containerhelper.hxx" +#include "oox/drawingml/color.hxx" #include "oox/xls/numberformatsbuffer.hxx" namespace com { namespace sun { namespace star { @@ -46,8 +47,6 @@ namespace com { namespace sun { namespace star { namespace oox { class PropertySet; } -#define OOX_XLS_USE_DEFAULT_STYLE 0 - namespace oox { namespace xls { @@ -67,9 +66,6 @@ const sal_Int32 OOX_COLOR_FONTAUTO = 0x7FFF; /// Font auto color (sys // ---------------------------------------------------------------------------- -const sal_Int32 API_RGB_TRANSPARENT = -1; /// Transparent color for API calls. -const sal_Int32 API_RGB_BLACK = 0; /// Black color for API calls. - const sal_Int16 API_LINE_NONE = 0; const sal_Int16 API_LINE_HAIR = 2; const sal_Int16 API_LINE_THIN = 35; @@ -85,11 +81,9 @@ const sal_Int8 API_ESCAPEHEIGHT_DEFAULT = 58; /// Relative character h // ============================================================================ -class Color +class Color : public ::oox::drawingml::Color { public: - explicit Color(); - /** Sets the color to automatic. */ void setAuto(); /** Sets the color to the passed RGB value. */ @@ -115,23 +109,7 @@ public: void importColorRgb( BiffInputStream& rStrm ); /** Returns true, if the color is set to automatic. */ - bool isAuto() const; - /** Returns the RGB value of the color, or nAuto for automatic colors. */ - sal_Int32 getColor( const WorkbookHelper& rHelper, sal_Int32 nAuto = API_RGB_TRANSPARENT ) const; - -private: - enum ColorMode - { - COLOR_AUTO, /// Automatic color (dependent on context). - COLOR_RGB, /// Hexadecimal RGB color. - COLOR_THEME, /// Indexed theme color. - COLOR_INDEXED, /// Indexed palette color. - COLOR_FINAL /// Finalized RGB color (resolved theme, applied tint). - }; - - mutable ColorMode meMode; /// Current color mode. - mutable sal_Int32 mnValue; /// RGB value, palette index, scheme index. - double mfTint; /// Color tint (darken/lighten). + inline bool isAuto() const { return isPlaceHolder(); } }; // ---------------------------------------------------------------------------- @@ -851,8 +829,6 @@ struct CellStyleModel inline bool isBuiltin() const { return mbBuiltin && (mnBuiltinId >= 0); } /** Returns true, if this style represents the default document cell style. */ bool isDefaultStyle() const; - /** Returns the style name used in the UI. */ - ::rtl::OUString createStyleName() const; }; // ============================================================================ @@ -868,18 +844,29 @@ public: void importCellStyle( RecordInputStream& rStrm ); /** Imports style settings from a STYLE record. */ void importStyle( BiffInputStream& rStrm ); + /** Sets the final style name to be used in the document. */ + inline void setFinalStyleName( const ::rtl::OUString& rStyleName ) { maFinalName = rStyleName; } + /** Returns true, if this style is a builtin style. */ + inline bool isBuiltin() const { return maModel.isBuiltin(); } /** Returns true, if this style represents the default document cell style. */ inline bool isDefaultStyle() const { return maModel.isDefaultStyle(); } /** Returns the XF identifier for this cell style. */ inline sal_Int32 getXfId() const { return maModel.mnXfId; } - - /** Creates the style sheet described by the style XF with the passed identifier. */ - const ::rtl::OUString& createCellStyle( sal_Int32 nXfId, bool bSkipDefaultBuiltin = false ); + /** Calculates a readable style name according to the settings. */ + ::rtl::OUString calcInitialStyleName() const; + /** Returns the final style name used in the document. */ + inline const ::rtl::OUString& getFinalStyleName() const { return maFinalName; } + + /** Creates the style sheet in the document described by this cell style object. */ + void createCellStyle(); + /** Creates the cell style, if it is user-defined or modified built-in. */ + void finalizeImport(); private: CellStyleModel maModel; - ::rtl::OUString maCalcName; /// Final style name used in API. + ::rtl::OUString maFinalName; /// Final style name used in API. + bool mbCreated; /// True = style sheet created. }; typedef ::boost::shared_ptr< CellStyle > CellStyleRef; @@ -964,11 +951,8 @@ public: const ::rtl::OUString& createCellStyle( sal_Int32 nXfId ) const; /** Creates the style sheet described by the DXF with the passed identifier. */ const ::rtl::OUString& createDxfStyle( sal_Int32 nDxfId ) const; -#if OOX_XLS_USE_DEFAULT_STYLE -#else /** Returns the default style sheet for unused cells. */ const ::rtl::OUString& getDefaultStyleName() const; -#endif /** Writes the font attributes of the specified font data to the passed property map. */ void writeFontToPropertyMap( PropertyMap& rPropMap, sal_Int32 nFontId ) const; @@ -992,12 +976,13 @@ private: void insertCellStyle( CellStyleRef xCellStyle ); private: - typedef RefVector< Font > FontVec; - typedef RefVector< Border > BorderVec; - typedef RefVector< Fill > FillVec; - typedef RefVector< Xf > XfVec; - typedef RefVector< Dxf > DxfVec; - typedef RefMap< sal_Int32, CellStyle > CellStyleMap; + typedef RefVector< Font > FontVec; + typedef RefVector< Border > BorderVec; + typedef RefVector< Fill > FillVec; + typedef RefVector< Xf > XfVec; + typedef RefVector< Dxf > DxfVec; + typedef RefMap< sal_Int32, CellStyle > CellStyleIdMap; + typedef RefMap< ::rtl::OUString, CellStyle > CellStyleNameMap; ColorPalette maPalette; /// Color palette. FontVec maFonts; /// List of font objects. @@ -1007,7 +992,8 @@ private: XfVec maCellXfs; /// List of cell formats. XfVec maStyleXfs; /// List of cell styles. DxfVec maDxfs; /// List of differential cell styles. - CellStyleMap maCellStyles; /// List of named cell styles. + CellStyleIdMap maCellStylesById; /// List of named cell styles, mapped by XF identifier. + CellStyleNameMap maCellStylesByName; /// List of named cell styles, mapped by name. ::rtl::OUString maDefStyleName; /// API name of default cell style. sal_Int32 mnDefStyleXf; /// Style XF index of default cell style. }; diff --git a/oox/inc/oox/xls/themebuffer.hxx b/oox/inc/oox/xls/themebuffer.hxx index ca0a80d983fe..b1ee4b4ebc66 100644 --- a/oox/inc/oox/xls/themebuffer.hxx +++ b/oox/inc/oox/xls/themebuffer.hxx @@ -49,8 +49,6 @@ public: /** Returns the theme color with the specified token identifier. */ sal_Int32 getColorByToken( sal_Int32 nToken ) const; - /** Returns the theme color with the specified index. */ - sal_Int32 getColorByIndex( sal_Int32 nIndex ) const; /** Returns the default font data for the current file type. */ inline const FontModel& getDefaultFontModel() const { return *mxDefFontModel; } diff --git a/oox/inc/oox/xls/viewsettings.hxx b/oox/inc/oox/xls/viewsettings.hxx index fceb1bc1a63c..f18d0371c6c2 100644 --- a/oox/inc/oox/xls/viewsettings.hxx +++ b/oox/inc/oox/xls/viewsettings.hxx @@ -92,6 +92,8 @@ struct SheetViewModel sal_Int32 getNormalZoom() const; /** Returns the zoom in pagebreak preview (returns default, if current value is 0). */ sal_Int32 getPageBreakZoom() const; + /** Returns the grid color as RGB value. */ + sal_Int32 getGridColor( const ::oox::core::FilterBase& rFilter ) const; /** Returns the selection data, if available, otherwise 0. */ const PaneSelectionModel* getPaneSelection( sal_Int32 nPaneId ) const; @@ -186,23 +188,23 @@ public: void importWindow1( BiffInputStream& rStrm ); /** Stores converted view settings for a specific worksheet. */ - void setSheetViewSettings( sal_Int32 nSheet, + void setSheetViewSettings( sal_Int16 nSheet, const SheetViewModelRef& rxSheetView, const ::com::sun::star::uno::Any& rProperties ); /** Converts all imported document view settings. */ void finalizeImport(); - /** Returns the index of the active sheet. */ - sal_Int32 getActiveSheetIndex() const; + /** Returns the Calc index of the active sheet. */ + sal_Int16 getActiveCalcSheet() const; private: WorkbookViewModel& createWorkbookView(); private: typedef RefVector< WorkbookViewModel > WorkbookViewModelVec; - typedef RefMap< sal_Int32, SheetViewModel > SheetViewModelMap; - typedef ::std::map< sal_Int32, ::com::sun::star::uno::Any > SheetPropertiesMap; + typedef RefMap< sal_Int16, SheetViewModel > SheetViewModelMap; + typedef ::std::map< sal_Int16, ::com::sun::star::uno::Any > SheetPropertiesMap; WorkbookViewModelVec maBookViews; /// Workbook view models. SheetViewModelMap maSheetViews; /// Active view model for each sheet. diff --git a/oox/inc/oox/xls/workbookfragment.hxx b/oox/inc/oox/xls/workbookfragment.hxx index a691fcf5cf57..d3925f9113d8 100644 --- a/oox/inc/oox/xls/workbookfragment.hxx +++ b/oox/inc/oox/xls/workbookfragment.hxx @@ -94,7 +94,7 @@ private: /** Imports a sheet fragment with passed type from current stream position. */ bool importSheetFragment( ISegmentProgressBar& rProgressBar, - BiffFragmentType eFragment, sal_Int32 nSheet ); + BiffFragmentType eFragment, sal_Int16 nCalcSheet ); }; // ============================================================================ diff --git a/oox/inc/oox/xls/workbookhelper.hxx b/oox/inc/oox/xls/workbookhelper.hxx index 207b69184c1d..1c4210deabf6 100644 --- a/oox/inc/oox/xls/workbookhelper.hxx +++ b/oox/inc/oox/xls/workbookhelper.hxx @@ -253,7 +253,7 @@ public: /** Returns a reference to the specified spreadsheet in the document model. */ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > - getSheetFromDoc( sal_Int32 nSheet ) const; + getSheetFromDoc( sal_Int16 nSheet ) const; /** Returns a reference to the specified spreadsheet in the document model. */ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet > getSheetFromDoc( const ::rtl::OUString& rSheet ) const; @@ -281,12 +281,11 @@ public: createNamedRangeObject( ::rtl::OUString& orName, sal_Int32 nNameFlags = 0 ) const; - /** Creates a com.sun.star.style.Style object and returns its final name. */ + /** Creates and returns a com.sun.star.style.Style object for cells or pages. */ ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle > createStyleObject( ::rtl::OUString& orStyleName, - bool bPageStyle, - bool bRenameOldExisting = false ) const; + bool bPageStyle ) const; // buffers ---------------------------------------------------------------- @@ -361,7 +360,7 @@ public: /** Enables workbook file mode, used for BIFF4 workspace files. */ void setIsWorkbookFile(); /** Recreates global buffers that are used per sheet in specific BIFF versions. */ - void createBuffersPerSheet(); + void createBuffersPerSheet( sal_Int16 nSheet ); /** Returns the codec helper that stores the encoder/decoder object. */ BiffCodecHelper& getCodecHelper() const; diff --git a/oox/inc/oox/xls/worksheetbuffer.hxx b/oox/inc/oox/xls/worksheetbuffer.hxx index a4ebdedef7e2..327ff5c5638d 100644 --- a/oox/inc/oox/xls/worksheetbuffer.hxx +++ b/oox/inc/oox/xls/worksheetbuffer.hxx @@ -31,9 +31,8 @@ #ifndef OOX_XLS_WORKSHEETBUFFER_HXX #define OOX_XLS_WORKSHEETBUFFER_HXX -#include <vector> -#include <map> #include <utility> +#include "oox/helper/containerhelper.hxx" #include "oox/xls/workbookhelper.hxx" namespace com { namespace sun { namespace star { @@ -50,7 +49,6 @@ struct SheetInfoModel { ::rtl::OUString maRelId; /// Relation identifier for the sheet substream. ::rtl::OUString maName; /// Original name of the sheet. - ::rtl::OUString maFinalName; /// Final (converted) name of the sheet. sal_Int32 mnSheetId; /// Sheet identifier. sal_Int32 mnState; /// Visibility state. @@ -70,6 +68,9 @@ class WorksheetBuffer : public WorkbookHelper public: explicit WorksheetBuffer( const WorkbookHelper& rHelper ); + /** Returns the base file name without path and file extension. */ + static ::rtl::OUString getBaseFileName( const ::rtl::OUString& rUrl ); + /** Initializes the buffer for single sheet files (BIFF2-BIFF4). */ void initializeSingleSheet(); @@ -79,34 +80,49 @@ public: void importSheet( RecordInputStream& rStrm ); /** Imports the SHEET record from the passed BIFF stream. */ void importSheet( BiffInputStream& rStrm ); - /** Inserts a new empty sheet into the document. Looks for an unused name. - @return Internal index of the new sheet. */ + @return Index of the new sheet in the Calc document. */ sal_Int16 insertEmptySheet( const ::rtl::OUString& rPreferredName, bool bVisible ); /** Returns the number of original sheets contained in the workbook. */ - sal_Int32 getSheetCount() const; - /** Returns the OOX relation identifier of the specified sheet. */ - ::rtl::OUString getSheetRelId( sal_Int32 nSheet ) const; - /** Returns the finalized name of the specified sheet. */ - ::rtl::OUString getCalcSheetName( sal_Int32 nSheet ) const; - /** Returns the finalized name of the sheet with the passed original name. */ - ::rtl::OUString getCalcSheetName( const ::rtl::OUString& rModelName ) const; - /** Returns the index of the sheet with the passed original name. */ - sal_Int32 getCalcSheetIndex( const ::rtl::OUString& rModelName ) const; + sal_Int32 getWorksheetCount() const; + /** Returns the OOX relation identifier of the specified worksheet. */ + ::rtl::OUString getWorksheetRelId( sal_Int32 nWorksheet ) const; + + /** Returns the Calc index of the specified worksheet. */ + sal_Int16 getCalcSheetIndex( sal_Int32 nWorksheet ) const; + /** Returns the finalized name of the specified worksheet. */ + ::rtl::OUString getCalcSheetName( sal_Int32 nWorksheet ) const; + + /** Returns the Calc index of the sheet with the passed original worksheet name. */ + sal_Int16 getCalcSheetIndex( const ::rtl::OUString& rWorksheetName ) const; + /** Returns the finalized name of the sheet with the passed worksheet name. */ + ::rtl::OUString getCalcSheetName( const ::rtl::OUString& rWorksheetName ) const; private: - typedef ::std::pair< sal_Int16, ::rtl::OUString > IndexNamePair; + struct SheetInfo : public SheetInfoModel + { + ::rtl::OUString maCalcName; + ::rtl::OUString maCalcQuotedName; + sal_Int16 mnCalcSheet; + + explicit SheetInfo( const SheetInfoModel& rModel, sal_Int16 nCalcSheet, const ::rtl::OUString& rCalcName ); + }; - const SheetInfoModel* getSheetInfo( sal_Int32 nSheet ) const; + typedef ::std::pair< sal_Int16, ::rtl::OUString > IndexNamePair; - IndexNamePair insertSheet( const ::rtl::OUString& rPreferredName, sal_Int16 nSheet, bool bVisible ); + /** Creates a new sheet in the Calc document. Does not insert anything in the own lists. */ + IndexNamePair createSheet( const ::rtl::OUString& rPreferredName, sal_Int32 nSheetPos, bool bVisible ); + /** Creates a new sheet in the Calc document and inserts the related SheetInfo. */ void insertSheet( const SheetInfoModel& rModel ); private: - typedef ::std::vector< SheetInfoModel > SheetInfoModelVec; + typedef RefVector< SheetInfo > SheetInfoVector; + SheetInfoVector maSheetInfos; - SheetInfoModelVec maSheetInfos; + struct SheetNameCompare { bool operator()( const ::rtl::OUString& rName1, const ::rtl::OUString& rName2 ) const; }; + typedef RefMap< ::rtl::OUString, SheetInfo, SheetNameCompare > SheetInfoMap; + SheetInfoMap maSheetInfosByName; }; // ============================================================================ diff --git a/oox/inc/oox/xls/worksheetfragment.hxx b/oox/inc/oox/xls/worksheetfragment.hxx index e5721265937f..110851ea9521 100644 --- a/oox/inc/oox/xls/worksheetfragment.hxx +++ b/oox/inc/oox/xls/worksheetfragment.hxx @@ -71,7 +71,7 @@ public: const ::rtl::OUString& rFragmentPath, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, - sal_Int32 nSheet ); + sal_Int16 nSheet ); protected: // oox.core.ContextHandler2Helper interface ------------------------------- @@ -147,7 +147,7 @@ public: const BiffWorkbookFragmentBase& rParent, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, - sal_Int32 nSheet ); + sal_Int16 nSheet ); virtual ~BiffWorksheetFragment(); /** Imports the entire worksheet fragment, returns true, if EOF record has been reached. */ diff --git a/oox/inc/oox/xls/worksheethelper.hxx b/oox/inc/oox/xls/worksheethelper.hxx index fc097783510b..7bb9b52ff117 100644 --- a/oox/inc/oox/xls/worksheethelper.hxx +++ b/oox/inc/oox/xls/worksheethelper.hxx @@ -175,8 +175,9 @@ struct PageBreakModel /** Stores data about a hyperlink range. */ struct HyperlinkModel : public ::oox::ole::StdHlinkInfo { - ::com::sun::star::table::CellRangeAddress maRange; - ::rtl::OUString maTooltip; + ::com::sun::star::table::CellRangeAddress + maRange; /// The cell area containing the hyperlink. + ::rtl::OUString maTooltip; /// Additional tooltip text. explicit HyperlinkModel(); }; @@ -442,7 +443,7 @@ protected: const WorkbookHelper& rHelper, ISegmentProgressBarRef xProgressBar, WorksheetType eSheetType, - sal_Int32 nSheet ); + sal_Int16 nSheet ); /** Constructs from another sheet helper, does not create a data object. */ explicit WorksheetHelperRoot( |