diff options
author | ka <kai.ahrens@sun.com> | 2010-05-27 12:19:08 +0200 |
---|---|---|
committer | ka <kai.ahrens@sun.com> | 2010-05-27 12:19:08 +0200 |
commit | 061369edf21348a62a8f1bbad7b5bcfcf30a6e3f (patch) | |
tree | b1b9c50eda2e877eaa9ff6dc886ee934c7257e25 /oox | |
parent | 6d659bf00a22f54ddc2030add79f79c6f9c08429 (diff) | |
parent | 17e7675fe6fccf5a0f084bb9f7bceb4f663f8e3b (diff) |
impressbi01: merged DEV300_m77
Diffstat (limited to 'oox')
26 files changed, 585 insertions, 237 deletions
diff --git a/oox/inc/oox/drawingml/shape.hxx b/oox/inc/oox/drawingml/shape.hxx index 9c997d972533..c2a5b6a4e79d 100644 --- a/oox/inc/oox/drawingml/shape.hxx +++ b/oox/inc/oox/drawingml/shape.hxx @@ -126,7 +126,8 @@ public: void setHidden( sal_Bool bHidden ) { mbHidden = bHidden; } void setSubType( sal_uInt32 nSubType ) { mnSubType = nSubType; } sal_Int32 getSubType() const { return mnSubType; } - void setIndex( sal_uInt32 nIndex ) { mnIndex = nIndex; } + void setSubTypeIndex( sal_uInt32 nSubTypeIndex ) { mnSubTypeIndex = nSubTypeIndex; } + sal_Int32 getSubTypeIndex() const { return mnSubTypeIndex; } // setDefaults has to be called if styles are imported (OfficeXML is not storing properties having the default value) void setDefaults(); @@ -187,11 +188,11 @@ protected: TextListStylePtr mpMasterTextListStyle; ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > mxShape; - rtl::OUString msServiceName; - rtl::OUString msName; - rtl::OUString msId; - sal_uInt32 mnSubType; // if this type is not zero, then the shape is a placeholder - sal_uInt32 mnIndex; + rtl::OUString msServiceName; + rtl::OUString msName; + rtl::OUString msId; + sal_uInt32 mnSubType; // if this type is not zero, then the shape is a placeholder + sal_uInt32 mnSubTypeIndex; ShapeStyleRefMap maShapeStyleRefs; diff --git a/oox/inc/oox/drawingml/textbodyproperties.hxx b/oox/inc/oox/drawingml/textbodyproperties.hxx index 7b17c561e286..6688eea7746c 100644 --- a/oox/inc/oox/drawingml/textbodyproperties.hxx +++ b/oox/inc/oox/drawingml/textbodyproperties.hxx @@ -41,6 +41,10 @@ struct TextBodyProperties PropertyMap maPropertyMap; OptValue< sal_Int32 > moRotation; OptValue< sal_Int32 > moVert; + + explicit TextBodyProperties(); + + void pushToPropMap( PropertyMap& rPropMap ) const; }; // ============================================================================ diff --git a/oox/inc/oox/drawingml/textparagraph.hxx b/oox/inc/oox/drawingml/textparagraph.hxx index e98232477f3b..d8c97cbfa114 100644 --- a/oox/inc/oox/drawingml/textparagraph.hxx +++ b/oox/inc/oox/drawingml/textparagraph.hxx @@ -54,8 +54,8 @@ public: inline TextParagraphProperties& getProperties() { return maProperties; } inline const TextParagraphProperties& getProperties() const { return maProperties; } - inline TextParagraphProperties& getEndProperties() { return maEndProperties; } - inline const TextParagraphProperties& getEndProperties() const { return maEndProperties; } + inline TextCharacterProperties& getEndProperties() { return maEndProperties; } + inline const TextCharacterProperties& getEndProperties() const { return maEndProperties; } //inline void setProperties( TextParagraphPropertiesPtr pProps ) { mpProperties = pProps; } @@ -69,7 +69,7 @@ public: private: TextParagraphProperties maProperties; - TextParagraphProperties maEndProperties; + TextCharacterProperties maEndProperties; TextRunVector maRuns; }; diff --git a/oox/inc/oox/xls/stylesbuffer.hxx b/oox/inc/oox/xls/stylesbuffer.hxx index 8af5127143de..7eb00d4bd57d 100644 --- a/oox/inc/oox/xls/stylesbuffer.hxx +++ b/oox/inc/oox/xls/stylesbuffer.hxx @@ -509,8 +509,13 @@ struct ApiBorderData bool mbDiagUsed; /// True = diagonal line format used. explicit ApiBorderData(); + + /** Returns true, if any of the outer border lines is visible. */ + bool hasAnyOuterBorder() const; }; +bool operator==( const ApiBorderData& rLeft, const ApiBorderData& rRight ); + // ============================================================================ class Border : public WorkbookHelper @@ -544,6 +549,11 @@ public: /** Final processing after import of all style settings. */ void finalizeImport(); + /** Returns the border model structure. */ + inline const BorderModel& getModel() const { return maModel; } + /** Returns the converted API border data struct. */ + inline const ApiBorderData& getApiData() const { return maApiData; } + /** Writes all border attributes to the passed property map. */ void writeToPropertyMap( PropertyMap& rPropMap ) const; @@ -619,6 +629,8 @@ struct ApiSolidFillData explicit ApiSolidFillData(); }; +bool operator==( const ApiSolidFillData& rLeft, const ApiSolidFillData& rRight ); + // ============================================================================ /** Contains cell fill attributes, either a pattern fill or a gradient fill. */ @@ -665,6 +677,13 @@ public: /** Final processing after import of all style settings. */ void finalizeImport(); + /** Returns the fill pattern model structure, if extant. */ + inline const PatternFillModel* getPatternModel() const { return mxPatternModel.get(); } + /** Returns the fill gradient model structure, if extant. */ + inline const GradientFillModel* getGradientModel() const { return mxGradientModel.get(); } + /** Returns the converted API fill data struct. */ + inline const ApiSolidFillData& getApiData() const { return maApiData; } + /** Writes all fill attributes to the passed property map. */ void writeToPropertyMap( PropertyMap& rPropMap ) const; @@ -734,6 +753,9 @@ public: /** Final processing after import of all style settings. */ void finalizeImport(); + /** Returns true, if the XF is a cell XF, and false, if it is a style XF. */ + inline bool isCellXf() const { return maModel.mbCellXf; } + /** Returns the referred font object. */ FontRef getFont() const; /** Returns the alignment data of this style. */ @@ -751,13 +773,13 @@ public: private: /** Sets 'attribute used' flags from the passed BIFF bit field. */ void setBiffUsedFlags( sal_uInt8 nUsedFlags ); - /** Updates own used flags from the passed cell style XF. */ - void updateUsedFlags( const Xf& rStyleXf ); private: XfModel maModel; /// Cell XF or style XF model data. Alignment maAlignment; /// Cell alignment data. Protection maProtection; /// Cell protection data. + ::com::sun::star::table::CellVertJustify + meRotationRef; /// Rotation reference dependent on border. }; typedef ::boost::shared_ptr< Xf > XfRef; @@ -964,6 +986,8 @@ public: sal_Int32 getPaletteColor( sal_Int32 nIndex ) const; /** Returns the specified font object. */ FontRef getFont( sal_Int32 nFontId ) const; + /** Returns the specified border object. */ + BorderRef getBorder( sal_Int32 nBorderId ) const; /** Returns the specified cell format object. */ XfRef getCellXf( sal_Int32 nXfId ) const; /** Returns the specified style format object. */ @@ -978,6 +1002,11 @@ public: /** Returns the model of the default application font (used in the "Normal" cell style). */ const FontModel& getDefaultFontModel() const; + /** Returns true, if the specified borders are equal. */ + bool equalBorders( sal_Int32 nBorderId1, sal_Int32 nBorderId2 ) const; + /** Returns true, if the specified fills are equal. */ + bool equalFills( sal_Int32 nFillId1, sal_Int32 nFillId2 ) const; + /** Returns the default style sheet for unused cells. */ ::rtl::OUString getDefaultStyleName() const; /** Creates the style sheet described by the style XF with the passed identifier. */ diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index 07c31736e9e7..07c31736e9e7 100644..100755 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index ded047f2436b..87faadd7a9ce 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -85,13 +85,25 @@ namespace core { // ============================================================================ +namespace { + +bool lclHasSuffix( const OUString& rFragmentPath, const OUString& rSuffix ) +{ + sal_Int32 nSuffixPos = rFragmentPath.getLength() - rSuffix.getLength(); + return (nSuffixPos >= 0) && rFragmentPath.match( rSuffix, nSuffixPos ); +} + +} // namespace + +// ============================================================================ + struct XmlFilterBaseImpl { typedef RefMap< OUString, Relations > RelationsMap; + Reference< XFastParser > mxFastParser; OUString maBinSuffix; - Reference< XFastTokenHandler > - mxTokenHandler; + OUString maVmlSuffix; RelationsMap maRelationsMap; TextFieldStack maTextFieldStack; explicit XmlFilterBaseImpl(); @@ -101,7 +113,7 @@ struct XmlFilterBaseImpl XmlFilterBaseImpl::XmlFilterBaseImpl() : maBinSuffix( CREATE_OUSTRING( ".bin" ) ), - mxTokenHandler( new FastTokenHandler ) + maVmlSuffix( CREATE_OUSTRING( ".vml" ) ) { } @@ -113,6 +125,38 @@ XmlFilterBase::XmlFilterBase( const Reference< XMultiServiceFactory >& rxGlobalF mnRelId( 1 ), mnMaxDocId( 0 ) { + try + { + // create the fast parser + mxImpl->mxFastParser.set( rxGlobalFactory->createInstance( CREATE_OUSTRING( "com.sun.star.xml.sax.FastParser" ) ), UNO_QUERY_THROW ); + mxImpl->mxFastParser->setTokenHandler( new FastTokenHandler ); + + // register XML namespaces + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://www.w3.org/XML/1998/namespace" ), NMSP_XML ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/relationships" ), NMSP_PACKAGE_RELATIONSHIPS ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/officeDocument/2006/relationships" ), NMSP_RELATIONSHIPS ); + + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/main" ), NMSP_DRAWINGML ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/diagram" ), NMSP_DIAGRAM ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/chart" ), NMSP_CHART ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing" ), NMSP_CDR ); + + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:vml" ), NMSP_VML ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:office" ), NMSP_OFFICE ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:word" ), NMSP_VML_DOC ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:excel" ), NMSP_VML_XLS ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:powerpoint" ), NMSP_VML_PPT ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.microsoft.com/office/2006/activeX" ), NMSP_AX ); + + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/spreadsheetml/2006/main"), NMSP_XLS ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" ), NMSP_XDR ); + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.microsoft.com/office/excel/2006/main" ), NMSP_XM ); + + mxImpl->mxFastParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/presentationml/2006/main"), NMSP_PPT ); + } + catch( Exception& ) + { + } } XmlFilterBase::~XmlFilterBase() @@ -140,8 +184,7 @@ bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& r return false; // try to import binary streams (fragment extension must be '.bin') - sal_Int32 nBinSuffixPos = aFragmentPath.getLength() - mxImpl->maBinSuffix.getLength(); - if( (nBinSuffixPos >= 0) && aFragmentPath.match( mxImpl->maBinSuffix, nBinSuffixPos ) ) + if( lclHasSuffix( aFragmentPath, mxImpl->maBinSuffix ) ) { try { @@ -170,41 +213,16 @@ bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& r if( !xDocHandler.is() ) return false; + // check that the fast parser exists + if( !mxImpl->mxFastParser.is() ) + return false; + // try to import XML stream try { // try to open the fragment stream (this may fail - do not assert) Reference< XInputStream > xInStrm( rxHandler->openFragmentStream(), UNO_SET_THROW ); - // create the fast parser - Reference< XFastParser > xParser( getGlobalFactory()->createInstance( - CREATE_OUSTRING( "com.sun.star.xml.sax.FastParser" ) ), UNO_QUERY_THROW ); - xParser->setFastDocumentHandler( xDocHandler ); - xParser->setTokenHandler( mxImpl->mxTokenHandler ); - - // register XML namespaces - xParser->registerNamespace( CREATE_OUSTRING( "http://www.w3.org/XML/1998/namespace" ), NMSP_XML ); - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/relationships" ), NMSP_PACKAGE_RELATIONSHIPS ); - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/officeDocument/2006/relationships" ), NMSP_RELATIONSHIPS ); - - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/main" ), NMSP_DRAWINGML ); - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/diagram" ), NMSP_DIAGRAM ); - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/chart" ), NMSP_CHART ); - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/chartDrawing" ), NMSP_CDR ); - - xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:vml" ), NMSP_VML ); - xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:office" ), NMSP_OFFICE ); - xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:word" ), NMSP_VML_DOC ); - xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:excel" ), NMSP_VML_XLS ); - xParser->registerNamespace( CREATE_OUSTRING( "urn:schemas-microsoft-com:office:powerpoint" ), NMSP_VML_PPT ); - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.microsoft.com/office/2006/activeX" ), NMSP_AX ); - - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/spreadsheetml/2006/main"), NMSP_XLS ); - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" ), NMSP_XDR ); - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.microsoft.com/office/excel/2006/main" ), NMSP_XM ); - - xParser->registerNamespace( CREATE_OUSTRING( "http://schemas.openxmlformats.org/presentationml/2006/main"), NMSP_PPT ); - // create the input source and parse the stream InputSource aSource; aSource.aInputStream = xInStrm; @@ -212,7 +230,8 @@ bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& r // own try/catch block for showing parser failure assertion with fragment path try { - xParser->parseStream( aSource ); + mxImpl->mxFastParser->setFastDocumentHandler( xDocHandler ); + mxImpl->mxFastParser->parseStream( aSource ); return true; } catch( Exception& ) diff --git a/oox/source/drawingml/makefile.mk b/oox/source/drawingml/makefile.mk index 443c30bb16a9..e2d4ea6b8f3d 100644 --- a/oox/source/drawingml/makefile.mk +++ b/oox/source/drawingml/makefile.mk @@ -66,6 +66,7 @@ SLOFILES = \ $(SLO)$/spdefcontext.obj\ $(SLO)$/textbody.obj\ $(SLO)$/textbodycontext.obj\ + $(SLO)$/textbodyproperties.obj\ $(SLO)$/textbodypropertiescontext.obj\ $(SLO)$/textcharacterproperties.obj\ $(SLO)$/textcharacterpropertiescontext.obj\ diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 11951f1c7da0..20d299c3ed83 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -47,6 +47,7 @@ #include <basegfx/point/b2dpoint.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <com/sun/star/document/XActionLockable.hpp> using rtl::OUString; using namespace ::oox::core; @@ -89,7 +90,7 @@ Shape::Shape( const sal_Char* pServiceName ) , mpCustomShapePropertiesPtr( new CustomShapeProperties ) , mpMasterTextListStyle( new TextListStyle ) , mnSubType( 0 ) -, mnIndex( 0 ) +, mnSubTypeIndex( -1 ) , mnRotation( 0 ) , mbFlipH( false ) , mbFlipV( false ) @@ -373,6 +374,10 @@ Reference< XShape > Shape::createAndInsert( xSet->setPropertyValue( sHidden, Any( mbHidden ) ); } + Reference< document::XActionLockable > xLockable( mxShape, UNO_QUERY ); + if( xLockable.is() ) + xLockable->addActionLock(); + // sj: removing default text of placeholder objects such as SlideNumberShape or HeaderShape if ( bClearText ) { @@ -417,13 +422,23 @@ Reference< XShape > Shape::createAndInsert( aFillProperties.assignUsed( getFillProperties() ); PropertyMap aShapeProperties; + PropertyMap::const_iterator aShapePropIter; + aShapeProperties.insert( getShapeProperties().begin(), getShapeProperties().end() ); if( mxCreateCallback.get() ) - aShapeProperties.insert( mxCreateCallback->getShapeProperties().begin(), mxCreateCallback->getShapeProperties().end() ); + { + for ( aShapePropIter = mxCreateCallback->getShapeProperties().begin(); + aShapePropIter != mxCreateCallback->getShapeProperties().end(); aShapePropIter++ ) + aShapeProperties[ (*aShapePropIter).first ] = (*aShapePropIter).second; + } // add properties from textbody to shape properties if( mpTextBody.get() ) - aShapeProperties.insert( mpTextBody->getTextProperties().maPropertyMap.begin(), mpTextBody->getTextProperties().maPropertyMap.end() ); + { + for ( aShapePropIter = mpTextBody->getTextProperties().maPropertyMap.begin(); + aShapePropIter != mpTextBody->getTextProperties().maPropertyMap.end(); aShapePropIter++ ) + aShapeProperties[ (*aShapePropIter).first ] = (*aShapePropIter).second; + } // applying properties PropertySet aPropSet( xSet ); @@ -469,6 +484,8 @@ Reference< XShape > Shape::createAndInsert( getTextBody()->insertAt( rFilterBase, xText, xAt, aCharStyleProperties, mpMasterTextListStyle ); } } + if( xLockable.is() ) + xLockable->removeActionLock(); } // use a callback for further processing on the XShape (e.g. charts) diff --git a/oox/source/drawingml/shapecontext.cxx b/oox/source/drawingml/shapecontext.cxx index 00332d1be0e3..a5f3b1598447 100644 --- a/oox/source/drawingml/shapecontext.cxx +++ b/oox/source/drawingml/shapecontext.cxx @@ -95,7 +95,7 @@ Reference< XFastContextHandler > ShapeContext::createFastChildContext( sal_Int32 } case XML_ph: mpShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); - mpShapePtr->setIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); break; // nvSpPr CT_ShapeNonVisual end diff --git a/oox/source/drawingml/shapegroupcontext.cxx b/oox/source/drawingml/shapegroupcontext.cxx index 1b90be3952ab..56ce53767641 100644 --- a/oox/source/drawingml/shapegroupcontext.cxx +++ b/oox/source/drawingml/shapegroupcontext.cxx @@ -75,7 +75,7 @@ Reference< XFastContextHandler > ShapeGroupContext::createFastChildContext( sal_ break; case XML_ph: mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) ); - mpGroupShapePtr->setIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); break; // nvSpPr CT_ShapeNonVisual end diff --git a/oox/source/drawingml/textbodycontext.cxx b/oox/source/drawingml/textbodycontext.cxx index 9a197ee691bf..8de730849b24 100644 --- a/oox/source/drawingml/textbodycontext.cxx +++ b/oox/source/drawingml/textbodycontext.cxx @@ -109,7 +109,7 @@ Reference< XFastContextHandler > TextParagraphContext::createFastChildContext( s xRet.set( new TextParagraphPropertiesContext( *this, xAttribs, mrParagraph.getProperties() ) ); break; case NMSP_DRAWINGML|XML_endParaRPr: - xRet.set( new TextParagraphPropertiesContext( *this, xAttribs, mrParagraph.getEndProperties() ) ); + xRet.set( new TextCharacterPropertiesContext( *this, xAttribs, mrParagraph.getEndProperties() ) ); break; } diff --git a/oox/source/drawingml/textbodyproperties.cxx b/oox/source/drawingml/textbodyproperties.cxx new file mode 100644 index 000000000000..afd4766b0106 --- /dev/null +++ b/oox/source/drawingml/textbodyproperties.cxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * 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: textbodyproperties.cxx,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. + * + ************************************************************************/ + +#include "oox/drawingml/textbodyproperties.hxx" +#include <com/sun/star/text/WritingMode.hpp> +#include "properties.hxx" +#include "tokens.hxx" + +namespace oox { +namespace drawingml { + +// ============================================================================ + +TextBodyProperties::TextBodyProperties() +{ +} + +void TextBodyProperties::pushToPropMap( PropertyMap& rPropMap ) const +{ + rPropMap.insert( maPropertyMap.begin(), maPropertyMap.end() ); + + // #160799# fake different vertical text modes by top-bottom writing mode + if( moVert.get( XML_horz ) != XML_horz ) + rPropMap[ PROP_TextWritingMode ] <<= ::com::sun::star::text::WritingMode_TB_RL; +} + +// ============================================================================ + +} // namespace drawingml +} // namespace oox + diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx index 291af2687149..ec605a3adadd 100644 --- a/oox/source/drawingml/textbodypropertiescontext.cxx +++ b/oox/source/drawingml/textbodypropertiescontext.cxx @@ -28,6 +28,8 @@ #include "oox/drawingml/textbodypropertiescontext.hxx" #include <com/sun/star/text/ControlCharacter.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include "oox/drawingml/textbodyproperties.hxx" #include "oox/drawingml/drawingmltypes.hxx" #include "oox/helper/attributelist.hxx" @@ -38,6 +40,7 @@ using ::rtl::OUString; using namespace ::oox::core; +using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::text; using namespace ::com::sun::star::xml::sax; @@ -56,7 +59,7 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent, // ST_TextWrappingType sal_Int32 nWrappingType = aAttribs.getToken( XML_wrap, XML_square ); - mrTextBodyProp.maPropertyMap[ PROP_TextWordWrap ] <<= (nWrappingType == XML_square); + mrTextBodyProp.maPropertyMap[ PROP_TextWordWrap ] <<= static_cast< sal_Bool >( nWrappingType == XML_square ); // ST_Coordinate OUString sValue; @@ -78,7 +81,17 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent, // ST_TextAnchoringType -// sal_Int32 nAnchoringType = xAttributes->getOptionalValueToken( XML_anchor, XML_t ); + drawing::TextVerticalAdjust eVA( drawing::TextVerticalAdjust_TOP ); + switch( xAttributes->getOptionalValueToken( XML_anchor, XML_t ) ) + { + case XML_b : eVA = drawing::TextVerticalAdjust_BOTTOM; break; + case XML_dist : + case XML_just : + case XML_ctr : eVA = drawing::TextVerticalAdjust_CENTER; break; + default: + case XML_t : eVA = drawing::TextVerticalAdjust_TOP; break; + } + mrTextBodyProp.maPropertyMap[ PROP_TextVerticalAdjust ] <<= eVA; // bool bAnchorCenter = aAttribs.getBool( XML_anchorCtr, false ); diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx b/oox/source/drawingml/textcharacterpropertiescontext.cxx index 6797b8336c02..cfba04a7b44b 100644 --- a/oox/source/drawingml/textcharacterpropertiescontext.cxx +++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx @@ -56,13 +56,20 @@ TextCharacterPropertiesContext::TextCharacterPropertiesContext( , mrTextCharacterProperties( rTextCharacterProperties ) { AttributeList aAttribs( rXAttributes ); - mrTextCharacterProperties.moLang = aAttribs.getString( XML_lang ); - mrTextCharacterProperties.moHeight = aAttribs.getInteger( XML_sz ); - mrTextCharacterProperties.moUnderline = aAttribs.getToken( XML_u ); - mrTextCharacterProperties.moStrikeout = aAttribs.getToken( XML_strike ); -// mrTextCharacterProperties.moCaseMap = aAttribs.getToken( XML_cap ); - mrTextCharacterProperties.moBold = aAttribs.getBool( XML_b ); - mrTextCharacterProperties.moItalic = aAttribs.getBool( XML_i ); + if ( aAttribs.hasAttribute( XML_lang ) ) + mrTextCharacterProperties.moLang = aAttribs.getString( XML_lang ); + if ( aAttribs.hasAttribute( XML_sz ) ) + mrTextCharacterProperties.moHeight = aAttribs.getInteger( XML_sz ); + if ( aAttribs.hasAttribute( XML_u ) ) + mrTextCharacterProperties.moUnderline = aAttribs.getToken( XML_u ); + if ( aAttribs.hasAttribute( XML_strike ) ) + mrTextCharacterProperties.moStrikeout = aAttribs.getToken( XML_strike ); + +// mrTextCharacterProperties.moCaseMap = aAttribs.getToken( XML_cap ); + if ( aAttribs.hasAttribute( XML_b ) ) + mrTextCharacterProperties.moBold = aAttribs.getBool( XML_b ); + if ( aAttribs.hasAttribute( XML_i ) ) + mrTextCharacterProperties.moItalic = aAttribs.getBool( XML_i ); // TODO /* todo: we need to be able to iterate over the XFastAttributes diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx index 1ff78541243e..a4bef1a5013c 100644 --- a/oox/source/drawingml/textparagraph.cxx +++ b/oox/source/drawingml/textparagraph.cxx @@ -29,6 +29,7 @@ #include "oox/drawingml/drawingmltypes.hxx" #include <rtl/ustring.hxx> +#include "oox/helper/propertyset.hxx" #include <com/sun/star/text/XText.hpp> #include <com/sun/star/text/XTextCursor.hpp> #include <com/sun/star/text/ControlCharacter.hpp> @@ -78,11 +79,21 @@ void TextParagraph::insertAt( xText->insertControlCharacter( xStart, ControlCharacter::APPEND_PARAGRAPH, sal_False ); xAt->gotoEnd( sal_True ); } + if ( maRuns.begin() == maRuns.end() ) + { + PropertySet aPropSet( xStart ); - for( TextRunVector::const_iterator aIt = maRuns.begin(), aEnd = maRuns.end(); aIt != aEnd; ++aIt ) + TextCharacterProperties aTextCharacterProps( aTextCharacterStyle ); + aTextCharacterProps.assignUsed( maEndProperties ); + aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase ); + } + else { - (*aIt)->insertAt( rFilterBase, xText, xAt, aTextCharacterStyle ); - nParagraphSize += (*aIt)->getText().getLength(); + for( TextRunVector::const_iterator aIt = maRuns.begin(), aEnd = maRuns.end(); aIt != aEnd; ++aIt ) + { + (*aIt)->insertAt( rFilterBase, xText, xAt, aTextCharacterStyle ); + nParagraphSize += (*aIt)->getText().getLength(); + } } xAt->gotoEnd( sal_True ); @@ -94,7 +105,6 @@ void TextParagraph::insertAt( pTextParagraphStyle->pushToPropSet( rFilterBase, xProps, aioBulletList, NULL, sal_False, fCharacterSize ); fCharacterSize = pTextParagraphStyle->getCharHeightPoints( 18 ); } - maProperties.pushToPropSet( rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), sal_True, fCharacterSize ); // empty paragraphs do not have bullets in ppt diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index a49d41ef4759..5aeb56883d2d 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1339,15 +1339,10 @@ void DrawingML::WriteConnectorConnections( EscherConnectorListEntry& rConnectorE // from sw/source/filter/ww8/wrtw8num.cxx for default bullets to export to MS intact static void lcl_SubstituteBullet(String& rNumStr, rtl_TextEncoding& rChrSet, String& rFontName) { - StarSymbolToMSMultiFont *pConvert = 0; - FontFamily eFamily = FAMILY_DECORATIVE; - - if (!pConvert) - { - pConvert = CreateStarSymbolToMSMultiFont(); - } sal_Unicode cChar = rNumStr.GetChar(0); + StarSymbolToMSMultiFont *pConvert = CreateStarSymbolToMSMultiFont(); String sFont = pConvert->ConvertChar(cChar); + delete pConvert; if (sFont.Len()) { rNumStr = static_cast< sal_Unicode >(cChar | 0xF000); @@ -1363,7 +1358,6 @@ static void lcl_SubstituteBullet(String& rNumStr, rtl_TextEncoding& rChrSet, Str let words own font substitution kick in */ rChrSet = RTL_TEXTENCODING_UNICODE; - eFamily = FAMILY_SWISS; rFontName = ::GetFontToken(rFontName, 0); } else @@ -1376,7 +1370,6 @@ static void lcl_SubstituteBullet(String& rNumStr, rtl_TextEncoding& rChrSet, Str rFontName.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Wingdings")); rNumStr = static_cast< sal_Unicode >(0x6C); } - delete pConvert; } sal_Unicode DrawingML::SubstituteBullet( sal_Unicode cBulletId, ::com::sun::star::awt::FontDescriptor& rFontDesc ) diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 9f99bf625333..96baaab4bb36 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -208,6 +208,16 @@ enum ApiTransparencyMode // ---------------------------------------------------------------------------- +/** Specifies how a form control supports the DefaultState property. */ +enum ApiDefaultStateMode +{ + API_DEFAULTSTATE_BOOLEAN, /// Control does not support tri-state, state is given as boolean. + API_DEFAULTSTATE_SHORT, /// Control does not support tri-state, state is given as short. + API_DEFAULTSTATE_TRISTATE /// Control supports tri-state, state is given as short. +}; + +// ---------------------------------------------------------------------------- + /** Converts the AX background formatting to UNO properties. */ void lclConvertBackground( AxControlHelper& rHelper, PropertyMap& rPropMap, sal_uInt32 nBackColor, sal_uInt32 nFlags, ApiTransparencyMode eTranspMode ) { @@ -318,8 +328,11 @@ void lclConvertPicture( AxControlHelper& rHelper, PropertyMap& rPropMap, const S // ---------------------------------------------------------------------------- /** Converts the AX value for checked/unchecked/dontknow to UNO properties. */ -void lclConvertState( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, const OUString& rValue, sal_Int32 nMultiSelect, bool bSupportsTriState ) +void lclConvertState( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, const OUString& rValue, sal_Int32 nMultiSelect, ApiDefaultStateMode eDefStateMode ) { + bool bBooleanState = eDefStateMode == API_DEFAULTSTATE_BOOLEAN; + bool bSupportsTriState = eDefStateMode == API_DEFAULTSTATE_TRISTATE; + // state sal_Int16 nState = bSupportsTriState ? API_STATE_DONTKNOW : API_STATE_UNCHECKED; if( rValue.getLength() == 1 ) switch( rValue[ 0 ] ) @@ -328,7 +341,10 @@ void lclConvertState( AxControlHelper& /*rHelper*/, PropertyMap& rPropMap, const case '1': nState = API_STATE_CHECKED; break; // any other string (also empty) means 'dontknow' } - rPropMap.setProperty( PROP_DefaultState, nState ); + if( bBooleanState ) + rPropMap.setProperty( PROP_DefaultState, nState != API_STATE_UNCHECKED ); + else + rPropMap.setProperty( PROP_DefaultState, nState ); // tristate if( bSupportsTriState ) @@ -808,6 +824,7 @@ void AxToggleButtonModel::convertProperties( AxControlHelper& rHelper, PropertyM rPropMap.setProperty( PROP_Toggle, true ); lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_NOTSUPPORTED ); lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); + lclConvertState( rHelper, rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_BOOLEAN ); AxMorphDataModel::convertProperties( rHelper, rPropMap ); } @@ -831,7 +848,7 @@ void AxCheckBoxModel::convertProperties( AxControlHelper& rHelper, PropertyMap& lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); lclConvertVisualEffect( rHelper, rPropMap, mnSpecialEffect ); lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); - lclConvertState( rHelper, rPropMap, maValue, mnMultiSelect, true ); + lclConvertState( rHelper, rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_TRISTATE ); AxMorphDataModel::convertProperties( rHelper, rPropMap ); } @@ -855,7 +872,7 @@ void AxOptionButtonModel::convertProperties( AxControlHelper& rHelper, PropertyM lclConvertBackground( rHelper, rPropMap, mnBackColor, mnFlags, API_TRANSPARENCY_VOID ); lclConvertVisualEffect( rHelper, rPropMap, mnSpecialEffect ); lclConvertPicture( rHelper, rPropMap, maPictureData, mnPicturePos ); - lclConvertState( rHelper, rPropMap, maValue, mnMultiSelect, false ); + lclConvertState( rHelper, rPropMap, maValue, mnMultiSelect, API_DEFAULTSTATE_SHORT ); AxMorphDataModel::convertProperties( rHelper, rPropMap ); } diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 016857161696..7b8c1ca95d35 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -93,6 +93,12 @@ void PPTShape::addShape( aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle(); } break; + case XML_subTitle : + { + if ( ( meShapeLocation == Master ) || ( meShapeLocation == Layout ) ) + sServiceName = rtl::OUString(); + } + break; case XML_obj : { const rtl::OUString sOutlinerShapeService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.presentation.OutlinerShape" ) ); @@ -155,37 +161,42 @@ void PPTShape::addShape( break; } } - if ( !aMasterTextListStyle.get() ) - aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getOtherTextStyle() : rSlidePersist.getOtherTextStyle(); - setMasterTextListStyle( aMasterTextListStyle ); - Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, bClearText ) ); - if ( !rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() && ( (sal_Int32)mnSubType == XML_title ) ) + if ( sServiceName.getLength() ) { - try - { - rtl::OUString aTitleText; - Reference< XTextRange > xText( xShape, UNO_QUERY_THROW ); - aTitleText = xText->getString(); - if ( aTitleText.getLength() && ( aTitleText.getLength() < 64 ) ) // just a magic value, but we don't want to set slide names which are too long + if ( !aMasterTextListStyle.get() ) + aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getOtherTextStyle() : rSlidePersist.getOtherTextStyle(); + setMasterTextListStyle( aMasterTextListStyle ); + + Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, bClearText ) ); + if ( !rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() && ( (sal_Int32)mnSubType == XML_title ) ) + { + try + { + rtl::OUString aTitleText; + Reference< XTextRange > xText( xShape, UNO_QUERY_THROW ); + aTitleText = xText->getString(); + if ( aTitleText.getLength() && ( aTitleText.getLength() < 64 ) ) // just a magic value, but we don't want to set slide names which are too long + { + Reference< container::XNamed > xName( rSlidePersist.getPage(), UNO_QUERY_THROW ); + xName->setName( aTitleText ); + } + } + catch( uno::Exception& ) { - Reference< container::XNamed > xName( rSlidePersist.getPage(), UNO_QUERY_THROW ); - xName->setName( aTitleText ); + } } - catch( uno::Exception& ) + if( pShapeMap && msId.getLength() ) { + (*pShapeMap)[ msId ] = shared_from_this(); } - } - if( pShapeMap && msId.getLength() ) - { - (*pShapeMap)[ msId ] = shared_from_this(); - } - // if this is a group shape, we have to add also each child shape - Reference< XShapes > xShapes( xShape, UNO_QUERY ); - if ( xShapes.is() ) - addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap ); + // if this is a group shape, we have to add also each child shape + Reference< XShapes > xShapes( xShape, UNO_QUERY ); + if ( xShapes.is() ) + addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap ); + } } } catch( const Exception& ) diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx index 472f5292770e..8379a6e95735 100644 --- a/oox/source/ppt/pptshapecontext.cxx +++ b/oox/source/ppt/pptshapecontext.cxx @@ -63,7 +63,7 @@ PPTShapeContext::PPTShapeContext( ContextHandler& rParent, const SlidePersistPtr { } -oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes ) +oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, sal_Int32 nSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes ) { oox::drawingml::ShapePtr aShapePtr; std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); @@ -71,11 +71,14 @@ oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, st { if ( (*aRevIter)->getSubType() == nMasterPlaceholder ) { - aShapePtr = *aRevIter; - break; + if ( ( nSubTypeIndex == -1 ) || ( nSubTypeIndex == (*aRevIter)->getSubTypeIndex() ) ) + { + aShapePtr = *aRevIter; + break; + } } std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren(); - aShapePtr = findPlaceholder( nMasterPlaceholder, rChildren ); + aShapePtr = findPlaceholder( nMasterPlaceholder, nSubTypeIndex, rChildren ); if ( aShapePtr.get() ) break; aRevIter++; @@ -84,10 +87,11 @@ oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, st } // if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder -oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes ) +oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, + sal_Int32 nSubTypeIndex, std::vector< oox::drawingml::ShapePtr >& rShapes ) { - oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, rShapes ); - return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, rShapes ); + oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, nSubTypeIndex, rShapes ); + return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, nSubTypeIndex, rShapes ); } Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) @@ -107,7 +111,7 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In { sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); mpShapePtr->setSubType( nSubType ); - mpShapePtr->setIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); if ( nSubType ) { PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() ); @@ -131,7 +135,8 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In nSecondPlaceholder = XML_title; break; case XML_obj : // slide/layout - nFirstPlaceholder = XML_body; + nFirstPlaceholder = XML_obj; + nSecondPlaceholder = XML_body; break; case XML_dt : // slide/layout/master/notes/notesmaster/handoutmaster case XML_sldNum : // slide/layout/master/notes/notesmaster/handoutmaster @@ -154,12 +159,13 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In { oox::drawingml::ShapePtr pPlaceholder; if ( eShapeLocation == Layout ) // for layout objects the referenced object can be found within the same shape tree - pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, mpSlidePersistPtr->getShapes()->getChildren() ); + pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, -1, mpSlidePersistPtr->getShapes()->getChildren() ); else if ( eShapeLocation == Slide ) // normal slide shapes have to search within the corresponding master tree for referenced objects { SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); if ( pMasterPersist.get() ) - pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pMasterPersist->getShapes()->getChildren() ); + pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, + pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() ); } if ( pPlaceholder.get() ) { diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx index 4113b399e6eb..ef8dbeedcd6c 100644 --- a/oox/source/ppt/pptshapegroupcontext.cxx +++ b/oox/source/ppt/pptshapegroupcontext.cxx @@ -76,7 +76,7 @@ Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( s break; case NMSP_PPT|XML_ph: mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) ); - mpGroupShapePtr->setIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); break; // nvSpPr CT_ShapeNonVisual end diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index c91a1bd1fd79..d5b3b13c762a 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -67,9 +67,11 @@ SlidePersist::SlidePersist( XmlFilterBase& rFilter, sal_Bool bMaster, sal_Bool b { if ( pDefaultTextStyle ) { + /* maTitleTextStylePtr->apply( *pDefaultTextStyle.get() ); maBodyTextStylePtr->apply( *pDefaultTextStyle.get() ); maNotesTextStylePtr->apply( *pDefaultTextStyle.get() ); + */ maOtherTextStylePtr->apply( *pDefaultTextStyle.get() ); } } diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 0ecd40ee6595..4d20b8f1c255 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -369,6 +369,7 @@ TextOverlap TextRightDistance TextRotation TextUpperDistance +TextVerticalAdjust TextWordWrap TextWritingMode Toggle diff --git a/oox/source/token/tokenmap.cxx b/oox/source/token/tokenmap.cxx index 339ff5c40b44..b5ed8e9a9323 100644 --- a/oox/source/token/tokenmap.cxx +++ b/oox/source/token/tokenmap.cxx @@ -32,6 +32,8 @@ #include "tokens.hxx" #include "oox/helper/containerhelper.hxx" +#include <string.h> + using ::rtl::OString; using ::rtl::OUString; using ::com::sun::star::uno::Sequence; diff --git a/oox/source/xls/biffhelper.cxx b/oox/source/xls/biffhelper.cxx index f69cac731ee7..8ecea303183e 100644 --- a/oox/source/xls/biffhelper.cxx +++ b/oox/source/xls/biffhelper.cxx @@ -119,19 +119,27 @@ struct CodePageEntry_TEPred // ---------------------------------------------------------------------------- -bool lclCalcRkFromDouble( sal_Int32& ornRkValue, double fValue ) +union DecodedDouble +{ + double mfValue; + sal_math_Double maStruct; + + inline explicit DecodedDouble() {} + inline explicit DecodedDouble( double fValue ) : mfValue( fValue ) {} +}; + +bool lclCalcRkFromDouble( sal_Int32& ornRkValue, const DecodedDouble& rDecDbl ) { // double - const sal_math_Double* pValue = reinterpret_cast< const sal_math_Double* >( &fValue ); - if( (pValue->w32_parts.lsw == 0) && ((pValue->w32_parts.msw & 0x3) == 0) ) + if( (rDecDbl.maStruct.w32_parts.lsw == 0) && ((rDecDbl.maStruct.w32_parts.msw & 0x3) == 0) ) { - ornRkValue = static_cast< sal_Int32 >( pValue->w32_parts.msw ); + ornRkValue = static_cast< sal_Int32 >( rDecDbl.maStruct.w32_parts.msw ); return true; } // integer double fInt = 0.0; - double fFrac = modf( fValue, &fInt ); + double fFrac = modf( rDecDbl.mfValue, &fInt ); if( (fFrac == 0.0) && (-536870912.0 <= fInt) && (fInt <= 536870911.0) ) // 2^29 { ornRkValue = static_cast< sal_Int32 >( fInt ); @@ -143,6 +151,22 @@ bool lclCalcRkFromDouble( sal_Int32& ornRkValue, double fValue ) return false; } +bool lclCalcRkFromDouble( sal_Int32& ornRkValue, double fValue ) +{ + DecodedDouble aDecDbl( fValue ); + if( lclCalcRkFromDouble( ornRkValue, aDecDbl ) ) + return true; + + aDecDbl.mfValue *= 100.0; + if( lclCalcRkFromDouble( ornRkValue, aDecDbl ) ) + { + ornRkValue |= BIFF_RK_100FLAG; + return true; + } + + return false; +} + // ---------------------------------------------------------------------------- void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, sal_Int32 nBytes, BiffType eBiff ) @@ -229,23 +253,22 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, /*static*/ double BiffHelper::calcDoubleFromRk( sal_Int32 nRkValue ) { - double fValue = 0.0; + DecodedDouble aDecDbl( 0.0 ); if( getFlag( nRkValue, BIFF_RK_INTFLAG ) ) { sal_Int32 nTemp = nRkValue >> 2; setFlag< sal_Int32 >( nTemp, 0xE0000000, nRkValue < 0 ); - fValue = nTemp; + aDecDbl.mfValue = nTemp; } else { - sal_math_Double* pDouble = reinterpret_cast< sal_math_Double* >( &fValue ); - pDouble->w32_parts.msw = static_cast< sal_uInt32 >( nRkValue & BIFF_RK_VALUEMASK ); + aDecDbl.maStruct.w32_parts.msw = static_cast< sal_uInt32 >( nRkValue & BIFF_RK_VALUEMASK ); } if( getFlag( nRkValue, BIFF_RK_100FLAG ) ) - fValue /= 100.0; + aDecDbl.mfValue /= 100.0; - return fValue; + return aDecDbl.mfValue; } /*static*/ bool BiffHelper::calcRkFromDouble( sal_Int32& ornRkValue, double fValue ) @@ -276,10 +299,10 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, case BIFF_ERR_NA: nApiError = 0x7FFF; break; default: OSL_ENSURE( false, "BiffHelper::calcDoubleFromError - unknown error code" ); } - double fValue; - ::rtl::math::setNan( &fValue ); - reinterpret_cast< sal_math_Double* >( &fValue )->nan_parts.fraction_lo = nApiError; - return fValue; + DecodedDouble aDecDbl; + ::rtl::math::setNan( &aDecDbl.mfValue ); + aDecDbl.maStruct.nan_parts.fraction_lo = nApiError; + return aDecDbl.mfValue; } /*static*/ rtl_TextEncoding BiffHelper::calcTextEncodingFromCodePage( sal_uInt16 nCodePage ) @@ -309,15 +332,14 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, sal_uInt16 nFormat, nEnv; sal_Int32 nBytes; rStrm >> nFormat >> nEnv >> nBytes; - OSL_ENSURE( (nFormat == BIFF_IMGDATA_WMF) || (nFormat == BIFF_IMGDATA_DIB) || (nFormat == BIFF_IMGDATA_NATIVE), "BiffHelper::importImgData - unknown format" ); OSL_ENSURE( nBytes > 0, "BiffHelper::importImgData - invalid data size" ); if( (0 < nBytes) && (nBytes <= rStrm.getRemaining()) ) { switch( nFormat ) { - case BIFF_IMGDATA_WMF: /* TODO */ break; +// case BIFF_IMGDATA_WMF: /* TODO */ break; case BIFF_IMGDATA_DIB: lclImportImgDataDib( orDataSeq, rStrm, nBytes, eBiff ); break; - case BIFF_IMGDATA_NATIVE: /* TODO */ break; +// case BIFF_IMGDATA_NATIVE: /* TODO */ break; default: OSL_ENSURE( false, "BiffHelper::importImgData - unknown image format" ); } } diff --git a/oox/source/xls/formulabase.cxx b/oox/source/xls/formulabase.cxx index b9b9c3d57dcc..b2e5ba0ee931 100644 --- a/oox/source/xls/formulabase.cxx +++ b/oox/source/xls/formulabase.cxx @@ -229,12 +229,13 @@ const size_t FUNCINFO_PARAMINFOCOUNT = 5; /// Number of parameter const sal_uInt16 FUNCFLAG_VOLATILE = 0x0001; /// Result is volatile (e.g. NOW() function). const sal_uInt16 FUNCFLAG_IMPORTONLY = 0x0002; /// Only used in import filter. const sal_uInt16 FUNCFLAG_EXPORTONLY = 0x0004; /// Only used in export filter. -const sal_uInt16 FUNCFLAG_MACROCALL = 0x0008; /// Function is simulated by macro call in Excel. -const sal_uInt16 FUNCFLAG_EXTERNAL = 0x0010; /// Function is external in Calc. -const sal_uInt16 FUNCFLAG_MACROFUNC = 0x0020; /// Function is a macro-sheet function. -const sal_uInt16 FUNCFLAG_MACROCMD = 0x0040; /// Function is a macro-sheet command. -const sal_uInt16 FUNCFLAG_ALWAYSVAR = 0x0080; /// Function is always represented by a tFuncVar token. -const sal_uInt16 FUNCFLAG_PARAMPAIRS = 0x0100; /// Optional parameters are expected to appear in pairs. +const sal_uInt16 FUNCFLAG_MACROCALL = 0x0008; /// Function is stored as macro call in Excel (_xlfn. prefix). OOXML name MUST exist. +const sal_uInt16 FUNCFLAG_MACROCALLODF = 0x0010; /// ODF-only function stored as macro call in Excel (_xlfnodf. prefix). ODF name MUST exist. +const sal_uInt16 FUNCFLAG_EXTERNAL = 0x0020; /// Function is external in Calc. +const sal_uInt16 FUNCFLAG_MACROFUNC = 0x0040; /// Function is a macro-sheet function. +const sal_uInt16 FUNCFLAG_MACROCMD = 0x0080; /// Function is a macro-sheet command. +const sal_uInt16 FUNCFLAG_ALWAYSVAR = 0x0100; /// Function is always represented by a tFuncVar token. +const sal_uInt16 FUNCFLAG_PARAMPAIRS = 0x0200; /// Optional parameters are expected to appear in pairs. const sal_uInt16 FUNCFLAG_FUNCLIBMASK = 0xF000; /// Mask for function library bits. const sal_uInt16 FUNCFLAG_EUROTOOL = 0x1000; /// Function is part of the EuroTool add-in. @@ -346,7 +347,6 @@ static const FunctionData saFuncTableBiff2[] = { "TREND", "TREND", 50, 50, 1, 3, A, { RA, RA, RA, C }, 0 }, { "LOGEST", "LOGEST", 51, 51, 1, 2, A, { RA, RA, C, C }, 0 }, { "GROWTH", "GROWTH", 52, 52, 1, 3, A, { RA, RA, RA, C }, 0 }, - { 0, "RETURN", 55, 55, 0, 1, R, { RO }, FUNCFLAG_MACROFUNC }, { "PV", "PV", 56, 56, 3, 5, V, { VR }, 0 }, { "FV", "FV", 57, 57, 3, 5, V, { VR }, 0 }, { "NPER", "NPER", 58, 58, 3, 5, V, { VR }, 0 }, @@ -370,11 +370,9 @@ static const FunctionData saFuncTableBiff2[] = { "ROWS", "ROWS", 76, 76, 1, 1, V, { RO }, 0 }, { "COLUMNS", "COLUMNS", 77, 77, 1, 1, V, { RO }, 0 }, { "OFFSET", "OFFSET", 78, 78, 3, 5, R, { RO, VR }, FUNCFLAG_VOLATILE }, - { 0, "ABSREF", 79, 79, 2, 2, R, { VR, RO }, FUNCFLAG_MACROFUNC }, { "SEARCH", "SEARCH", 82, 82, 2, 3, V, { VR }, 0 }, { "TRANSPOSE", "TRANSPOSE", 83, 83, 1, 1, A, { VO }, 0 }, { "TYPE", "TYPE", 86, 86, 1, 1, V, { VX }, 0 }, - { 0, "ACTIVE.CELL", 94, 94, 0, 0, R, {}, FUNCFLAG_MACROFUNC }, { "ATAN2", "ATAN2", 97, 97, 2, 2, V, { VR }, 0 }, { "ASIN", "ASIN", 98, 98, 1, 1, V, { VR }, 0 }, { "ACOS", "ACOS", 99, 99, 1, 1, V, { VR }, 0 }, @@ -408,9 +406,6 @@ static const FunctionData saFuncTableBiff2[] = { "SYD", "SYD", 143, 143, 4, 4, V, { VR }, 0 }, { "DDB", "DDB", 144, 144, 4, 5, V, { VR }, 0 }, { "INDIRECT", "INDIRECT", 148, 148, 1, 2, R, { VR }, FUNCFLAG_VOLATILE }, - { 0, "ADD.BAR", 151, 151, 0, 0, V, {}, FUNCFLAG_MACROFUNC | FUNCFLAG_ALWAYSVAR }, - { 0, "ADD.MENU", 152, 152, 2, 2, V, { VR, RO }, FUNCFLAG_MACROFUNC | FUNCFLAG_ALWAYSVAR }, - { 0, "ADD.COMMAND", 153, 153, 3, 3, V, { VR, RO }, FUNCFLAG_MACROFUNC | FUNCFLAG_ALWAYSVAR }, { "CLEAN", "CLEAN", 162, 162, 1, 1, V, { VR }, 0 }, { "MDETERM", "MDETERM", 163, 163, 1, 1, V, { VA }, 0 }, { "MINVERSE", "MINVERSE", 164, 164, 1, 1, A, { VA }, 0 }, @@ -434,10 +429,16 @@ static const FunctionData saFuncTableBiff2[] = // *** macro sheet commands *** { 0, "A1.R1C1", 30, 30, 0, 1, V, { VR }, FUNCFLAG_MACROCMD }, + { 0, "RETURN", 55, 55, 0, 1, R, { RO }, FUNCFLAG_MACROFUNC }, + { 0, "ABSREF", 79, 79, 2, 2, R, { VR, RO }, FUNCFLAG_MACROFUNC }, { 0, "ADD.ARROW", 81, 81, 0, 0, V, {}, FUNCFLAG_MACROCMD }, + { 0, "ACTIVE.CELL", 94, 94, 0, 0, R, {}, FUNCFLAG_MACROFUNC }, { 0, "ACTIVATE", 103, 103, 0, 2, V, { VR }, FUNCFLAG_MACROCMD }, { 0, "ACTIVATE.NEXT", 104, 104, 0, 0, V, {}, FUNCFLAG_MACROCMD }, - { 0, "ACTIVATE.PREV", 105, 105, 0, 0, V, {}, FUNCFLAG_MACROCMD } + { 0, "ACTIVATE.PREV", 105, 105, 0, 0, V, {}, FUNCFLAG_MACROCMD }, + { 0, "ADD.BAR", 151, 151, 0, 0, V, {}, FUNCFLAG_MACROFUNC | FUNCFLAG_ALWAYSVAR }, + { 0, "ADD.MENU", 152, 152, 2, 2, V, { VR, RO }, FUNCFLAG_MACROFUNC | FUNCFLAG_ALWAYSVAR }, + { 0, "ADD.COMMAND", 153, 153, 3, 3, V, { VR, RO }, FUNCFLAG_MACROFUNC | FUNCFLAG_ALWAYSVAR } }; /** Functions new in BIFF3. */ @@ -447,9 +448,6 @@ static const FunctionData saFuncTableBiff3[] = { "TREND", "TREND", 50, 50, 1, 4, A, { RA, RA, RA, VV }, 0 }, // BIFF2: 1-3, BIFF3: 1-4 { "LOGEST", "LOGEST", 51, 51, 1, 4, A, { RA, RA, VV }, 0 }, // BIFF2: 1-2, BIFF3: 1-4 { "GROWTH", "GROWTH", 52, 52, 1, 4, A, { RA, RA, RA, VV }, 0 }, // BIFF2: 1-3, BIFF3: 1-4 - { 0, "ADD.BAR", 151, 151, 0, 1, V, { VR }, FUNCFLAG_MACROFUNC }, // BIFF2: 0, BIFF3: 0-1 - { 0, "ADD.MENU", 152, 152, 2, 3, V, { VR, RO }, FUNCFLAG_MACROFUNC }, // BIFF2: 2, BIFF3: 2-3 - { 0, "ADD.COMMAND", 153, 153, 3, 4, V, { VR, RO }, FUNCFLAG_MACROFUNC }, // BIFF2: 3, BIFF3: 3-4 { "TRUNC", "TRUNC", 197, 197, 1, 2, V, { VR }, 0 }, // BIFF2: 1, BIFF3: 1-2 { "DOLLAR", "USDOLLAR", 204, 204, 1, 2, V, { VR }, FUNCFLAG_IMPORTONLY }, { 0/*"FIND"*/, "FINDB", 205, 205, 2, 3, V, { VR }, 0 }, @@ -478,7 +476,13 @@ static const FunctionData saFuncTableBiff3[] = { "ATANH", "ATANH", 234, 234, 1, 1, V, { VR }, 0 }, { "ACOTH", "ATANH", 234, 234, 1, 1, V, { VR }, FUNCFLAG_EXPORTONLY }, { "DGET", "DGET", 235, 235, 3, 3, V, { RO, RR }, 0 }, - { "INFO", "INFO", 244, 244, 1, 1, V, { VR }, FUNCFLAG_VOLATILE } + { "INFO", "INFO", 244, 244, 1, 1, V, { VR }, FUNCFLAG_VOLATILE }, + + // *** macro sheet commands *** + + { 0, "ADD.BAR", 151, 151, 0, 1, V, { VR }, FUNCFLAG_MACROFUNC }, // BIFF2: 0, BIFF3: 0-1 + { 0, "ADD.MENU", 152, 152, 2, 3, V, { VR, RO }, FUNCFLAG_MACROFUNC }, // BIFF2: 2, BIFF3: 2-3 + { 0, "ADD.COMMAND", 153, 153, 3, 4, V, { VR, RO }, FUNCFLAG_MACROFUNC } // BIFF2: 3, BIFF3: 3-4 }; /** Functions new in BIFF4. */ @@ -662,8 +666,6 @@ static const FunctionData saFuncTableBiff5[] = { "WEEKDAY", "WEEKDAY", 70, 70, 1, 2, V, { VR }, 0 }, // BIFF2-4: 1, BIFF5: 1-2 { "HLOOKUP", "HLOOKUP", 101, 101, 3, 4, V, { VV, RO, RO, VV }, 0 }, // BIFF2-4: 3, BIFF5: 3-4 { "VLOOKUP", "VLOOKUP", 102, 102, 3, 4, V, { VV, RO, RO, VV }, 0 }, // BIFF2-4: 3, BIFF5: 3-4 - { 0, "ADD.MENU", 152, 152, 2, 4, V, { VR, RO, RO, VR }, FUNCFLAG_MACROFUNC }, // BIFF3-4: 2-3, BIFF5: 2-4 - { 0, "ADD.COMMAND", 153, 153, 3, 5, V, { VR, RO, RO, RO, VR }, FUNCFLAG_MACROFUNC }, // BIFF3-4: 3-4, BIFF5: 3-5 { "DAYS360", "DAYS360", 220, 220, 2, 3, V, { VR }, 0 }, // BIFF3-4: 2, BIFF5: 2-3 { 0, "EXTERN.CALL", 255, 255, 1, MX, R, { RO_E, RO }, FUNCFLAG_EXPORTONLY }, // MACRO or EXTERNAL { "CONCATENATE", "CONCATENATE", 336, 336, 0, MX, V, { VR }, 0 }, @@ -686,6 +688,8 @@ static const FunctionData saFuncTableBiff5[] = // *** macro sheet commands *** + { 0, "ADD.MENU", 152, 152, 2, 4, V, { VR, RO, RO, VR }, FUNCFLAG_MACROFUNC }, // BIFF3-4: 2-3, BIFF5: 2-4 + { 0, "ADD.COMMAND", 153, 153, 3, 5, V, { VR, RO, RO, RO, VR }, FUNCFLAG_MACROFUNC }, // BIFF3-4: 3-4, BIFF5: 3-5 { 0, "ADD.CHART.AUTOFORMAT", 390, 390, 0, 2, V, { VR }, FUNCFLAG_MACROCMD }, { 0, "ADD.LIST.ITEM", 451, 451, 0, 2, V, { VR }, FUNCFLAG_MACROCMD }, { 0, "ACTIVE.CELL.FONT", 476, 476, 0, 14, V, { VR }, FUNCFLAG_MACROCMD } @@ -738,41 +742,39 @@ static const FunctionData saFuncTableOox[] = /** Functions defined by OpenFormula, but not supported by Calc or by Excel. */ static const FunctionData saFuncTableOdf[] = { - { "ARABIC", 0, NOID, NOID, 1, 1, V, { VR }, 0 }, - { "B", 0, NOID, NOID, 3, 4, V, { VR }, 0 }, - { "BASE", 0, NOID, NOID, 2, 3, V, { VR }, 0 }, - { "BITAND", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "BITLSHIFT", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "BITOR", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "BITRSHIFT", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "BITXOR", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "CHISQDIST", 0, NOID, NOID, 2, 3, V, { VR }, 0 }, - { "CHISQINV", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "COMBINA", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "DAYS", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "DDE", 0, NOID, NOID, 3, 4, V, { VR }, 0 }, - { "DECIMAL", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "FDIST", 0, NOID, NOID, 3, 4, V, { VR }, 0 }, - { "FINV", 0, NOID, NOID, 3, 3, V, { VR }, 0 }, - { "FORMULA", 0, NOID, NOID, 1, 1, V, { RO }, 0 }, - { "GAMMA", 0, NOID, NOID, 1, 1, V, { VR }, 0 }, - { "GAUSS", 0, NOID, NOID, 1, 1, V, { VR }, 0 }, - { "IFNA", 0, NOID, NOID, 2, 2, V, { VR, RO }, 0 }, - { "ISFORMULA", 0, NOID, NOID, 1, 1, V, { RO }, 0 }, - { "ISOWEEKNUM", 0, NOID, NOID, 1, 2, V, { VR }, 0 }, - { "MULTIPLE.OPERATIONS", 0, NOID, NOID, 3, 5, V, { RO }, 0 }, - { "MUNIT", 0, NOID, NOID, 1, 1, A, { VR }, 0 }, - { "NUMBERVALUE", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "PDURATION", 0, NOID, NOID, 3, 3, V, { VR }, 0 }, - { "PERMUTATIONA", 0, NOID, NOID, 2, 2, V, { VR }, 0 }, - { "PHI", 0, NOID, NOID, 1, 1, V, { VR }, 0 }, - { "RRI", 0, NOID, NOID, 3, 3, V, { VR }, 0 }, - { "SHEET", 0, NOID, NOID, 1, 1, V, { RO }, 0 }, - { "SHEETS", 0, NOID, NOID, 0, 1, V, { RO }, 0 }, - { "SKEWP", 0, NOID, NOID, 1, MX, V, { RX }, 0 }, - { "UNICHAR", 0, NOID, NOID, 1, 1, V, { VR }, 0 }, - { "UNICODE", 0, NOID, NOID, 1, 1, V, { VR }, 0 }, - { "XOR", 0, NOID, NOID, 1, MX, V, { RX }, 0 } + { "ARABIC", 0, NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "B", 0, NOID, NOID, 3, 4, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "BASE", 0, NOID, NOID, 2, 3, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "BITAND", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "BITLSHIFT", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "BITOR", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "BITRSHIFT", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "BITXOR", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "CHISQDIST", 0, NOID, NOID, 2, 3, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "CHISQINV", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "COMBINA", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "DAYS", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "DECIMAL", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "FDIST", 0, NOID, NOID, 3, 4, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "FINV", 0, NOID, NOID, 3, 3, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "FORMULA", 0, NOID, NOID, 1, 1, V, { RO }, FUNCFLAG_MACROCALLODF }, + { "GAMMA", 0, NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "GAUSS", 0, NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "IFNA", 0, NOID, NOID, 2, 2, V, { VR, RO }, FUNCFLAG_MACROCALLODF }, + { "ISFORMULA", 0, NOID, NOID, 1, 1, V, { RO }, FUNCFLAG_MACROCALLODF }, + { "ISOWEEKNUM", 0, NOID, NOID, 1, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "MUNIT", 0, NOID, NOID, 1, 1, A, { VR }, FUNCFLAG_MACROCALLODF }, + { "NUMBERVALUE", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "PDURATION", 0, NOID, NOID, 3, 3, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "PERMUTATIONA", 0, NOID, NOID, 2, 2, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "PHI", 0, NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "RRI", 0, NOID, NOID, 3, 3, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "SHEET", 0, NOID, NOID, 1, 1, V, { RO }, FUNCFLAG_MACROCALLODF }, + { "SHEETS", 0, NOID, NOID, 0, 1, V, { RO }, FUNCFLAG_MACROCALLODF }, + { "SKEWP", 0, NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALLODF }, + { "UNICHAR", 0, NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "UNICODE", 0, NOID, NOID, 1, 1, V, { VR }, FUNCFLAG_MACROCALLODF }, + { "XOR", 0, NOID, NOID, 1, MX, V, { RX }, FUNCFLAG_MACROCALLODF } }; // ---------------------------------------------------------------------------- @@ -895,6 +897,7 @@ FunctionProviderImpl::FunctionProviderImpl( FilterType eFilter, BiffType eBiff, initFuncs( saFuncTableBiff8, STATIC_ARRAY_END( saFuncTableBiff8 ), nMaxParam, bImportFilter ); if( eFilter == FILTER_OOX ) initFuncs( saFuncTableOox, STATIC_ARRAY_END( saFuncTableOox ), nMaxParam, bImportFilter ); + initFuncs( saFuncTableOdf, STATIC_ARRAY_END( saFuncTableOdf ), nMaxParam, bImportFilter ); } void FunctionProviderImpl::initFunc( const FunctionData& rFuncData, sal_uInt8 nMaxParam ) @@ -905,13 +908,25 @@ void FunctionProviderImpl::initFunc( const FunctionData& rFuncData, sal_uInt8 nM xFuncInfo->maOdfFuncName = OUString::createFromAscii( rFuncData.mpcOdfFuncName ); if( rFuncData.mpcOoxFuncName ) xFuncInfo->maOoxFuncName = OUString::createFromAscii( rFuncData.mpcOoxFuncName ); + if( getFlag( rFuncData.mnFlags, FUNCFLAG_MACROCALL ) ) + { + OSL_ENSURE( xFuncInfo->maOoxFuncName.getLength() > 0, "FunctionProviderImpl::initFunc - missing OOXML function name" ); + OSL_ENSURE( !getFlag( rFuncData.mnFlags, FUNCFLAG_MACROCALLODF ), "FunctionProviderImpl::initFunc - unexpected flag FUNCFLAG_MACROCALLODF" ); xFuncInfo->maBiffMacroName = CREATE_OUSTRING( "_xlfn." ) + xFuncInfo->maOoxFuncName; + } + else if( getFlag( rFuncData.mnFlags, FUNCFLAG_MACROCALLODF ) ) + { + OSL_ENSURE( xFuncInfo->maOdfFuncName.getLength() > 0, "FunctionProviderImpl::initFunc - missing ODF function name" ); + xFuncInfo->maBiffMacroName = CREATE_OUSTRING( "_xlfnodf." ) + xFuncInfo->maOdfFuncName; + } + switch( rFuncData.mnFlags & FUNCFLAG_FUNCLIBMASK ) { case FUNCFLAG_EUROTOOL: xFuncInfo->meFuncLibType = FUNCLIB_EUROTOOL; break; default: xFuncInfo->meFuncLibType = FUNCLIB_UNKNOWN; } + xFuncInfo->mnApiOpCode = -1; xFuncInfo->mnOobFuncId = rFuncData.mnOobFuncId; xFuncInfo->mnBiffFuncId = rFuncData.mnBiffFuncId; diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx index 3eac90040667..cd914ceae196 100644 --- a/oox/source/xls/stylesbuffer.cxx +++ b/oox/source/xls/stylesbuffer.cxx @@ -69,6 +69,7 @@ using ::com::sun::star::awt::FontDescriptor; using ::com::sun::star::awt::XDevice; using ::com::sun::star::awt::XFont2; using ::com::sun::star::table::BorderLine; +using ::com::sun::star::table::TableBorder; using ::com::sun::star::text::XText; using ::com::sun::star::style::XStyle; using ::oox::core::FilterBase; @@ -1398,7 +1399,6 @@ void Alignment::writeToPropertyMap( PropertyMap& rPropMap ) const rPropMap[ PROP_VertJustify ] <<= maApiData.meVerJustify; rPropMap[ PROP_WritingMode ] <<= maApiData.mnWritingMode; rPropMap[ PROP_RotateAngle ] <<= maApiData.mnRotation; - rPropMap[ PROP_RotateReference ] <<= ::com::sun::star::table::CellVertJustify_STANDARD; // rotation reference rPropMap[ PROP_Orientation ] <<= maApiData.meOrientation; rPropMap[ PROP_ParaIndent ] <<= maApiData.mnIndent; rPropMap[ PROP_IsTextWrapped ] <<= maApiData.mbWrapText; @@ -1517,6 +1517,57 @@ ApiBorderData::ApiBorderData() : { } +bool ApiBorderData::hasAnyOuterBorder() const +{ + return + (maBorder.IsTopLineValid && (maBorder.TopLine.OuterLineWidth > 0)) || + (maBorder.IsBottomLineValid && (maBorder.BottomLine.OuterLineWidth > 0)) || + (maBorder.IsLeftLineValid && (maBorder.LeftLine.OuterLineWidth > 0)) || + (maBorder.IsRightLineValid && (maBorder.RightLine.OuterLineWidth > 0)); +} + +namespace { + +bool operator==( const BorderLine& rLeft, const BorderLine& rRight ) +{ + return + (rLeft.Color == rRight.Color) && + (rLeft.InnerLineWidth == rRight.InnerLineWidth) && + (rLeft.OuterLineWidth == rRight.OuterLineWidth) && + (rLeft.LineDistance == rRight.LineDistance); +} + +bool operator==( const TableBorder& rLeft, const TableBorder& rRight ) +{ + return + (rLeft.TopLine == rRight.TopLine) && + (rLeft.IsTopLineValid == rRight.IsTopLineValid) && + (rLeft.BottomLine == rRight.BottomLine) && + (rLeft.IsBottomLineValid == rRight.IsBottomLineValid) && + (rLeft.LeftLine == rRight.LeftLine) && + (rLeft.IsLeftLineValid == rRight.IsLeftLineValid) && + (rLeft.RightLine == rRight.RightLine) && + (rLeft.IsRightLineValid == rRight.IsRightLineValid) && + (rLeft.HorizontalLine == rRight.HorizontalLine) && + (rLeft.IsHorizontalLineValid == rRight.IsHorizontalLineValid) && + (rLeft.VerticalLine == rRight.VerticalLine) && + (rLeft.IsVerticalLineValid == rRight.IsVerticalLineValid) && + (rLeft.Distance == rRight.Distance) && + (rLeft.IsDistanceValid == rRight.IsDistanceValid); +} + +} // namespace + +bool operator==( const ApiBorderData& rLeft, const ApiBorderData& rRight ) +{ + return + (rLeft.maBorder == rRight.maBorder) && + (rLeft.maTLtoBR == rRight.maTLtoBR) && + (rLeft.maBLtoTR == rRight.maBLtoTR) && + (rLeft.mbBorderUsed == rRight.mbBorderUsed) && + (rLeft.mbDiagUsed == rRight.mbDiagUsed); +} + // ============================================================================ namespace { @@ -1820,6 +1871,14 @@ ApiSolidFillData::ApiSolidFillData() : { } +bool operator==( const ApiSolidFillData& rLeft, const ApiSolidFillData& rRight ) +{ + return + (rLeft.mnColor == rRight.mnColor) && + (rLeft.mbTransparent == rRight.mbTransparent) && + (rLeft.mbUsed == rRight.mbUsed); +} + // ============================================================================ namespace { @@ -2132,7 +2191,8 @@ XfModel::XfModel() : Xf::Xf( const WorkbookHelper& rHelper ) : WorkbookHelper( rHelper ), maAlignment( rHelper ), - maProtection( rHelper ) + maProtection( rHelper ), + meRotationRef( ::com::sun::star::table::CellVertJustify_STANDARD ) { } @@ -2315,13 +2375,46 @@ void Xf::importXf( BiffInputStream& rStrm ) void Xf::finalizeImport() { + StylesBuffer& rStyles = getStyles(); + // alignment and protection maAlignment.finalizeImport(); maProtection.finalizeImport(); - // update used flags from cell style - if( maModel.mbCellXf ) - if( const Xf* pStyleXf = getStyles().getStyleXf( maModel.mnStyleXfId ).get() ) - updateUsedFlags( *pStyleXf ); + + /* Enables the used flags, if the formatting attributes differ from the + style XF. In cell XFs Excel uses the cell attributes, if they differ + from the parent style XF (even if the used flag is switched off). + #109899# ...or if the respective flag is not set in parent style XF. + */ + const Xf* pStyleXf = isCellXf() ? rStyles.getStyleXf( maModel.mnStyleXfId ).get() : 0; + if( pStyleXf ) + { + const XfModel& rStyleData = pStyleXf->maModel; + if( !maModel.mbFontUsed ) + maModel.mbFontUsed = !rStyleData.mbFontUsed || (maModel.mnFontId != rStyleData.mnFontId); + if( !maModel.mbNumFmtUsed ) + maModel.mbNumFmtUsed = !rStyleData.mbNumFmtUsed || (maModel.mnNumFmtId != rStyleData.mnNumFmtId); + if( !maModel.mbAlignUsed ) + maModel.mbAlignUsed = !rStyleData.mbAlignUsed || !(maAlignment.getApiData() == pStyleXf->maAlignment.getApiData()); + if( !maModel.mbProtUsed ) + maModel.mbProtUsed = !rStyleData.mbProtUsed || !(maProtection.getApiData() == pStyleXf->maProtection.getApiData()); + if( !maModel.mbBorderUsed ) + maModel.mbBorderUsed = !rStyleData.mbBorderUsed || !rStyles.equalBorders( maModel.mnBorderId, rStyleData.mnBorderId ); + if( !maModel.mbAreaUsed ) + maModel.mbAreaUsed = !rStyleData.mbAreaUsed || !rStyles.equalFills( maModel.mnFillId, rStyleData.mnFillId ); + } + + /* #i38709# Decide which rotation reference mode to use. If any outer + border line of the cell is set (either explicitly or via cell style), + and the cell contents are rotated, set rotation reference to bottom of + cell. This causes the borders to be painted rotated with the text. */ + if( const Alignment* pAlignment = maModel.mbAlignUsed ? &maAlignment : (pStyleXf ? &pStyleXf->maAlignment : 0) ) + { + sal_Int32 nBorderId = maModel.mbBorderUsed ? maModel.mnBorderId : (pStyleXf ? pStyleXf->maModel.mnBorderId : -1); + if( const Border* pBorder = rStyles.getBorder( nBorderId ).get() ) + if( (pAlignment->getApiData().mnRotation != 0) && pBorder->getApiData().hasAnyOuterBorder() ) + meRotationRef = ::com::sun::star::table::CellVertJustify_BOTTOM; + } } FontRef Xf::getFont() const @@ -2341,7 +2434,7 @@ void Xf::writeToPropertyMap( PropertyMap& rPropMap ) const StylesBuffer& rStyles = getStyles(); // create and set cell style - if( maModel.mbCellXf ) + if( isCellXf() ) rPropMap[ PROP_CellStyle ] <<= rStyles.createCellStyle( maModel.mnStyleXfId ); if( maModel.mbFontUsed ) @@ -2356,6 +2449,8 @@ void Xf::writeToPropertyMap( PropertyMap& rPropMap ) const rStyles.writeBorderToPropertyMap( rPropMap, maModel.mnBorderId ); if( maModel.mbAreaUsed ) rStyles.writeFillToPropertyMap( rPropMap, maModel.mnFillId ); + if( maModel.mbAlignUsed || maModel.mbBorderUsed ) + rPropMap[ PROP_RotateReference ] <<= meRotationRef; } void Xf::writeToPropertySet( PropertySet& rPropSet ) const @@ -2371,37 +2466,15 @@ void Xf::setBiffUsedFlags( sal_uInt8 nUsedFlags ) - In cell XFs a *set* bit means a used attribute. - In style XFs a *cleared* bit means a used attribute. The boolean flags always store true, if the attribute is used. - The "maModel.mbCellXf == getFlag(...)" construct evaluates to true in - both mentioned cases: cell XF and set bit; or style XF and cleared bit. - */ - maModel.mbFontUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF_XF_FONT_USED ); - maModel.mbNumFmtUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF_XF_NUMFMT_USED ); - maModel.mbAlignUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF_XF_ALIGN_USED ); - maModel.mbProtUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF_XF_PROT_USED ); - maModel.mbBorderUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF_XF_BORDER_USED ); - maModel.mbAreaUsed = maModel.mbCellXf == getFlag( nUsedFlags, BIFF_XF_AREA_USED ); -} - -void Xf::updateUsedFlags( const Xf& rStyleXf ) -{ - /* Enables the used flags, if the formatting attributes differ from the - passed style XF. In cell XFs Excel uses the cell attributes, if they - differ from the parent style XF. - #109899# ...or if the respective flag is not set in parent style XF. + The "isCellXf() == getFlag(...)" construct evaluates to true in both + mentioned cases: cell XF and set bit; or style XF and cleared bit. */ - const XfModel& rStyleData = rStyleXf.maModel; - if( !maModel.mbFontUsed ) - maModel.mbFontUsed = !rStyleData.mbFontUsed || (maModel.mnFontId != rStyleData.mnFontId); - if( !maModel.mbNumFmtUsed ) - maModel.mbNumFmtUsed = !rStyleData.mbNumFmtUsed || (maModel.mnNumFmtId != rStyleData.mnNumFmtId); - if( !maModel.mbAlignUsed ) - maModel.mbAlignUsed = !rStyleData.mbAlignUsed || !(maAlignment.getApiData() == rStyleXf.maAlignment.getApiData()); - if( !maModel.mbProtUsed ) - maModel.mbProtUsed = !rStyleData.mbProtUsed || !(maProtection.getApiData() == rStyleXf.maProtection.getApiData()); - if( !maModel.mbBorderUsed ) - maModel.mbBorderUsed = !rStyleData.mbBorderUsed || (maModel.mnBorderId != rStyleData.mnBorderId); - if( !maModel.mbAreaUsed ) - maModel.mbAreaUsed = !rStyleData.mbAreaUsed || (maModel.mnFillId != rStyleData.mnFillId); + maModel.mbFontUsed = isCellXf() == getFlag( nUsedFlags, BIFF_XF_FONT_USED ); + maModel.mbNumFmtUsed = isCellXf() == getFlag( nUsedFlags, BIFF_XF_NUMFMT_USED ); + maModel.mbAlignUsed = isCellXf() == getFlag( nUsedFlags, BIFF_XF_ALIGN_USED ); + maModel.mbProtUsed = isCellXf() == getFlag( nUsedFlags, BIFF_XF_PROT_USED ); + maModel.mbBorderUsed = isCellXf() == getFlag( nUsedFlags, BIFF_XF_BORDER_USED ); + maModel.mbAreaUsed = isCellXf() == getFlag( nUsedFlags, BIFF_XF_AREA_USED ); } // ============================================================================ @@ -3133,11 +3206,12 @@ void StylesBuffer::importFormat( BiffInputStream& rStrm ) void StylesBuffer::importXf( BiffInputStream& rStrm ) { XfRef xXf( new Xf( *this ) ); - // store XF in both lists (except BIFF2 which does not support cell styles) - maCellXfs.push_back( xXf ); - if( getBiff() != BIFF2 ) - maStyleXfs.push_back( xXf ); xXf->importXf( rStrm ); + + XfRef xCellXf, xStyleXf; + (xXf->isCellXf() ? xCellXf : xStyleXf) = xXf; + maCellXfs.push_back( xCellXf ); + maStyleXfs.push_back( xStyleXf ); } void StylesBuffer::importStyle( BiffInputStream& rStrm ) @@ -3156,20 +3230,11 @@ void StylesBuffer::finalizeImport() // borders and fills maBorders.forEachMem( &Border::finalizeImport ); maFills.forEachMem( &Fill::finalizeImport ); - - /* Style XFs and cell XFs. The BIFF format stores cell XFs and style XFs - mixed in a single list. The import filter has stored the XFs in both - lists to make the getStyleXf() function working correctly (e.g. for - retrieving the default font, see getDefaultFont() function), except for - BIFF2 which does not support cell styles at all. Therefore, if in BIFF - filter mode, we do not need to finalize the cell styles list. */ - if( getFilterType() == FILTER_OOX ) - maStyleXfs.forEachMem( &Xf::finalizeImport ); + // style XFs and cell XFs + maStyleXfs.forEachMem( &Xf::finalizeImport ); maCellXfs.forEachMem( &Xf::finalizeImport ); - // built-in and user defined cell styles maCellStyles.finalizeImport(); - // differential formatting (for conditional formatting) maDxfs.forEachMem( &Dxf::finalizeImport ); } @@ -3184,6 +3249,11 @@ FontRef StylesBuffer::getFont( sal_Int32 nFontId ) const return maFonts.get( nFontId ); } +BorderRef StylesBuffer::getBorder( sal_Int32 nBorderId ) const +{ + return maBorders.get( nBorderId ); +} + XfRef StylesBuffer::getCellXf( sal_Int32 nXfId ) const { return maCellXfs.get( nXfId ); @@ -3225,6 +3295,56 @@ const FontModel& StylesBuffer::getDefaultFontModel() const return xDefFont.get() ? xDefFont->getModel() : getTheme().getDefaultFontModel(); } +bool StylesBuffer::equalBorders( sal_Int32 nBorderId1, sal_Int32 nBorderId2 ) const +{ + if( nBorderId1 == nBorderId2 ) + return true; + + switch( getFilterType() ) + { + case FILTER_OOX: + // in OOXML, borders are assumed to be unique + return false; + + case FILTER_BIFF: + { + // in BIFF, a new border entry has been created for every XF + const Border* pBorder1 = maBorders.get( nBorderId1 ).get(); + const Border* pBorder2 = maBorders.get( nBorderId2 ).get(); + return pBorder1 && pBorder2 && (pBorder1->getApiData() == pBorder2->getApiData()); + } + + case FILTER_UNKNOWN: + break; + } + return false; +} + +bool StylesBuffer::equalFills( sal_Int32 nFillId1, sal_Int32 nFillId2 ) const +{ + if( nFillId1 == nFillId2 ) + return true; + + switch( getFilterType() ) + { + case FILTER_OOX: + // in OOXML, fills are assumed to be unique + return false; + + case FILTER_BIFF: + { + // in BIFF, a new fill entry has been created for every XF + const Fill* pFill1 = maFills.get( nFillId1 ).get(); + const Fill* pFill2 = maFills.get( nFillId2 ).get(); + return pFill1 && pFill2 && (pFill1->getApiData() == pFill2->getApiData()); + } + + case FILTER_UNKNOWN: + break; + } + return false; +} + OUString StylesBuffer::getDefaultStyleName() const { return maCellStyles.getDefaultStyleName(); |