diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-06-19 20:09:46 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-06-19 20:09:46 +0200 |
commit | ae2ebf8fac893aeb2a328918ce1b12ef6834f16d (patch) | |
tree | d75f454c5866f8c605245814daadd7fafa1ec98d /oox/source | |
parent | 6e135ba19ae197fa6b1ca65034ad3dc8876a6be0 (diff) | |
parent | 7aedcad054e814a904e8378a75632b42a3295e92 (diff) |
Merge branch 'master' into feature/gnumake4
Conflicts:
filter/source/config/cache/filtercache.cxx
filter/source/odfflatxml/makefile.mk
oox/Library_oox.mk
oox/Makefile
oox/Module_oox.mk
oox/Package_generated.mk
oox/Package_inc.mk
oox/prj/build.lst
oox/prj/d.lst
oox/prj/makefile.mk
oox/source/dump/makefile.mk
unoxml/Library_unordf.mk
unoxml/Library_unoxml.mk
writerfilter/CppunitTest_writerfilter_doctok.mk
writerfilter/Library_writerfilter.mk
writerfilter/Module_writerfilter.mk
writerfilter/Package_inc.mk
writerfilter/inc/resourcemodel/TagLogger.hxx
writerfilter/inc/resourcemodel/WW8ResourceModel.hxx
writerfilter/prj/build.lst
writerfilter/prj/makefile.mk
writerfilter/qa/complex/ooxml/makefile.mk
writerfilter/qa/cppunittests/doctok/makefile.mk
writerfilter/qa/cppunittests/doctok/testdoctok.cxx
writerfilter/qa/cppunittests/xxml/testXXML.cxx
writerfilter/source/dmapper/DomainMapper.cxx
writerfilter/source/dmapper/DomainMapperTableHandler.cxx
writerfilter/source/dmapper/DomainMapperTableManager.cxx
writerfilter/source/dmapper/DomainMapper_Impl.cxx
writerfilter/source/dmapper/FontTable.cxx
writerfilter/source/dmapper/GraphicHelpers.cxx
writerfilter/source/dmapper/PropertyIds.cxx
writerfilter/source/dmapper/PropertyMap.cxx
writerfilter/source/dmapper/SettingsTable.cxx
writerfilter/source/dmapper/StyleSheetTable.cxx
writerfilter/source/dmapper/TablePropertiesHandler.cxx
writerfilter/source/dmapper/TblStylePrHandler.cxx
writerfilter/source/dmapper/ThemeTable.cxx
writerfilter/source/doctok/WW8DocumentImpl.cxx
writerfilter/source/doctok/resourcesimpl.xsl
writerfilter/source/filter/WriterFilter.cxx
writerfilter/source/generated.mk
writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
writerfilter/source/ooxml/OOXMLFactory.cxx
writerfilter/source/ooxml/OOXMLFactory.hxx
writerfilter/source/ooxml/OOXMLStreamImpl.cxx
writerfilter/source/ooxml/RefAndPointer.hxx
writerfilter/source/resourcemodel/TagLogger.cxx
writerfilter/unocomponent/component.cxx
writerfilter/unocomponent/debugservices/rtftok/ScannerTestService.cxx
writerfilter/unocomponent/debugservices/rtftok/XMLScanner.cxx
Diffstat (limited to 'oox/source')
279 files changed, 9776 insertions, 1183 deletions
diff --git a/oox/source/core/binarycodec.cxx b/oox/source/core/binarycodec.cxx index 3f406ba1af08..6ea81e1c4d72 100644 --- a/oox/source/core/binarycodec.cxx +++ b/oox/source/core/binarycodec.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -198,7 +199,7 @@ bool BinaryCodec_XOR::initCodec( const uno::Sequence< beans::NamedValue >& aData mnHash = (sal_uInt16)aHashData.getUnpackedValueOrDefault( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XOR95PasswordHash" ) ), (sal_Int16)0 ); } else - OSL_ENSURE( sal_False, "Unexpected key size!\n" ); + OSL_FAIL( "Unexpected key size!\n" ); return bResult; } @@ -306,10 +307,10 @@ bool BinaryCodec_RCF::initCodec( const uno::Sequence< beans::NamedValue >& aData bResult = sal_False; } else - OSL_ENSURE( sal_False, "Unexpected document ID!\n" ); + OSL_FAIL( "Unexpected document ID!\n" ); } else - OSL_ENSURE( sal_False, "Unexpected key size!\n" ); + OSL_FAIL( "Unexpected key size!\n" ); return bResult; } @@ -425,3 +426,5 @@ bool BinaryCodec_RCF::skip( sal_Int32 nBytes ) } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/binaryfilterbase.cxx b/oox/source/core/binaryfilterbase.cxx index edff8a788808..e28c6bce1551 100644 --- a/oox/source/core/binaryfilterbase.cxx +++ b/oox/source/core/binaryfilterbase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -67,3 +68,5 @@ StorageRef BinaryFilterBase::implCreateStorage( const Reference< XStream >& rxOu } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/contexthandler.cxx b/oox/source/core/contexthandler.cxx index 1ff793cd0c84..d781a811d520 100644 --- a/oox/source/core/contexthandler.cxx +++ b/oox/source/core/contexthandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -150,3 +151,5 @@ void ContextHandler::endRecord( sal_Int32 ) } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/contexthandler2.cxx b/oox/source/core/contexthandler2.cxx index 48f5718f9149..fc79afce76e2 100644 --- a/oox/source/core/contexthandler2.cxx +++ b/oox/source/core/contexthandler2.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -49,6 +50,7 @@ struct ElementInfo bool mbTrimSpaces; /// True = trims leading/trailing spaces from text data. inline explicit ElementInfo() : mnElement( XML_TOKEN_INVALID ), mbTrimSpaces( false ) {} + ElementInfo( sal_Int32 nElement ) : mnElement( nElement ), mbTrimSpaces(false) {} }; // ============================================================================ @@ -72,11 +74,20 @@ ContextHandler2Helper::~ContextHandler2Helper() { } -sal_Int32 ContextHandler2Helper::getCurrentElement() const +sal_Int32 ContextHandler2Helper::getCurrentElementWithMce() const { return mxContextStack->empty() ? XML_ROOT_CONTEXT : mxContextStack->back().mnElement; } +sal_Int32 ContextHandler2Helper::getCurrentElement() const +{ + for ( ContextStack::reverse_iterator It = mxContextStack->rbegin(); + It != mxContextStack->rend(); ++It ) + if( getNamespace( It->mnElement ) != NMSP_mce ) + return It->mnElement; + return XML_ROOT_CONTEXT; +} + sal_Int32 ContextHandler2Helper::getParentElement( sal_Int32 nCountBack ) const { if( (nCountBack < 0) || (mxContextStack->size() < static_cast< size_t >( nCountBack )) ) @@ -110,13 +121,13 @@ void ContextHandler2Helper::implCharacters( const OUString& rChars ) { // #i76091# collect characters until new element starts or this element ends if( !mxContextStack->empty() ) - mxContextStack->back().maChars.append( rChars ); + mxContextStack->back().maChars.append(rChars); } void ContextHandler2Helper::implEndElement( sal_Int32 nElement ) { (void)nElement; // prevent "unused parameter" warning in product build - OSL_ENSURE( getCurrentElement() == nElement, "ContextHandler2Helper::implEndElement - context stack broken" ); + OSL_ENSURE( getCurrentElementWithMce() == nElement, "ContextHandler2Helper::implEndElement - context stack broken" ); if( !mxContextStack->empty() ) { // #i76091# process collected characters (calls onCharacters() if needed) @@ -140,7 +151,7 @@ void ContextHandler2Helper::implStartRecord( sal_Int32 nRecId, SequenceInputStre void ContextHandler2Helper::implEndRecord( sal_Int32 nRecId ) { (void)nRecId; // prevent "unused parameter" warning in product build - OSL_ENSURE( getCurrentElement() == nRecId, "ContextHandler2Helper::implEndRecord - context stack broken" ); + OSL_ENSURE( getCurrentElementWithMce() == nRecId, "ContextHandler2Helper::implEndRecord - context stack broken" ); if( !mxContextStack->empty() ) { onEndRecord(); @@ -266,3 +277,5 @@ void ContextHandler2::onEndRecord() } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/fastparser.cxx b/oox/source/core/fastparser.cxx index eaf8c428b92c..947397a33228 100755..100644 --- a/oox/source/core/fastparser.cxx +++ b/oox/source/core/fastparser.cxx @@ -130,6 +130,21 @@ void FastParser::parseStream( StorageBase& rStorage, const OUString& rStreamName parseStream( rStorage.openInputStream( rStreamName ), rStreamName, bCloseStream ); } +OUString FastParser::getNamespaceURL( const OUString& rPrefix ) throw( IllegalArgumentException, RuntimeException ) +{ + if( !mxParser.is() ) + throw RuntimeException(); + return mxParser->getNamespaceURL( rPrefix ); +} + +sal_Int32 FastParser::getNamespaceId( const OUString& rUrl ) +{ + for( NamespaceMap::const_iterator aIt = mrNamespaceMap.begin(), aEnd = mrNamespaceMap.end(); aIt != aEnd; ++aIt ) + if( rUrl == aIt->second ) + return aIt->first; + return 0; +} + // ============================================================================ } // namespace core diff --git a/oox/source/core/fasttokenhandler.cxx b/oox/source/core/fasttokenhandler.cxx index e09687cc5470..7b2c6c687fad 100644 --- a/oox/source/core/fasttokenhandler.cxx +++ b/oox/source/core/fasttokenhandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -117,3 +118,5 @@ sal_Int32 FastTokenHandler::getTokenFromUTF8( const Sequence< sal_Int8 >& rIdent } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index b215150acb88..5c8ca79307ec 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,6 +29,7 @@ #include "oox/core/filterbase.hxx" #include <set> +#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/task/XStatusIndicator.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> @@ -56,6 +58,7 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::task; using namespace ::com::sun::star::uno; +using ::com::sun::star::container::XNameAccess; using ::comphelper::MediaDescriptor; using ::comphelper::SequenceAsHashMap; using ::oox::ole::OleObjectHelper; @@ -139,6 +142,7 @@ struct FilterBaseImpl MediaDescriptor maMediaDesc; OUString maFileUrl; StorageRef mxStorage; + OoxmlVersion meVersion; GraphicHelperRef mxGraphicHelper; /// Graphic and graphic object handling. ModelObjHelperRef mxModelObjHelper; /// Tables to create new named drawing objects. @@ -234,6 +238,11 @@ bool FilterBase::isExportFilter() const return mxImpl->meDirection == FILTERDIRECTION_EXPORT; } +OoxmlVersion FilterBase::getVersion() const +{ + return mxImpl->meVersion; +} + // ---------------------------------------------------------------------------- Any FilterBase::getArgument( const OUString& rArgName ) const @@ -552,7 +561,7 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc switch( mxImpl->meDirection ) { case FILTERDIRECTION_UNKNOWN: - OSL_ENSURE( false, "FilterBase::setMediaDescriptor - invalid filter direction" ); + OSL_FAIL( "FilterBase::setMediaDescriptor - invalid filter direction" ); break; case FILTERDIRECTION_IMPORT: mxImpl->maMediaDesc.addInputStream(); @@ -569,6 +578,25 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc mxImpl->mxTargetFrame = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_FRAME(), Reference< XFrame >() ); mxImpl->mxStatusIndicator = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STATUSINDICATOR(), Reference< XStatusIndicator >() ); mxImpl->mxInteractionHandler = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() ); + + // Check for ISO OOXML + OUString sFilterName = mxImpl->maMediaDesc.getUnpackedValueOrDefault( CREATE_OUSTRING( "FilterName" ), OUString() ); + try + { + Reference< XNameAccess > xFilters( getServiceFactory()->createInstance( + CREATE_OUSTRING( "com.sun.star.document.FilterFactory" ) ), UNO_QUERY_THROW ); + Any aValues = xFilters->getByName( sFilterName ); + Sequence<PropertyValue > aPropSeq; + aValues >>= aPropSeq; + SequenceAsHashMap aProps( aPropSeq ); + + sal_Int32 nVersion = aProps.getUnpackedValueOrDefault( CREATE_OUSTRING( "FileFormatVersion" ), sal_Int32( 0 ) ); + mxImpl->meVersion = OoxmlVersion( nVersion ); + } + catch ( Exception& ) + { + // Not ISO OOXML + } } GraphicHelper* FilterBase::implCreateGraphicHelper() const @@ -581,3 +609,5 @@ GraphicHelper* FilterBase::implCreateGraphicHelper() const } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index f836720a48a2..5c01b2e0f8f0 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -38,6 +39,7 @@ #include "oox/helper/binaryoutputstream.hxx" #include "oox/helper/zipstorage.hxx" #include "oox/ole/olestorage.hxx" +#include <com/sun/star/uri/UriReferenceFactory.hpp> namespace oox { namespace core { @@ -56,8 +58,8 @@ using ::rtl::OUString; // ============================================================================ -FilterDetectDocHandler::FilterDetectDocHandler( OUString& rFilterName ) : - mrFilterName( rFilterName ) +FilterDetectDocHandler::FilterDetectDocHandler( const Reference< XComponentContext >& rxContext, OUString& rFilterName ) : + mrFilterName( rFilterName ), mxContext( rxContext ) { maContextStack.reserve( 2 ); } @@ -161,37 +163,58 @@ void SAL_CALL FilterDetectDocHandler::processingInstruction( void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs ) { OUString aType = rAttribs.getString( XML_Type, OUString() ); - if( aType.equalsAscii( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" ) ) - maTargetPath = OUString( sal_Unicode( '/' ) ) + rAttribs.getString( XML_Target, OUString() ); + if( aType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" ) ) ) + { + Reference< com::sun::star::uri::XUriReferenceFactory > xFac = com::sun::star::uri::UriReferenceFactory::create( mxContext ); + try + { + // use '/' to representent the root of the zip package ( and provide a 'file' scheme to + // keep the XUriReference implementation happy ) + Reference< com::sun::star::uri::XUriReference > xBase = xFac->parse( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("file:///" ) ) ); + + Reference< com::sun::star::uri::XUriReference > xPart = xFac->parse( rAttribs.getString( XML_Target, OUString() ) ); + Reference< com::sun::star::uri::XUriReference > xAbs = xFac->makeAbsolute( xBase, xPart, sal_True, com::sun::star::uri::RelativeUriExcessParentSegments_RETAIN ); + + if ( xAbs.is() ) + maTargetPath = xAbs->getPath(); + } + catch( Exception& e) + { + } + } } OUString FilterDetectDocHandler::getFilterNameFromContentType( const OUString& rContentType ) const { - if( rContentType.equalsAscii( "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" ) || - rContentType.equalsAscii( "application/vnd.ms-word.document.macroEnabled.main+xml" ) ) + if( rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" ) ) || + rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.ms-word.document.macroEnabled.main+xml" ) ) ) return CREATE_OUSTRING( "writer_MS_Word_2007" ); - if( rContentType.equalsAscii( "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml" ) || - rContentType.equalsAscii( "application/vnd.ms-word.template.macroEnabledTemplate.main+xml" ) ) + if( rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml" ) ) || + rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.ms-word.template.macroEnabledTemplate.main+xml" ) ) ) return CREATE_OUSTRING( "writer_MS_Word_2007_Template" ); - if( rContentType.equalsAscii( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" ) || - rContentType.equalsAscii( "application/vnd.ms-excel.sheet.macroEnabled.main+xml" ) ) + if( rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" ) ) || + rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.ms-excel.sheet.macroEnabled.main+xml" ) ) ) return CREATE_OUSTRING( "MS Excel 2007 XML" ); - if( rContentType.equalsAscii( "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml" ) || - rContentType.equalsAscii( "application/vnd.ms-excel.template.macroEnabled.main+xml" ) ) + if( rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml" ) ) || + rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.ms-excel.template.macroEnabled.main+xml" ) ) ) return CREATE_OUSTRING( "MS Excel 2007 XML Template" ); - if( rContentType.equalsAscii( "application/vnd.ms-excel.sheet.binary.macroEnabled.main" ) ) + if( rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.ms-excel.sheet.binary.macroEnabled.main" ) ) ) return CREATE_OUSTRING( "MS Excel 2007 Binary" ); - if( rContentType.equalsAscii( "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" ) || - rContentType.equalsAscii( "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml" ) ) + if( rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" ) ) || + rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml" ) ) ) return CREATE_OUSTRING( "MS PowerPoint 2007 XML" ); - if( rContentType.equalsAscii( "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml" ) || - rContentType.equalsAscii( "application/vnd.ms-powerpoint.template.macroEnabled.main+xml" ) ) + if( rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml" ) ) || + rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml" ) ) ) + return CREATE_OUSTRING( "MS PowerPoint 2007 XML AutoPlay" ); + + if( rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml" ) ) || + rContentType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "application/vnd.ms-powerpoint.template.macroEnabled.main+xml" ) ) ) return CREATE_OUSTRING( "MS PowerPoint 2007 XML Template" ); return OUString(); @@ -326,9 +349,9 @@ void lclDeriveKey( const sal_uInt8* pnHash, sal_uInt32 nHashLen, sal_uInt8* pnKe pnBuffer[ i ] ^= pnHash[ i ]; rtlDigest aDigest = rtl_digest_create( rtl_Digest_AlgorithmSHA1 ); - rtlDigestError aError = rtl_digest_update( aDigest, pnBuffer, sizeof( pnBuffer ) ); + rtl_digest_update( aDigest, pnBuffer, sizeof( pnBuffer ) ); sal_uInt8 pnX1[ RTL_DIGEST_LENGTH_SHA1 ]; - aError = rtl_digest_get( aDigest, pnX1, RTL_DIGEST_LENGTH_SHA1 ); + rtl_digest_get( aDigest, pnX1, RTL_DIGEST_LENGTH_SHA1 ); rtl_digest_destroy( aDigest ); memset( pnBuffer, 0x5C, sizeof( pnBuffer ) ); @@ -336,9 +359,9 @@ void lclDeriveKey( const sal_uInt8* pnHash, sal_uInt32 nHashLen, sal_uInt8* pnKe pnBuffer[ i ] ^= pnHash[ i ]; aDigest = rtl_digest_create( rtl_Digest_AlgorithmSHA1 ); - aError = rtl_digest_update( aDigest, pnBuffer, sizeof( pnBuffer ) ); + rtl_digest_update( aDigest, pnBuffer, sizeof( pnBuffer ) ); sal_uInt8 pnX2[ RTL_DIGEST_LENGTH_SHA1 ]; - aError = rtl_digest_get( aDigest, pnX2, RTL_DIGEST_LENGTH_SHA1 ); + rtl_digest_get( aDigest, pnX2, RTL_DIGEST_LENGTH_SHA1 ); rtl_digest_destroy( aDigest ); if( nRequiredKeyLen > RTL_DIGEST_LENGTH_SHA1 ) @@ -380,9 +403,9 @@ bool lclCheckEncryptionData( const sal_uInt8* pnKey, sal_uInt32 nKeySize, const EVP_CIPHER_CTX_cleanup( &aes_ctx ); rtlDigest aDigest = rtl_digest_create( rtl_Digest_AlgorithmSHA1 ); - rtlDigestError aError = rtl_digest_update( aDigest, pnTmpVerifier, sizeof( pnTmpVerifier ) ); + rtl_digest_update( aDigest, pnTmpVerifier, sizeof( pnTmpVerifier ) ); sal_uInt8 pnSha1Hash[ RTL_DIGEST_LENGTH_SHA1 ]; - aError = rtl_digest_get( aDigest, pnSha1Hash, RTL_DIGEST_LENGTH_SHA1 ); + rtl_digest_get( aDigest, pnSha1Hash, RTL_DIGEST_LENGTH_SHA1 ); rtl_digest_destroy( aDigest ); bResult = ( memcmp( pnSha1Hash, pnTmpVerifierHash, RTL_DIGEST_LENGTH_SHA1 ) == 0 ); @@ -405,28 +428,28 @@ Sequence< NamedValue > lclGenerateEncryptionKey( const PackageEncryptionInfo& rE ByteOrderConverter::writeLittleEndian( pnPasswordLoc, static_cast< sal_uInt16 >( *pStr ) ); rtlDigest aDigest = rtl_digest_create( rtl_Digest_AlgorithmSHA1 ); - rtlDigestError aError = rtl_digest_update( aDigest, pnBuffer, nBufferSize ); + rtl_digest_update( aDigest, pnBuffer, nBufferSize ); delete[] pnBuffer; size_t nHashSize = RTL_DIGEST_LENGTH_SHA1 + 4; sal_uInt8* pnHash = new sal_uInt8[ nHashSize ]; - aError = rtl_digest_get( aDigest, pnHash + 4, RTL_DIGEST_LENGTH_SHA1 ); + rtl_digest_get( aDigest, pnHash + 4, RTL_DIGEST_LENGTH_SHA1 ); rtl_digest_destroy( aDigest ); for( sal_uInt32 i = 0; i < 50000; ++i ) { ByteOrderConverter::writeLittleEndian( pnHash, i ); aDigest = rtl_digest_create( rtl_Digest_AlgorithmSHA1 ); - aError = rtl_digest_update( aDigest, pnHash, nHashSize ); - aError = rtl_digest_get( aDigest, pnHash + 4, RTL_DIGEST_LENGTH_SHA1 ); + rtl_digest_update( aDigest, pnHash, nHashSize ); + rtl_digest_get( aDigest, pnHash + 4, RTL_DIGEST_LENGTH_SHA1 ); rtl_digest_destroy( aDigest ); } memmove( pnHash, pnHash + 4, RTL_DIGEST_LENGTH_SHA1 ); memset( pnHash + RTL_DIGEST_LENGTH_SHA1, 0, 4 ); aDigest = rtl_digest_create( rtl_Digest_AlgorithmSHA1 ); - aError = rtl_digest_update( aDigest, pnHash, nHashSize ); - aError = rtl_digest_get( aDigest, pnHash, RTL_DIGEST_LENGTH_SHA1 ); + rtl_digest_update( aDigest, pnHash, nHashSize ); + rtl_digest_get( aDigest, pnHash, RTL_DIGEST_LENGTH_SHA1 ); rtl_digest_destroy( aDigest ); lclDeriveKey( pnHash, RTL_DIGEST_LENGTH_SHA1, pnKey, nRequiredKeyLen ); @@ -526,7 +549,7 @@ Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescript BinaryXInputStream aInfoStrm( xEncryptionInfo, true ); bool bValidInfo = lclReadEncryptionInfo( aEncryptInfo, aInfoStrm ); - // check flags and agorithm IDs, requiered are AES128 and SHA-1 + // check flags and algorithm IDs, required are AES128 and SHA-1 bool bImplemented = bValidInfo && getFlag( aEncryptInfo.mnFlags, ENCRYPTINFO_CRYPTOAPI ) && getFlag( aEncryptInfo.mnFlags, ENCRYPTINFO_AES ) && @@ -654,7 +677,7 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& rMediaDescSeq aParser.registerNamespace( NMSP_packageRel ); aParser.registerNamespace( NMSP_officeRel ); aParser.registerNamespace( NMSP_packageContentTypes ); - aParser.setDocumentHandler( new FilterDetectDocHandler( aFilterName ) ); + aParser.setDocumentHandler( new FilterDetectDocHandler( mxContext, aFilterName ) ); /* Parse '_rels/.rels' to get the target path and '[Content_Types].xml' to determine the content type of the part at the target path. */ @@ -662,7 +685,7 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& rMediaDescSeq aParser.parseStream( aZipStorage, CREATE_OUSTRING( "[Content_Types].xml" ) ); } } - catch( Exception& ) + catch( Exception& e ) { } @@ -675,3 +698,5 @@ OUString SAL_CALL FilterDetect::detect( Sequence< PropertyValue >& rMediaDescSeq } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/fragmenthandler.cxx b/oox/source/core/fragmenthandler.cxx index 14abe0d537fc..9def856eb3b7 100644 --- a/oox/source/core/fragmenthandler.cxx +++ b/oox/source/core/fragmenthandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -139,3 +140,5 @@ const RecordInfo* FragmentHandler::getRecordInfos() const } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/fragmenthandler2.cxx b/oox/source/core/fragmenthandler2.cxx index 7771b89747b9..bc8974b73f1d 100644 --- a/oox/source/core/fragmenthandler2.cxx +++ b/oox/source/core/fragmenthandler2.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,6 +27,7 @@ ************************************************************************/ #include "oox/core/fragmenthandler2.hxx" +#include "oox/core/xmlfilterbase.hxx" namespace oox { namespace core { @@ -37,6 +39,9 @@ using namespace ::com::sun::star::xml::sax; using ::rtl::OUString; + +using ::com::sun::star::uno::Sequence; + // ============================================================================ FragmentHandler2::FragmentHandler2( XmlFilterBase& rFilter, const OUString& rFragmentPath, bool bEnableTrimSpace ) : @@ -61,11 +66,58 @@ void SAL_CALL FragmentHandler2::endDocument() throw( SAXException, RuntimeExcept finalizeImport(); } +bool FragmentHandler2::prepareMceContext( sal_Int32 nElement, const AttributeList& rAttribs ) +{ + switch( nElement ) + { + case MCE_TOKEN( AlternateContent ): + aMceState.push_back( MCE_STARTED ); + break; + + case MCE_TOKEN( Choice ): + { + OUString aRequires = rAttribs.getString( ( XML_Requires ), OUString(RTL_CONSTASCII_USTRINGPARAM("none")) ); + aRequires = getFilter().getNamespaceURL( aRequires ); + if( getFilter().getNamespaceId( aRequires ) > 0 && !aMceState.empty() && aMceState.back() == MCE_STARTED ) + aMceState.back() = MCE_FOUND_CHOICE; + else + return false; + } + break; + + case MCE_TOKEN( Fallback ): + if( !aMceState.empty() && aMceState.back() == MCE_STARTED ) + break; + return false; + default: + { + OUString str = rAttribs.getString( MCE_TOKEN( Ignorable ), OUString() ); + if( !str.isEmpty() ) + { + Sequence< ::com::sun::star::xml::FastAttribute > attrs = rAttribs.getFastAttributeList()->getFastAttributes(); + // printf("MCE: %s\n", ::rtl::OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() ); + // TODO: Check & Get the namespaces in "Ignorable" + // printf("NS: %d : %s\n", attrs.getLength(), ::rtl::OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() ); + } + } + return false; + } + return true; +} + + + // com.sun.star.xml.sax.XFastContextHandler interface ------------------------- Reference< XFastContextHandler > SAL_CALL FragmentHandler2::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs ) throw( SAXException, RuntimeException ) { + if( getNamespace( nElement ) == NMSP_mce ) // TODO for checking 'Ignorable' + { + if( prepareMceContext( nElement, AttributeList( rxAttribs ) ) ) + return getFastContextHandler(); + return NULL; + } return implCreateChildContext( nElement, rxAttribs ); } @@ -82,6 +134,14 @@ void SAL_CALL FragmentHandler2::characters( const OUString& rChars ) throw( SAXE void SAL_CALL FragmentHandler2::endFastElement( sal_Int32 nElement ) throw( SAXException, RuntimeException ) { + /* If MCE */ + switch( nElement ) + { + case MCE_TOKEN( AlternateContent ): + aMceState.pop_back(); + break; + } + implEndElement( nElement ); } @@ -148,3 +208,5 @@ void FragmentHandler2::finalizeImport() } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/recordparser.cxx b/oox/source/core/recordparser.cxx index aef73ceed86c..e1c060b4c3e5 100644 --- a/oox/source/core/recordparser.cxx +++ b/oox/source/core/recordparser.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -348,3 +349,5 @@ const RecordInfo* RecordParser::getEndRecordInfo( sal_Int32 nRecId ) const } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/relations.cxx b/oox/source/core/relations.cxx index f6cade391a0f..3030ef436883 100644 --- a/oox/source/core/relations.cxx +++ b/oox/source/core/relations.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -146,3 +147,5 @@ OUString Relations::getFragmentPathFromFirstType( const OUString& rType ) const } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/relationshandler.cxx b/oox/source/core/relationshandler.cxx index 6812a4acada6..021b73a53487 100644 --- a/oox/source/core/relationshandler.cxx +++ b/oox/source/core/relationshandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -108,3 +109,5 @@ Reference< XFastContextHandler > RelationsFragment::createFastChildContext( } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index a77789edbeb8..6638ffe5d4d9 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -45,6 +46,18 @@ #include "oox/helper/containerhelper.hxx" #include "oox/helper/propertyset.hxx" #include "oox/helper/zipstorage.hxx" +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/document/XOOXMLDocumentPropertiesImporter.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <comphelper/processfactory.hxx> +#include <comphelper/mediadescriptor.hxx> +#include <oox/core/filterdetect.hxx> +#include <comphelper/storagehelper.hxx> +using ::com::sun::star::uno::XComponentContext; +using ::com::sun::star::document::XOOXMLDocumentPropertiesImporter; +using ::com::sun::star::document::XDocumentPropertiesSupplier; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::lang::XComponent; namespace oox { namespace core { @@ -68,6 +81,10 @@ using ::rtl::OUStringBuffer; using ::sax_fastparser::FSHelperPtr; using ::sax_fastparser::FastSerializerHelper; + + + + // ============================================================================ namespace { @@ -124,10 +141,30 @@ XmlFilterBaseImpl::XmlFilterBaseImpl( const Reference< XComponentContext >& rxCo maFastParser.registerNamespace( NMSP_ax ); maFastParser.registerNamespace( NMSP_xm ); + maFastParser.registerNamespace( NMSP_mce ); + maFastParser.registerNamespace( NMSP_mceTest ); +} + + +static Reference< XComponentContext > lcl_getComponentContext(Reference< XMultiServiceFactory > aFactory) +{ + Reference< XComponentContext > xContext; + try + { + Reference< XPropertySet > xFactProp( aFactory, UNO_QUERY ); + if( xFactProp.is() ) + xFactProp->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext; + } + catch( Exception& ) + {} + + return xContext; } // ============================================================================ +// ============================================================================ + XmlFilterBase::XmlFilterBase( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) : FilterBase( rxContext ), mxImpl( new XmlFilterBaseImpl( rxContext ) ), @@ -142,6 +179,25 @@ XmlFilterBase::~XmlFilterBase() // ---------------------------------------------------------------------------- +void XmlFilterBase::importDocumentProperties() throw() +{ + Reference< XMultiServiceFactory > xFactory( getServiceFactory(), UNO_QUERY ); + MediaDescriptor aMediaDesc( getMediaDescriptor() ); + Reference< XInputStream > xInputStream; + Reference< XComponentContext > xContext = lcl_getComponentContext(getServiceFactory()); + ::oox::core::FilterDetect aDetector( xContext ); + xInputStream = aDetector.extractUnencryptedPackage( aMediaDesc ); + Reference< XComponent > xModel( getModel(), UNO_QUERY ); + Reference< XStorage > xDocumentStorage ( + ::comphelper::OStorageHelper::GetStorageOfFormatFromInputStream( OFOPXML_STORAGE_FORMAT_STRING, xInputStream ) ); + Reference< XInterface > xTemp = xContext->getServiceManager()->createInstanceWithContext( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.OOXMLDocumentPropertiesImporter")), + xContext); + Reference< XOOXMLDocumentPropertiesImporter > xImporter( xTemp, UNO_QUERY ); + Reference< XDocumentPropertiesSupplier > xPropSupplier( xModel, UNO_QUERY); + xImporter->importProperties( xDocumentStorage, xPropSupplier->getDocumentProperties() ); +} + OUString XmlFilterBase::getFragmentPathFromFirstType( const OUString& rType ) { // importRelations() caches the relations map for subsequence calls @@ -208,7 +264,7 @@ bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& r } catch( Exception& ) { - OSL_ENSURE( false, OStringBuffer( "XmlFilterBase::importFragment - XML parser failed in fragment '" ). + OSL_FAIL( OStringBuffer( "XmlFilterBase::importFragment - XML parser failed in fragment '" ). append( OUStringToOString( aFragmentPath, RTL_TEXTENCODING_ASCII_US ) ).append( '\'' ).getStr() ); } } @@ -218,6 +274,16 @@ bool XmlFilterBase::importFragment( const ::rtl::Reference< FragmentHandler >& r return false; } +OUString XmlFilterBase::getNamespaceURL( const OUString& rPrefix ) +{ + return mxImpl->maFastParser.getNamespaceURL( rPrefix ); +} + +sal_Int32 XmlFilterBase::getNamespaceId( const OUString& rUrl ) +{ + return mxImpl->maFastParser.getNamespaceId( rUrl ); +} + RelationsRef XmlFilterBase::importRelations( const OUString& rFragmentPath ) { // try to find cached relations @@ -241,7 +307,11 @@ Reference< XOutputStream > XmlFilterBase::openFragmentStream( const OUString& rS FSHelperPtr XmlFilterBase::openFragmentStreamWithSerializer( const OUString& rStreamName, const OUString& rMediaType ) { - return FSHelperPtr( new FastSerializerHelper( openFragmentStream( rStreamName, rMediaType ) ) ); + bool bWriteHeader = true; + if( rMediaType.indexOfAsciiL( "vml", 3 ) >= 0 && + rMediaType.indexOfAsciiL( "+xml", 4 ) < 0 ) + bWriteHeader = false; + return FSHelperPtr( new FastSerializerHelper( openFragmentStream( rStreamName, rMediaType ), bWriteHeader ) ); } TextFieldStack& XmlFilterBase::getTextFieldStack() const @@ -367,9 +437,13 @@ writeElement( FSHelperPtr pDoc, sal_Int32 nXmlElement, const Locale& rLocale ) static void writeCoreProperties( XmlFilterBase& rSelf, Reference< XDocumentProperties > xProperties ) { - rSelf.addRelation( - CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" ), - CREATE_OUSTRING( "docProps/core.xml" ) ); + OUString sValue; + if( rSelf.getVersion() == oox::core::ISOIEC_29500_2008 ) + sValue = CREATE_OUSTRING( "http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties" ); + else + sValue = CREATE_OUSTRING( "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" ); + + rSelf.addRelation( sValue, CREATE_OUSTRING( "docProps/core.xml" ) ); FSHelperPtr pCoreProps = rSelf.openFragmentStreamWithSerializer( CREATE_OUSTRING( "docProps/core.xml" ), CREATE_OUSTRING( "application/vnd.openxmlformats-package.core-properties+xml" ) ); @@ -508,3 +582,5 @@ StorageRef XmlFilterBase::implCreateStorage( const Reference< XStream >& rxOutSt } // namespace core } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx index 560fcf141c19..242d83b8e0fb 100644 --- a/oox/source/docprop/docprophandler.cxx +++ b/oox/source/docprop/docprophandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -89,7 +90,7 @@ void OOXMLDocPropHandler::AddCustomProperty( const uno::Any& aAny ) } catch( uno::Exception& ) { - OSL_ASSERT( "Can not add custom property!" ); + OSL_FAIL( "Can not add custom property!" ); } } } @@ -241,7 +242,7 @@ void OOXMLDocPropHandler::UpdateDocStatistic( const ::rtl::OUString& aChars ) break; default: - OSL_ASSERT( "Unexpected statistic!" ); + OSL_FAIL( "Unexpected statistic!" ); break; } @@ -305,7 +306,7 @@ void SAL_CALL OOXMLDocPropHandler::startFastElement( ::sal_Int32 nElement, const } else { - OSL_ASSERT( "Unexpected file format!" ); + OSL_FAIL( "Unexpected file format!" ); } } else if ( m_nState && m_nInBlock == 1 ) // that tag should contain the property name @@ -324,7 +325,7 @@ void SAL_CALL OOXMLDocPropHandler::startFastElement( ::sal_Int32 nElement, const } else { - OSL_ASSERT( "For now unexpected tags are ignored!" ); + OSL_FAIL( "For now unexpected tags are ignored!" ); } if ( m_nInBlock == SAL_MAX_INT32 ) @@ -341,7 +342,7 @@ void SAL_CALL OOXMLDocPropHandler::startUnknownElement( const ::rtl::OUString& a aUnknown += aNamespace; aUnknown += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":" ) ); aUnknown += aName; - OSL_ASSERT( ::rtl::OUStringToOString( aUnknown, RTL_TEXTENCODING_UTF8 ).getStr() ); + OSL_FAIL( ::rtl::OUStringToOString( aUnknown, RTL_TEXTENCODING_UTF8 ).getStr() ); if ( m_nInBlock == SAL_MAX_INT32 ) throw uno::RuntimeException(); @@ -486,7 +487,7 @@ void SAL_CALL OOXMLDocPropHandler::characters( const ::rtl::OUString& aChars ) break; default: - OSL_ASSERT( "Unexpected core property!" ); + OSL_FAIL( "Unexpected core property!" ); } } else if ( m_nState == EXTPR_TOKEN( Properties ) ) @@ -599,7 +600,7 @@ void SAL_CALL OOXMLDocPropHandler::characters( const ::rtl::OUString& aChars ) break; default: - OSL_ASSERT( "Unexpected extended property!" ); + OSL_FAIL( "Unexpected extended property!" ); } } else if ( m_nState == CUSTPR_TOKEN( Properties ) ) @@ -652,7 +653,7 @@ void SAL_CALL OOXMLDocPropHandler::characters( const ::rtl::OUString& aChars ) } else { - OSL_ASSERT( "Unexpected tag in custom property!" ); + OSL_FAIL( "Unexpected tag in custom property!" ); } } } @@ -689,3 +690,4 @@ void SAL_CALL OOXMLDocPropHandler::processingInstruction( const ::rtl::OUString& } // namespace docprop } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/docprop/docprophandler.hxx b/oox/source/docprop/docprophandler.hxx index 13e6e47b025e..47f34f77e740 100644 --- a/oox/source/docprop/docprophandler.hxx +++ b/oox/source/docprop/docprophandler.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -100,3 +101,4 @@ public: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/docprop/ooxmldocpropimport.cxx b/oox/source/docprop/ooxmldocpropimport.cxx index 7f3a08859302..736e3400c3de 100644 --- a/oox/source/docprop/ooxmldocpropimport.cxx +++ b/oox/source/docprop/ooxmldocpropimport.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -187,3 +188,5 @@ void SAL_CALL DocumentPropertiesImport::importProperties( } // namespace docprop } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/docprop/ooxmldocpropimport.hxx b/oox/source/docprop/ooxmldocpropimport.hxx index 79f4d1f7e60b..1e568af80bc3 100644 --- a/oox/source/docprop/ooxmldocpropimport.hxx +++ b/oox/source/docprop/ooxmldocpropimport.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -69,3 +70,5 @@ private: } // namespace oox #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/axiscontext.cxx b/oox/source/drawingml/chart/axiscontext.cxx index e590bf1c64cb..f1837ab908f8 100644 --- a/oox/source/drawingml/chart/axiscontext.cxx +++ b/oox/source/drawingml/chart/axiscontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -318,3 +319,5 @@ ContextHandlerRef ValAxisContext::onCreateContext( sal_Int32 nElement, const Att } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx index 18dc00b9d866..2225d7f5ae27 100644 --- a/oox/source/drawingml/chart/axisconverter.cxx +++ b/oox/source/drawingml/chart/axisconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -291,7 +292,7 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo } break; default: - OSL_ENSURE( false, "AxisConverter::convertFromModel - unknown axis type" ); + OSL_FAIL( "AxisConverter::convertFromModel - unknown axis type" ); } /* Do not set a value to the Origin member anymore (already done via @@ -354,7 +355,7 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo } catch( Exception& ) { - OSL_ENSURE( false, "AxisConverter::convertFromModel - cannot insert axis into coordinate system" ); + OSL_FAIL( "AxisConverter::convertFromModel - cannot insert axis into coordinate system" ); } } @@ -363,3 +364,5 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/axismodel.cxx b/oox/source/drawingml/chart/axismodel.cxx index c1bec6c1e1be..0ba061d61c81 100644 --- a/oox/source/drawingml/chart/axismodel.cxx +++ b/oox/source/drawingml/chart/axismodel.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -77,3 +78,5 @@ AxisModel::~AxisModel() } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/chartcontextbase.cxx b/oox/source/drawingml/chart/chartcontextbase.cxx index 69c1f2622b46..d5a5f599527e 100644 --- a/oox/source/drawingml/chart/chartcontextbase.cxx +++ b/oox/source/drawingml/chart/chartcontextbase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -120,3 +121,5 @@ ContextHandlerRef LayoutContext::onCreateContext( sal_Int32 nElement, const Attr } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/chartconverter.cxx b/oox/source/drawingml/chart/chartconverter.cxx index 02672088c763..e66eca6bc0e2 100644 --- a/oox/source/drawingml/chart/chartconverter.cxx +++ b/oox/source/drawingml/chart/chartconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,7 +31,12 @@ #include <com/sun/star/chart2/XChartDocument.hpp> #include "oox/drawingml/chart/chartspaceconverter.hxx" #include "oox/drawingml/chart/chartspacemodel.hxx" +#include "oox/helper/containerhelper.hxx" +#include "oox/core/xmlfilterbase.hxx" +using ::oox::drawingml::chart::DataSequenceModel; +using ::com::sun::star::uno::Any; +using ::rtl::OUStringBuffer; namespace oox { namespace drawingml { namespace chart { @@ -48,6 +54,50 @@ using ::rtl::OUString; // ============================================================================ +static const sal_Unicode API_TOKEN_ARRAY_OPEN = '{'; +static const sal_Unicode API_TOKEN_ARRAY_CLOSE = '}'; +static const sal_Unicode API_TOKEN_ARRAY_ROWSEP = '|'; +static const sal_Unicode API_TOKEN_ARRAY_COLSEP = ';'; + +// Code similar to oox/source/xls/FormulaParser.cxx +static OUString lclGenerateApiString( const OUString& rString ) +{ + OUString aRetString = rString; + sal_Int32 nQuotePos = aRetString.getLength(); + while( (nQuotePos = aRetString.lastIndexOf( '"', nQuotePos )) >= 0 ) + aRetString = aRetString.replaceAt( nQuotePos, 1, CREATE_OUSTRING( "\"\"" ) ); + return OUStringBuffer().append( sal_Unicode( '"' ) ).append( aRetString ).append( sal_Unicode( '"' ) ).makeStringAndClear(); +} + + static ::rtl::OUString lclGenerateApiArray( const Matrix< Any >& rMatrix ) +{ + OSL_ENSURE( !rMatrix.empty(), "ChartConverter::lclGenerateApiArray - missing matrix values" ); + OUStringBuffer aBuffer; + aBuffer.append( API_TOKEN_ARRAY_OPEN ); + for( size_t nRow = 0, nHeight = rMatrix.height(); nRow < nHeight; ++nRow ) + { + if( nRow > 0 ) + aBuffer.append( API_TOKEN_ARRAY_ROWSEP ); + for( Matrix< Any >::const_iterator aBeg = rMatrix.row_begin( nRow ), aIt = aBeg, aEnd = rMatrix.row_end( nRow ); aIt != aEnd; ++aIt ) + { + double fValue = 0.0; + ::rtl::OUString aString; + if( aIt != aBeg ) + aBuffer.append( API_TOKEN_ARRAY_COLSEP ); + if( *aIt >>= fValue ) + aBuffer.append( fValue ); + else if( *aIt >>= aString ) + aBuffer.append( lclGenerateApiString( aString ) ); + else + aBuffer.appendAscii( "\"\"" ); + } + } + aBuffer.append( API_TOKEN_ARRAY_CLOSE ); + return aBuffer.makeStringAndClear(); +} + +// ============================================================================ + ChartConverter::ChartConverter() { } @@ -81,8 +131,35 @@ void ChartConverter::createDataProvider( const Reference< XChartDocument >& rxCh } } -Reference< XDataSequence > ChartConverter::createDataSequence( const Reference< XDataProvider >&, const DataSequenceModel& ) +Reference< XDataSequence > ChartConverter::createDataSequence( const Reference< XDataProvider >& rxDataProvider, const DataSequenceModel& rDataSeq ) { + Reference< XDataSequence > xDataSeq; + if( rxDataProvider.is() ) + { + ::rtl::OUString aRangeRep; + if( !rDataSeq.maData.empty() ) + { + // create a single-row array from constant source data + Matrix< Any > aMatrix( rDataSeq.maData.size(), 1 ); + Matrix< Any >::iterator aMIt = aMatrix.begin(); + // TODO: how to handle missing values in the map? + for( DataSequenceModel::AnyMap::const_iterator aDIt = rDataSeq.maData.begin(), aDEnd = rDataSeq.maData.end(); aDIt != aDEnd; ++aDIt, ++aMIt ) + *aMIt = aDIt->second; + aRangeRep = lclGenerateApiArray( aMatrix ); + } + + if( aRangeRep.getLength() > 0 ) try + { + // create the data sequence + xDataSeq = rxDataProvider->createDataSequenceByRangeRepresentation( aRangeRep ); + return xDataSeq; + } + catch( Exception& ) + { + OSL_FAIL( "ExcelChartConverter::createDataSequence - cannot create data sequence" ); + } + } + return 0; } @@ -91,3 +168,5 @@ Reference< XDataSequence > ChartConverter::createDataSequence( const Reference< } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/chartdrawingfragment.cxx b/oox/source/drawingml/chart/chartdrawingfragment.cxx index deac5ee3f823..4d0109b1fbb1 100644 --- a/oox/source/drawingml/chart/chartdrawingfragment.cxx +++ b/oox/source/drawingml/chart/chartdrawingfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -73,13 +74,13 @@ void ShapeAnchor::setPos( sal_Int32 nElement, sal_Int32 nParentContext, const OU pAnchorPos = &maTo; break; default: - OSL_ENSURE( false, "ShapeAnchor::setPos - unexpected parent element" ); + OSL_FAIL( "ShapeAnchor::setPos - unexpected parent element" ); } if( pAnchorPos ) switch( nElement ) { case CDR_TOKEN( x ): pAnchorPos->mfX = rValue.toDouble(); break; case CDR_TOKEN( y ): pAnchorPos->mfY = rValue.toDouble(); break; - default: OSL_ENSURE( false, "ShapeAnchor::setPos - unexpected element" ); + default: OSL_FAIL( "ShapeAnchor::setPos - unexpected element" ); } } @@ -224,7 +225,8 @@ void ChartDrawingFragment::onEndElement() getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Y, 0, SAL_MAX_INT32 ), getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Width, 0, SAL_MAX_INT32 ), getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Height, 0, SAL_MAX_INT32 ) ); - mxShape->addShape( getFilter(), getFilter().getCurrentTheme(), mxDrawPage, &aShapeRectEmu32 ); + basegfx::B2DHomMatrix aMatrix; + mxShape->addShape( getFilter(), getFilter().getCurrentTheme(), mxDrawPage, aMatrix, &aShapeRectEmu32 ); } } mxShape.reset(); @@ -237,3 +239,5 @@ void ChartDrawingFragment::onEndElement() } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/chartspaceconverter.cxx b/oox/source/drawingml/chart/chartspaceconverter.cxx index bfcad1b43d04..44ae5c0e95b2 100644 --- a/oox/source/drawingml/chart/chartspaceconverter.cxx +++ b/oox/source/drawingml/chart/chartspaceconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -227,3 +228,5 @@ void ChartSpaceConverter::convertFromModel( const Reference< XShapes >& rxExtern } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/chartspacefragment.cxx b/oox/source/drawingml/chart/chartspacefragment.cxx index 06da27c02d01..0058dfb40ade 100644 --- a/oox/source/drawingml/chart/chartspacefragment.cxx +++ b/oox/source/drawingml/chart/chartspacefragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -130,3 +131,5 @@ ContextHandlerRef ChartSpaceFragment::onCreateContext( sal_Int32 nElement, const } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/chartspacemodel.cxx b/oox/source/drawingml/chart/chartspacemodel.cxx index 7f86448c8d08..baa05c3f7a2c 100644 --- a/oox/source/drawingml/chart/chartspacemodel.cxx +++ b/oox/source/drawingml/chart/chartspacemodel.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -52,3 +53,5 @@ ChartSpaceModel::~ChartSpaceModel() } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx index 7e601ff016af..7e563ae15b03 100644 --- a/oox/source/drawingml/chart/converterbase.cxx +++ b/oox/source/drawingml/chart/converterbase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -38,7 +39,7 @@ #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <tools/solar.h> // for F_PI180 +#include "basegfx/numeric/ftools.hxx" #include "oox/core/xmlfilterbase.hxx" #include "oox/drawingml/theme.hxx" @@ -309,11 +310,11 @@ sal_Int32 lclCalcPosition( sal_Int32 nChartSize, double fPos, sal_Int32 nPosMode case XML_edge: // absolute start position as factor of chart size return getLimitedValue< sal_Int32, double >( nChartSize * fPos + 0.5, 0, nChartSize ); case XML_factor: // position relative to object default position - OSL_ENSURE( false, "lclCalcPosition - relative positioning not supported" ); + OSL_FAIL( "lclCalcPosition - relative positioning not supported" ); return -1; }; - OSL_ENSURE( false, "lclCalcPosition - unknown positioning mode" ); + OSL_FAIL( "lclCalcPosition - unknown positioning mode" ); return -1; } @@ -329,7 +330,7 @@ sal_Int32 lclCalcSize( sal_Int32 nPos, sal_Int32 nChartSize, double fSize, sal_I return nValue - nPos + 1; }; - OSL_ENSURE( false, "lclCalcSize - unknown size mode" ); + OSL_FAIL( "lclCalcSize - unknown size mode" ); return -1; } @@ -437,3 +438,5 @@ bool LayoutConverter::convertFromModel( const Reference< XShape >& rxShape, doub } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/datasourcecontext.cxx b/oox/source/drawingml/chart/datasourcecontext.cxx index a044dd67018d..087e6fd57abc 100644 --- a/oox/source/drawingml/chart/datasourcecontext.cxx +++ b/oox/source/drawingml/chart/datasourcecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -102,7 +103,17 @@ void DoubleSequenceContext::onCharacters( const OUString& rChars ) break; case C_TOKEN( v ): if( mnPtIndex >= 0 ) - mrModel.maData[ mnPtIndex ] <<= rChars.toDouble(); + { + /* Import categories as String even though it could + * be values. + * TODO: NumberFormat conversion, remove the check then. + */ + if( isParentElement( C_TOKEN( cat ), 4 ) || + isParentElement( C_TOKEN( xVal ), 4 ) ) + mrModel.maData[ mnPtIndex ] <<= rChars; + else + mrModel.maData[ mnPtIndex ] <<= rChars.toDouble(); + } break; } } @@ -231,3 +242,5 @@ ContextHandlerRef DataSourceContext::onCreateContext( sal_Int32 nElement, const } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/datasourceconverter.cxx b/oox/source/drawingml/chart/datasourceconverter.cxx index c68a6cbe4adf..805595f12467 100644 --- a/oox/source/drawingml/chart/datasourceconverter.cxx +++ b/oox/source/drawingml/chart/datasourceconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -92,3 +93,5 @@ Reference< XDataSequence > DataSourceConverter::createDataSequence( const OUStri } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/datasourcemodel.cxx b/oox/source/drawingml/chart/datasourcemodel.cxx index aad5a1bff959..b3535358231b 100644 --- a/oox/source/drawingml/chart/datasourcemodel.cxx +++ b/oox/source/drawingml/chart/datasourcemodel.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -57,3 +58,5 @@ DataSourceModel::~DataSourceModel() } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/modelbase.cxx b/oox/source/drawingml/chart/modelbase.cxx index f32a118c5589..b780a0b9011a 100644 --- a/oox/source/drawingml/chart/modelbase.cxx +++ b/oox/source/drawingml/chart/modelbase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -76,3 +77,5 @@ LayoutModel::~LayoutModel() } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx index 339a14cad516..1b07ae33c494 100644 --- a/oox/source/drawingml/chart/objectformatter.cxx +++ b/oox/source/drawingml/chart/objectformatter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -190,7 +191,7 @@ static const AutoFormatEntry spNoFormats[] = AUTOFORMAT_END() }; -static const AutoFormatEntry spChartSpaceLines[] = +static const AutoFormatEntry spDataTableLines[] = { AUTOFORMAT_COLORMOD( 1, 32, THEMED_STYLE_SUBTLE, XML_tx1, XML_tint, 75000 ), AUTOFORMAT_COLORMOD( 33, 40, THEMED_STYLE_SUBTLE, XML_dk1, XML_tint, 75000 ), @@ -198,14 +199,6 @@ static const AutoFormatEntry spChartSpaceLines[] = AUTOFORMAT_END() }; -static const AutoFormatEntry spChartSpaceFills[] = -{ - AUTOFORMAT_COLOR( 1, 32, THEMED_STYLE_SUBTLE, XML_bg1 ), - AUTOFORMAT_COLOR( 33, 40, THEMED_STYLE_SUBTLE, XML_lt1 ), - AUTOFORMAT_COLOR( 41, 48, THEMED_STYLE_SUBTLE, XML_dk1 ), - AUTOFORMAT_END() -}; - static const AutoFormatEntry spPlotArea2dFills[] = { AUTOFORMAT_COLOR( 1, 32, THEMED_STYLE_SUBTLE, XML_bg1 ), @@ -550,7 +543,7 @@ struct ObjectTypeFormatEntry static const ObjectTypeFormatEntry spObjTypeFormatEntries[] = { // object type property info auto text auto line auto fill auto effect - TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE, &saCommonPropInfo, 0, spChartSpaceLines, spChartSpaceFills, 0 /* eq to Ch2 */ ), + TYPEFORMAT_FRAME( OBJECTTYPE_CHARTSPACE, &saCommonPropInfo, 0, spNoFormats, spNoFormats, 0 /* eq to Ch2 */ ), TYPEFORMAT_FRAME( OBJECTTYPE_CHARTTITLE, &saCommonPropInfo, spChartTitleTexts, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */, 0 /* eq to Ch2 */ ), TYPEFORMAT_FRAME( OBJECTTYPE_LEGEND, &saCommonPropInfo, spOtherTexts, spNoFormats, spNoFormats, 0 /* eq to Ch2 */ ), TYPEFORMAT_FRAME( OBJECTTYPE_PLOTAREA2D, &saCommonPropInfo, 0, 0 /* eq to Ch2 */, spPlotArea2dFills, 0 /* eq to Ch2 */ ), @@ -575,7 +568,7 @@ static const ObjectTypeFormatEntry spObjTypeFormatEntries[] = TYPEFORMAT_LINE( OBJECTTYPE_HILOLINE, &saLinearPropInfo, 0, spOtherLines ), TYPEFORMAT_FRAME( OBJECTTYPE_UPBAR, &saCommonPropInfo, 0, spUpDownBarLines, spUpBarFills, spUpDownBarEffects ), TYPEFORMAT_FRAME( OBJECTTYPE_DOWNBAR, &saCommonPropInfo, 0, spUpDownBarLines, spDownBarFills, spUpDownBarEffects ), - TYPEFORMAT_LINE( OBJECTTYPE_DATATABLE, &saCommonPropInfo, spOtherTexts, spChartSpaceLines ) + TYPEFORMAT_LINE( OBJECTTYPE_DATATABLE, &saCommonPropInfo, spOtherTexts, spDataTableLines ) }; #undef TYPEFORMAT_FRAME @@ -675,7 +668,7 @@ public: void convertFormatting( ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, - sal_Int32 nSeriesIdx ); + sal_Int32 nSeriesIdx ) const; }; // ---------------------------------------------------------------------------- @@ -930,8 +923,8 @@ EffectFormatter::EffectFormatter( ObjectFormatterData& rData, const AutoFormatEn DetailFormatterBase( rData, pAutoFormatEntry ) { } - -void EffectFormatter::convertFormatting( ShapePropertyMap& /*rPropMap*/, const ModelRef< Shape >& /*rxShapeProp*/, sal_Int32 /*nSeriesIdx*/ ) +//TODO : +void EffectFormatter::convertFormatting( ShapePropertyMap& /*rPropMap*/, const ModelRef< Shape >& /*rxShapeProp*/, sal_Int32 /*nSeriesIdx*/ ) const { } @@ -1056,7 +1049,7 @@ ObjectFormatterData::ObjectFormatterData( const XmlFilterBase& rFilter, const Re try { - Reference< XNumberFormatsSupplier > xNumFmtsSupp( mrFilter.getModel(), UNO_QUERY_THROW ); + Reference< XNumberFormatsSupplier > xNumFmtsSupp( rxChartDoc, UNO_QUERY_THROW ); mxNumFmts = xNumFmtsSupp->getNumberFormats(); mxNumTypes.set( mxNumFmts, UNO_QUERY ); } @@ -1162,8 +1155,7 @@ void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFo } catch( Exception& ) { - OSL_ENSURE( false, - OStringBuffer( "ObjectFormatter::convertNumberFormat - cannot create number format '" ). + OSL_FAIL( OStringBuffer( "ObjectFormatter::convertNumberFormat - cannot create number format '" ). append( OUStringToOString( rNumberFormat.maFormatCode, osl_getThreadTextEncoding() ) ).append( '\'' ).getStr() ); } } @@ -1196,3 +1188,5 @@ void ObjectFormatter::convertAutomaticFill( PropertySet& rPropSet, ObjectType eO } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/plotareacontext.cxx b/oox/source/drawingml/chart/plotareacontext.cxx index 17c6487b59b4..82c529dc29a4 100644 --- a/oox/source/drawingml/chart/plotareacontext.cxx +++ b/oox/source/drawingml/chart/plotareacontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -185,3 +186,5 @@ ContextHandlerRef PlotAreaContext::onCreateContext( sal_Int32 nElement, const At } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx index 78379ae855bd..c3da08067121 100644 --- a/oox/source/drawingml/chart/plotareaconverter.cxx +++ b/oox/source/drawingml/chart/plotareaconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -300,7 +301,7 @@ void WallFloorConverter::convertFromModel( const Reference< XDiagram >& rxDiagra { case OBJECTTYPE_FLOOR: aPropSet.set( rxDiagram->getFloor() ); break; case OBJECTTYPE_WALL: aPropSet.set( rxDiagram->getWall() ); break; - default: OSL_ENSURE( false, "WallFloorConverter::convertFromModel - invalid object type" ); + default: OSL_FAIL( "WallFloorConverter::convertFromModel - invalid object type" ); } if( aPropSet.is() ) getFormatter().convertFrameFormatting( aPropSet, mrModel.mxShapeProp, mrModel.mxPicOptions.getOrCreate(), eObjType ); @@ -437,7 +438,7 @@ void PlotAreaConverter::convertPositionFromModel() xPositioning->setDiagramPositionIncludingAxes( aDiagramRect ); break; default: - OSL_ENSURE( false, "PlotAreaConverter::convertPositionFromModel - unknown positioning target" ); + OSL_FAIL( "PlotAreaConverter::convertPositionFromModel - unknown positioning target" ); } } catch( Exception& ) @@ -450,3 +451,5 @@ void PlotAreaConverter::convertPositionFromModel() } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/plotareamodel.cxx b/oox/source/drawingml/chart/plotareamodel.cxx index 324186526cc6..f514252fb4c3 100644 --- a/oox/source/drawingml/chart/plotareamodel.cxx +++ b/oox/source/drawingml/chart/plotareamodel.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -70,3 +71,4 @@ PlotAreaModel::~PlotAreaModel() } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/seriescontext.cxx b/oox/source/drawingml/chart/seriescontext.cxx index 014ca51e869d..83ebddcc877c 100644 --- a/oox/source/drawingml/chart/seriescontext.cxx +++ b/oox/source/drawingml/chart/seriescontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -752,3 +753,5 @@ ContextHandlerRef SurfaceSeriesContext::onCreateContext( sal_Int32 nElement, con } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index b9eaee5c01be..f6f1ad8523ec 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -288,7 +289,7 @@ void ErrorBarConverter::convertFromModel( const Reference< XDataSeries >& rxData aBarProp.setProperty( PROP_ErrorBarStyle, cssc::ErrorBarStyle::STANDARD_ERROR ); break; default: - OSL_ENSURE( false, "ErrorBarConverter::convertFromModel - unknown error bar type" ); + OSL_FAIL( "ErrorBarConverter::convertFromModel - unknown error bar type" ); xErrorBar.clear(); } @@ -302,13 +303,13 @@ void ErrorBarConverter::convertFromModel( const Reference< XDataSeries >& rxData { case XML_x: aSeriesProp.setProperty( PROP_ErrorBarX, xErrorBar ); break; case XML_y: aSeriesProp.setProperty( PROP_ErrorBarY, xErrorBar ); break; - default: OSL_ENSURE( false, "ErrorBarConverter::convertFromModel - invalid error bar direction" ); + default: OSL_FAIL( "ErrorBarConverter::convertFromModel - invalid error bar direction" ); } } } catch( Exception& ) { - OSL_ENSURE( false, "ErrorBarConverter::convertFromModel - error while creating error bars" ); + OSL_FAIL( "ErrorBarConverter::convertFromModel - error while creating error bars" ); } } @@ -380,7 +381,7 @@ void TrendlineConverter::convertFromModel( const Reference< XDataSeries >& rxDat case XML_movingAvg: /* #i66819# moving average trendlines not supported */ break; case XML_poly: /* #i20819# polynomial trendlines not supported */ break; case XML_power: aServiceName = CREATE_OUSTRING( "com.sun.star.chart2.PotentialRegressionCurve" ); break; - default: OSL_ENSURE( false, "TrendlineConverter::convertFromModel - unknown trendline type" ); + default: OSL_FAIL( "TrendlineConverter::convertFromModel - unknown trendline type" ); } if( aServiceName.getLength() > 0 ) { @@ -411,7 +412,7 @@ void TrendlineConverter::convertFromModel( const Reference< XDataSeries >& rxDat } catch( Exception& ) { - OSL_ENSURE( false, "TrendlineConverter::convertFromModel - error while creating trendline" ); + OSL_FAIL( "TrendlineConverter::convertFromModel - error while creating trendline" ); } } @@ -617,3 +618,5 @@ Reference< XLabeledDataSequence > SeriesConverter::createLabeledDataSequence( } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/seriesmodel.cxx b/oox/source/drawingml/chart/seriesmodel.cxx index 417d250caf77..9db26a7225b2 100644 --- a/oox/source/drawingml/chart/seriesmodel.cxx +++ b/oox/source/drawingml/chart/seriesmodel.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -154,3 +155,5 @@ SeriesModel::~SeriesModel() } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/titlecontext.cxx b/oox/source/drawingml/chart/titlecontext.cxx index cc2b7ace0e72..100235d7c2c6 100644 --- a/oox/source/drawingml/chart/titlecontext.cxx +++ b/oox/source/drawingml/chart/titlecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -157,3 +158,5 @@ ContextHandlerRef LegendContext::onCreateContext( sal_Int32 nElement, const Attr } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/titleconverter.cxx b/oox/source/drawingml/chart/titleconverter.cxx index 8163241e5a31..5699a0d3f4b8 100644 --- a/oox/source/drawingml/chart/titleconverter.cxx +++ b/oox/source/drawingml/chart/titleconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -257,3 +258,5 @@ void LegendConverter::convertFromModel( const Reference< XDiagram >& rxDiagram ) } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/titlemodel.cxx b/oox/source/drawingml/chart/titlemodel.cxx index d1dc2c664e8f..8a6d433fab9f 100644 --- a/oox/source/drawingml/chart/titlemodel.cxx +++ b/oox/source/drawingml/chart/titlemodel.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -69,3 +70,5 @@ LegendModel::~LegendModel() } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/typegroupcontext.cxx b/oox/source/drawingml/chart/typegroupcontext.cxx index 781b2665d6f1..53a22082a634 100644 --- a/oox/source/drawingml/chart/typegroupcontext.cxx +++ b/oox/source/drawingml/chart/typegroupcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -402,3 +403,5 @@ ContextHandlerRef SurfaceTypeGroupContext::onCreateContext( sal_Int32 nElement, } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/typegroupconverter.cxx b/oox/source/drawingml/chart/typegroupconverter.cxx index 6c0d3660a670..5dba350de392 100644 --- a/oox/source/drawingml/chart/typegroupconverter.cxx +++ b/oox/source/drawingml/chart/typegroupconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -164,7 +165,7 @@ TypeGroupConverter::TypeGroupConverter( const ConverterRoot& rParent, TypeGroupM case C_TOKEN( stockChart ): ENSURE_AXESCOUNT( 2, 2 ); eTypeId = TYPEID_STOCK; mb3dChart = false; break; case C_TOKEN( surface3DChart ): ENSURE_AXESCOUNT( 3, 3 ); eTypeId = TYPEID_SURFACE; mb3dChart = true; break; case C_TOKEN( surfaceChart ): ENSURE_AXESCOUNT( 2, 3 ); eTypeId = TYPEID_SURFACE; mb3dChart = true; break; // 3D bar chart from all surface charts - default: OSL_ENSURE( false, "TypeGroupConverter::TypeGroupConverter - unknown chart type" ); + default: OSL_FAIL( "TypeGroupConverter::TypeGroupConverter - unknown chart type" ); #undef ENSURE_AXESCOUNT } @@ -437,7 +438,7 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra } catch( Exception& ) { - OSL_ENSURE( false, "TypeGroupConverter::convertFromModel - cannot add chart type" ); + OSL_FAIL( "TypeGroupConverter::convertFromModel - cannot add chart type" ); } } @@ -499,7 +500,7 @@ void TypeGroupConverter::convertBarGeometry( PropertySet& rPropSet, sal_Int32 nO case XML_cylinder: nGeom3d = cssc::DataPointGeometry3D::CYLINDER; break; case XML_pyramid: nGeom3d = cssc::DataPointGeometry3D::PYRAMID; break; case XML_pyramidToMax: nGeom3d = cssc::DataPointGeometry3D::PYRAMID; break; - default: OSL_ENSURE( false, "TypeGroupConverter::convertBarGeometry - unknown 3D bar shape type" ); + default: OSL_FAIL( "TypeGroupConverter::convertBarGeometry - unknown 3D bar shape type" ); } rPropSet.setProperty( PROP_Geometry3D, nGeom3d ); } @@ -554,7 +555,7 @@ void TypeGroupConverter::insertDataSeries( const Reference< XChartType >& rxChar } catch( Exception& ) { - OSL_ENSURE( false, "TypeGroupConverter::insertDataSeries - cannot add data series" ); + OSL_FAIL( "TypeGroupConverter::insertDataSeries - cannot add data series" ); } } } @@ -564,3 +565,5 @@ void TypeGroupConverter::insertDataSeries( const Reference< XChartType >& rxChar } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/chart/typegroupmodel.cxx b/oox/source/drawingml/chart/typegroupmodel.cxx index ee5eefc4d163..8ddc70704917 100644 --- a/oox/source/drawingml/chart/typegroupmodel.cxx +++ b/oox/source/drawingml/chart/typegroupmodel.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -80,3 +81,5 @@ TypeGroupModel::~TypeGroupModel() } // namespace chart } // namespace drawingml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/clrscheme.cxx b/oox/source/drawingml/clrscheme.cxx index b011cd27b147..776cbb1f7045 100644 --- a/oox/source/drawingml/clrscheme.cxx +++ b/oox/source/drawingml/clrscheme.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -80,3 +81,5 @@ void ClrScheme::setColor( sal_Int32 nSchemeClrToken, sal_Int32 nColor ) } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/clrschemecontext.cxx b/oox/source/drawingml/clrschemecontext.cxx index fad92dd35c3c..3355b95e8e04 100644 --- a/oox/source/drawingml/clrschemecontext.cxx +++ b/oox/source/drawingml/clrschemecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -103,3 +104,5 @@ Reference< XFastContextHandler > clrSchemeContext::createFastChildContext( } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx index de061a91fcb4..9b2ce7ec324e 100644 --- a/oox/source/drawingml/color.cxx +++ b/oox/source/drawingml/color.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -591,7 +592,7 @@ void Color::toRgb() const } break; default: - OSL_ENSURE( false, "Color::toRgb - unexpected color mode" ); + OSL_FAIL( "Color::toRgb - unexpected color mode" ); } } @@ -612,7 +613,7 @@ void Color::toCrgb() const // nothing to do break; default: - OSL_ENSURE( false, "Color::toCrgb - unexpected color mode" ); + OSL_FAIL( "Color::toCrgb - unexpected color mode" ); } } @@ -659,7 +660,7 @@ void Color::toHsl() const // nothing to do break; default: - OSL_ENSURE( false, "Color::toHsl - unexpected color mode" ); + OSL_FAIL( "Color::toHsl - unexpected color mode" ); } } @@ -668,3 +669,4 @@ void Color::toHsl() const } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/colorchoicecontext.cxx b/oox/source/drawingml/colorchoicecontext.cxx index a909f2f68d0c..3bc48cbba4e3 100644 --- a/oox/source/drawingml/colorchoicecontext.cxx +++ b/oox/source/drawingml/colorchoicecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -158,3 +159,4 @@ Reference< XFastContextHandler > ColorContext::createFastChildContext( } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/connectorshapecontext.cxx b/oox/source/drawingml/connectorshapecontext.cxx index f2840a8d82fa..3028608d4f11 100644 --- a/oox/source/drawingml/connectorshapecontext.cxx +++ b/oox/source/drawingml/connectorshapecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -77,3 +78,5 @@ Reference< XFastContextHandler > ConnectorShapeContext::createFastChildContext( } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/customshapegeometry.cxx b/oox/source/drawingml/customshapegeometry.cxx index d0c5c6a2dde2..3a7277a0b718 100644 --- a/oox/source/drawingml/customshapegeometry.cxx +++ b/oox/source/drawingml/customshapegeometry.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,7 +30,7 @@ #include <com/sun/star/xml/sax/FastToken.hpp> #include <comphelper/stl_types.hxx> -#include <hash_map> +#include <boost/unordered_map.hpp> #include "oox/helper/helper.hxx" #include "oox/helper/attributelist.hxx" #include "oox/helper/propertymap.hxx" @@ -90,7 +91,7 @@ static FormularCommandNameTable pFormularCommandNameTable[] = { "val", FC_VAL } }; -typedef std::hash_map< rtl::OUString, FormularCommand, comphelper::UStringHash, comphelper::UStringEqual > FormulaCommandHMap; +typedef boost::unordered_map< rtl::OUString, FormularCommand, comphelper::UStringHash, comphelper::UStringEqual > FormulaCommandHMap; static const FormulaCommandHMap* pCommandHashMap; @@ -400,7 +401,7 @@ static EnhancedCustomShapeParameter GetAdjCoordinate( CustomShapeProperties& rCu } if ( ( n >= '0' ) && ( n <= '9' ) ) { // seems to be a ST_Coordinate - aRet.Value = Any( rValue.toInt32() ); + aRet.Value = Any( (sal_Int32)(rValue.toInt32() / 5) ); aRet.Type = EnhancedCustomShapeParameterType::NORMAL; } else @@ -482,7 +483,7 @@ static rtl::OUString convertToOOEquation( CustomShapeProperties& rCustomShapePro while ( nIndex >= 0 ); rtl::OUString aEquation; - if ( aTokens.size() ) + if ( !aTokens.empty() ) { sal_Int32 i, nParameters = aTokens.size() - 1; if ( nParameters > 3 ) @@ -1470,7 +1471,8 @@ OUString GetShapeType( sal_Int32 nType ) sType = sBracePair; } break; case XML_straightConnector1: { - static const OUString sStraightConnector1 = CREATE_OUSTRING( "mso-spt32" ); + static const OUString sStraightConnector1 = CREATE_OUSTRING( "ooxml-straight-connector-1" ); + OSL_TRACE("preset resolved as: ooxml-straight-connector-1"); sType = sStraightConnector1; } break; case XML_bentConnector2: { @@ -2063,3 +2065,5 @@ Reference< XFastContextHandler > PresetTextShapeContext::createFastChildContext( } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx index 052fdc5e1dfc..23e2e19a546d 100644 --- a/oox/source/drawingml/customshapeproperties.cxx +++ b/oox/source/drawingml/customshapeproperties.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -44,6 +45,8 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::graphic; using namespace ::com::sun::star::drawing; +# define USS(x) OUStringToOString( x, RTL_TEXTENCODING_UTF8 ).getStr() + namespace oox { namespace drawingml { CustomShapeProperties::CustomShapeProperties() @@ -93,10 +96,1823 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi { if ( maShapePresetType.getLength() ) { - //const uno::Reference < drawing::XShape > xShape( xPropSet, UNO_QUERY ); - Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( xShape, UNO_QUERY ); - if( xDefaulter.is() ) - xDefaulter->createCustomShapeDefaults( maShapePresetType ); + OSL_TRACE("preset: %s", USS(maShapePresetType)); + + static OUString sLeftRightArrow = CREATE_OUSTRING("left-right-arrow"); + static OUString sRightArrow = CREATE_OUSTRING("right-arrow"); + static OUString sStripedRightArrow = CREATE_OUSTRING("striped-right-arrow"); + static OUString sWedgeRoundedRectCallout = CREATE_OUSTRING("round-rectangular-callout"); + +if ( maShapePresetType.equals( sWedgeRoundedRectCallout ) ) { + PropertyMap aPropertyMap; + + Sequence< EnhancedCustomShapeAdjustmentValue > aAdjSequence (3); + { + Any aAny ((sal_Int32) -4166); + aAdjSequence [0].Value = aAny; + } + { + Any aAny ((sal_Int32) 12500); + aAdjSequence [1].Value = aAny; + } + { + Any aAny ((sal_Int32) 3333); + aAdjSequence [2].Value = aAny; + } + aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; + + Sequence< OUString > aStringSequence (43); + aStringSequence[0] = CREATE_OUSTRING ("width*$0 /20000"); + aStringSequence[1] = CREATE_OUSTRING ("height*$1 /20000"); + aStringSequence[2] = CREATE_OUSTRING ("width/2"); + aStringSequence[3] = CREATE_OUSTRING ("?2 +?0 -0"); + aStringSequence[4] = CREATE_OUSTRING ("height/2"); + aStringSequence[5] = CREATE_OUSTRING ("?4 +?1 -0"); + aStringSequence[6] = CREATE_OUSTRING ("?0 *height/width"); + aStringSequence[7] = CREATE_OUSTRING ("abs(?1 )"); + aStringSequence[8] = CREATE_OUSTRING ("abs(?6 )"); + aStringSequence[9] = CREATE_OUSTRING ("?7 +0-?8 "); + aStringSequence[10] = CREATE_OUSTRING (""); + aStringSequence[11] = CREATE_OUSTRING (""); + aStringSequence[12] = CREATE_OUSTRING ("width*?10 /2"); + aStringSequence[13] = CREATE_OUSTRING ("width*?11 /2"); + aStringSequence[14] = CREATE_OUSTRING (""); + aStringSequence[15] = CREATE_OUSTRING (""); + aStringSequence[16] = CREATE_OUSTRING ("height*?14 /2"); + aStringSequence[17] = CREATE_OUSTRING ("height*?15 /2"); + aStringSequence[18] = CREATE_OUSTRING (""); + aStringSequence[19] = CREATE_OUSTRING (""); + aStringSequence[20] = CREATE_OUSTRING (""); + aStringSequence[21] = CREATE_OUSTRING (""); + aStringSequence[22] = CREATE_OUSTRING (""); + aStringSequence[23] = CREATE_OUSTRING (""); + aStringSequence[24] = CREATE_OUSTRING (""); + aStringSequence[25] = CREATE_OUSTRING (""); + aStringSequence[26] = CREATE_OUSTRING (""); + aStringSequence[27] = CREATE_OUSTRING (""); + aStringSequence[28] = CREATE_OUSTRING (""); + aStringSequence[29] = CREATE_OUSTRING (""); + aStringSequence[30] = CREATE_OUSTRING (""); + aStringSequence[31] = CREATE_OUSTRING (""); + aStringSequence[32] = CREATE_OUSTRING (""); + aStringSequence[33] = CREATE_OUSTRING (""); + aStringSequence[34] = CREATE_OUSTRING ("min(width,height)"); + aStringSequence[35] = CREATE_OUSTRING ("?34 *$2 /20000"); + aStringSequence[36] = CREATE_OUSTRING ("width+0-?35 "); + aStringSequence[37] = CREATE_OUSTRING ("height+0-?35 "); + aStringSequence[38] = CREATE_OUSTRING ("?35 *5857/20000"); + aStringSequence[39] = CREATE_OUSTRING ("width+0-?38 "); + aStringSequence[40] = CREATE_OUSTRING ("height+0-?38 "); + aStringSequence[41] = CREATE_OUSTRING ("height"); + aStringSequence[42] = CREATE_OUSTRING ("width"); + aPropertyMap [PROP_Equations] <<= aStringSequence; + + Sequence< Sequence < PropertyValue > > aPropSequenceSequence (1); + { + Sequence< PropertyValue > aPropSequence (7); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Position"); + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 3); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aPropSequence [0].Value = makeAny (aParameterPair); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("RangeXMaximum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 429496729); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [1].Value = makeAny (aParameter); + } + { + aPropSequence [2].Name = CREATE_OUSTRING ("RangeXMinimum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) -429496729); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [2].Value = makeAny (aParameter); + } + { + aPropSequence [3].Name = CREATE_OUSTRING ("RangeYMaximum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 429496729); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [3].Value = makeAny (aParameter); + } + { + aPropSequence [4].Name = CREATE_OUSTRING ("RangeYMinimum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) -429496729); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [4].Value = makeAny (aParameter); + } + { + aPropSequence [5].Name = CREATE_OUSTRING ("RefX"); + Any aAny ((sal_Int32) 0); + aPropSequence [5].Value = makeAny (aAny); + } + { + aPropSequence [6].Name = CREATE_OUSTRING ("RefY"); + Any aAny ((sal_Int32) 1); + aPropSequence [6].Value = makeAny (aAny); + } + aPropSequenceSequence [0] = aPropSequence; + } + aPropertyMap [PROP_Handles] <<= aPropSequenceSequence; + + aPropertyMap [PROP_MirroredX] <<= Any ((sal_Bool) sal_False); + + aPropertyMap [PROP_MirroredY] <<= Any ((sal_Bool) sal_False); + + Sequence< PropertyValue > aPropSequence (2); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Coordinates"); + Sequence< EnhancedCustomShapeParameterPair > aParameterPairSeq (32); + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 35); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [0] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [1] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [2] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [3] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [4] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 12); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [5] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 21); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 29); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [6] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 13); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [7] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 36); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [8] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [9] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [10] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [11] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [12] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 42); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 16); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [13] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 23); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 31); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [14] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 42); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 17); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [15] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 42); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 37); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [16] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [17] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [18] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [19] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [20] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 13); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 41); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [21] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 25); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 33); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [22] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 12); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 41); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [23] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 35); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 41); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [24] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [25] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [26] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [27] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [28] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 17); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [29] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 19); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 27); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [30] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 16); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [31] = aParameterPair; + } + aPropSequence [0].Value = makeAny (aParameterPairSeq); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("Segments"); + Sequence< EnhancedCustomShapeSegment > aSegmentSeq (11); + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 1; + aSegment.Count = 1; + aSegmentSeq [0] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 10; + aSegment.Count = 1; + aSegmentSeq [1] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 2; + aSegment.Count = 4; + aSegmentSeq [2] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 10; + aSegment.Count = 1; + aSegmentSeq [3] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 2; + aSegment.Count = 4; + aSegmentSeq [4] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 10; + aSegment.Count = 1; + aSegmentSeq [5] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 2; + aSegment.Count = 4; + aSegmentSeq [6] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 10; + aSegment.Count = 1; + aSegmentSeq [7] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 2; + aSegment.Count = 3; + aSegmentSeq [8] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 4; + aSegment.Count = 0; + aSegmentSeq [9] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 5; + aSegment.Count = 0; + aSegmentSeq [10] = aSegment; + } + aPropSequence [1].Value = makeAny (aSegmentSeq); + } + aPropertyMap [PROP_Path] <<= aPropSequence; + + awt::Rectangle aRectangle; + aRectangle.X = 0; + aRectangle.Y = 0; + aRectangle.Width = 4663800; + aRectangle.Height = 283680; + aPropertyMap [PROP_ViewBox] <<= aRectangle; + + aPropertyMap [ PROP_Type ] <<= CREATE_OUSTRING("ooxml-wedge-round-rect-callout"); + + Sequence< PropertyValue > aSeq = aPropertyMap.makePropertyValueSequence(); + PropertySet aPropSet( xPropSet ); + aPropSet.setProperty( PROP_CustomShapeGeometry, aSeq ); + OSL_TRACE("created ooxml preset for ooxml-wedge-round-rect-callout"); + } + else if ( maShapePresetType.equals( sLeftRightArrow ) ) { + PropertyMap aPropertyMap; + + Sequence< EnhancedCustomShapeAdjustmentValue > aAdjSequence (2); + { + Any aAny ((sal_Int32) 10000); + aAdjSequence [0].Value = aAny; + } + { + Any aAny ((sal_Int32) 10000); + aAdjSequence [1].Value = aAny; + } + aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; + + Sequence< OUString > aStringSequence (16); + aStringSequence[0] = CREATE_OUSTRING ("min(width,height)"); + aStringSequence[1] = CREATE_OUSTRING ("10000*width/?0 "); + aStringSequence[2] = CREATE_OUSTRING ("if(0-$0 ,0,if(20000-$0 ,$0 ,20000))"); + aStringSequence[3] = CREATE_OUSTRING ("if(0-$1 ,0,if(?1 -$1 ,$1 ,?1 ))"); + aStringSequence[4] = CREATE_OUSTRING ("?0 *?3 /20000"); + aStringSequence[5] = CREATE_OUSTRING ("width+0-?4 "); + aStringSequence[6] = CREATE_OUSTRING ("height*?2 /40000"); + aStringSequence[7] = CREATE_OUSTRING ("height/2"); + aStringSequence[8] = CREATE_OUSTRING ("?7 +0-?6 "); + aStringSequence[9] = CREATE_OUSTRING ("?7 +?6 -0"); + aStringSequence[10] = CREATE_OUSTRING ("height/2"); + aStringSequence[11] = CREATE_OUSTRING ("?8 *?4 /?10 "); + aStringSequence[12] = CREATE_OUSTRING ("?4 +0-?11 "); + aStringSequence[13] = CREATE_OUSTRING ("?5 +?11 -0"); + aStringSequence[14] = CREATE_OUSTRING ("width"); + aStringSequence[15] = CREATE_OUSTRING ("height"); + aPropertyMap [PROP_Equations] <<= aStringSequence; + + Sequence< Sequence < PropertyValue > > aPropSequenceSequence (2); + { + Sequence< PropertyValue > aPropSequence (4); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Position"); + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 8); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aPropSequence [0].Value = makeAny (aParameterPair); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("RangeYMaximum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 20000); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [1].Value = makeAny (aParameter); + } + { + aPropSequence [2].Name = CREATE_OUSTRING ("RangeYMinimum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 0); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [2].Value = makeAny (aParameter); + } + { + aPropSequence [3].Name = CREATE_OUSTRING ("RefY"); + Any aAny ((sal_Int32) 0); + aPropSequence [3].Value = makeAny (aAny); + } + aPropSequenceSequence [0] = aPropSequence; + } + { + Sequence< PropertyValue > aPropSequence (4); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Position"); + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 4); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aPropSequence [0].Value = makeAny (aParameterPair); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("RangeXMaximum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 1); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aPropSequence [1].Value = makeAny (aParameter); + } + { + aPropSequence [2].Name = CREATE_OUSTRING ("RangeXMinimum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 0); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [2].Value = makeAny (aParameter); + } + { + aPropSequence [3].Name = CREATE_OUSTRING ("RefX"); + Any aAny ((sal_Int32) 1); + aPropSequence [3].Value = makeAny (aAny); + } + aPropSequenceSequence [1] = aPropSequence; + } + aPropertyMap [PROP_Handles] <<= aPropSequenceSequence; + + aPropertyMap [PROP_MirroredX] <<= Any ((sal_Bool) sal_False); + + aPropertyMap [PROP_MirroredY] <<= Any ((sal_Bool) sal_False); + + Sequence< PropertyValue > aPropSequence (2); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Coordinates"); + Sequence< EnhancedCustomShapeParameterPair > aParameterPairSeq (10); + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 7); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [0] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 4); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [1] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 4); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 8); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [2] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 8); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [3] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [4] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 14); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 7); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [5] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 15); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [6] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [7] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 4); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [8] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 4); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 15); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [9] = aParameterPair; + } + aPropSequence [0].Value = makeAny (aParameterPairSeq); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("Segments"); + Sequence< EnhancedCustomShapeSegment > aSegmentSeq (4); + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 1; + aSegment.Count = 1; + aSegmentSeq [0] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 2; + aSegment.Count = 9; + aSegmentSeq [1] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 4; + aSegment.Count = 0; + aSegmentSeq [2] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 5; + aSegment.Count = 0; + aSegmentSeq [3] = aSegment; + } + aPropSequence [1].Value = makeAny (aSegmentSeq); + } + aPropertyMap [PROP_Path] <<= aPropSequence; + + awt::Rectangle aRectangle; + aRectangle.X = 0; + aRectangle.Y = 0; + aRectangle.Width = 4663800; + aRectangle.Height = 283680; + aPropertyMap [PROP_ViewBox] <<= aRectangle; + + aPropertyMap [ PROP_Type ] <<= CREATE_OUSTRING("ooxml-left-right-arrow"); + + Sequence< PropertyValue > aSeq = aPropertyMap.makePropertyValueSequence(); + PropertySet aPropSet( xPropSet ); + aPropSet.setProperty( PROP_CustomShapeGeometry, aSeq ); + OSL_TRACE("created ooxml preset for ooxml-left-right-arrow"); + + } else if ( maShapePresetType.equals( sStripedRightArrow ) ) { + PropertyMap aPropertyMap; + + Sequence< EnhancedCustomShapeAdjustmentValue > aAdjSequence (2); + { + Any aAny ((sal_Int32) 10000); + aAdjSequence [0].Value = aAny; + } + { + Any aAny ((sal_Int32) 10000); + aAdjSequence [1].Value = aAny; + } + aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; + + Sequence< OUString > aStringSequence (17); + aStringSequence[0] = CREATE_OUSTRING ("min(width,height)"); + aStringSequence[1] = CREATE_OUSTRING ("16875*width/?0 "); + aStringSequence[2] = CREATE_OUSTRING ("if(0-$0 ,0,if(20000-$0 ,$0 ,20000))"); + aStringSequence[3] = CREATE_OUSTRING ("if(0-$1 ,0,if(?1 -$1 ,$1 ,?1 ))"); + aStringSequence[4] = CREATE_OUSTRING ("?0 *1/6"); + aStringSequence[5] = CREATE_OUSTRING ("?0 *?3 /20000"); + aStringSequence[6] = CREATE_OUSTRING ("width+0-?5 "); + aStringSequence[7] = CREATE_OUSTRING ("height*?2 /40000"); + aStringSequence[8] = CREATE_OUSTRING ("height/2"); + aStringSequence[9] = CREATE_OUSTRING ("?8 +0-?7 "); + aStringSequence[10] = CREATE_OUSTRING ("?8 +?7 -0"); + aStringSequence[11] = CREATE_OUSTRING ("height/2"); + aStringSequence[12] = CREATE_OUSTRING ("?7 *?5 /?11 "); + aStringSequence[13] = CREATE_OUSTRING ("width+0-?12 "); + aStringSequence[14] = CREATE_OUSTRING ("height"); + aStringSequence[15] = CREATE_OUSTRING ("width"); + aStringSequence[16] = CREATE_OUSTRING ("min(width,height)/8"); + aPropertyMap [PROP_Equations] <<= aStringSequence; + + Sequence< Sequence < PropertyValue > > aPropSequenceSequence (2); + { + Sequence< PropertyValue > aPropSequence (4); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Position"); + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aPropSequence [0].Value = makeAny (aParameterPair); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("RangeYMaximum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 20000); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [1].Value = makeAny (aParameter); + } + { + aPropSequence [2].Name = CREATE_OUSTRING ("RangeYMinimum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 0); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [2].Value = makeAny (aParameter); + } + { + aPropSequence [3].Name = CREATE_OUSTRING ("RefY"); + Any aAny ((sal_Int32) 0); + aPropSequence [3].Value = makeAny (aAny); + } + aPropSequenceSequence [0] = aPropSequence; + } + { + Sequence< PropertyValue > aPropSequence (4); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Position"); + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 6); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aPropSequence [0].Value = makeAny (aParameterPair); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("RangeXMaximum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 1); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aPropSequence [1].Value = makeAny (aParameter); + } + { + aPropSequence [2].Name = CREATE_OUSTRING ("RangeXMinimum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 0); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [2].Value = makeAny (aParameter); + } + { + aPropSequence [3].Name = CREATE_OUSTRING ("RefX"); + Any aAny ((sal_Int32) 1); + aPropSequence [3].Value = makeAny (aAny); + } + aPropSequenceSequence [1] = aPropSequence; + } + aPropertyMap [PROP_Handles] <<= aPropSequenceSequence; + + aPropertyMap [PROP_MirroredX] <<= Any ((sal_Bool) sal_False); + + aPropertyMap [PROP_MirroredY] <<= Any ((sal_Bool) sal_False); + + Sequence< PropertyValue > aPropSequence (2); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Coordinates"); + Sequence< EnhancedCustomShapeParameterPair > aParameterPairSeq (15); + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [0] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + OUString str = CREATE_OUSTRING ("ssd32"); + aParameter.Value = makeAny (str); + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [1] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + OUString str = CREATE_OUSTRING ("ssd32"); + aParameter.Value = makeAny (str); + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 10); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [2] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 10); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [3] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + OUString str = CREATE_OUSTRING ("ssd16"); + aParameter.Value = makeAny (str); + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [4] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 16); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [5] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 16); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 10); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [6] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + OUString str = CREATE_OUSTRING ("ssd16"); + aParameter.Value = makeAny (str); + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 10); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [7] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 4); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [8] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 6); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [9] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 6); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [10] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 15); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 8); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [11] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 6); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 14); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [12] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 6); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 10); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [13] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 4); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 10); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [14] = aParameterPair; + } + aPropSequence [0].Value = makeAny (aParameterPairSeq); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("Segments"); + Sequence< EnhancedCustomShapeSegment > aSegmentSeq (10); + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 1; + aSegment.Count = 1; + aSegmentSeq [0] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 2; + aSegment.Count = 3; + aSegmentSeq [1] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 4; + aSegment.Count = 0; + aSegmentSeq [2] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 1; + aSegment.Count = 1; + aSegmentSeq [3] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 2; + aSegment.Count = 3; + aSegmentSeq [4] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 4; + aSegment.Count = 0; + aSegmentSeq [5] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 1; + aSegment.Count = 1; + aSegmentSeq [6] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 2; + aSegment.Count = 6; + aSegmentSeq [7] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 4; + aSegment.Count = 0; + aSegmentSeq [8] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 5; + aSegment.Count = 0; + aSegmentSeq [9] = aSegment; + } + aPropSequence [1].Value = makeAny (aSegmentSeq); + } + aPropertyMap [PROP_Path] <<= aPropSequence; + + awt::Rectangle aRectangle; + aRectangle.X = 0; + aRectangle.Y = 0; + aRectangle.Width = 4663800; + aRectangle.Height = 283680; + aPropertyMap [PROP_ViewBox] <<= aRectangle; + + aPropertyMap [ PROP_Type ] <<= CREATE_OUSTRING("ooxml-striped-right-arrow"); + + Sequence< PropertyValue > aSeq = aPropertyMap.makePropertyValueSequence(); + PropertySet aPropSet( xPropSet ); + aPropSet.setProperty( PROP_CustomShapeGeometry, aSeq ); + OSL_TRACE("created ooxml preset for ooxml-striped-right-arrow"); + + } else if ( maShapePresetType.equals( sRightArrow ) ) { + PropertyMap aPropertyMap; + + Sequence< EnhancedCustomShapeAdjustmentValue > aAdjSequence (2); + { + Any aAny ((sal_Int32) 18000); + aAdjSequence [0].Value = aAny; + } + { + Any aAny ((sal_Int32) 10000); + aAdjSequence [1].Value = aAny; + } + aPropertyMap [PROP_AdjustmentValues] <<= aAdjSequence; + + Sequence< OUString > aStringSequence (15); + aStringSequence[0] = CREATE_OUSTRING ("min(width,height)"); + aStringSequence[1] = CREATE_OUSTRING ("20000*width/?0 "); + aStringSequence[2] = CREATE_OUSTRING ("if(0-$0 ,0,if(20000-$0 ,$0 ,20000))"); + aStringSequence[3] = CREATE_OUSTRING ("if(0-$1 ,0,if(?1 -$1 ,$1 ,?1 ))"); + aStringSequence[4] = CREATE_OUSTRING ("?0 *?3 /20000"); + aStringSequence[5] = CREATE_OUSTRING ("width+0-?4 "); + aStringSequence[6] = CREATE_OUSTRING ("height*?2 /40000"); + aStringSequence[7] = CREATE_OUSTRING ("height/2"); + aStringSequence[8] = CREATE_OUSTRING ("?7 +0-?6 "); + aStringSequence[9] = CREATE_OUSTRING ("?7 +?6 -0"); + aStringSequence[10] = CREATE_OUSTRING ("height/2"); + aStringSequence[11] = CREATE_OUSTRING ("?8 *?4 /?10 "); + aStringSequence[12] = CREATE_OUSTRING ("?5 +?11 -0"); + aStringSequence[13] = CREATE_OUSTRING ("height"); + aStringSequence[14] = CREATE_OUSTRING ("width"); + aPropertyMap [PROP_Equations] <<= aStringSequence; + + Sequence< Sequence < PropertyValue > > aPropSequenceSequence (2); + { + Sequence< PropertyValue > aPropSequence (4); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Position"); + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 8); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aPropSequence [0].Value = makeAny (aParameterPair); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("RangeYMaximum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 20000); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [1].Value = makeAny (aParameter); + } + { + aPropSequence [2].Name = CREATE_OUSTRING ("RangeYMinimum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 0); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [2].Value = makeAny (aParameter); + } + { + aPropSequence [3].Name = CREATE_OUSTRING ("RefY"); + Any aAny ((sal_Int32) 0); + aPropSequence [3].Value = makeAny (aAny); + } + aPropSequenceSequence [0] = aPropSequence; + } + { + Sequence< PropertyValue > aPropSequence (4); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Position"); + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aPropSequence [0].Value = makeAny (aParameterPair); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("RangeXMaximum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 1); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aPropSequence [1].Value = makeAny (aParameter); + } + { + aPropSequence [2].Name = CREATE_OUSTRING ("RangeXMinimum"); + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 0); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::NORMAL; + aPropSequence [2].Value = makeAny (aParameter); + } + { + aPropSequence [3].Name = CREATE_OUSTRING ("RefX"); + Any aAny ((sal_Int32) 1); + aPropSequence [3].Value = makeAny (aAny); + } + aPropSequenceSequence [1] = aPropSequence; + } + aPropertyMap [PROP_Handles] <<= aPropSequenceSequence; + + aPropertyMap [PROP_MirroredX] <<= Any ((sal_Bool) sal_False); + + aPropertyMap [PROP_MirroredY] <<= Any ((sal_Bool) sal_False); + + Sequence< PropertyValue > aPropSequence (2); + { + aPropSequence [0].Name = CREATE_OUSTRING ("Coordinates"); + Sequence< EnhancedCustomShapeParameterPair > aParameterPairSeq (7); + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 8); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [0] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 8); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [1] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [2] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 14); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 7); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [3] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 13); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [4] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 5); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [5] = aParameterPair; + } + { + EnhancedCustomShapeParameterPair aParameterPair; + { + EnhancedCustomShapeParameter aParameter; + aParameterPair.First = aParameter; + } + { + EnhancedCustomShapeParameter aParameter; + Any aAny ((sal_Int32) 9); + aParameter.Value = aAny; + aParameter.Type = EnhancedCustomShapeParameterType::EQUATION; + aParameterPair.Second = aParameter; + } + aParameterPairSeq [6] = aParameterPair; + } + aPropSequence [0].Value = makeAny (aParameterPairSeq); + } + { + aPropSequence [1].Name = CREATE_OUSTRING ("Segments"); + Sequence< EnhancedCustomShapeSegment > aSegmentSeq (4); + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 1; + aSegment.Count = 1; + aSegmentSeq [0] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 2; + aSegment.Count = 6; + aSegmentSeq [1] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 4; + aSegment.Count = 0; + aSegmentSeq [2] = aSegment; + } + { + EnhancedCustomShapeSegment aSegment; + aSegment.Command = 5; + aSegment.Count = 0; + aSegmentSeq [3] = aSegment; + } + aPropSequence [1].Value = makeAny (aSegmentSeq); + } + aPropertyMap [PROP_Path] <<= aPropSequence; + + awt::Rectangle aRectangle; + aRectangle.X = 0; + aRectangle.Y = 0; + aRectangle.Width = 1050480; + aRectangle.Height = 456840; + aPropertyMap [PROP_ViewBox] <<= aRectangle; + + + aPropertyMap [ PROP_Type ] <<= CREATE_OUSTRING("ooxml-right-arrow"); + //aPropertyMap[ PROP_Type ] <<= CREATE_OUSTRING( "non-primitive" ); + + Sequence< PropertyValue > aSeq = aPropertyMap.makePropertyValueSequence(); + PropertySet aPropSet( xPropSet ); + aPropSet.setProperty( PROP_CustomShapeGeometry, aSeq ); + OSL_TRACE("created ooxml preset"); + +#ifdef DEBUG + aPropertyMap.dump(); + aPropertyMap.dumpCode(); +#endif + } else { + //const uno::Reference < drawing::XShape > xShape( xPropSet, UNO_QUERY ); + Reference< drawing::XEnhancedCustomShapeDefaulter > xDefaulter( xShape, UNO_QUERY ); + if( xDefaulter.is() ) + xDefaulter->createCustomShapeDefaults( maShapePresetType ); + } if ( maAdjustmentGuideList.size() ) { @@ -128,6 +1944,11 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi aAdjustmentVal.State = PropertyState_DIRECT_VALUE; aAdjustmentSeq[ nAdjustmentIndex ] = aAdjustmentVal; } + } else if ( aAdjustmentSeq.getLength() > 0 ) { + EnhancedCustomShapeAdjustmentValue aAdjustmentVal; + aAdjustmentVal.Value <<= (*aIter).maFormula.toInt32(); + aAdjustmentVal.State = PropertyState_DIRECT_VALUE; + aAdjustmentSeq[ 0 ] = aAdjustmentVal; } aIter++; } @@ -135,7 +1956,7 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi xPropSet->setPropertyValue( sCustomShapeGeometry, Any( aGeoPropSeq ) ); } } - else if ( aGeoPropSeq[ i ].Name.equals( sType ) ) + else if ( aGeoPropSeq[ i ].Name.equals( sType ) && !maShapePresetType.equals ( CREATE_OUSTRING ( "right-arrow" ) ) ) { aGeoPropSeq[ i ].Value <<= maShapePresetType; } @@ -202,7 +2023,7 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi // to determine the correct adjustment handle that should be updated with the adjustment // position. here is the solution: the adjustment value that is used within the position // has to be updated, in case the position is a formula the first usage of a - // adjument value is decisive + // adjustment value is decisive if ( maAdjustHandleList[ i ].polar ) { aHandle[ PROP_Position ] <<= maAdjustHandleList[ i ].pos; @@ -248,6 +2069,10 @@ void CustomShapeProperties::pushToPropSet( const ::oox::core::FilterBase& /* rFi } aPropertyMap[ PROP_Handles ] <<= aHandles; +#ifdef DEBUG + aPropertyMap.dump(); + aPropertyMap.dumpCode(); +#endif // converting the vector to a sequence Sequence< PropertyValue > aSeq = aPropertyMap.makePropertyValueSequence(); PropertySet aPropSet( xPropSet ); @@ -266,3 +2091,5 @@ double CustomShapeProperties::getValue( const std::vector< CustomShapeGuide >& r } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/diagram/datamodelcontext.cxx b/oox/source/drawingml/diagram/datamodelcontext.cxx index 8d81c800b2df..230edf59ea67 100644 --- a/oox/source/drawingml/diagram/datamodelcontext.cxx +++ b/oox/source/drawingml/diagram/datamodelcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -332,3 +333,5 @@ DataModelContext::createFastChildContext( ::sal_Int32 aElement, } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index cebb730af103..30c6e5b78134 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -129,7 +130,7 @@ void DiagramLayout::layout( const dgm::PointsTreePtr & pTree, const awt::Point & awt::Point nextPt = pt; nextPt.Y += 50; dgm::PointsTree::Childrens::const_iterator iter; - for( iter = pTree->beginChild(); iter != pTree->endChild(); iter++ ) + for( iter = pTree->beginChild(); iter != pTree->endChild(); ++iter ) { layout( *iter, nextPt ); nextPt.X += 50; @@ -241,7 +242,7 @@ void Diagram::build( ) mpRoot = aRoots.begin()->second; OSL_TRACE( "root is %s", OUSTRING_TO_CSTR( mpRoot->getPoint()->getModelId() ) ); for( PointsTreeMap::iterator iter = aTreeMap.begin(); - iter != aTreeMap.end(); iter++ ) + iter != aTreeMap.end(); ++iter ) { if(! iter->second->getParent() ) { @@ -295,3 +296,5 @@ OUString Diagram::getLayoutId() const } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx index ac98bfb18c38..a405926761c1 100644 --- a/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx +++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -113,3 +114,5 @@ DiagramDefinitionContext::createFastChildContext( ::sal_Int32 aElement, } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx b/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx index 99407aed80d3..43af67efd4b0 100644 --- a/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx +++ b/oox/source/drawingml/diagram/diagramdefinitioncontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -49,3 +50,5 @@ private: } } #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/diagram/diagramfragmenthandler.cxx b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx index 644e84771b3e..5d905bcbf384 100644 --- a/oox/source/drawingml/diagram/diagramfragmenthandler.cxx +++ b/oox/source/drawingml/diagram/diagramfragmenthandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -220,3 +221,5 @@ DiagramColorsFragmentHandler::createFastChildContext( ::sal_Int32 aElement, } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index a351189f3067..dd213fda6c36 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -139,3 +140,5 @@ bool ConditionAtom::test() } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/diagram/layoutnodecontext.cxx b/oox/source/drawingml/diagram/layoutnodecontext.cxx index 0815843dd424..3edf483555da 100644 --- a/oox/source/drawingml/diagram/layoutnodecontext.cxx +++ b/oox/source/drawingml/diagram/layoutnodecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -220,7 +221,7 @@ void SAL_CALL LayoutNodeContext::endFastElement( ::sal_Int32 ) } /** convert the XML tag to a variable index in the array - * @param aTag the tag, wihout namespace + * @param aTag the tag, without namespace * @return the variable index. -1 is an error */ sal_Int32 LayoutNodeContext::tagToVarIdx( sal_Int32 aTag ) @@ -354,3 +355,5 @@ LayoutNodeContext::createFastChildContext( ::sal_Int32 aElement, } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/diagram/layoutnodecontext.hxx b/oox/source/drawingml/diagram/layoutnodecontext.hxx index 19cb19aa602d..0b2270bb0a86 100644 --- a/oox/source/drawingml/diagram/layoutnodecontext.hxx +++ b/oox/source/drawingml/diagram/layoutnodecontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -50,3 +51,5 @@ private: } } #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/drawingmltypes.cxx b/oox/source/drawingml/drawingmltypes.cxx index f99fdc21ab55..915a3146dd3d 100644 --- a/oox/source/drawingml/drawingmltypes.cxx +++ b/oox/source/drawingml/drawingmltypes.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -293,3 +294,4 @@ IndexRange GetIndexRange( const Reference< XFastAttributeList >& xAttributes ) } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/embeddedwavaudiofile.cxx b/oox/source/drawingml/embeddedwavaudiofile.cxx index 5c9484894109..2edea7949711 100644 --- a/oox/source/drawingml/embeddedwavaudiofile.cxx +++ b/oox/source/drawingml/embeddedwavaudiofile.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -51,3 +52,5 @@ namespace oox { namespace drawingml { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx index 8b49398eb96a..699f8a92ab65 100644 --- a/oox/source/drawingml/fillproperties.cxx +++ b/oox/source/drawingml/fillproperties.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -415,3 +416,4 @@ void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelpe } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/fillpropertiesgroupcontext.cxx b/oox/source/drawingml/fillpropertiesgroupcontext.cxx index 15b1ef0f2404..82a2f5906923 100644 --- a/oox/source/drawingml/fillpropertiesgroupcontext.cxx +++ b/oox/source/drawingml/fillpropertiesgroupcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -306,3 +307,4 @@ SimpleFillPropertiesContext::~SimpleFillPropertiesContext() } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/graphicshapecontext.cxx b/oox/source/drawingml/graphicshapecontext.cxx index 646017aa22ea..5df5c45de1c3 100644 --- a/oox/source/drawingml/graphicshapecontext.cxx +++ b/oox/source/drawingml/graphicshapecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -124,11 +125,11 @@ Reference< XFastContextHandler > GraphicalObjectFrameContext::createFastChildCon case XML_graphicData : // CT_GraphicalObjectData { OUString sUri( xAttribs->getOptionalValue( XML_uri ) ); - if ( sUri.equalsAscii( "http://schemas.openxmlformats.org/presentationml/2006/ole" ) ) + if ( sUri.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "http://schemas.openxmlformats.org/presentationml/2006/ole" ) ) ) xRet.set( new OleObjectGraphicDataContext( *this, mpShapePtr ) ); - else if ( sUri.equalsAscii( "http://schemas.openxmlformats.org/drawingml/2006/diagram" ) ) + else if ( sUri.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "http://schemas.openxmlformats.org/drawingml/2006/diagram" ) ) ) xRet.set( new DiagramGraphicDataContext( *this, mpShapePtr ) ); - else if ( sUri.equalsAscii( "http://schemas.openxmlformats.org/drawingml/2006/chart" ) ) + else if ( sUri.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "http://schemas.openxmlformats.org/drawingml/2006/chart" ) ) ) xRet.set( new ChartGraphicDataContext( *this, mpShapePtr, mbEmbedShapesInChart ) ); else if ( sUri.compareToAscii( "http://schemas.openxmlformats.org/drawingml/2006/table" ) == 0 ) xRet.set( new table::TableContext( *this, mpShapePtr ) ); @@ -315,3 +316,4 @@ Reference< XFastContextHandler > ChartGraphicDataContext::createFastChildContext } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/guidcontext.cxx b/oox/source/drawingml/guidcontext.cxx index d5fbc10783ac..83665c5c2922 100644 --- a/oox/source/drawingml/guidcontext.cxx +++ b/oox/source/drawingml/guidcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -45,3 +46,5 @@ void GuidContext::characters( const OUString& aChars ) throw ( SAXException, Run } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/hyperlinkcontext.cxx b/oox/source/drawingml/hyperlinkcontext.cxx index 2b2b1ee1cef6..1975561ab808 100644 --- a/oox/source/drawingml/hyperlinkcontext.cxx +++ b/oox/source/drawingml/hyperlinkcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -174,3 +175,4 @@ Reference< XFastContextHandler > HyperLinkContext::createFastChildContext( } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/hyperlinkcontext.hxx b/oox/source/drawingml/hyperlinkcontext.hxx index aa5b5f0a19ec..1d57e612fff2 100644 --- a/oox/source/drawingml/hyperlinkcontext.hxx +++ b/oox/source/drawingml/hyperlinkcontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -56,3 +57,4 @@ protected: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx index 3f3c295ba0a8..2fd4a37d292f 100644 --- a/oox/source/drawingml/lineproperties.cxx +++ b/oox/source/drawingml/lineproperties.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -92,7 +93,7 @@ void lclConvertPresetDash( LineDash& orLineDash, sal_Int32 nPresetDash ) case XML_sysDashDotDot: lclSetDashData( orLineDash, 2, 1, 1, 3, 1 ); break; default: - OSL_ENSURE( false, "lclConvertPresetDash - unsupported preset dash" ); + OSL_FAIL( "lclConvertPresetDash - unsupported preset dash" ); lclSetDashData( orLineDash, 0, 0, 1, 4, 3 ); } } @@ -106,7 +107,7 @@ void lclConvertCustomDash( LineDash& orLineDash, const LineProperties::DashStopV { if( rCustomDash.empty() ) { - OSL_ENSURE( false, "lclConvertCustomDash - unexpected empty custom dash" ); + OSL_FAIL( "lclConvertCustomDash - unexpected empty custom dash" ); lclSetDashData( orLineDash, 0, 0, 1, 4, 3 ); return; } @@ -429,3 +430,4 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap, } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/linepropertiescontext.cxx b/oox/source/drawingml/linepropertiescontext.cxx index a200b60f9e4b..d9cf4b684640 100644 --- a/oox/source/drawingml/linepropertiescontext.cxx +++ b/oox/source/drawingml/linepropertiescontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -104,3 +105,5 @@ Reference< XFastContextHandler > LinePropertiesContext::createFastChildContext( } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/objectdefaultcontext.cxx b/oox/source/drawingml/objectdefaultcontext.cxx index d233379f9b02..7c29cc06b273 100644 --- a/oox/source/drawingml/objectdefaultcontext.cxx +++ b/oox/source/drawingml/objectdefaultcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -57,3 +58,5 @@ Reference< XFastContextHandler > objectDefaultContext::createFastChildContext( s } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index d108eb06aff8..2524e190a793 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -49,8 +50,10 @@ #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/drawing/HomogenMatrix3.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/text/XText.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> #include <basegfx/point/b2dpoint.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> @@ -65,13 +68,15 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::text; using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::style; namespace oox { namespace drawingml { // ============================================================================ Shape::Shape( const sal_Char* pServiceName ) -: mpLinePropertiesPtr( new LineProperties ) +: mbIsChild( false ) +, mpLinePropertiesPtr( new LineProperties ) , mpFillPropertiesPtr( new FillProperties ) , mpGraphicPropertiesPtr( new GraphicProperties ) , mpCustomShapePropertiesPtr( new CustomShapeProperties ) @@ -102,13 +107,15 @@ table::TablePropertiesPtr Shape::getTableProperties() void Shape::setDefaults() { - maShapeProperties[ PROP_TextAutoGrowHeight ] <<= false; - maShapeProperties[ PROP_TextWordWrap ] <<= true; - maShapeProperties[ PROP_TextLeftDistance ] <<= static_cast< sal_Int32 >( 250 ); - maShapeProperties[ PROP_TextUpperDistance ] <<= static_cast< sal_Int32 >( 125 ); - maShapeProperties[ PROP_TextRightDistance ] <<= static_cast< sal_Int32 >( 250 ); - maShapeProperties[ PROP_TextLowerDistance ] <<= static_cast< sal_Int32 >( 125 ); - maShapeProperties[ PROP_CharHeight ] <<= static_cast< float >( 18.0 ); + maDefaultShapeProperties[ PROP_TextAutoGrowHeight ] <<= false; + maDefaultShapeProperties[ PROP_TextWordWrap ] <<= true; + maDefaultShapeProperties[ PROP_TextLeftDistance ] <<= static_cast< sal_Int32 >( 250 ); + maDefaultShapeProperties[ PROP_TextUpperDistance ] <<= static_cast< sal_Int32 >( 125 ); + maDefaultShapeProperties[ PROP_TextRightDistance ] <<= static_cast< sal_Int32 >( 250 ); + maDefaultShapeProperties[ PROP_TextLowerDistance ] <<= static_cast< sal_Int32 >( 125 ); + maDefaultShapeProperties[ PROP_CharHeight ] <<= static_cast< float >( 18.0 ); + maDefaultShapeProperties[ PROP_TextVerticalAdjust ] <<= TextVerticalAdjust_TOP; + maDefaultShapeProperties[ PROP_ParaAdjust ] <<= static_cast< sal_Int16 >( ParagraphAdjust_LEFT ); // check for RTL? } ::oox::vml::OleObjectInfo& Shape::setOleObjectType() @@ -161,6 +168,7 @@ void Shape::addShape( ::oox::core::XmlFilterBase& rFilterBase, const Theme* pTheme, const Reference< XShapes >& rxShapes, + basegfx::B2DHomMatrix& aTransformation, const awt::Rectangle* pShapeRect, ShapeIdMap* pShapeMap ) { @@ -169,7 +177,8 @@ void Shape::addShape( rtl::OUString sServiceName( msServiceName ); if( sServiceName.getLength() ) { - Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, sal_False ) ); + basegfx::B2DHomMatrix aMatrix( aTransformation ); + Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, sal_False, aMatrix ) ); if( pShapeMap && msId.getLength() ) { @@ -179,7 +188,7 @@ void Shape::addShape( // 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 ); + addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap, aMatrix ); } Reference< document::XActionLockable > xLockable( mxShape, UNO_QUERY ); if( xLockable.is() ) @@ -192,7 +201,10 @@ void Shape::addShape( void Shape::applyShapeReference( const Shape& rReferencedShape ) { - mpTextBody = TextBodyPtr( new TextBody( *rReferencedShape.mpTextBody.get() ) ); + if ( rReferencedShape.mpTextBody.get() ) + mpTextBody = TextBodyPtr( new TextBody( *rReferencedShape.mpTextBody.get() ) ); + else + mpTextBody.reset(); maShapeProperties = rReferencedShape.maShapeProperties; mpLinePropertiesPtr = LinePropertiesPtr( new LineProperties( *rReferencedShape.mpLinePropertiesPtr.get() ) ); mpFillPropertiesPtr = FillPropertiesPtr( new FillProperties( *rReferencedShape.mpFillPropertiesPtr.get() ) ); @@ -214,57 +226,30 @@ void Shape::addChildren( Shape& rMaster, const Theme* pTheme, const Reference< XShapes >& rxShapes, - const awt::Rectangle& rClientRect, - ShapeIdMap* pShapeMap ) + const awt::Rectangle&, + ShapeIdMap* pShapeMap, + basegfx::B2DHomMatrix& aTransformation ) { - // first the global child union needs to be calculated - sal_Int32 nGlobalLeft = SAL_MAX_INT32; - sal_Int32 nGlobalRight = SAL_MIN_INT32; - sal_Int32 nGlobalTop = SAL_MAX_INT32; - sal_Int32 nGlobalBottom= SAL_MIN_INT32; + basegfx::B2DHomMatrix aChildTransformation; + + aChildTransformation.translate(-maChPosition.X, -maChPosition.Y); + aChildTransformation.scale(1/(maChSize.Width ? maChSize.Width : 1.0), 1/(maChSize.Height ? maChSize.Height : 1.0)); + aChildTransformation *= aTransformation; + + OSL_TRACE("parent matrix:\n%f %f %f\n%f %f %f\n%f %f %f", + aChildTransformation.get(0, 0), + aChildTransformation.get(0, 1), + aChildTransformation.get(0, 2), + aChildTransformation.get(1, 0), + aChildTransformation.get(1, 1), + aChildTransformation.get(1, 2), + aChildTransformation.get(2, 0), + aChildTransformation.get(2, 1), + aChildTransformation.get(2, 2)); + std::vector< ShapePtr >::iterator aIter( rMaster.maChildren.begin() ); while( aIter != rMaster.maChildren.end() ) - { - sal_Int32 l = (*aIter)->maPosition.X; - sal_Int32 t = (*aIter)->maPosition.Y; - sal_Int32 r = l + (*aIter)->maSize.Width; - sal_Int32 b = t + (*aIter)->maSize.Height; - if ( nGlobalLeft > l ) - nGlobalLeft = l; - if ( nGlobalRight < r ) - nGlobalRight = r; - if ( nGlobalTop > t ) - nGlobalTop = t; - if ( nGlobalBottom < b ) - nGlobalBottom = b; - aIter++; - } - aIter = rMaster.maChildren.begin(); - while( aIter != rMaster.maChildren.end() ) - { - awt::Rectangle aShapeRect; - awt::Rectangle* pShapeRect = 0; - if ( ( nGlobalLeft != SAL_MAX_INT32 ) && ( nGlobalRight != SAL_MIN_INT32 ) && ( nGlobalTop != SAL_MAX_INT32 ) && ( nGlobalBottom != SAL_MIN_INT32 ) ) - { - sal_Int32 nGlobalWidth = nGlobalRight - nGlobalLeft; - sal_Int32 nGlobalHeight = nGlobalBottom - nGlobalTop; - if ( nGlobalWidth && nGlobalHeight ) - { - double fWidth = (*aIter)->maSize.Width; - double fHeight= (*aIter)->maSize.Height; - double fXScale = (double)rClientRect.Width / (double)nGlobalWidth; - double fYScale = (double)rClientRect.Height / (double)nGlobalHeight; - aShapeRect.X = static_cast< sal_Int32 >( ( ( (*aIter)->maPosition.X - nGlobalLeft ) * fXScale ) + rClientRect.X ); - aShapeRect.Y = static_cast< sal_Int32 >( ( ( (*aIter)->maPosition.Y - nGlobalTop ) * fYScale ) + rClientRect.Y ); - fWidth *= fXScale; - fHeight *= fYScale; - aShapeRect.Width = static_cast< sal_Int32 >( fWidth ); - aShapeRect.Height = static_cast< sal_Int32 >( fHeight ); - pShapeRect = &aShapeRect; - } - } - (*aIter++)->addShape( rFilterBase, pTheme, rxShapes, pShapeRect, pShapeMap ); - } + (*aIter++)->addShape( rFilterBase, pTheme, rxShapes, aChildTransformation, NULL, pShapeMap ); } Reference< XShape > Shape::createAndInsert( @@ -272,23 +257,23 @@ Reference< XShape > Shape::createAndInsert( const rtl::OUString& rServiceName, const Theme* pTheme, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes, - const awt::Rectangle* pShapeRect, - sal_Bool bClearText ) + const awt::Rectangle* /* pShapeRect */, + sal_Bool bClearText, + basegfx::B2DHomMatrix& aParentTransformation ) { - awt::Size aSize( pShapeRect ? awt::Size( pShapeRect->Width, pShapeRect->Height ) : maSize ); - awt::Point aPosition( pShapeRect ? awt::Point( pShapeRect->X, pShapeRect->Y ) : maPosition ); - awt::Rectangle aShapeRectHmm( aPosition.X / 360, aPosition.Y / 360, aSize.Width / 360, aSize.Height / 360 ); + awt::Rectangle aShapeRectHmm( maPosition.X / 360, maPosition.Y / 360, maSize.Width / 360, maSize.Height / 360 ); OUString aServiceName = finalizeServiceName( rFilterBase, rServiceName, aShapeRectHmm ); - sal_Bool bIsCustomShape = aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.CustomShape" ) ); + sal_Bool bIsCustomShape = aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.CustomShape" ) ) || aServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.drawing.ConnectorShape" ) ); basegfx::B2DHomMatrix aTransformation; - if( aSize.Width != 1 || aSize.Height != 1) + + if( maSize.Width != 1 || maSize.Height != 1) { // take care there are no zeros used by error aTransformation.scale( - aSize.Width ? aSize.Width / 360.0 : 1.0, - aSize.Height ? aSize.Height / 360.0 : 1.0 ); + maSize.Width ? maSize.Width : 1.0, + maSize.Height ? maSize.Height : 1.0 ); } if( mbFlipH || mbFlipV || mnRotation != 0) @@ -316,14 +301,18 @@ Reference< XShape > Shape::createAndInsert( aTransformation.translate( aCenter.getX(), aCenter.getY() ); } - if( aPosition.X != 0 || aPosition.Y != 0) + if( maPosition.X != 0 || maPosition.Y != 0) { // if global position is used, add it to transformation - aTransformation.translate( aPosition.X / 360.0, aPosition.Y / 360.0 ); + aTransformation.translate( maPosition.X, maPosition.Y ); } + aTransformation = aParentTransformation*aTransformation; + aParentTransformation = aTransformation; + aTransformation.scale(1/360.0, 1/360.0); + // special for lineshape - if ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.LineShape" ) ) + if ( aServiceName == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.LineShape")) ) { ::basegfx::B2DPolygon aPoly; aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) ); @@ -344,7 +333,7 @@ Reference< XShape > Shape::createAndInsert( maShapeProperties[ PROP_PolyPolygon ] <<= aPolyPolySequence; } - else if ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.ConnectorShape" ) ) + else if ( aServiceName == OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ConnectorShape")) ) { ::basegfx::B2DPolygon aPoly; aPoly.insert( 0, ::basegfx::B2DPoint( 0, 0 ) ); @@ -364,6 +353,7 @@ Reference< XShape > Shape::createAndInsert( // now set transformation for this object HomogenMatrix3 aMatrix; + aMatrix.Line1.Column1 = aTransformation.get(0,0); aMatrix.Line1.Column2 = aTransformation.get(0,1); aMatrix.Line1.Column3 = aTransformation.get(0,2); @@ -378,6 +368,7 @@ Reference< XShape > Shape::createAndInsert( maShapeProperties[ PROP_Transformation ] <<= aMatrix; } + Reference< lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW ); if ( !mxShape.is() ) mxShape = Reference< drawing::XShape >( xServiceFact->createInstance( aServiceName ), UNO_QUERY_THROW ); @@ -456,9 +447,10 @@ Reference< XShape > Shape::createAndInsert( // applying properties aShapeProps.assignUsed( getShapeProperties() ); - if ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.GraphicObjectShape" ) ) + aShapeProps.assignUsed( maDefaultShapeProperties ); + if ( aServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GraphicObjectShape")) ) mpGraphicPropertiesPtr->pushToPropMap( aShapeProps, rGraphicHelper ); - if ( mpTablePropertiesPtr.get() && ( aServiceName == OUString::createFromAscii( "com.sun.star.drawing.TableShape" ) ) ) + if ( mpTablePropertiesPtr.get() && aServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape")) ) mpTablePropertiesPtr->pushToPropSet( rFilterBase, xSet, mpMasterTextListStyle ); aFillProperties.pushToPropMap( aShapeProps, rGraphicHelper, mnRotation, nFillPhClr ); aLineProperties.pushToPropMap( aShapeProps, rGraphicHelper, nLinePhClr ); @@ -473,7 +465,7 @@ Reference< XShape > Shape::createAndInsert( xSet->setPropertyValue( rPropName, Any( false ) ); // do not set properties at a group shape (this causes assertions from svx) - if( aServiceName != OUString::createFromAscii( "com.sun.star.drawing.GroupShape" ) ) + if( aServiceName != OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GroupShape")) ) PropertySet( xSet ).setProperties( aShapeProps ); if( bIsCustomShape ) @@ -522,7 +514,7 @@ void addMissingProperties( const PropertyMap& rSource, PropertyMap& rDest ) { if ( rDest.find( (*aSourceIter ).first ) == rDest.end() ) rDest[ (*aSourceIter).first ] <<= (*aSourceIter).second; - aSourceIter++; + ++aSourceIter; } } @@ -616,3 +608,5 @@ void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >& // ============================================================================ } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/shapecontext.cxx b/oox/source/drawingml/shapecontext.cxx index d4781fdaa436..f613e89ce6a9 100644 --- a/oox/source/drawingml/shapecontext.cxx +++ b/oox/source/drawingml/shapecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -39,6 +40,7 @@ #include "oox/drawingml/drawingmltypes.hxx" #include "oox/drawingml/customshapegeometry.hxx" #include "oox/drawingml/textbodycontext.hxx" +#include "hyperlinkcontext.hxx" using rtl::OUString; using namespace oox::core; @@ -91,9 +93,14 @@ Reference< XFastContextHandler > ShapeContext::createFastChildContext( sal_Int32 mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); break; } + case XML_hlinkMouseOver: + case XML_hlinkClick: + xRet = new HyperLinkContext( *this, xAttribs, getShape()->getShapeProperties() ); + break; case XML_ph: mpShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); - mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + if( xAttribs->hasAttribute( XML_idx ) ) + mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); break; // nvSpPr CT_ShapeNonVisual end @@ -125,3 +132,5 @@ Reference< XFastContextHandler > ShapeContext::createFastChildContext( sal_Int32 } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/shapegroupcontext.cxx b/oox/source/drawingml/shapegroupcontext.cxx index 183302667066..81c396b170ef 100644 --- a/oox/source/drawingml/shapegroupcontext.cxx +++ b/oox/source/drawingml/shapegroupcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -78,7 +79,8 @@ Reference< XFastContextHandler > ShapeGroupContext::createFastChildContext( sal_ } case XML_ph: mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) ); - mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + if( xAttribs->hasAttribute( XML_idx ) ) + mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); break; // nvSpPr CT_ShapeNonVisual end @@ -117,3 +119,5 @@ Reference< XFastContextHandler > ShapeGroupContext::createFastChildContext( sal_ } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/shapepropertiescontext.cxx b/oox/source/drawingml/shapepropertiescontext.cxx index 13fd8c421784..2cc1874a29bb 100644 --- a/oox/source/drawingml/shapepropertiescontext.cxx +++ b/oox/source/drawingml/shapepropertiescontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -117,3 +118,5 @@ Reference< XFastContextHandler > ShapePropertiesContext::createFastChildContext( } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/shapestylecontext.cxx b/oox/source/drawingml/shapestylecontext.cxx index a1ae5df43cda..e0ba3dc7f4c0 100644 --- a/oox/source/drawingml/shapestylecontext.cxx +++ b/oox/source/drawingml/shapestylecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -84,3 +85,4 @@ Reference< XFastContextHandler > ShapeStyleContext::createFastChildContext( sal_ } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/spdefcontext.cxx b/oox/source/drawingml/spdefcontext.cxx index da86e031ddec..387cddd0b83b 100644 --- a/oox/source/drawingml/spdefcontext.cxx +++ b/oox/source/drawingml/spdefcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -74,3 +75,5 @@ Reference< XFastContextHandler > spDefContext::createFastChildContext( sal_Int32 } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablebackgroundstylecontext.cxx b/oox/source/drawingml/table/tablebackgroundstylecontext.cxx index 075e8ded9b31..ea23e72fdf3e 100644 --- a/oox/source/drawingml/table/tablebackgroundstylecontext.cxx +++ b/oox/source/drawingml/table/tablebackgroundstylecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -89,3 +90,5 @@ TableBackgroundStyleContext::createFastChildContext( ::sal_Int32 aElementToken, } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablecell.cxx b/oox/source/drawingml/table/tablecell.cxx index af1a96b7a358..be51773de826 100644 --- a/oox/source/drawingml/table/tablecell.cxx +++ b/oox/source/drawingml/table/tablecell.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -35,7 +36,7 @@ #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/table/XTable.hpp> #include <com/sun/star/table/XMergeableCellRange.hpp> -#include <com/sun/star/table/BorderLine.hpp> +#include <com/sun/star/table/BorderLine2.hpp> #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> @@ -46,7 +47,7 @@ using namespace ::oox::core; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; -using ::com::sun::star::table::BorderLine; +using ::com::sun::star::table::BorderLine2; using ::com::sun::star::drawing::LineStyle; namespace oox { namespace drawingml { namespace table { @@ -74,7 +75,7 @@ void applyLineAttributes( const ::oox::core::XmlFilterBase& rFilterBase, Reference< XPropertySet >& rxPropSet, oox::drawingml::LineProperties& rLineProperties, sal_Int32 nPropId ) { - BorderLine aBorderLine( 0, 0, 0, 0 ); + BorderLine2 aBorderLine; if( rLineProperties.maLineFill.moFillType.differsFrom( XML_noFill ) ) { Color aColor = rLineProperties.maLineFill.getBestSolidColor(); @@ -96,7 +97,7 @@ void applyBorder( TableStylePart& rTableStylePart, sal_Int32 nLineType, oox::dra rLineProperties.assignUsed( *aIter->second ); } -void applyTableStylePart( const ::oox::core::XmlFilterBase& rFilterBase, const Reference < ::com::sun::star::table::XCell >& rxCell, oox::drawingml::FillProperties& rFillProperties, +void applyTableStylePart( const ::oox::core::XmlFilterBase& rFilterBase, const Reference < text::XTextRange >& rxStart, oox::drawingml::FillProperties& rFillProperties, oox::drawingml::LineProperties& rLeftBorder, oox::drawingml::LineProperties& rRightBorder, oox::drawingml::LineProperties& rTopBorder, @@ -122,9 +123,13 @@ void applyTableStylePart( const ::oox::core::XmlFilterBase& rFilterBase, const R aTextCharProps.maComplexFont = rTableStylePart.getComplexFont(); aTextCharProps.maSymbolFont = rTableStylePart.getSymbolFont(); aTextCharProps.maCharColor = rTableStylePart.getTextColor(); + if( rTableStylePart.getTextBoldStyle().is_initialized() ) + aTextCharProps.moBold = rTableStylePart.getTextBoldStyle(); + if( rTableStylePart.getTextItalicStyle().is_initialized() ) + aTextCharProps.moItalic = rTableStylePart.getTextItalicStyle(); - PropertySet aPropSet( rxCell ); - aTextCharProps.pushToPropSet( aPropSet, rFilterBase ); + PropertySet aPropSet( rxStart ); + aTextCharProps.pushToPropSet( aPropSet, rFilterBase, true ); } void applyTableCellProperties( const Reference < ::com::sun::star::table::XCell >& rxCell, const TableCell& rTableCell ) @@ -167,6 +172,9 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo applyTableCellProperties( rxCell, *this ); TextCharacterProperties aTextStyleProps; getTextBody()->insertAt( rFilterBase, xText, xAt, aTextStyleProps, pMasterTextListStyle ); + xAt->gotoStart( sal_True ); + Reference< text::XTextRange > xStart( xAt, UNO_QUERY ); + xAt->gotoEnd( sal_True ); Reference< XPropertySet > xPropSet( rxCell, UNO_QUERY_THROW ); oox::drawingml::FillProperties aFillProperties; @@ -181,7 +189,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo if ( rBackgroundFillPropertiesPtr.get() ) aFillProperties.assignUsed( *rBackgroundFillPropertiesPtr ); - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -192,7 +200,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo if ( rProperties.isFirstRow() && ( nRow == 0 ) ) { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -203,7 +211,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo } if ( rProperties.isLastRow() && ( nRow == nMaxRow ) ) { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -214,7 +222,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo } if ( rProperties.isFirstCol() && ( nColumn == 0 ) ) { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -225,7 +233,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo } if ( rProperties.isLastCol() && ( nColumn == nMaxColumn ) ) { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -244,7 +252,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo nBand++; if ( nBand & 1 ) { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -255,7 +263,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo } else { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -268,7 +276,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo } if ( ( nRow == 0 ) && ( nColumn == 0 ) ) { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -279,7 +287,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo } if ( ( nRow == nMaxRow ) && ( nColumn == 0 ) ) { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -290,7 +298,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo } if ( ( nRow == 0 ) && ( nColumn == nMaxColumn ) ) { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -301,7 +309,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo } if ( ( nRow == nMaxColumn ) && ( nColumn == nMaxColumn ) ) { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -320,7 +328,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo nBand++; if ( nBand & 1 ) { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -331,7 +339,7 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo } else { - applyTableStylePart( rFilterBase, rxCell, aFillProperties, + applyTableStylePart( rFilterBase, xStart, aFillProperties, aLinePropertiesLeft, aLinePropertiesRight, aLinePropertiesTop, @@ -363,3 +371,5 @@ void TableCell::pushToXCell( const ::oox::core::XmlFilterBase& rFilterBase, ::oo } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablecellcontext.cxx b/oox/source/drawingml/table/tablecellcontext.cxx index 844f134c3e85..608c1572e215 100644 --- a/oox/source/drawingml/table/tablecellcontext.cxx +++ b/oox/source/drawingml/table/tablecellcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -124,3 +125,5 @@ TableCellContext::createFastChildContext( ::sal_Int32 aElementToken, const uno:: } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablecontext.cxx b/oox/source/drawingml/table/tablecontext.cxx index f7e7af620428..30968e052c62 100644 --- a/oox/source/drawingml/table/tablecontext.cxx +++ b/oox/source/drawingml/table/tablecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -105,3 +106,5 @@ TableContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::Refe } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablepartstylecontext.cxx b/oox/source/drawingml/table/tablepartstylecontext.cxx index 1d48cbcf2a18..4a7a8e390efb 100644 --- a/oox/source/drawingml/table/tablepartstylecontext.cxx +++ b/oox/source/drawingml/table/tablepartstylecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -74,3 +75,5 @@ TablePartStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tableproperties.cxx b/oox/source/drawingml/table/tableproperties.cxx index e0d0ac91c2ab..a6434c64c294 100644 --- a/oox/source/drawingml/table/tableproperties.cxx +++ b/oox/source/drawingml/table/tableproperties.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,7 +33,7 @@ #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/table/XMergeableCellRange.hpp> -#include <com/sun/star/table/BorderLine.hpp> +#include <com/sun/star/table/BorderLine2.hpp> #include "oox/core/xmlfilterbase.hxx" #include "oox/helper/propertyset.hxx" @@ -75,7 +76,7 @@ void CreateTableRows( uno::Reference< XTableRows > xTableRows, const std::vector static const rtl::OUString sHeight( RTL_CONSTASCII_USTRINGPARAM ( "Height" ) ); Reference< XPropertySet > xPropSet( xIndexAccess->getByIndex( n ), UNO_QUERY_THROW ); xPropSet->setPropertyValue( sHeight, Any( static_cast< sal_Int32 >( aTableRowIter->getHeight() / 360 ) ) ); - aTableRowIter++; + ++aTableRowIter; } } @@ -127,7 +128,7 @@ const TableStyle& TableProperties::getUsedTableStyle( const ::oox::core::XmlFilt pTableStyle = &const_cast< TableStyle& >( *aIter ); break; // we get the correct style } - aIter++; + ++aIter; } } if ( !pTableStyle ) @@ -176,3 +177,5 @@ void TableProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBa } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablerow.cxx b/oox/source/drawingml/table/tablerow.cxx index 3c4af56a5d42..fd2c305ed008 100644 --- a/oox/source/drawingml/table/tablerow.cxx +++ b/oox/source/drawingml/table/tablerow.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,7 +33,7 @@ #include "oox/helper/propertyset.hxx" #include <com/sun/star/table/XTable.hpp> #include <com/sun/star/table/XMergeableCellRange.hpp> -#include <com/sun/star/table/BorderLine.hpp> +#include <com/sun/star/table/BorderLine2.hpp> using rtl::OUString; using namespace ::oox::core; @@ -51,3 +52,5 @@ TableRow::~TableRow() } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablerowcontext.cxx b/oox/source/drawingml/table/tablerowcontext.cxx index 1a6c38167a8d..4c812ea4cc3f 100644 --- a/oox/source/drawingml/table/tablerowcontext.cxx +++ b/oox/source/drawingml/table/tablerowcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -76,3 +77,5 @@ TableRowContext::createFastChildContext( ::sal_Int32 aElementToken, const uno::R } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestyle.cxx b/oox/source/drawingml/table/tablestyle.cxx index 78a110ebb8cb..233d32f260f3 100644 --- a/oox/source/drawingml/table/tablestyle.cxx +++ b/oox/source/drawingml/table/tablestyle.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -38,3 +39,5 @@ TableStyle::~TableStyle() } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestylecellstylecontext.cxx b/oox/source/drawingml/table/tablestylecellstylecontext.cxx index 56127b0c049c..76042663d20d 100644 --- a/oox/source/drawingml/table/tablestylecellstylecontext.cxx +++ b/oox/source/drawingml/table/tablestylecellstylecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -123,3 +124,5 @@ TableStyleCellStyleContext::createFastChildContext( ::sal_Int32 aElementToken, c } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestylecontext.cxx b/oox/source/drawingml/table/tablestylecontext.cxx index aee23eaf9c7b..b63008c8f45e 100644 --- a/oox/source/drawingml/table/tablestylecontext.cxx +++ b/oox/source/drawingml/table/tablestylecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -114,3 +115,5 @@ TableStyleContext::createFastChildContext( ::sal_Int32 aElementToken, const uno: } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestylelist.cxx b/oox/source/drawingml/table/tablestylelist.cxx index 36ebc56a84a3..18a6af4a3330 100644 --- a/oox/source/drawingml/table/tablestylelist.cxx +++ b/oox/source/drawingml/table/tablestylelist.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -39,3 +40,5 @@ TableStyleList::~TableStyleList() } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx b/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx index 7b837d27e826..3b366163256e 100644 --- a/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx +++ b/oox/source/drawingml/table/tablestylelistfragmenthandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -82,3 +83,4 @@ Reference< XFastContextHandler > TableStyleListFragmentHandler::createFastChildC } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestylepart.cxx b/oox/source/drawingml/table/tablestylepart.cxx index b4a68fd488cd..9a17973d6b81 100644 --- a/oox/source/drawingml/table/tablestylepart.cxx +++ b/oox/source/drawingml/table/tablestylepart.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -45,3 +46,5 @@ TableStylePart::~TableStylePart() } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/table/tablestyletextstylecontext.cxx b/oox/source/drawingml/table/tablestyletextstylecontext.cxx index 7c04e3293eb1..28f134070493 100644 --- a/oox/source/drawingml/table/tablestyletextstylecontext.cxx +++ b/oox/source/drawingml/table/tablestyletextstylecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -44,17 +45,21 @@ TableStyleTextStyleContext::TableStyleTextStyleContext( ContextHandler& rParent, : ContextHandler( rParent ) , mrTableStylePart( rTableStylePart ) { - sal_Int32 nB = xAttribs->getOptionalValueToken( XML_b, XML_def ); - if ( nB == XML_on ) - mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_True ); - else if ( nB == XML_off ) - mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_False ); + if( xAttribs->hasAttribute( XML_b ) ) { + sal_Int32 nB = xAttribs->getOptionalValueToken( XML_b, XML_def ); + if ( nB == XML_on ) + mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_True ); + else if ( nB == XML_off ) + mrTableStylePart.getTextBoldStyle() = ::boost::optional< sal_Bool >( sal_False ); + } - sal_Int32 nI = xAttribs->getOptionalValueToken( XML_i, XML_def ); - if ( nI == XML_on ) - mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_True ); - else if ( nI == XML_off ) - mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_False ); + if( xAttribs->hasAttribute( XML_i ) ) { + sal_Int32 nI = xAttribs->getOptionalValueToken( XML_i, XML_def ); + if ( nI == XML_on ) + mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_True ); + else if ( nI == XML_off ) + mrTableStylePart.getTextItalicStyle() = ::boost::optional< sal_Bool >( sal_False ); + } } TableStyleTextStyleContext::~TableStyleTextStyleContext() @@ -106,3 +111,5 @@ TableStyleTextStyleContext::createFastChildContext( ::sal_Int32 aElementToken, c } } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textbody.cxx b/oox/source/drawingml/textbody.cxx index 20c554ef3e64..43ef01287105 100644 --- a/oox/source/drawingml/textbody.cxx +++ b/oox/source/drawingml/textbody.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -42,6 +43,14 @@ TextBody::TextBody() { } +TextBody::TextBody( TextBodyPtr pBody ) +{ + if( pBody.get() ) { + maTextProperties = pBody->maTextProperties; + maTextListStyle = pBody->maTextListStyle; + } +} + TextBody::~TextBody() { } @@ -70,3 +79,5 @@ void TextBody::insertAt( } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textbodycontext.cxx b/oox/source/drawingml/textbodycontext.cxx index 8d695e295fd4..5c7e96ac7e5c 100644 --- a/oox/source/drawingml/textbodycontext.cxx +++ b/oox/source/drawingml/textbodycontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -210,3 +211,4 @@ Reference< XFastContextHandler > TextBodyContext::createFastChildContext( sal_In } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textbodyproperties.cxx b/oox/source/drawingml/textbodyproperties.cxx index 4339c93aa0ae..7a7461064096 100644 --- a/oox/source/drawingml/textbodyproperties.cxx +++ b/oox/source/drawingml/textbodyproperties.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -52,3 +53,4 @@ void TextBodyProperties::pushToPropMap( PropertyMap& rPropMap ) const } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx index f22258075e16..7cc7affbbb24 100644 --- a/oox/source/drawingml/textbodypropertiescontext.cxx +++ b/oox/source/drawingml/textbodypropertiescontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,8 +31,9 @@ #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/text/ControlCharacter.hpp> #include <com/sun/star/text/WritingMode.hpp> -#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/TextFitToSizeType.hpp> #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include "oox/drawingml/textbodyproperties.hxx" #include "oox/drawingml/drawingmltypes.hxx" #include "oox/helper/attributelist.hxx" @@ -85,23 +87,26 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent, } // ST_TextAnchoringType - 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; + if( xAttributes->hasAttribute( XML_anchor ) ) { + 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; } - mrTextBodyProp.maPropertyMap[ PROP_TextVerticalAdjust ] <<= eVA; bool bAnchorCenter = aAttribs.getBool( XML_anchorCtr, false ); - if( bAnchorCenter ) - mrTextBodyProp.maPropertyMap[ PROP_TextHorizontalAdjust ] <<= - TextHorizontalAdjust_CENTER; - + if( xAttributes->hasAttribute( XML_anchorCtr ) ) { + if( bAnchorCenter ) + mrTextBodyProp.maPropertyMap[ PROP_TextHorizontalAdjust ] <<= + TextHorizontalAdjust_CENTER; + } // bool bCompatLineSpacing = aAttribs.getBool( XML_compatLnSpc, false ); // bool bForceAA = aAttribs.getBool( XML_forceAA, false ); // bool bFromWordArt = aAttribs.getBool( XML_fromWordArt, false ); @@ -124,19 +129,21 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent, // bool bUpRight = aAttribs.getBool( XML_upright, 0 ); // ST_TextVerticalType - mrTextBodyProp.moVert = aAttribs.getToken( XML_vert ); - bool bRtl = aAttribs.getBool( XML_rtl, false ); - sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz ); - if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert ) { - mrTextBodyProp.maPropertyMap[ PROP_TextWritingMode ] - <<= WritingMode_TB_RL; - // workaround for TB_LR as using WritingMode2 doesn't work - if( !bAnchorCenter ) - mrTextBodyProp.maPropertyMap[ PROP_TextHorizontalAdjust ] <<= - TextHorizontalAdjust_LEFT; - } else - mrTextBodyProp.maPropertyMap[ PROP_TextWritingMode ] - <<= ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB ); + if( xAttributes->hasAttribute( XML_vert ) ) { + mrTextBodyProp.moVert = aAttribs.getToken( XML_vert ); + bool bRtl = aAttribs.getBool( XML_rtl, false ); + sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz ); + if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert ) { + mrTextBodyProp.maPropertyMap[ PROP_TextWritingMode ] + <<= WritingMode_TB_RL; + // workaround for TB_LR as using WritingMode2 doesn't work + if( !bAnchorCenter ) + mrTextBodyProp.maPropertyMap[ PROP_TextHorizontalAdjust ] <<= + TextHorizontalAdjust_LEFT; + } else + mrTextBodyProp.maPropertyMap[ PROP_TextWritingMode ] + <<= ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB ); + } } // -------------------------------------------------------------------- @@ -162,7 +169,7 @@ Reference< XFastContextHandler > TextBodyPropertiesContext::createFastChildConte mrTextBodyProp.maPropertyMap[ PROP_TextAutoGrowHeight ] <<= false; // CT_TextNoAutofit break; case A_TOKEN( normAutofit ): // CT_TextNormalAutofit - mrTextBodyProp.maPropertyMap[ PROP_TextFitToSize ] <<= true; + mrTextBodyProp.maPropertyMap[ PROP_TextFitToSize ] <<= TextFitToSizeType_AUTOFIT; mrTextBodyProp.maPropertyMap[ PROP_TextAutoGrowHeight ] <<= false; break; case A_TOKEN( spAutoFit ): @@ -185,3 +192,4 @@ Reference< XFastContextHandler > TextBodyPropertiesContext::createFastChildConte } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textcharacterproperties.cxx b/oox/source/drawingml/textcharacterproperties.cxx index 61333535c38f..fb4b0690bc80 100644 --- a/oox/source/drawingml/textcharacterproperties.cxx +++ b/oox/source/drawingml/textcharacterproperties.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -68,7 +69,7 @@ void TextCharacterProperties::assignUsed( const TextCharacterProperties& rSource moUnderlineFillFollowText.assignIfUsed( rSourceProps.moUnderlineFillFollowText ); } -void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFilterBase& rFilter ) const + void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFilterBase& rFilter, bool bUseOptional ) const { OUString aFontName; sal_Int16 nFontPitch = 0; @@ -132,15 +133,19 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil rPropMap[ PROP_CharStrikeout ] <<= GetFontStrikeout( moStrikeout.get( XML_noStrike ) ); rPropMap[ PROP_CharCaseMap ] <<= GetCaseMap( moCaseMap.get( XML_none ) ); - float fWeight = moBold.get( false ) ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL; - rPropMap[ PROP_CharWeight ] <<= fWeight; - rPropMap[ PROP_CharWeightAsian ] <<= fWeight; - rPropMap[ PROP_CharWeightComplex ] <<= fWeight; + if( !bUseOptional || moBold.has() ) { + float fWeight = moBold.get( false ) ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL; + rPropMap[ PROP_CharWeight ] <<= fWeight; + rPropMap[ PROP_CharWeightAsian ] <<= fWeight; + rPropMap[ PROP_CharWeightComplex ] <<= fWeight; + } - awt::FontSlant eSlant = moItalic.get( false ) ? awt::FontSlant_ITALIC : awt::FontSlant_NONE; - rPropMap[ PROP_CharPosture ] <<= eSlant; - rPropMap[ PROP_CharPostureAsian ] <<= eSlant; - rPropMap[ PROP_CharPostureComplex ] <<= eSlant; + if( !bUseOptional || moItalic.has() ) { + awt::FontSlant eSlant = moItalic.get( false ) ? awt::FontSlant_ITALIC : awt::FontSlant_NONE; + rPropMap[ PROP_CharPosture ] <<= eSlant; + rPropMap[ PROP_CharPostureAsian ] <<= eSlant; + rPropMap[ PROP_CharPostureComplex ] <<= eSlant; + } bool bUnderlineFillFollowText = moUnderlineFillFollowText.get( false ); if( moUnderline.has() && maUnderlineColor.isUsed() && !bUnderlineFillFollowText ) @@ -150,10 +155,10 @@ void TextCharacterProperties::pushToPropMap( PropertyMap& rPropMap, const XmlFil } } -void TextCharacterProperties::pushToPropSet( PropertySet& rPropSet, const XmlFilterBase& rFilter ) const + void TextCharacterProperties::pushToPropSet( PropertySet& rPropSet, const XmlFilterBase& rFilter, bool bUseOptional ) const { PropertyMap aPropMap; - pushToPropMap( aPropMap, rFilter ); + pushToPropMap( aPropMap, rFilter, bUseOptional ); rPropSet.setProperties( aPropMap ); } @@ -167,3 +172,4 @@ float TextCharacterProperties::getCharHeightPoints( float fDefault ) const } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textcharacterpropertiescontext.cxx b/oox/source/drawingml/textcharacterpropertiescontext.cxx index f3be44773a39..7fffb56fa317 100644 --- a/oox/source/drawingml/textcharacterpropertiescontext.cxx +++ b/oox/source/drawingml/textcharacterpropertiescontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -58,6 +59,8 @@ TextCharacterPropertiesContext::TextCharacterPropertiesContext( mrTextCharacterProperties.moLang = aAttribs.getString( XML_lang ); if ( aAttribs.hasAttribute( XML_sz ) ) mrTextCharacterProperties.moHeight = aAttribs.getInteger( XML_sz ); + if ( aAttribs.hasAttribute( XML_spc ) ) + mrTextCharacterProperties.moSpacing = aAttribs.getInteger( XML_spc ); if ( aAttribs.hasAttribute( XML_u ) ) mrTextCharacterProperties.moUnderline = aAttribs.getToken( XML_u ); if ( aAttribs.hasAttribute( XML_strike ) ) @@ -175,3 +178,4 @@ Reference< XFastContextHandler > TextCharacterPropertiesContext::createFastChild } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textfield.cxx b/oox/source/drawingml/textfield.cxx index c3049415c89a..2eb831c89c09 100644 --- a/oox/source/drawingml/textfield.cxx +++ b/oox/source/drawingml/textfield.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -138,12 +139,13 @@ void lclCreateTextFields( std::list< Reference< XTextField > > & aFields, } // namespace -void TextField::insertAt( +sal_Int32 TextField::insertAt( const ::oox::core::XmlFilterBase& rFilterBase, const Reference < XText > & xText, const Reference < XTextCursor > &xAt, const TextCharacterProperties& rTextCharacterStyle ) const { + sal_Int32 nCharHeight = 0; try { PropertyMap aioBulletList; @@ -151,11 +153,13 @@ void TextField::insertAt( Reference< XPropertySet > xProps( xStart, UNO_QUERY); PropertySet aPropSet( xProps ); - maTextParagraphProperties.pushToPropSet( rFilterBase, xProps, aioBulletList, NULL, sal_True, 18 ); + maTextParagraphProperties.pushToPropSet( &rFilterBase, xProps, aioBulletList, NULL, sal_True, 18 ); TextCharacterProperties aTextCharacterProps( rTextCharacterStyle ); aTextCharacterProps.assignUsed( maTextParagraphProperties.getTextCharacterProperties() ); aTextCharacterProps.assignUsed( getTextCharacterProperties() ); + if ( aTextCharacterProps.moHeight.has() ) + nCharHeight = aTextCharacterProps.moHeight.get(); aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase ); std::list< Reference< XTextField > > fields; @@ -190,6 +194,10 @@ void TextField::insertAt( { OSL_TRACE("OOX: TextField::insertAt() exception"); } + + return nCharHeight; } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textfieldcontext.cxx b/oox/source/drawingml/textfieldcontext.cxx index 4e9f576a0ca9..53cc02525592 100644 --- a/oox/source/drawingml/textfieldcontext.cxx +++ b/oox/source/drawingml/textfieldcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -87,3 +88,5 @@ Reference< XFastContextHandler > TextFieldContext::createFastChildContext( sal_I } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textfont.cxx b/oox/source/drawingml/textfont.cxx index b4f9d359fb14..5cd0fe2b996f 100644 --- a/oox/source/drawingml/textfont.cxx +++ b/oox/source/drawingml/textfont.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -80,7 +81,7 @@ void TextFont::assignIfUsed( const TextFont& rTextFont ) *this = rTextFont; } -bool TextFont::getFontData( OUString& rFontName, sal_Int16 rnFontPitch, sal_Int16& rnFontFamily, const XmlFilterBase& rFilter ) const +bool TextFont::getFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily, const XmlFilterBase& rFilter ) const { if( const Theme* pTheme = rFilter.getCurrentTheme() ) if( const TextFont* pFont = pTheme->resolveFont( maTypeface ) ) @@ -88,7 +89,7 @@ bool TextFont::getFontData( OUString& rFontName, sal_Int16 rnFontPitch, sal_Int1 return implGetFontData( rFontName, rnFontPitch, rnFontFamily ); } -bool TextFont::implGetFontData( OUString& rFontName, sal_Int16 rnFontPitch, sal_Int16& rnFontFamily ) const +bool TextFont::implGetFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily ) const { rFontName = maTypeface; rnFontPitch = lclGetFontPitch( extractValue< sal_Int16 >( mnPitch, 0, 4 ) ); @@ -101,3 +102,4 @@ bool TextFont::implGetFontData( OUString& rFontName, sal_Int16 rnFontPitch, sal_ } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textliststyle.cxx b/oox/source/drawingml/textliststyle.cxx index 8a491076909f..520c5d6b73d1 100644 --- a/oox/source/drawingml/textliststyle.cxx +++ b/oox/source/drawingml/textliststyle.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -51,11 +52,11 @@ void applyStyleList( const TextParagraphPropertiesVector& rSourceListStyle, Text if ( aDestListStyleIter != rDestListStyle.end() ) { (*aDestListStyleIter)->apply( **aSourceListStyleIter ); - aDestListStyleIter++; + ++aDestListStyleIter; } else rDestListStyle.push_back( TextParagraphPropertiesPtr( new TextParagraphProperties( **aSourceListStyleIter ) ) ); - aSourceListStyleIter++; + ++aSourceListStyleIter; } } @@ -66,3 +67,5 @@ void TextListStyle::apply( const TextListStyle& rTextListStyle ) } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textliststylecontext.cxx b/oox/source/drawingml/textliststylecontext.cxx index 21afc698d730..d32c6089989c 100644 --- a/oox/source/drawingml/textliststylecontext.cxx +++ b/oox/source/drawingml/textliststylecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -108,3 +109,4 @@ Reference< XFastContextHandler > TextListStyleContext::createFastChildContext( s } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx index a4bef1a5013c..54ae10ba1f80 100644 --- a/oox/source/drawingml/textparagraph.cxx +++ b/oox/source/drawingml/textparagraph.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -79,19 +80,23 @@ void TextParagraph::insertAt( xText->insertControlCharacter( xStart, ControlCharacter::APPEND_PARAGRAPH, sal_False ); xAt->gotoEnd( sal_True ); } + + sal_Int32 nCharHeight = 0; if ( maRuns.begin() == maRuns.end() ) { PropertySet aPropSet( xStart ); TextCharacterProperties aTextCharacterProps( aTextCharacterStyle ); aTextCharacterProps.assignUsed( maEndProperties ); + if ( aTextCharacterProps.moHeight.has() ) + nCharHeight = aTextCharacterProps.moHeight.get(); aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase ); } else { for( TextRunVector::const_iterator aIt = maRuns.begin(), aEnd = maRuns.end(); aIt != aEnd; ++aIt ) { - (*aIt)->insertAt( rFilterBase, xText, xAt, aTextCharacterStyle ); + nCharHeight = std::max< sal_Int32 >( nCharHeight, (*aIt)->insertAt( rFilterBase, xText, xAt, aTextCharacterStyle ) ); nParagraphSize += (*aIt)->getText().getLength(); } } @@ -99,13 +104,13 @@ void TextParagraph::insertAt( PropertyMap aioBulletList; Reference< XPropertySet > xProps( xStart, UNO_QUERY); - float fCharacterSize = 18; + float fCharacterSize = nCharHeight > 0 ? GetFontHeight( nCharHeight ) : 18; if ( pTextParagraphStyle.get() ) { - pTextParagraphStyle->pushToPropSet( rFilterBase, xProps, aioBulletList, NULL, sal_False, fCharacterSize ); - fCharacterSize = pTextParagraphStyle->getCharHeightPoints( 18 ); + pTextParagraphStyle->pushToPropSet( &rFilterBase, xProps, aioBulletList, NULL, sal_False, fCharacterSize ); + fCharacterSize = pTextParagraphStyle->getCharHeightPoints( fCharacterSize ); } - maProperties.pushToPropSet( rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), sal_True, fCharacterSize ); + maProperties.pushToPropSet( &rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), sal_True, fCharacterSize ); // empty paragraphs do not have bullets in ppt if ( !nParagraphSize ) @@ -128,3 +133,4 @@ void TextParagraph::insertAt( } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx index cd969874513e..e2130b394d60 100644 --- a/oox/source/drawingml/textparagraphproperties.cxx +++ b/oox/source/drawingml/textparagraphproperties.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -40,6 +41,17 @@ #include "oox/core/xmlfilterbase.hxx" #include "oox/drawingml/drawingmltypes.hxx" +#if OSL_DEBUG_LEVEL > 0 +#include <vcl/unohelp.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <comphelper/genericpropertyset.hxx> +#include <comphelper/processfactory.hxx> +#include <oox/ppt/pptimport.hxx> +#include <oox/ppt/slidepersist.hxx> +#endif + using rtl::OUString; using namespace ::oox::core; using namespace ::com::sun::star::uno; @@ -61,7 +73,7 @@ bool BulletList::is() const return mnNumberingType.hasValue(); } -void BulletList::setBulletChar( const ::rtl::OUString & sChar ) +void BulletList::setBulletChar( const OUString & sChar ) { mnNumberingType <<= NumberingType::CHAR_SPECIAL; msBulletChar <<= sChar; @@ -276,7 +288,7 @@ void BulletList::apply( const BulletList& rSource ) maGraphic = rSource.maGraphic; } -void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase& rFilterBase, PropertyMap& rPropMap ) const +void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase* pFilterBase, PropertyMap& rPropMap ) const { if( msNumberingPrefix.hasValue() ) rPropMap[ PROP_Prefix ] = msNumberingPrefix; @@ -292,22 +304,50 @@ void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase& rFilterBase, P OUString aBulletFontName; sal_Int16 nBulletFontPitch = 0; sal_Int16 nBulletFontFamily = 0; - if( maBulletFont.getFontData( aBulletFontName, nBulletFontPitch, nBulletFontFamily, rFilterBase ) ) - { - FontDescriptor aFontDesc; - sal_Int16 nFontSize = 0; - if( mnFontSize >>= nFontSize ) - aFontDesc.Height = nFontSize; - - // TODO move the to the TextFont struct. - aFontDesc.Name = aBulletFontName; - aFontDesc.Pitch = nBulletFontPitch; - aFontDesc.Family = nBulletFontFamily; - rPropMap[ PROP_BulletFont ] <<= aFontDesc; - rPropMap[ PROP_BulletFontName ] <<= aBulletFontName; + sal_Bool bSymbolFont = sal_False; + if( pFilterBase) { + if (maBulletFont.getFontData( aBulletFontName, nBulletFontPitch, nBulletFontFamily, *pFilterBase ) ) + { + FontDescriptor aFontDesc; + sal_Int16 nFontSize = 0; + if( mnFontSize >>= nFontSize ) + aFontDesc.Height = nFontSize; + + // TODO move the to the TextFont struct. + aFontDesc.Name = aBulletFontName; + aFontDesc.Pitch = nBulletFontPitch; + aFontDesc.Family = nBulletFontFamily; + if ( aBulletFontName.equalsIgnoreAsciiCaseAscii( "Wingdings" ) || + aBulletFontName.equalsIgnoreAsciiCaseAscii( "Wingdings 2" ) || + aBulletFontName.equalsIgnoreAsciiCaseAscii( "Wingdings 3" ) || + aBulletFontName.equalsIgnoreAsciiCaseAscii( "Monotype Sorts" ) || + aBulletFontName.equalsIgnoreAsciiCaseAscii( "Monotype Sorts 2" ) || + aBulletFontName.equalsIgnoreAsciiCaseAscii( "Webdings" ) || + aBulletFontName.equalsIgnoreAsciiCaseAscii( "StarBats" ) || + aBulletFontName.equalsIgnoreAsciiCaseAscii( "StarMath" ) || + aBulletFontName.equalsIgnoreAsciiCaseAscii( "ZapfDingbats" ) ) { + aFontDesc.CharSet = RTL_TEXTENCODING_SYMBOL; + bSymbolFont = sal_True; + } + rPropMap[ PROP_BulletFont ] <<= aFontDesc; + rPropMap[ PROP_BulletFontName ] <<= aBulletFontName; + } + } + if ( msBulletChar.hasValue() ) { + OUString sBuChar; + + msBulletChar >>= sBuChar; + + if( pFilterBase && sBuChar.getLength() == 1 && maBulletFont.getFontData( aBulletFontName, nBulletFontPitch, nBulletFontFamily, *pFilterBase ) && bSymbolFont ) + { + sal_Unicode nBuChar = sBuChar.toChar(); + nBuChar &= 0x00ff; + nBuChar |= 0xf000; + sBuChar = OUString( &nBuChar, 1 ); + } + + rPropMap[ PROP_BulletChar ] <<= sBuChar; } - if ( msBulletChar.hasValue() ) - rPropMap[ PROP_BulletChar ] = msBulletChar; if ( maGraphic.hasValue() ) { Reference< com::sun::star::awt::XBitmap > xBitmap( maGraphic, UNO_QUERY ); @@ -318,8 +358,10 @@ void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase& rFilterBase, P rPropMap[ PROP_BulletRelSize ] = mnSize; if ( maStyleName.hasValue() ) rPropMap[ PROP_CharStyleName ] <<= maStyleName; - if ( maBulletColorPtr->isUsed() ) - rPropMap[ PROP_BulletColor ] <<= maBulletColorPtr->getColor( rFilterBase.getGraphicHelper() ); + if (pFilterBase ) { + if ( maBulletColorPtr->isUsed() ) + rPropMap[ PROP_BulletColor ] <<= maBulletColorPtr->getColor( pFilterBase->getGraphicHelper() ); + } } TextParagraphProperties::TextParagraphProperties() @@ -346,7 +388,7 @@ void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps moFirstLineIndentation = rSourceProps.moFirstLineIndentation; } -void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase, +void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase, const Reference < XPropertySet >& xPropSet, PropertyMap& rioBulletMap, const BulletList* pMasterBuList, sal_Bool bApplyBulletMap, float fCharacterSize ) const { PropertySet aPropSet( xPropSet ); @@ -360,12 +402,12 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase& r if ( nNumberingType == NumberingType::NUMBER_NONE ) aPropSet.setProperty< sal_Int16 >( PROP_NumberingLevel, -1 ); - maBulletList.pushToPropMap( rFilterBase, rioBulletMap ); + maBulletList.pushToPropMap( pFilterBase, rioBulletMap ); if ( maParaTopMargin.bHasValue ) - aPropSet.setProperty( PROP_ParaTopMargin, maParaTopMargin.toMargin( getCharHeightPoints( 18.0 ) ) ); + aPropSet.setProperty( PROP_ParaTopMargin, maParaTopMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 18.0 ) ) ); if ( maParaBottomMargin.bHasValue ) - aPropSet.setProperty( PROP_ParaBottomMargin, maParaBottomMargin.toMargin( getCharHeightPoints( 18.0 ) ) ); + aPropSet.setProperty( PROP_ParaBottomMargin, maParaBottomMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 18.0 ) ) ); if ( nNumberingType == NumberingType::BITMAP ) { fCharacterSize = getCharHeightPoints( fCharacterSize ); @@ -402,6 +444,9 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase& r { if( !rioBulletMap.empty() ) { + // fix default bullet size to be 100% + if( rioBulletMap.find( PROP_BulletRelSize ) == rioBulletMap.end() ) + rioBulletMap[ PROP_BulletRelSize ] <<= static_cast< sal_Int16 >( 100 ); Sequence< PropertyValue > aBulletPropSeq = rioBulletMap.makePropertyValueSequence(); xNumRule->replaceByIndex( getLevel(), makeAny( aBulletPropSeq ) ); } @@ -410,7 +455,7 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase& r } } if ( noParaLeftMargin ) - aPropSet.setProperty( PROP_ParaLeftMargin, *noParaLeftMargin ); + aPropSet.setProperty( PROP_ParaLeftMargin, sal_Int32(0) /**noParaLeftMargin*/ ); if ( noFirstLineIndentation ) aPropSet.setProperty( PROP_ParaFirstLineIndent, *noFirstLineIndentation ); } @@ -420,4 +465,30 @@ float TextParagraphProperties::getCharHeightPoints( float fDefault ) const return maTextCharacterProperties.getCharHeightPoints( fDefault ); } + +#if OSL_DEBUG_LEVEL > 0 + +void TextParagraphProperties::dump() const +{ + Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); + Reference< ::com::sun::star::drawing::XShape > xShape( oox::ppt::PowerPointImport::mpDebugFilterBase->getModelFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.presentation.TitleTextShape" ) ), UNO_QUERY ); + Reference< ::com::sun::star::text::XText > xText( xShape, UNO_QUERY ); + + ppt::SlidePersist::mxDebugPage->add( xShape ); + + PropertyMap emptyMap; + + const OUString sText = CREATE_OUSTRING("debug"); + xText->setString( sText ); + Reference< ::com::sun::star::text::XTextCursor > xStart( xText->createTextCursor(), UNO_QUERY ); + Reference< ::com::sun::star::text::XTextRange > xRange( xStart, UNO_QUERY ); + xStart->gotoEnd( sal_True ); + Reference< XPropertySet > xPropSet( xRange, UNO_QUERY ); + pushToPropSet( NULL, xPropSet, emptyMap, NULL, false, 0 ); + PropertySet pSet( xPropSet ); + pSet.dump(); +} +#endif } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx index eb888867556b..0bee2766e673 100644 --- a/oox/source/drawingml/textparagraphpropertiescontext.cxx +++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -281,3 +282,4 @@ Reference< XFastContextHandler > TextParagraphPropertiesContext::createFastChild } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textrun.cxx b/oox/source/drawingml/textrun.cxx index 1e435defaa2d..3c5b99c419fd 100644 --- a/oox/source/drawingml/textrun.cxx +++ b/oox/source/drawingml/textrun.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -35,6 +36,7 @@ #include "oox/helper/helper.hxx" #include "oox/helper/propertyset.hxx" #include "oox/core/xmlfilterbase.hxx" +#include "oox/token/tokens.hxx" using ::rtl::OUString; using namespace ::com::sun::star::uno; @@ -54,18 +56,21 @@ TextRun::~TextRun() { } -void TextRun::insertAt( +sal_Int32 TextRun::insertAt( const ::oox::core::XmlFilterBase& rFilterBase, const Reference < XText > & xText, const Reference < XTextCursor > &xAt, const TextCharacterProperties& rTextCharacterStyle ) const { + sal_Int32 nCharHeight = 0; try { Reference< XTextRange > xStart( xAt, UNO_QUERY ); PropertySet aPropSet( xStart ); TextCharacterProperties aTextCharacterProps( rTextCharacterStyle ); aTextCharacterProps.assignUsed( maTextCharacterProperties ); + if ( aTextCharacterProps.moHeight.has() ) + nCharHeight = aTextCharacterProps.moHeight.get(); aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase ); if( maTextCharacterProperties.maHyperlinkPropertyMap.empty() ) @@ -78,13 +83,13 @@ void TextRun::insertAt( else { OUString aLatinFontName, aSymbolFontName; - sal_Int16 nLatinFontPitch = 0, nSymbolFontPitch = 0; - sal_Int16 nLatinFontFamily = 0, nSymbolFontFamily = 0; + sal_Int16 nSymbolFontFamily = 0, nSymbolFontPitch = 0; if ( !aTextCharacterProps.maSymbolFont.getFontData( aSymbolFontName, nSymbolFontPitch, nSymbolFontFamily, rFilterBase ) ) xText->insertString( xStart, getText(), sal_False ); else if ( getText().getLength() ) { // !!#i113673<<< + sal_Int16 nLatinFontPitch = 0, nLatinFontFamily = 0; aTextCharacterProps.maLatinFont.getFontData( aLatinFontName, nLatinFontPitch, nLatinFontFamily, rFilterBase ); sal_Int32 nIndex = 0; @@ -145,6 +150,16 @@ void TextRun::insertAt( xText->insertTextContent( xStart, xContent, sal_False ); xTextFieldCursor->gotoEnd( sal_True ); + + if ( !maTextCharacterProperties.maCharColor.isUsed() ) + aTextCharacterProps.maCharColor.setSchemeClr( XML_hlink ); + if ( !maTextCharacterProperties.moUnderline.has() ) + aTextCharacterProps.moUnderline.set( XML_sng ); + + Reference< XTextRange > xFieldRange( xTextFieldCursor, UNO_QUERY ); + PropertySet aFieldTextPropSet( xFieldRange ); + aTextCharacterProps.pushToPropSet( aFieldTextPropSet, rFilterBase ); + oox::core::TextField aTextField; aTextField.xText = xText; aTextField.xTextCursor = xTextFieldCursor; @@ -162,7 +177,11 @@ void TextRun::insertAt( { OSL_TRACE("OOX: TextRun::insertAt() exception"); } + + return nCharHeight; } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textspacingcontext.cxx b/oox/source/drawingml/textspacingcontext.cxx index 5eb5f3d77f82..6ba72137e18a 100644 --- a/oox/source/drawingml/textspacingcontext.cxx +++ b/oox/source/drawingml/textspacingcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -73,3 +74,5 @@ namespace oox { namespace drawingml { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/textspacingcontext.hxx b/oox/source/drawingml/textspacingcontext.hxx index 5b646c14d240..9f91129f16eb 100644 --- a/oox/source/drawingml/textspacingcontext.hxx +++ b/oox/source/drawingml/textspacingcontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -55,3 +56,4 @@ private: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/texttabstoplistcontext.cxx b/oox/source/drawingml/texttabstoplistcontext.cxx index 78248fd0b6f7..4e3340f7f192 100644 --- a/oox/source/drawingml/texttabstoplistcontext.cxx +++ b/oox/source/drawingml/texttabstoplistcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -93,3 +94,4 @@ namespace oox { namespace drawingml { } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/texttabstoplistcontext.hxx b/oox/source/drawingml/texttabstoplistcontext.hxx index 5545e1231e3d..4567466db01f 100644 --- a/oox/source/drawingml/texttabstoplistcontext.hxx +++ b/oox/source/drawingml/texttabstoplistcontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -56,3 +57,4 @@ protected: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/theme.cxx b/oox/source/drawingml/theme.cxx index b37ccdbaf13c..47a7d30bc470 100644 --- a/oox/source/drawingml/theme.cxx +++ b/oox/source/drawingml/theme.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -106,3 +107,4 @@ const TextFont* Theme::resolveFont( const OUString& rName ) const } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/themeelementscontext.cxx b/oox/source/drawingml/themeelementscontext.cxx index a27afdbc0ea3..9d6573b8e20e 100644 --- a/oox/source/drawingml/themeelementscontext.cxx +++ b/oox/source/drawingml/themeelementscontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -239,3 +240,4 @@ Reference< XFastContextHandler > ThemeElementsContext::createFastChildContext( s } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/themefragmenthandler.cxx b/oox/source/drawingml/themefragmenthandler.cxx index 3cae10e40b4f..2068c8af0abd 100644 --- a/oox/source/drawingml/themefragmenthandler.cxx +++ b/oox/source/drawingml/themefragmenthandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -85,3 +86,4 @@ ContextHandlerRef ThemeFragmentHandler::onCreateContext( sal_Int32 nElement, con } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/drawingml/transform2dcontext.cxx b/oox/source/drawingml/transform2dcontext.cxx index c686feed165c..1d4501890beb 100644 --- a/oox/source/drawingml/transform2dcontext.cxx +++ b/oox/source/drawingml/transform2dcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -63,11 +64,12 @@ Reference< XFastContextHandler > Transform2DContext::createFastChildContext( sal case A_TOKEN( ext ): // horz/vert size mrShape.setSize( Size( xAttribs->getOptionalValue( XML_cx ).toInt32(), xAttribs->getOptionalValue( XML_cy ).toInt32() ) ); break; -/* todo: what to do? case A_TOKEN( chOff ): // horz/vert translation of children + mrShape.setChildPosition( Point( xAttribs->getOptionalValue( XML_x ).toInt32(), xAttribs->getOptionalValue( XML_y ).toInt32() ) ); + break; case A_TOKEN( chExt ): // horz/vert size of children + mrShape.setChildSize( Size( xAttribs->getOptionalValue( XML_cx ).toInt32(), xAttribs->getOptionalValue( XML_cy ).toInt32() ) ); break; -*/ } return 0; @@ -78,3 +80,4 @@ Reference< XFastContextHandler > Transform2DContext::createFastChildContext( sal } // namespace drawingml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/dump/biffdumper.cxx b/oox/source/dump/biffdumper.cxx index 7974a66ba250..976ae644ca0d 100644 --- a/oox/source/dump/biffdumper.cxx +++ b/oox/source/dump/biffdumper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -2506,7 +2507,7 @@ void WorkbookStreamObject::implDumpRecordBody() case BIFF_ID_HYPERLINK: dumpRange(); - if( cfg().getStringOption( dumpGuid( "guid" ), OUString() ).equalsAscii( "StdHlink" ) ) + if( cfg().getStringOption( dumpGuid( "guid" ), OUString() ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StdHlink" ) ) ) StdHlinkObject( *this ).dump(); break; @@ -4526,11 +4527,11 @@ RootStorageObject::RootStorageObject( const DumperBase& rParent ) void RootStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) { - if( (rStrgPath.getLength() == 0) && (rStrmName.equalsAscii( "Book" ) || rStrmName.equalsAscii( "Workbook" )) ) + if( (rStrgPath.getLength() == 0) && (rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Book" ) ) || rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Workbook" ) )) ) WorkbookStreamObject( *this, rxStrm, rSysFileName ).dump(); - else if( rStrgPath.equalsAscii( "_SX_DB" ) ) + else if( rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "_SX_DB" ) ) ) PivotCacheStreamObject( *this, rxStrm, BIFF5, rSysFileName ).dump(); - else if( rStrgPath.equalsAscii( "_SX_DB_CUR" ) ) + else if( rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "_SX_DB_CUR" ) ) ) PivotCacheStreamObject( *this, rxStrm, BIFF8, rSysFileName ).dump(); else OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); @@ -4538,7 +4539,7 @@ void RootStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, void RootStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) { - if( rStrgPath.equalsAscii( "_VBA_PROJECT_CUR" ) ) + if( rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "_VBA_PROJECT_CUR" ) ) ) VbaProjectStorageObject( *this, rxStrg, rSysPath ).dump(); else if( rStrgPath.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "MBD" ) ) ) VbaContainerStorageObject( *this, rxStrg, rSysPath ).dump(); @@ -4586,3 +4587,5 @@ void Dumper::implDump() } // namespace oox #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/dump/dffdumper.cxx b/oox/source/dump/dffdumper.cxx index 01994865c69d..66f46554ce7a 100644 --- a/oox/source/dump/dffdumper.cxx +++ b/oox/source/dump/dffdumper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -243,13 +244,13 @@ void DffStreamObject::dumpDffOpt() { const ItemFormat& rItemFmt = aIt->second; aName = rItemFmt.maItemName; - if( rItemFmt.maListName.equalsAscii( "binary" ) ) + if( rItemFmt.maListName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "binary" ) ) ) eType = PROPTYPE_BINARY; - else if( rItemFmt.maListName.equalsAscii( "string" ) ) + else if( rItemFmt.maListName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "string" ) ) ) eType = PROPTYPE_STRING; - else if( rItemFmt.maListName.equalsAscii( "blip" ) ) + else if( rItemFmt.maListName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "blip" ) ) ) eType = PROPTYPE_BLIP; - else if( rItemFmt.maListName.equalsAscii( "colorarray" ) ) + else if( rItemFmt.maListName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "colorarray" ) ) ) eType = PROPTYPE_COLORARRAY; } aPropInfos.push_back( PropInfo( aName( "property-data" ), eType, nBaseId, nValue ) ); @@ -322,3 +323,5 @@ sal_uInt16 DffStreamObject::dumpDffOptPropHeader() } // namespace oox #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx index eeca65e88cc5..81bc3fbd8db9 100644 --- a/oox/source/dump/dumperbase.cxx +++ b/oox/source/dump/dumperbase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -209,9 +210,9 @@ OUStringVector::const_iterator ItemFormat::parse( const OUStringVector& rFormatV if( meFmtType == FORMATTYPE_NONE ) { - if( aFmtType.equalsAscii( "unused" ) ) + if( aFmtType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "unused" ) ) ) set( meDataType, FORMATTYPE_HEX, CREATE_OUSTRING( OOX_DUMP_UNUSED ) ); - else if( aFmtType.equalsAscii( "unknown" ) ) + else if( aFmtType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "unknown" ) ) ) set( meDataType, FORMATTYPE_HEX, CREATE_OUSTRING( OOX_DUMP_UNKNOWN ) ); } @@ -765,25 +766,25 @@ OString StringHelper::convertToUtf8( const OUString& rStr ) DataType StringHelper::convertToDataType( const OUString& rStr ) { DataType eType = DATATYPE_VOID; - if( rStr.equalsAscii( "int8" ) ) + if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "int8" ) ) ) eType = DATATYPE_INT8; - else if( rStr.equalsAscii( "uint8" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "uint8" ) ) ) eType = DATATYPE_UINT8; - else if( rStr.equalsAscii( "int16" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "int16" ) ) ) eType = DATATYPE_INT16; - else if( rStr.equalsAscii( "uint16" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "uint16" ) ) ) eType = DATATYPE_UINT16; - else if( rStr.equalsAscii( "int32" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "int32" ) ) ) eType = DATATYPE_INT32; - else if( rStr.equalsAscii( "uint32" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "uint32" ) ) ) eType = DATATYPE_UINT32; - else if( rStr.equalsAscii( "int64" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "int64" ) ) ) eType = DATATYPE_INT64; - else if( rStr.equalsAscii( "uint64" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "uint64" ) ) ) eType = DATATYPE_UINT64; - else if( rStr.equalsAscii( "float" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "float" ) ) ) eType = DATATYPE_FLOAT; - else if( rStr.equalsAscii( "double" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "double" ) ) ) eType = DATATYPE_DOUBLE; return eType; } @@ -791,17 +792,17 @@ DataType StringHelper::convertToDataType( const OUString& rStr ) FormatType StringHelper::convertToFormatType( const OUString& rStr ) { FormatType eType = FORMATTYPE_NONE; - if( rStr.equalsAscii( "dec" ) ) + if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "dec" ) ) ) eType = FORMATTYPE_DEC; - else if( rStr.equalsAscii( "hex" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "hex" ) ) ) eType = FORMATTYPE_HEX; - else if( rStr.equalsAscii( "shorthex" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "shorthex" ) ) ) eType = FORMATTYPE_SHORTHEX; - else if( rStr.equalsAscii( "bin" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "bin" ) ) ) eType = FORMATTYPE_BIN; - else if( rStr.equalsAscii( "fix" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "fix" ) ) ) eType = FORMATTYPE_FIX; - else if( rStr.equalsAscii( "bool" ) ) + else if( rStr.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "bool" ) ) ) eType = FORMATTYPE_BOOL; return eType; } @@ -865,9 +866,9 @@ bool StringHelper::convertStringToDouble( double& orfData, const OUString& rData bool StringHelper::convertStringToBool( const OUString& rData ) { - if( rData.equalsAscii( "true" ) ) + if( rData.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "true" ) ) ) return true; - if( rData.equalsAscii( "false" ) ) + if( rData.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "false" ) ) ) return false; sal_Int64 nData; return convertStringToInt( nData, rData ) && (nData != 0); @@ -1074,7 +1075,7 @@ ConfigItemBase::LineType ConfigItemBase::readConfigLine( OUStringPair aPair = StringHelper::convertStringToPair( aLine ); orKey = aPair.first; orData = aPair.second; - return ((orKey.getLength() > 0) && ((orData.getLength() > 0) || !orKey.equalsAscii( "end" ))) ? + return ((orKey.getLength() > 0) && ((orData.getLength() > 0) || !orKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "end" ) ))) ? LINETYPE_DATA : LINETYPE_END; } @@ -1123,9 +1124,9 @@ bool NameListBase::implIsValid() const void NameListBase::implProcessConfigItemStr( TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { - if( rKey.equalsAscii( "include" ) ) + if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "include" ) ) ) include( rData ); - else if( rKey.equalsAscii( "exclude" ) ) + else if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "exclude" ) ) ) exclude( rData ); else ConfigItemBase::implProcessConfigItemStr( rStrm, rKey, rData ); @@ -1185,9 +1186,9 @@ ConstList::ConstList( const SharedConfigData& rCfgData ) : void ConstList::implProcessConfigItemStr( TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { - if( rKey.equalsAscii( "default" ) ) + if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "default" ) ) ) setDefaultName( rData ); - else if( rKey.equalsAscii( "quote-names" ) ) + else if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "quote-names" ) ) ) setQuoteNames( StringHelper::convertStringToBool( rData ) ); else NameListBase::implProcessConfigItemStr( rStrm, rKey, rData ); @@ -1244,7 +1245,7 @@ void MultiList::setNamesFromVec( sal_Int64 nStartKey, const OUStringVector& rNam void MultiList::implProcessConfigItemStr( TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { - if( rKey.equalsAscii( "ignore-empty" ) ) + if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ignore-empty" ) ) ) mbIgnoreEmpty = StringHelper::convertStringToBool( rData ); else ConstList::implProcessConfigItemStr( rStrm, rKey, rData ); @@ -1268,7 +1269,7 @@ FlagsList::FlagsList( const SharedConfigData& rCfgData ) : void FlagsList::implProcessConfigItemStr( TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { - if( rKey.equalsAscii( "ignore" ) ) + if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ignore" ) ) ) { sal_Int64 nIgnore; if( StringHelper::convertStringToInt( nIgnore, rData ) ) @@ -1373,11 +1374,11 @@ void CombiList::implSetName( sal_Int64 nKey, const OUString& rName ) for( OUStringVector::iterator aIt = aRemain.begin(), aEnd = aRemain.end(); aIt != aEnd; ++aIt ) { OUStringPair aPair = StringHelper::convertStringToPair( *aIt ); - if( aPair.first.equalsAscii( "noshift" ) ) + if( aPair.first.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "noshift" ) ) ) { aItemFmt.mbShiftValue = StringHelper::convertStringToBool( aPair.second ); } - else if( aPair.first.equalsAscii( "filter" ) ) + else if( aPair.first.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "filter" ) ) ) { OUStringPair aFilter = StringHelper::convertStringToPair( aPair.second, '~' ); ExtItemFormatKey aKey( nKey ); @@ -1579,19 +1580,19 @@ bool SharedConfigData::implIsValid() const void SharedConfigData::implProcessConfigItemStr( TextInputStream& rStrm, const OUString& rKey, const OUString& rData ) { - if( rKey.equalsAscii( "include-config-file" ) ) + if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "include-config-file" ) ) ) readConfigFile( maConfigPath + rData ); - else if( rKey.equalsAscii( "constlist" ) ) + else if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "constlist" ) ) ) readNameList< ConstList >( rStrm, rData ); - else if( rKey.equalsAscii( "multilist" ) ) + else if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "multilist" ) ) ) readNameList< MultiList >( rStrm, rData ); - else if( rKey.equalsAscii( "flagslist" ) ) + else if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "flagslist" ) ) ) readNameList< FlagsList >( rStrm, rData ); - else if( rKey.equalsAscii( "combilist" ) ) + else if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "combilist" ) ) ) readNameList< CombiList >( rStrm, rData ); - else if( rKey.equalsAscii( "shortlist" ) ) + else if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "shortlist" ) ) ) createShortList( rData ); - else if( rKey.equalsAscii( "unitconverter" ) ) + else if( rKey.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "unitconverter" ) ) ) createUnitConverter( rData ); else setOption( rKey, rData ); @@ -3179,3 +3180,5 @@ void DumperBase::construct( const ConfigRef& rxConfig ) } // namespace oox #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx index e0135af1604f..a7c0daf85a7a 100644 --- a/oox/source/dump/oledumper.cxx +++ b/oox/source/dump/oledumper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -180,15 +181,15 @@ bool StdHlinkObject::dumpGuidAndMoniker() bool bValidMoniker = true; OUString aGuid = cfg().getStringOption( dumpGuid( "moniker" ), OUString() ); IndentGuard aIndGuard( mxOut ); - if( aGuid.equalsAscii( "URLMoniker" ) ) + if( aGuid.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "URLMoniker" ) ) ) dumpUrlMoniker(); - else if( aGuid.equalsAscii( "FileMoniker" ) ) + else if( aGuid.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "FileMoniker" ) ) ) dumpFileMoniker(); - else if( aGuid.equalsAscii( "ItemMoniker" ) ) + else if( aGuid.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ItemMoniker" ) ) ) dumpItemMoniker(); - else if( aGuid.equalsAscii( "AntiMoniker" ) ) + else if( aGuid.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "AntiMoniker" ) ) ) dumpAntiMoniker(); - else if( aGuid.equalsAscii( "CompositeMoniker" ) ) + else if( aGuid.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CompositeMoniker" ) ) ) dumpCompositeMoniker(); else bValidMoniker = false; @@ -386,9 +387,9 @@ void OlePropertyStreamObject::dumpSection( const OUString& rGuid, sal_uInt32 nSt // property ID names mxPropIds = cfg().createNameList< ConstList >( "OLEPROP-IDS" ); OUString aGuidName = cfg().getStringOption( rGuid, OUString() ); - if( aGuidName.equalsAscii( "GlobalDocProp" ) ) + if( aGuidName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "GlobalDocProp" ) ) ) mxPropIds->includeList( cfg().getNameList( "OLEPROP-GLOBALIDS" ) ); - else if( aGuidName.equalsAscii( "BuiltinDocProp" ) ) + else if( aGuidName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "BuiltinDocProp" ) ) ) mxPropIds->includeList( cfg().getNameList( "OLEPROP-BUILTINIDS" ) ); else mxPropIds->includeList( cfg().getNameList( "OLEPROP-BASEIDS" ) ); @@ -677,9 +678,9 @@ void OleStorageObject::construct( const ObjectBase& rParent ) void OleStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& /*rStrgPath*/, const OUString& rStrmName, const OUString& rSysFileName ) { - if( rStrmName.equalsAscii( "\001CompObj" ) ) + if( rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "\001CompObj" ) ) ) OleCompObjObject( *this, rxStrm, rSysFileName ).dump(); - else if( rStrmName.equalsAscii( "\005SummaryInformation" ) || rStrmName.equalsAscii( "\005DocumentSummaryInformation" ) ) + else if( rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "\005SummaryInformation" ) ) || rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "\005DocumentSummaryInformation" ) ) ) OlePropertyStreamObject( *this, rxStrm, rSysFileName ).dump(); else BinaryStreamObject( *this, rxStrm, rSysFileName ).dump(); @@ -778,7 +779,7 @@ bool ComCtlObjectBase::dumpComCtlComplex() writeEmptyItem( "font" ); IndentGuard aIndGuard2( mxOut ); OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() ); - if( aClassName.equalsAscii( "StdFont" ) ) + if( aClassName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StdFont" ) ) ) StdFontObject( *this ).dump(); } if( !mxStrm->isEof() && (nFlags & 0x02) ) @@ -786,7 +787,7 @@ bool ComCtlObjectBase::dumpComCtlComplex() writeEmptyItem( "mouse-icon" ); IndentGuard aIndGuard2( mxOut ); OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() ); - if( aClassName.equalsAscii( "StdPic" ) ) + if( aClassName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StdPic" ) ) ) StdPicObject( *this ).dump(); } return !mxStrm->isEof(); @@ -1340,11 +1341,11 @@ void AxPropertyObjectBase::dumpLargeProperties() { IndentGuard aIndGuard2( mxOut ); OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() ); - if( aClassName.equalsAscii( "StdFont" ) ) + if( aClassName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StdFont" ) ) ) StdFontObject( *this ).dump(); - else if( aClassName.equalsAscii( "StdPic" ) ) + else if( aClassName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StdPic" ) ) ) StdPicObject( *this ).dump(); - else if( aClassName.equalsAscii( "CFontNew" ) ) + else if( aClassName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CFontNew" ) ) ) AxCFontNewObject( *this ).dump(); else ensureValid( false ); @@ -1655,55 +1656,55 @@ void FormControlStreamObject::implDump() if( (maProgId.getLength() > 0) && !mxStrm->isEof() ) { - if( maProgId.equalsAscii( "Forms.CommandButton.1" ) ) + if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CommandButton.1" ) ) ) AxCommandButtonObject( *this ).dump(); - else if( maProgId.equalsAscii( "Forms.TextBox.1" ) || - maProgId.equalsAscii( "Forms.ListBox.1" ) || - maProgId.equalsAscii( "Forms.ComboBox.1" ) || - maProgId.equalsAscii( "Forms.CheckBox.1" ) || - maProgId.equalsAscii( "Forms.OptionButton.1" ) || - maProgId.equalsAscii( "Forms.ToggleButton.1" ) || - maProgId.equalsAscii( "RefEdit.Ctrl" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.TextBox.1" ) ) || + maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ListBox.1" ) ) || + maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ComboBox.1" ) ) || + maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CheckBox.1" ) ) || + maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.OptionButton.1" ) ) || + maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ToggleButton.1" ) ) || + maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "RefEdit.Ctrl" ) ) ) AxMorphControlObject( *this ).dump(); - else if( maProgId.equalsAscii( "Forms.Label.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Label.1" ) ) ) AxLabelObject( *this ).dump(); - else if( maProgId.equalsAscii( "Forms.Image.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Image.1" ) ) ) AxImageObject( *this ).dump(); - else if( maProgId.equalsAscii( "Forms.ScrollBar.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ScrollBar.1" ) ) ) AxScrollBarObject( *this ).dump(); - else if( maProgId.equalsAscii( "Forms.SpinButton.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.SpinButton.1" ) ) ) AxSpinButtonObject( *this ).dump(); - else if( maProgId.equalsAscii( "Forms.TabStrip.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.TabStrip.1" ) ) ) AxTabStripObject( *this ).dump(); - else if( maProgId.equalsAscii( "MSComCtl2.FlatScrollBar.2" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MSComCtl2.FlatScrollBar.2" ) ) ) ComCtlScrollBarObject( *this, 6 ).dump(); - else if( maProgId.equalsAscii( "COMCTL.ProgCtrl.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "COMCTL.ProgCtrl.1" ) ) ) ComCtlProgressBarObject( *this, 5 ).dump(); - else if( maProgId.equalsAscii( "MSComctlLib.ProgCtrl.2" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MSComctlLib.ProgCtrl.2" ) ) ) ComCtlProgressBarObject( *this, 6 ).dump(); - else if( maProgId.equalsAscii( "COMCTL.Slider.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "COMCTL.Slider.1" ) ) ) ComCtlSliderObject( *this, 5 ).dump(); - else if( maProgId.equalsAscii( "MSComctlLib.Slider.2" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MSComctlLib.Slider.2" ) ) ) ComCtlSliderObject( *this, 6 ).dump(); - else if( maProgId.equalsAscii( "ComCtl2.UpDown.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ComCtl2.UpDown.1" ) ) ) ComCtlUpDownObject( *this, 5 ).dump(); - else if( maProgId.equalsAscii( "MSComCtl2.UpDown.2" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MSComCtl2.UpDown.2" ) ) ) ComCtlUpDownObject( *this, 6 ).dump(); - else if( maProgId.equalsAscii( "COMCTL.ImageListCtrl.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "COMCTL.ImageListCtrl.1" ) ) ) ComCtlImageListObject( *this, 5 ).dump(); - else if( maProgId.equalsAscii( "MSComctlLib.ImageListCtrl.2" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MSComctlLib.ImageListCtrl.2" ) ) ) ComCtlImageListObject( *this, 6 ).dump(); - else if( maProgId.equalsAscii( "COMCTL.TabStrip.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "COMCTL.TabStrip.1" ) ) ) ComCtlTabStripObject( *this, 5 ).dump(); - else if( maProgId.equalsAscii( "MSComctlLib.TabStrip.2" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MSComctlLib.TabStrip.2" ) ) ) ComCtlTabStripObject( *this, 6 ).dump(); - else if( maProgId.equalsAscii( "COMCTL.TreeCtrl.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "COMCTL.TreeCtrl.1" ) ) ) ComCtlTreeViewObject( *this, 5 ).dump(); - else if( maProgId.equalsAscii( "MSComctlLib.TreeCtrl.2" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MSComctlLib.TreeCtrl.2" ) ) ) ComCtlTreeViewObject( *this, 6 ).dump(); - else if( maProgId.equalsAscii( "COMCTL.SBarCtrl.1" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "COMCTL.SBarCtrl.1" ) ) ) ComCtlStatusBarObject( *this, 5 ).dump(); - else if( maProgId.equalsAscii( "StdPic" ) ) + else if( maProgId.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "StdPic" ) ) ) StdPicObject( *this ).dump(); } dumpRemainingStream(); @@ -2058,11 +2059,11 @@ VbaContainerStorageObject::VbaContainerStorageObject( const ObjectBase& rParent, void VbaContainerStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) { - if( rStrmName.equalsAscii( "f" ) ) + if( rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "f" ) ) ) VbaFStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); - else if( rStrmName.equalsAscii( "o" ) ) + else if( rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "o" ) ) ) VbaOStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); - else if( rStrmName.equalsAscii( "x" ) ) + else if( rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "x" ) ) ) VbaXStreamObject( *this, rxStrm, rSysFileName, maFormData ).dump(); else OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); @@ -2282,7 +2283,7 @@ VbaStorageObject::VbaStorageObject( const ObjectBase& rParent, const StorageRef& void VbaStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) { - if( (rStrgPath.getLength() == 0) && rStrmName.equalsAscii( "dir" ) ) + if( (rStrgPath.getLength() == 0) && rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "dir" ) ) ) VbaDirStreamObject( *this, rxStrm, rSysFileName, mrVbaData ).dump(); else if( mrVbaData.isModuleStream( rStrmName ) ) VbaModuleStreamObject( *this, rxStrm, rSysFileName, mrVbaData, mrVbaData.getStreamOffset( rStrmName ) ).dump(); @@ -2300,7 +2301,7 @@ VbaFormStorageObject::VbaFormStorageObject( const ObjectBase& rParent, const Sto void VbaFormStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) { - if( rStrmName.equalsAscii( "\003VBFrame" ) ) + if( rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "\003VBFrame" ) ) ) TextLineStreamObject( *this, rxStrm, mrVbaData.meTextEnc, rSysFileName ).dump(); else VbaContainerStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); @@ -2316,7 +2317,7 @@ VbaProjectStorageObject::VbaProjectStorageObject( const ObjectBase& rParent, con void VbaProjectStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, const OUString& rStrgPath, const OUString& rStrmName, const OUString& rSysFileName ) { - if( (rStrgPath.getLength() == 0) && rStrmName.equalsAscii( "PROJECT" ) ) + if( (rStrgPath.getLength() == 0) && rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "PROJECT" ) ) ) TextLineStreamObject( *this, rxStrm, maVbaData.meTextEnc, rSysFileName ).dump(); else OleStorageObject::implDumpStream( rxStrm, rStrgPath, rStrmName, rSysFileName ); @@ -2324,7 +2325,7 @@ void VbaProjectStorageObject::implDumpStream( const Reference< XInputStream >& r void VbaProjectStorageObject::implDumpStorage( const StorageRef& rxStrg, const OUString& rStrgPath, const OUString& rSysPath ) { - if( rStrgPath.equalsAscii( "VBA" ) ) + if( rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VBA" ) ) ) VbaStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump(); else VbaFormStorageObject( *this, rxStrg, rSysPath, maVbaData ).dump(); @@ -2350,3 +2351,5 @@ void ActiveXStorageObject::implDumpBaseStream( const BinaryInputStreamRef& rxStr } // namespace oox #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/dump/pptxdumper.cxx b/oox/source/dump/pptxdumper.cxx index c98ffac7e38d..798d805ae5e5 100644 --- a/oox/source/dump/pptxdumper.cxx +++ b/oox/source/dump/pptxdumper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -92,17 +93,17 @@ void RootStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, } else if( aExt.equalsIgnoreAsciiCaseAscii( "bin" ) ) { - if( rStrgPath.equalsAscii( "ppt" ) && rStrmName.equalsAscii( "vbaProject.bin" ) ) + if( rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ppt" ) ) && rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "vbaProject.bin" ) ) ) { StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, false ) ); VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump(); } - else if( rStrgPath.equalsAscii( "ppt/embeddings" ) ) + else if( rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ppt/embeddings" ) ) ) { StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, false ) ); OleStorageObject( *this, xStrg, rSysFileName ).dump(); } - else if( rStrgPath.equalsAscii( "ppt/activeX" ) ) + else if( rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ppt/activeX" ) ) ) { StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, true ) ); ActiveXStorageObject( *this, xStrg, rSysFileName ).dump(); @@ -147,3 +148,5 @@ void Dumper::implDump() } // namespace oox #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/dump/xlsbdumper.cxx b/oox/source/dump/xlsbdumper.cxx index a5ffab059b52..9a13d973fb3b 100644 --- a/oox/source/dump/xlsbdumper.cxx +++ b/oox/source/dump/xlsbdumper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -2268,31 +2269,31 @@ void RootStorageObject::implDumpStream( const Reference< XInputStream >& rxStrm, } else if( aExt.equalsIgnoreAsciiCaseAscii( "bin" ) ) { - if( rStrgPath.equalsAscii( "xl" ) && rStrmName.equalsAscii( "vbaProject.bin" ) ) + if( rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl" ) ) && rStrmName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "vbaProject.bin" ) ) ) { StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, false ) ); VbaProjectStorageObject( *this, xStrg, rSysFileName ).dump(); } - else if( rStrgPath.equalsAscii( "xl/embeddings" ) ) + else if( rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/embeddings" ) ) ) { StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, false ) ); OleStorageObject( *this, xStrg, rSysFileName ).dump(); } else if( - rStrgPath.equalsAscii( "xl" ) || - rStrgPath.equalsAscii( "xl/chartsheets" ) || - rStrgPath.equalsAscii( "xl/dialogsheets" ) || - rStrgPath.equalsAscii( "xl/externalLinks" ) || - rStrgPath.equalsAscii( "xl/macrosheets" ) || - rStrgPath.equalsAscii( "xl/pivotCache" ) || - rStrgPath.equalsAscii( "xl/pivotTables" ) || - rStrgPath.equalsAscii( "xl/queryTables" ) || - rStrgPath.equalsAscii( "xl/tables" ) || - rStrgPath.equalsAscii( "xl/worksheets" ) ) + rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl" ) ) || + rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/chartsheets" ) ) || + rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/dialogsheets" ) ) || + rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/externalLinks" ) ) || + rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/macrosheets" ) ) || + rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/pivotCache" ) ) || + rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/pivotTables" ) ) || + rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/queryTables" ) ) || + rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/tables" ) ) || + rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/worksheets" ) ) ) { RecordStreamObject( *this, rxStrm, rSysFileName ).dump(); } - else if( rStrgPath.equalsAscii( "xl/activeX" ) ) + else if( rStrgPath.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "xl/activeX" ) ) ) { StorageRef xStrg( new ::oox::ole::OleStorage( getContext(), rxStrm, true ) ); ActiveXStorageObject( *this, xStrg, rSysFileName ).dump(); @@ -2337,3 +2338,5 @@ void Dumper::implDump() } // namespace oox #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/export/ColorPropertySet.cxx b/oox/source/export/ColorPropertySet.cxx new file mode 100644 index 000000000000..cd00e5670f53 --- /dev/null +++ b/oox/source/export/ColorPropertySet.cxx @@ -0,0 +1,233 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove + +#include "ColorPropertySet.hxx" + +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/drawing/FillStyle.hpp> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::beans; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; +using ::com::sun::star::uno::RuntimeException; + +// ================================================================================ + +namespace +{ +class lcl_ColorPropertySetInfo : public ::cppu::WeakImplHelper1< + XPropertySetInfo > +{ +public: + lcl_ColorPropertySetInfo( bool bFillColor ); + +protected: + // ____ XPropertySetInfo ____ + virtual Sequence< Property > SAL_CALL getProperties() throw (RuntimeException); + virtual Property SAL_CALL getPropertyByName( const OUString& aName ) throw (UnknownPropertyException, RuntimeException); + virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) throw (RuntimeException); + +private: + bool m_bIsFillColor; + OUString m_aColorPropName; + Property m_aColorProp; +}; + +lcl_ColorPropertySetInfo::lcl_ColorPropertySetInfo( bool bFillColor ) : + m_bIsFillColor( bFillColor ), + // note: length of FillColor and LineColor is 9 + m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ), + m_aColorProp( m_aColorPropName, -1, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 0) +{} + +Sequence< Property > SAL_CALL lcl_ColorPropertySetInfo::getProperties() + throw (RuntimeException) +{ + + return Sequence< Property >( & m_aColorProp, 1 ); +} + +Property SAL_CALL lcl_ColorPropertySetInfo::getPropertyByName( const OUString& aName ) + throw (UnknownPropertyException, RuntimeException) +{ + if( aName.equals( m_aColorPropName )) + return m_aColorProp; + throw UnknownPropertyException( m_aColorPropName, static_cast< uno::XWeak * >( this )); +} + +sal_Bool SAL_CALL lcl_ColorPropertySetInfo::hasPropertyByName( const OUString& Name ) + throw (RuntimeException) +{ + return Name.equals( m_aColorPropName ); +} + +} // anonymous namespace + +// ================================================================================ + +namespace oox +{ +namespace drawingml +{ + +ColorPropertySet::ColorPropertySet( sal_Int32 nColor, bool bFillColor /* = true */ ) : + // note: length of FillColor and LineColor is 9 + m_aColorPropName( (bFillColor ? "FillColor" : "LineColor"), 9, RTL_TEXTENCODING_ASCII_US ), + m_nColor( nColor ), + m_bIsFillColor( bFillColor ), + m_nDefaultColor( 0x0099ccff ) // blue 8 +{} + +ColorPropertySet::~ColorPropertySet() +{} + +void ColorPropertySet::setColor( sal_Int32 nColor ) +{ + m_nColor = nColor; +} + +sal_Int32 ColorPropertySet::getColor() +{ + return m_nColor; +} + +// ____ XPropertySet ____ + +Reference< XPropertySetInfo > SAL_CALL ColorPropertySet::getPropertySetInfo() + throw (uno::RuntimeException) +{ + if( ! m_xInfo.is()) + m_xInfo.set( new lcl_ColorPropertySetInfo( m_bIsFillColor )); + + return m_xInfo; +} + +void SAL_CALL ColorPropertySet::setPropertyValue( const OUString& /* aPropertyName */, const uno::Any& aValue ) + throw (UnknownPropertyException, + PropertyVetoException, + lang::IllegalArgumentException, + lang::WrappedTargetException, + uno::RuntimeException) +{ + aValue >>= m_nColor; +} + +uno::Any SAL_CALL ColorPropertySet::getPropertyValue( const OUString& aPropertyName ) + throw (UnknownPropertyException, + lang::WrappedTargetException, + uno::RuntimeException) +{ + if( aPropertyName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("FillStyle")) && m_bIsFillColor ) + { + ::com::sun::star::drawing::FillStyle aFillStyle = ::com::sun::star::drawing::FillStyle_SOLID; + return uno::makeAny(aFillStyle); + } + return uno::makeAny( m_nColor ); +} + +void SAL_CALL ColorPropertySet::addPropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* xListener */ ) + throw (UnknownPropertyException, + lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_FAIL( "Not Implemented" ); + return; +} + +void SAL_CALL ColorPropertySet::removePropertyChangeListener( const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* aListener */ ) + throw (UnknownPropertyException, + lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_FAIL( "Not Implemented" ); + return; +} + +void SAL_CALL ColorPropertySet::addVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ ) + throw (UnknownPropertyException, + lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_FAIL( "Not Implemented" ); + return; +} + +void SAL_CALL ColorPropertySet::removeVetoableChangeListener( const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ ) + throw (UnknownPropertyException, + lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_FAIL( "Not Implemented" ); + return; +} + +// ____ XPropertyState ____ + +PropertyState SAL_CALL ColorPropertySet::getPropertyState( const OUString& /* PropertyName */ ) + throw (UnknownPropertyException, + uno::RuntimeException) +{ + return PropertyState_DIRECT_VALUE; +} + +Sequence< PropertyState > SAL_CALL ColorPropertySet::getPropertyStates( const Sequence< OUString >& /* aPropertyName */ ) + throw (UnknownPropertyException, + uno::RuntimeException) +{ + PropertyState aState = PropertyState_DIRECT_VALUE; + return Sequence< PropertyState >( & aState, 1 ); +} + +void SAL_CALL ColorPropertySet::setPropertyToDefault( const OUString& PropertyName ) + throw (UnknownPropertyException, + uno::RuntimeException) +{ + if( PropertyName.equals( m_aColorPropName )) + m_nColor = m_nDefaultColor; +} + +uno::Any SAL_CALL ColorPropertySet::getPropertyDefault( const OUString& aPropertyName ) + throw (UnknownPropertyException, + lang::WrappedTargetException, + uno::RuntimeException) +{ + if( aPropertyName.equals( m_aColorPropName )) + return uno::makeAny( m_nDefaultColor ); + return uno::Any(); +} + +} // namespace chart +} // namespace xmloff + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/export/ColorPropertySet.hxx b/oox/source/export/ColorPropertySet.hxx new file mode 100644 index 000000000000..0da33fc51369 --- /dev/null +++ b/oox/source/export/ColorPropertySet.hxx @@ -0,0 +1,129 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 + * + * 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 XMLOFF_COLORPROPERTYSET_HXX +#define XMLOFF_COLORPROPERTYSET_HXX + +#include <cppuhelper/implbase2.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> + +namespace oox +{ +namespace drawingml +{ + +class ColorPropertySet : public ::cppu::WeakImplHelper2< + ::com::sun::star::beans::XPropertySet, + ::com::sun::star::beans::XPropertyState > +{ +public: + // if bFillColor == false, the color is a LineColor + explicit ColorPropertySet( sal_Int32 nColor, bool bFillColor = true ); + virtual ~ColorPropertySet(); + + void setColor( sal_Int32 nColor ); + sal_Int32 getColor(); + +protected: + // ____ XPropertySet ____ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Any& aValue ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( + const ::rtl::OUString& PropertyName ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& PropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& PropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // ____ XPropertyState ____ + virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( + const ::rtl::OUString& PropertyName ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( + const ::rtl::OUString& PropertyName ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( + const ::rtl::OUString& aPropertyName ) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > m_xInfo; + ::rtl::OUString m_aColorPropName; + sal_Int32 m_nColor; + bool m_bIsFillColor; + sal_Int32 m_nDefaultColor; +}; + +} // namespace chart +} // namespace xmloff + +// XMLOFF_COLORPROPERTYSET_HXX +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/export/SchXMLSeriesHelper.cxx b/oox/source/export/SchXMLSeriesHelper.cxx new file mode 100644 index 000000000000..d9a92644dbdb --- /dev/null +++ b/oox/source/export/SchXMLSeriesHelper.cxx @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "SchXMLSeriesHelper.hxx" +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +// header for define RTL_CONSTASCII_USTRINGPARAM +#include <rtl/ustring.h> +// header for define DBG_ERROR1 +#include <tools/debug.hxx> + +#include <typeinfo> + +using namespace ::com::sun::star; +using ::rtl::OUString; +using ::rtl::OUStringToOString; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +// ---------------------------------------- + +::std::vector< Reference< chart2::XDataSeries > > + SchXMLSeriesHelper::getDataSeriesFromDiagram( + const Reference< chart2::XDiagram > & xDiagram ) +{ + ::std::vector< Reference< chart2::XDataSeries > > aResult; + + try + { + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( + xDiagram, uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( + xCooSysCnt->getCoordinateSystems()); + for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i ) + { + Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); + for( sal_Int32 j=0; j<aChartTypeSeq.getLength(); ++j ) + { + Reference< chart2::XDataSeriesContainer > xDSCnt( aChartTypeSeq[j], uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); + ::std::copy( aSeriesSeq.getConstArray(), aSeriesSeq.getConstArray() + aSeriesSeq.getLength(), + ::std::back_inserter( aResult )); + } + } + } + catch( uno::Exception & ex ) + { + (void)ex; // avoid warning for pro build + + OSL_FAIL( OUStringToOString( OUString( + OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) + + OUString::createFromAscii( typeid( ex ).name()) + + OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) + + ex.Message), RTL_TEXTENCODING_ASCII_US ).getStr()); + + } + + return aResult; +} + +::std::map< Reference< chart2::XDataSeries >, sal_Int32 > SchXMLSeriesHelper::getDataSeriesIndexMapFromDiagram( + const Reference< chart2::XDiagram > & xDiagram ) +{ + ::std::map< Reference< chart2::XDataSeries >, sal_Int32 > aRet; + + sal_Int32 nIndex=0; + + ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( SchXMLSeriesHelper::getDataSeriesFromDiagram( xDiagram )); + for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aSeriesIt( aSeriesVector.begin() ) + ; aSeriesIt != aSeriesVector.end() + ; aSeriesIt++, nIndex++ ) + { + Reference< chart2::XDataSeries > xSeries( *aSeriesIt ); + if( xSeries.is() ) + { + if( aRet.end() == aRet.find(xSeries) ) + aRet[xSeries]=nIndex; + } + } + return aRet; +} + +uno::Reference< chart2::XChartType > lcl_getChartTypeOfSeries( + const uno::Reference< chart2::XDiagram >& xDiagram + , const Reference< chart2::XDataSeries >& xSeries ) +{ + if(!xDiagram.is()) + return 0; + + //iterate through the model to find the given xSeries + //the found parent indicates the charttype + + //iterate through all coordinate systems + uno::Reference< chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY ); + if( !xCooSysContainer.is()) + return 0; + + uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysList( xCooSysContainer->getCoordinateSystems() ); + for( sal_Int32 nCS = 0; nCS < aCooSysList.getLength(); ++nCS ) + { + uno::Reference< chart2::XCoordinateSystem > xCooSys( aCooSysList[nCS] ); + + //iterate through all chart types in the current coordinate system + uno::Reference< chart2::XChartTypeContainer > xChartTypeContainer( xCooSys, uno::UNO_QUERY ); + OSL_ASSERT( xChartTypeContainer.is()); + if( !xChartTypeContainer.is() ) + continue; + uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypeList( xChartTypeContainer->getChartTypes() ); + for( sal_Int32 nT = 0; nT < aChartTypeList.getLength(); ++nT ) + { + uno::Reference< chart2::XChartType > xChartType( aChartTypeList[nT] ); + + //iterate through all series in this chart type + uno::Reference< chart2::XDataSeriesContainer > xDataSeriesContainer( xChartType, uno::UNO_QUERY ); + OSL_ASSERT( xDataSeriesContainer.is()); + if( !xDataSeriesContainer.is() ) + continue; + + uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesList( xDataSeriesContainer->getDataSeries() ); + for( sal_Int32 nS = 0; nS < aSeriesList.getLength(); ++nS ) + { + Reference< chart2::XDataSeries > xCurrentSeries( aSeriesList[nS] ); + + if( xSeries == xCurrentSeries ) + return xChartType; + } + } + } + return 0; +} + +bool SchXMLSeriesHelper::isCandleStickSeries( + const Reference< chart2::XDataSeries >& xSeries + , const Reference< frame::XModel >& xChartModel ) +{ + bool bRet = false; + + uno::Reference< chart2::XChartDocument > xNewDoc( xChartModel, uno::UNO_QUERY ); + if( xNewDoc.is() ) + { + uno::Reference< chart2::XDiagram > xNewDiagram( xNewDoc->getFirstDiagram() ); + if( xNewDiagram.is() ) + { + uno::Reference< chart2::XChartType > xChartType( lcl_getChartTypeOfSeries( + xNewDiagram, xSeries ) ); + if( xChartType.is() ) + { + rtl::OUString aServiceName( xChartType->getChartType() ); + if( aServiceName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.CandleStickChartType" ) ) ) ) + bRet = true; + } + } + } + return bRet; +} + +// static +Reference< chart2::XDataSeries > SchXMLSeriesHelper::getFirstCandleStickSeries( + const Reference< chart2::XDiagram > & xDiagram ) +{ + Reference< chart2::XDataSeries > xResult; + + try + { + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + for( sal_Int32 nCooSysIdx=0; !xResult.is() && nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) + { + Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes()); + for( sal_Int32 nCTIdx=0; !xResult.is() && nCTIdx<aCTSeq.getLength(); ++nCTIdx ) + { + if( aCTSeq[nCTIdx]->getChartType().equals( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.CandleStickChartType")))) + { + Reference< chart2::XDataSeriesContainer > xSeriesCnt( aCTSeq[nCTIdx], uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesCnt->getDataSeries() ); + if( aSeriesSeq.getLength()) + xResult.set( aSeriesSeq[0] ); + break; + } + } + } + } + catch( const uno::Exception & ) + { + OSL_FAIL( "Exception caught" ); + } + return xResult; +} + +//static +uno::Reference< beans::XPropertySet > SchXMLSeriesHelper::createOldAPISeriesPropertySet( + const uno::Reference< chart2::XDataSeries >& xSeries + , const uno::Reference< frame::XModel >& xChartModel ) +{ + uno::Reference< beans::XPropertySet > xRet; + + if( xSeries.is() ) + { + try + { + uno::Reference< lang::XMultiServiceFactory > xFactory( xChartModel, uno::UNO_QUERY ); + if( xFactory.is() ) + { + xRet = uno::Reference< beans::XPropertySet >( xFactory->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart2.DataSeriesWrapper")) ), uno::UNO_QUERY ); + Reference< lang::XInitialization > xInit( xRet, uno::UNO_QUERY ); + if(xInit.is()) + { + Sequence< uno::Any > aArguments(1); + aArguments[0]=uno::makeAny(xSeries); + xInit->initialize(aArguments); + } + } + } + catch( uno::Exception & rEx ) + { + (void)rEx; // avoid warning for pro build + OSL_TRACE( "Exception caught SchXMLSeriesHelper::createOldAPISeriesPropertySet: %s", + OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + } + } + + return xRet; +} + +//static +uno::Reference< beans::XPropertySet > SchXMLSeriesHelper::createOldAPIDataPointPropertySet( + const uno::Reference< chart2::XDataSeries >& xSeries + , sal_Int32 nPointIndex + , const uno::Reference< frame::XModel >& xChartModel ) +{ + uno::Reference< beans::XPropertySet > xRet; + + if( xSeries.is() ) + { + try + { + uno::Reference< lang::XMultiServiceFactory > xFactory( xChartModel, uno::UNO_QUERY ); + if( xFactory.is() ) + { + xRet = uno::Reference< beans::XPropertySet >( xFactory->createInstance( + OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart2.DataSeriesWrapper")) ), uno::UNO_QUERY ); + Reference< lang::XInitialization > xInit( xRet, uno::UNO_QUERY ); + if(xInit.is()) + { + Sequence< uno::Any > aArguments(2); + aArguments[0]=uno::makeAny(xSeries); + aArguments[1]=uno::makeAny(nPointIndex); + xInit->initialize(aArguments); + } + } + } + catch( uno::Exception & rEx ) + { + (void)rEx; // avoid warning for pro build + + OSL_TRACE( "Exception caught SchXMLSeriesHelper::createOldAPIDataPointPropertySet: %s", + OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + } + } + + return xRet; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/export/SchXMLSeriesHelper.hxx b/oox/source/export/SchXMLSeriesHelper.hxx new file mode 100644 index 000000000000..1fdabba3aa9b --- /dev/null +++ b/oox/source/export/SchXMLSeriesHelper.hxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 + * + * 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 _XMLOFF_SCH_XML_SERIESHELPER_HXX +#define _XMLOFF_SCH_XML_SERIESHELPER_HXX + +#include <com/sun/star/chart2/data/XDataSequence.hpp> +#include <com/sun/star/chart2/data/XDataSource.hpp> +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <com/sun/star/chart2/XDiagram.hpp> +#include <com/sun/star/frame/XModel.hpp> + +#include <vector> +#include <map> + +class SchXMLSeriesHelper +{ +public: + static ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > + getDataSeriesFromDiagram( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDiagram > & xDiagram ); + static ::std::map< ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >, sal_Int32 > + getDataSeriesIndexMapFromDiagram( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDiagram > & xDiagram ); + + static bool isCandleStickSeries( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >& xSeries + , const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); + + static ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > getFirstCandleStickSeries( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDiagram > & xDiagram ); + + static ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > createOldAPISeriesPropertySet( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >& xSeries + , const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); + + static ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > createOldAPIDataPointPropertySet( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >& xSeries + , sal_Int32 nPointIndex + , const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); +}; + +// _XMLOFF_SCH_XML_SERIESHELPER_HXX +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx new file mode 100644 index 000000000000..4bb7663daf34 --- /dev/null +++ b/oox/source/export/chartexport.cxx @@ -0,0 +1,2806 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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$ + * $Revision$ + * + * 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/token/tokens.hxx> +#include "oox/core/xmlfilterbase.hxx" +#include "oox/export/chartexport.hxx" +#include "oox/export/utils.hxx" +#include "oox/drawingml/chart/typegroupconverter.hxx" + +#include <cstdio> + +#include <com/sun/star/chart/XChartDocument.hpp> +#include <com/sun/star/chart/ChartLegendPosition.hpp> +#include <com/sun/star/chart/XTwoAxisXSupplier.hpp> +#include <com/sun/star/chart/XTwoAxisYSupplier.hpp> +#include <com/sun/star/chart/XAxisZSupplier.hpp> +#include <com/sun/star/chart/XChartDataArray.hpp> +#include <com/sun/star/chart/ChartDataRowSource.hpp> +#include <com/sun/star/chart/ChartAxisAssign.hpp> +#include <com/sun/star/chart/ChartSeriesAddress.hpp> +#include <com/sun/star/chart/X3DDisplay.hpp> +#include <com/sun/star/chart/XStatisticDisplay.hpp> +#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp> +#include <com/sun/star/chart/ChartSymbolType.hpp> +#include <com/sun/star/chart/ChartAxisMarks.hpp> +#include <com/sun/star/chart/ChartAxisLabelPosition.hpp> +#include <com/sun/star/chart/ChartAxisPosition.hpp> +#include <com/sun/star/chart/ChartSolidType.hpp> + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XDiagram.hpp> +#include <com/sun/star/chart2/RelativePosition.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> +#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> +#include <com/sun/star/chart2/DataPointGeometry3D.hpp> +#include <com/sun/star/chart2/data/XDataSource.hpp> +#include <com/sun/star/chart2/data/XDataSink.hpp> +#include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include <com/sun/star/chart2/data/XDataProvider.hpp> +#include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp> +#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> +#include <com/sun/star/chart2/data/XTextualDataSequence.hpp> +#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/BitmapMode.hpp> + +#include <com/sun/star/table/CellAddress.hpp> +#include <com/sun/star/sheet/XFormulaParser.hpp> +#include <com/sun/star/sheet/XFormulaTokens.hpp> +#include <com/sun/star/sheet/FormulaToken.hpp> +#include <com/sun/star/sheet/AddressConvention.hpp> + +#include <com/sun/star/text/WritingMode.hpp> +#include <com/sun/star/container/XNamed.hpp> + +#include <comphelper/processfactory.hxx> +#include "SchXMLSeriesHelper.hxx" +#include "ColorPropertySet.hxx" +#include "oox/xls/formulaparser.hxx" +#include "oox/xls/workbookhelper.hxx" +#include "oox/xls/addressconverter.hxx" +#include <set> +#include <time.h> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing; +using namespace ::oox::core; +using ::com::sun::star::beans::PropertyState; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::beans::XPropertyState; +using ::com::sun::star::container::XEnumeration; +using ::com::sun::star::container::XEnumerationAccess; +using ::com::sun::star::container::XIndexAccess; +using ::com::sun::star::container::XNamed; +using ::com::sun::star::io::XOutputStream; +using ::com::sun::star::table::CellAddress; +using ::com::sun::star::sheet::XFormulaParser; +using ::com::sun::star::sheet::XFormulaTokens; +using ::oox::core::XmlFilterBase; +using ::rtl::OString; +using ::rtl::OStringBuffer; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::sax_fastparser::FSHelperPtr; + +DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet)); + +#define IDS(x) (OString(#x " ") + OString::valueOf( mnShapeIdMax++ )).getStr() + +namespace oox { namespace drawingml { + +#define GETA(propName) \ + GetProperty( rXPropSet, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ) ) + +#define GETAD(propName) \ + ( GetPropertyAndState( rXPropSet, rXPropState, String( RTL_CONSTASCII_USTRINGPARAM( #propName ) ), eState ) && eState == beans::PropertyState_DIRECT_VALUE ) + +#define GET(variable, propName) \ + if ( GETA(propName) ) \ + mAny >>= variable; + +Reference< uno::XComponentContext > lcl_getComponentContext() +{ + Reference< uno::XComponentContext > xContext; + try + { + Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY ); + if( xFactProp.is()) + xFactProp->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))) >>= xContext; + } + catch( uno::Exception& ) + {} + + return xContext; +} + +class lcl_MatchesRole : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool > +{ +public: + explicit lcl_MatchesRole( const OUString & aRole ) : + m_aRole( aRole ) + {} + + bool operator () ( const Reference< chart2::data::XLabeledDataSequence > & xSeq ) const + { + if( !xSeq.is() ) + return false; + Reference< beans::XPropertySet > xProp( xSeq->getValues(), uno::UNO_QUERY ); + OUString aRole; + + return ( xProp.is() && + (xProp->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" )) ) >>= aRole ) && + m_aRole.equals( aRole )); + } + +private: + OUString m_aRole; +}; + +template< typename T > + void lcl_SequenceToVectorAppend( const Sequence< T > & rSource, ::std::vector< T > & rDestination ) +{ + rDestination.reserve( rDestination.size() + rSource.getLength()); + ::std::copy( rSource.getConstArray(), rSource.getConstArray() + rSource.getLength(), + ::std::back_inserter( rDestination )); +} + +Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Reference< chart2::XDiagram > & xDiagram ) +{ + Reference< chart2::data::XLabeledDataSequence > xResult; + try + { + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( + xDiagram, uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( + xCooSysCnt->getCoordinateSystems()); + for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i ) + { + Reference< chart2::XCoordinateSystem > xCooSys( aCooSysSeq[i] ); + OSL_ASSERT( xCooSys.is()); + for( sal_Int32 nN = xCooSys->getDimension(); nN--; ) + { + const sal_Int32 nMaxAxisIndex = xCooSys->getMaximumAxisIndexByDimension(nN); + for(sal_Int32 nI=0; nI<=nMaxAxisIndex; ++nI) + { + Reference< chart2::XAxis > xAxis = xCooSys->getAxisByDimension( nN, nI ); + OSL_ASSERT( xAxis.is()); + if( xAxis.is()) + { + chart2::ScaleData aScaleData = xAxis->getScaleData(); + if( aScaleData.Categories.is()) + { + xResult.set( aScaleData.Categories ); + break; + } + } + } + } + } + } + catch( uno::Exception & ex ) + { + (void)ex; // avoid warning for pro build + OSL_FAIL( rtl::OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) + + OUString::createFromAscii( typeid( ex ).name()) + + OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) + + ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); + } + + return xResult; +} + +Reference< chart2::data::XDataSource > lcl_createDataSource( + const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aData ) +{ + Reference< chart2::data::XDataSink > xSink; + Reference< uno::XComponentContext > xContext( lcl_getComponentContext()); + if( xContext.is() ) + xSink.set( + xContext->getServiceManager()->createInstanceWithContext( + OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.data.DataSource")), + xContext ), uno::UNO_QUERY_THROW ); + if( xSink.is()) + xSink->setData( aData ); + + return Reference< chart2::data::XDataSource >( xSink, uno::UNO_QUERY ); +} + +Sequence< Reference< chart2::data::XLabeledDataSequence > > lcl_getAllSeriesSequences( const Reference< chart2::XChartDocument >& xChartDoc ) +{ + ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aContainer; + if( xChartDoc.is() ) + { + Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram()); + ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( SchXMLSeriesHelper::getDataSeriesFromDiagram( xDiagram )); + for( ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aSeriesIt( aSeriesVector.begin() ) + ; aSeriesIt != aSeriesVector.end(); ++aSeriesIt ) + { + Reference< chart2::data::XDataSource > xDataSource( *aSeriesIt, uno::UNO_QUERY ); + if( !xDataSource.is() ) + continue; + uno::Sequence< Reference< chart2::data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); + lcl_SequenceToVectorAppend( aDataSequences, aContainer ); + } + } + + Sequence< Reference< chart2::data::XLabeledDataSequence > > aRet( aContainer.size()); + ::std::copy( aContainer.begin(), aContainer.end(), aRet.getArray()); + + return aRet; +} + +Reference< chart2::data::XLabeledDataSequence > + lcl_getDataSequenceByRole( + const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aLabeledSeq, + const OUString & rRole ) +{ + Reference< chart2::data::XLabeledDataSequence > aNoResult; + + const Reference< chart2::data::XLabeledDataSequence > * pBegin = aLabeledSeq.getConstArray(); + const Reference< chart2::data::XLabeledDataSequence > * pEnd = pBegin + aLabeledSeq.getLength(); + const Reference< chart2::data::XLabeledDataSequence > * pMatch = + ::std::find_if( pBegin, pEnd, lcl_MatchesRole( rRole )); + + if( pMatch != pEnd ) + return *pMatch; + + return aNoResult; +} + +Reference< chart2::data::XDataSource > lcl_pressUsedDataIntoRectangularFormat( const Reference< chart2::XChartDocument >& xChartDoc, sal_Bool& rOutSourceHasCategoryLabels ) +{ + ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aLabeledSeqVector; + + //categories are always the first sequence + Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram()); + Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( xDiagram ) ); + if( xCategories.is() ) + aLabeledSeqVector.push_back( xCategories ); + rOutSourceHasCategoryLabels = sal_Bool(xCategories.is()); + + Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeriesSeqVector( + lcl_getAllSeriesSequences( xChartDoc ) ); + + //the first x-values is always the next sequence //todo ... other x-values get lost for old format + Reference< chart2::data::XLabeledDataSequence > xXValues( + lcl_getDataSequenceByRole( aSeriesSeqVector, OUString(RTL_CONSTASCII_USTRINGPARAM("values-x")) ) ); + if( xXValues.is() ) + aLabeledSeqVector.push_back( xXValues ); + + //add all other sequences now without x-values + lcl_MatchesRole aHasXValues( OUString(RTL_CONSTASCII_USTRINGPARAM("values-x")) ); + for( sal_Int32 nN=0; nN<aSeriesSeqVector.getLength(); nN++ ) + { + if( !aHasXValues( aSeriesSeqVector[nN] ) ) + aLabeledSeqVector.push_back( aSeriesSeqVector[nN] ); + } + + Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeq( aLabeledSeqVector.size() ); + ::std::copy( aLabeledSeqVector.begin(), aLabeledSeqVector.end(), aSeq.getArray() ); + + return lcl_createDataSource( aSeq ); +} + +bool lcl_isSeriesAttachedToFirstAxis( + const Reference< chart2::XDataSeries > & xDataSeries ) +{ + bool bResult=true; + + try + { + sal_Int32 nAxisIndex = 0; + Reference< beans::XPropertySet > xProp( xDataSeries, uno::UNO_QUERY_THROW ); + if( xProp.is() ) + xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("AttachedAxisIndex") ) ) >>= nAxisIndex; + bResult = (0==nAxisIndex); + } + catch( uno::Exception & ex ) + { + (void)ex; // avoid warning for pro build + OSL_FAIL( rtl::OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) + + OUString::createFromAscii( typeid( ex ).name()) + + OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) + + ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); + } + + return bResult; +} + +OUString lcl_ConvertRange( const ::rtl::OUString & rRange, const Reference< chart2::XChartDocument > & xDoc ) +{ + OUString aResult = rRange; + + if( !xDoc.is() ) + return aResult; + Reference< chart2::data::XRangeXMLConversion > xConversion( + xDoc->getDataProvider(), uno::UNO_QUERY ); + if( xConversion.is()) + aResult = xConversion->convertRangeToXML( rRange ); + OSL_TRACE("lcl_ConvertRange, the originla formula is %s, the new formula is %s ", rtl::OUStringToOString( rRange, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( aResult, RTL_TEXTENCODING_UTF8 ).getStr()); + return aResult; +} + +typedef ::std::pair< OUString, OUString > tLabelAndValueRange; + +sal_Int32 lcl_getSequenceLengthByRole( + const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aSeqCnt, + const OUString & rRole ) +{ + Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( + lcl_getDataSequenceByRole( aSeqCnt, rRole )); + if( xLabeledSeq.is()) + { + Reference< chart2::data::XDataSequence > xSeq( xLabeledSeq->getValues()); + return xSeq->getData().getLength(); + } + return 0; +} + +bool lcl_hasChartType( const Reference< chart2::XDiagram > & xDiagram, const OUString & rChartType ) +{ + try + { + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) + { + Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); + for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) + { + if( aChartTypes[nCTIdx]->getChartType().equals( rChartType )) + return true; + } + } + } + catch( uno::Exception & ) + { + OSL_FAIL( "Exception while searching for chart type in diagram" ); + } + return false; +} + +OUString lcl_flattenStringSequence( const Sequence< OUString > & rSequence ) +{ + OUStringBuffer aResult; + bool bPrecedeWithSpace = false; + for( sal_Int32 nIndex=0; nIndex<rSequence.getLength(); ++nIndex ) + { + if( rSequence[nIndex].getLength()) + { + if( bPrecedeWithSpace ) + aResult.append( static_cast< sal_Unicode >( ' ' )); + aResult.append( rSequence[nIndex] ); + bPrecedeWithSpace = true; + } + } + return aResult.makeStringAndClear(); +} + +OUString lcl_getLabelString( const Reference< chart2::data::XDataSequence > & xLabelSeq ) +{ + Sequence< OUString > aLabels; + + uno::Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xLabelSeq, uno::UNO_QUERY ); + if( xTextualDataSequence.is()) + { + aLabels = xTextualDataSequence->getTextualData(); + } + else if( xLabelSeq.is()) + { + Sequence< uno::Any > aAnies( xLabelSeq->getData()); + aLabels.realloc( aAnies.getLength()); + for( sal_Int32 i=0; i<aAnies.getLength(); ++i ) + aAnies[i] >>= aLabels[i]; + } + + return lcl_flattenStringSequence( aLabels ); +} + +void lcl_fillCategoriesIntoStringVector( + const Reference< chart2::data::XDataSequence > & xCategories, + ::std::vector< OUString > & rOutCategories ) +{ + OSL_ASSERT( xCategories.is()); + if( !xCategories.is()) + return; + Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xCategories, uno::UNO_QUERY ); + if( xTextualDataSequence.is()) + { + rOutCategories.clear(); + Sequence< OUString > aTextData( xTextualDataSequence->getTextualData()); + ::std::copy( aTextData.getConstArray(), aTextData.getConstArray() + aTextData.getLength(), + ::std::back_inserter( rOutCategories )); + } + else + { + Sequence< uno::Any > aAnies( xCategories->getData()); + rOutCategories.resize( aAnies.getLength()); + for( sal_Int32 i=0; i<aAnies.getLength(); ++i ) + aAnies[i] >>= rOutCategories[i]; + } +} + +double lcl_getValueFromSequence( const Reference< chart2::data::XDataSequence > & xSeq, sal_Int32 nIndex ) +{ + double fResult = 0.0; + ::rtl::math::setNan( &fResult ); + Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY ); + if( xNumSeq.is()) + { + Sequence< double > aValues( xNumSeq->getNumericalData()); + if( nIndex < aValues.getLength() ) + fResult = aValues[nIndex]; + } + else + { + Sequence< uno::Any > aAnies( xSeq->getData()); + if( nIndex < aAnies.getLength() ) + aAnies[nIndex] >>= fResult; + } + return fResult; +} + +::std::vector< double > lcl_getAllValuesFromSequence( const Reference< chart2::data::XDataSequence > & xSeq ) +{ + double fNan = 0.0; + ::rtl::math::setNan( &fNan ); + ::std::vector< double > aResult; + + Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY ); + if( xNumSeq.is()) + { + Sequence< double > aValues( xNumSeq->getNumericalData()); + ::std::copy( aValues.getConstArray(), aValues.getConstArray() + aValues.getLength(), + ::std::back_inserter( aResult )); + } + else if( xSeq.is()) + { + Sequence< uno::Any > aAnies( xSeq->getData()); + aResult.resize( aAnies.getLength(), fNan ); + for( sal_Int32 i=0; i<aAnies.getLength(); ++i ) + aAnies[i] >>= aResult[i]; + } + return aResult; +} + +bool lcl_SequenceHasUnhiddenData( const uno::Reference< chart2::data::XDataSequence >& xDataSequence ) +{ + if( !xDataSequence.is() ) + return false; + uno::Reference< beans::XPropertySet > xProp( xDataSequence, uno::UNO_QUERY ); + if( xProp.is() ) + { + uno::Sequence< sal_Int32 > aHiddenValues; + try + { + xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "HiddenValues" ) ) ) >>= aHiddenValues; + if( !aHiddenValues.getLength() ) + return true; + } + catch( uno::Exception& e ) + { + (void)e; // avoid warning + return true; + } + } + if( xDataSequence->getData().getLength() ) + return true; + return false; +} + + +sal_Int32 lcl_getChartType( const OUString& sChartType ) +{ + chart::TypeId eChartTypeId = chart::TYPEID_UNKNOWN; + if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.BarDiagram" ))) + || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ColumnChartType") ) ) ) + eChartTypeId = chart::TYPEID_BAR; + else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.AreaDiagram" ))) + || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.AreaChartType") ) ) ) + eChartTypeId = chart::TYPEID_AREA; + else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.LineDiagram" ))) + || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.LineChartType") ) ) ) + eChartTypeId = chart::TYPEID_LINE; + else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.PieDiagram" ))) + || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.PieChartType") ) ) ) + eChartTypeId = chart::TYPEID_PIE; + else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.DonutDiagram" ))) + || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.DonutChartType") ) ) ) + eChartTypeId = chart::TYPEID_DOUGHNUT; + else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.XYDiagram" ))) + || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.ScatterChartType") ) ) ) + eChartTypeId = chart::TYPEID_SCATTER; + else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.NetDiagram" ))) + || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.NetChartType") ) ) ) + eChartTypeId = chart::TYPEID_RADARLINE; + else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.FilledNetDiagram" ))) + || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.FilledNetChartType") ) ) ) + eChartTypeId = chart::TYPEID_RADARAREA; + else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.StockDiagram" ))) + || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.CandleStickChartType") ) ) ) + eChartTypeId = chart::TYPEID_STOCK; + else if(( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.chart.BubbleDiagram" ))) + || ( 0 == sChartType.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.BubbleChartType") ) ) ) + eChartTypeId = chart::TYPEID_BUBBLE; + + return eChartTypeId; +} + +sal_Int32 lcl_generateRandomValue() +{ + static sal_Int32 MAX_NUMBER = 100000000; + //srand( unsigned( time( NULL ) )); + return sal_Int32( rand() % MAX_NUMBER ); +} + +ChartExport::ChartExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, Reference< frame::XModel >& xModel, XmlFilterBase* pFB, DocumentType eDocumentType ) + : DrawingML( pFS, pFB, eDocumentType ) + , mnXmlNamespace( nXmlNamespace ) + , maFraction( 1, 576 ) + , mxChartModel( xModel ) + , mbHasSeriesLabels( sal_False ) + , mbHasCategoryLabels( sal_False ) + , mbRowSourceColumns( sal_True ) + , mbHasXAxis( sal_False ) + , mbHasYAxis( sal_False ) + , mbHasZAxis( sal_False ) + , mbHasSecondaryXAxis( sal_False ) + , mbHasSecondaryYAxis( sal_False ) + , mbIs3DChart( sal_False ) +{ +} + +sal_Int32 ChartExport::GetXmlNamespace() const +{ + return mnXmlNamespace; +} + +ChartExport& ChartExport::SetXmlNamespace( sal_Int32 nXmlNamespace ) +{ + mnXmlNamespace = nXmlNamespace; + return *this; +} + +sal_Int32 ChartExport::GetChartID( ) +{ + sal_Int32 nID = GetFB()->GetUniqueId(); + return nID; +} + +sal_Int32 ChartExport::getChartType( ) +{ + OUString sChartType = mxDiagram->getDiagramType(); + return lcl_getChartType( sChartType ); +} + +OUString ChartExport::parseFormula( const OUString& rRange ) +{ + OUString aResult; + Reference< XFormulaParser > xParser; + uno::Reference< lang::XMultiServiceFactory > xSF( GetFB()->getModelFactory(), uno::UNO_QUERY ); + if( xSF.is() ) + { + try + { + xParser.set( xSF->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.FormulaParser")) ), UNO_QUERY ); + } + catch( Exception& ) + { + } + } + if( xParser.is() ) + { + OSL_TRACE("ChartExport::parseFormula, parser is valid"); + Reference< XPropertySet > xParserProps( xParser, uno::UNO_QUERY ); + if( xParserProps.is() ) + { + xParserProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("FormulaConvention")), uno::makeAny(::com::sun::star::sheet::AddressConvention::OOO) ); + } + uno::Sequence<sheet::FormulaToken> aTokens = xParser->parseFormula( rRange, CellAddress( 0, 0, 0 ) ); + if( xParserProps.is() ) + { + xParserProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("FormulaConvention")), uno::makeAny(::com::sun::star::sheet::AddressConvention::XL_OOX) ); + } + aResult = xParser->printFormula( aTokens, CellAddress( 0, 0, 0 ) ); + } + else + { + OSL_TRACE("ChartExport::parseFormula, parser is invalid"); + //FIXME: currently just using simple converter, e.g $Sheet1.$A$1:$C$1 -> Sheet1!$A$1:$C$1 + String aRange( rRange ); + if( aRange.SearchAscii("$") == 0 ) + aRange = aRange.Copy(1); + aRange.SearchAndReplaceAllAscii(".$", String::CreateFromAscii("!$") ); + aResult = aRange; + } + + OSL_TRACE("ChartExport::parseFormula, the originla formula is %s, the new formula is %s ", rtl::OUStringToOString( rRange, RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString( aResult, RTL_TEXTENCODING_UTF8 ).getStr()); + return aResult; +} + +ChartExport& ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nChartCount ) +{ + OSL_TRACE("ChartExport::WriteChartObj -- writer chart object"); + FSHelperPtr pFS = GetFS(); + + pFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND ); + + pFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND ); + + // TODO: get the correct chart name chart id + OUString sName = S("Object 1"); + Reference< XNamed > xNamed( xShape, UNO_QUERY ); + if (xNamed.is()) + sName = xNamed->getName(); + + sal_Int32 nID = GetChartID(); + + pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, + XML_id, I32S( nID ), + XML_name, USS( sName ), + FSEND ); + + pFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr, + FSEND ); + + if( GetDocumentType() == DOCUMENT_PPTX ) + pFS->singleElementNS( mnXmlNamespace, XML_nvPr, + FSEND ); + pFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr ); + + // visual chart properties + WriteShapeTransformation( xShape, mnXmlNamespace ); + + // writer chart object + pFS->startElement( FSNS( XML_a, XML_graphic ), FSEND ); + pFS->startElement( FSNS( XML_a, XML_graphicData ), + XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/chart", + FSEND ); + OUString sId; + const char* sFullPath = NULL; + const char* sRelativePath = NULL; + switch( GetDocumentType() ) + { + case DOCUMENT_DOCX: + { + sFullPath = "word/charts/chart"; + sRelativePath = "charts/chart"; + break; + } + case DOCUMENT_PPTX: + { + sFullPath = "ppt/charts/chart"; + sRelativePath = "../charts/chart"; + break; + } + case DOCUMENT_XLSX: + { + sFullPath = "xl/charts/chart"; + sRelativePath = "../charts/chart"; + break; + } + default: + { + sFullPath = "charts/chart"; + sRelativePath = "charts/chart"; + break; + } + } + OUString sFullStream = OUStringBuffer() + .appendAscii(sFullPath) + .append(nChartCount) + .appendAscii( ".xml" ) + .makeStringAndClear(); + OUString sRelativeStream = OUStringBuffer() + .appendAscii(sRelativePath) + .append(nChartCount) + .appendAscii( ".xml" ) + .makeStringAndClear(); + FSHelperPtr pChart = CreateOutputStream( + sFullStream, + sRelativeStream, + pFS->getOutputStream(), + "application/vnd.openxmlformats-officedocument.drawingml.chart+xml", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart", + &sId ); + + pFS->singleElement( FSNS( XML_c, XML_chart ), + FSNS( XML_xmlns, XML_c ), "http://schemas.openxmlformats.org/drawingml/2006/chart", + FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships", + FSNS( XML_r, XML_id ), USS( sId ), + FSEND ); + + pFS->endElement( FSNS( XML_a, XML_graphicData ) ); + pFS->endElement( FSNS( XML_a, XML_graphic ) ); + pFS->endElementNS( mnXmlNamespace, XML_graphicFrame ); + + SetFS( pChart ); + ExportContent(); + + return *this; +} + +void ChartExport::InitRangeSegmentationProperties( const Reference< chart2::XChartDocument > & xChartDoc ) +{ + if( xChartDoc.is()) + try + { + Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() ); + OSL_ENSURE( xDataProvider.is(), "No DataProvider" ); + if( xDataProvider.is()) + { + Reference< chart2::data::XDataSource > xDataSource( lcl_pressUsedDataIntoRectangularFormat( xChartDoc, mbHasCategoryLabels )); + Sequence< beans::PropertyValue > aArgs( xDataProvider->detectArguments( xDataSource )); + ::rtl::OUString sCellRange, sBrokenRange; + bool bBrokenRangeAvailable = false; + for( sal_Int32 i=0; i<aArgs.getLength(); ++i ) + { + if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation"))) + aArgs[i].Value >>= sCellRange; + else if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("BrokenCellRangeForExport"))) + { + if( aArgs[i].Value >>= sBrokenRange ) + bBrokenRangeAvailable = true; + } + else if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DataRowSource"))) + { + ::com::sun::star::chart::ChartDataRowSource eRowSource; + aArgs[i].Value >>= eRowSource; + mbRowSourceColumns = ( eRowSource == ::com::sun::star::chart::ChartDataRowSource_COLUMNS ); + } + else if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FirstCellAsLabel"))) + aArgs[i].Value >>= mbHasSeriesLabels; + else if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SequenceMapping"))) + aArgs[i].Value >>= maSequenceMapping; + else if( aArgs[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("TableNumberList"))) + aArgs[i].Value >>= msTableNumberList; + } + + // #i79009# For Writer we have to export a broken version of the + // range, where every row number is noe too large, so that older + // version can correctly read those files. + msChartAddress = (bBrokenRangeAvailable ? sBrokenRange : sCellRange); + if( msChartAddress.getLength() > 0 ) + { + // convert format to XML-conform one + Reference< chart2::data::XRangeXMLConversion > xConversion( xDataProvider, uno::UNO_QUERY ); + if( xConversion.is()) + msChartAddress = xConversion->convertRangeToXML( msChartAddress ); + } + } + } + catch( uno::Exception & ex ) + { + (void)ex; // avoid warning for pro build + OSL_FAIL( rtl::OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( "Exception caught. Type: " )) + + OUString::createFromAscii( typeid( ex ).name()) + + OUString( RTL_CONSTASCII_USTRINGPARAM( ", Message: " )) + + ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); + } +} + +void ChartExport::ExportContent() +{ + Reference< chart2::XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); + OSL_ASSERT( xChartDoc.is() ); + if( !xChartDoc.is() ) + return; + InitRangeSegmentationProperties( xChartDoc ); + // TODO: export chart + _ExportContent( ); +} + +void ChartExport::_ExportContent() +{ + Reference< ::com::sun::star::chart::XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); + if( xChartDoc.is()) + { + // determine if data comes from the outside + sal_Bool bIncludeTable = sal_True; + + Reference< chart2::XChartDocument > xNewDoc( xChartDoc, uno::UNO_QUERY ); + if( xNewDoc.is()) + { + // check if we have own data. If so we must not export the complete + // range string, as this is our only indicator for having own or + // external data. @todo: fix this in the file format! + Reference< lang::XServiceInfo > xDPServiceInfo( xNewDoc->getDataProvider(), uno::UNO_QUERY ); + if( ! (xDPServiceInfo.is() && + xDPServiceInfo->getImplementationName().equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( "com.sun.star.comp.chart.InternalDataProvider" )))) + { + bIncludeTable = sal_False; + } + } + else + { + Reference< lang::XServiceInfo > xServ( xChartDoc, uno::UNO_QUERY ); + if( xServ.is()) + { + if( xServ->supportsService( + OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.ChartTableAddressSupplier")))) + { + Reference< beans::XPropertySet > xProp( xServ, uno::UNO_QUERY ); + if( xProp.is()) + { + Any aAny; + try + { + OUString sChartAddress; + aAny = xProp->getPropertyValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("ChartRangeAddress"))); + aAny >>= msChartAddress; + //maExportHelper.SetChartRangeAddress( sChartAddress ); + + OUString sTableNumberList; + aAny = xProp->getPropertyValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("TableNumberList"))); + aAny >>= msTableNumberList; + //maExportHelper.SetTableNumberList( sTableNumberList ); + + // do not include own table if there are external addresses + bIncludeTable = (sChartAddress.getLength() == 0); + } + catch( beans::UnknownPropertyException & ) + { + OSL_FAIL( "Property ChartRangeAddress not supported by ChartDocument" ); + } + } + } + } + } + exportChartSpace( xChartDoc, bIncludeTable ); + } + else + { + OSL_FAIL( "Couldn't export chart due to wrong XModel" ); + } +} + +void ChartExport::exportChartSpace( Reference< ::com::sun::star::chart::XChartDocument > rChartDoc, + sal_Bool bIncludeTable ) +{ + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_chartSpace ), + FSNS( XML_xmlns, XML_c ), "http://schemas.openxmlformats.org/drawingml/2006/chart", + FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main", + FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships", + FSEND ); + // TODO: get the correct editing lanauge + pFS->singleElement( FSNS( XML_c, XML_lang ), + XML_val, "en-US", + FSEND ); + + if( !bIncludeTable ) + { + // TODO:external data + } + //XML_chart + exportChart(rChartDoc); + + // TODO: printSettings + // TODO: style + // TODO: text properties + // TODO: shape properties + Reference< XPropertySet > xPropSet( rChartDoc->getArea(), uno::UNO_QUERY ); + if( xPropSet.is() ) + exportShapeProps( xPropSet ); + pFS->endElement( FSNS( XML_c, XML_chartSpace ) ); +} + +void ChartExport::exportChart( Reference< ::com::sun::star::chart::XChartDocument > rChartDoc ) +{ + Reference< chart2::XChartDocument > xNewDoc( rChartDoc, uno::UNO_QUERY ); + mxDiagram.set( rChartDoc->getDiagram() ); + if( xNewDoc.is()) + mxNewDiagram.set( xNewDoc->getFirstDiagram()); + + // get Properties of ChartDocument + sal_Bool bHasMainTitle = sal_False; + sal_Bool bHasSubTitle = sal_False; + sal_Bool bHasLegend = sal_False; + Reference< beans::XPropertySet > xDocPropSet( rChartDoc, uno::UNO_QUERY ); + if( xDocPropSet.is()) + { + try + { + Any aAny( xDocPropSet->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "HasMainTitle" )))); + aAny >>= bHasMainTitle; + aAny = xDocPropSet->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "HasSubTitle" ))); + aAny >>= bHasSubTitle; + aAny = xDocPropSet->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "HasLegend" ))); + aAny >>= bHasLegend; + } + catch( beans::UnknownPropertyException & ) + { + DBG_WARNING( "Required property not found in ChartDocument" ); + } + } // if( xDocPropSet.is()) + + // chart element + // ------------- + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_chart ), + FSEND ); + + // title + if( bHasMainTitle ) + { + Reference< drawing::XShape > xShape = rChartDoc->getTitle(); + if( xShape.is() ) + exportTitle( xShape ); + } + InitPlotArea( ); + if( mbIs3DChart ) + { + exportView3D(); + + // sideWall + + // backWall + Reference< beans::XPropertySet > xBackWall( mxNewDiagram->getWall(), uno::UNO_QUERY ); + if( xBackWall.is() ) + { + pFS->startElement( FSNS( XML_c, XML_backWall ), + FSEND ); + exportShapeProps( xBackWall ); + pFS->endElement( FSNS( XML_c, XML_backWall ) ); + } + + // floor + Reference< beans::XPropertySet > xFloor( mxNewDiagram->getFloor(), uno::UNO_QUERY ); + if( xFloor.is() ) + { + pFS->startElement( FSNS( XML_c, XML_floor ), + FSEND ); + exportShapeProps( xFloor ); + pFS->endElement( FSNS( XML_c, XML_floor ) ); + } + + } + // plot area + exportPlotArea( ); + // legend + if( bHasLegend ) + exportLegend( rChartDoc ); + // only visible cells should be plotted on the chart + pFS->singleElement( FSNS( XML_c, XML_plotVisOnly ), + XML_val, "1", + FSEND ); + + pFS->endElement( FSNS( XML_c, XML_chart ) ); +} + +void ChartExport::exportLegend( Reference< ::com::sun::star::chart::XChartDocument > rChartDoc ) +{ + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_legend ), + FSEND ); + + Reference< beans::XPropertySet > xProp( rChartDoc->getLegend(), uno::UNO_QUERY ); + if( xProp.is() ) + { + // position + ::com::sun::star::chart::ChartLegendPosition aLegendPos = ::com::sun::star::chart::ChartLegendPosition_NONE; + try + { + Any aAny( xProp->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "Alignment" )))); + aAny >>= aLegendPos; + } + catch( beans::UnknownPropertyException & ) + { + DBG_WARNING( "Property Align not found in ChartLegend" ); + } + + const char* strPos = NULL; + switch( aLegendPos ) + { + case ::com::sun::star::chart::ChartLegendPosition_LEFT: + strPos = "l"; + break; + case ::com::sun::star::chart::ChartLegendPosition_RIGHT: + strPos = "r"; + break; + case ::com::sun::star::chart::ChartLegendPosition_TOP: + strPos = "t"; + break; + case ::com::sun::star::chart::ChartLegendPosition_BOTTOM: + strPos = "b"; + break; + case ::com::sun::star::chart::ChartLegendPosition_NONE: + case ::com::sun::star::chart::ChartLegendPosition_MAKE_FIXED_SIZE: + // nothing + break; + } + + if( strPos != NULL ) + { + pFS->singleElement( FSNS( XML_c, XML_legendPos ), + XML_val, strPos, + FSEND ); + } + + // shape properties + exportShapeProps( xProp ); + } + + // legendEntry + + pFS->endElement( FSNS( XML_c, XML_legend ) ); +} + +void ChartExport::exportTitle( Reference< XShape > xShape ) +{ + OUString sText; + Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY ); + if( xPropSet.is()) + { + xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "String" ))) >>= sText; + } + if( sText.getLength() == 0 ) + return; + + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_title ), + FSEND ); + // TODO:customize layout + pFS->singleElement( FSNS( XML_c, XML_layout ), + FSEND ); + + pFS->startElement( FSNS( XML_c, XML_tx ), + FSEND ); + pFS->startElement( FSNS( XML_c, XML_rich ), + FSEND ); + + // TODO: bodyPr + const char* sWritingMode = NULL; + sal_Bool bVertical = sal_False; + xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "StackedText" ))) >>= bVertical; + if( bVertical ) + sWritingMode = "wordArtVert"; + + pFS->singleElement( FSNS( XML_a, XML_bodyPr ), + XML_vert, sWritingMode, + FSEND ); + // TODO: lstStyle + pFS->singleElement( FSNS( XML_a, XML_lstStyle ), + FSEND ); + // FIXME: handle multipul paragraphs to parse aText + pFS->startElement( FSNS( XML_a, XML_p ), + FSEND ); + + pFS->startElement( FSNS( XML_a, XML_pPr ), + FSEND ); + pFS->singleElement( FSNS( XML_a, XML_defRPr ), + FSEND ); + pFS->endElement( FSNS( XML_a, XML_pPr ) ); + + pFS->startElement( FSNS( XML_a, XML_r ), + FSEND ); + WriteRunProperties( xPropSet, sal_False ); + pFS->startElement( FSNS( XML_a, XML_t ), + FSEND ); + pFS->writeEscaped( sText ); + pFS->endElement( FSNS( XML_a, XML_t ) ); + pFS->endElement( FSNS( XML_a, XML_r ) ); + + pFS->endElement( FSNS( XML_a, XML_p ) ); + + pFS->endElement( FSNS( XML_c, XML_rich ) ); + pFS->endElement( FSNS( XML_c, XML_tx ) ); + pFS->endElement( FSNS( XML_c, XML_title ) ); +} + +void ChartExport::exportPlotArea( ) +{ + Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( mxNewDiagram, uno::UNO_QUERY ); + if( ! xBCooSysCnt.is()) + return; + + // plot-area element + // ----------------- + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_plotArea ), + FSEND ); + // layout + pFS->singleElement( FSNS( XML_c, XML_layout ), + FSEND ); + + // chart type + Sequence< Reference< chart2::XCoordinateSystem > > + aCooSysSeq( xBCooSysCnt->getCoordinateSystems()); + for( sal_Int32 nCSIdx=0; nCSIdx<aCooSysSeq.getLength(); ++nCSIdx ) + { + Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCSIdx], uno::UNO_QUERY ); + if( ! xCTCnt.is()) + continue; + Sequence< Reference< chart2::XChartType > > aCTSeq( xCTCnt->getChartTypes()); + for( sal_Int32 nCTIdx=0; nCTIdx<aCTSeq.getLength(); ++nCTIdx ) + { + Reference< chart2::XDataSeriesContainer > xDSCnt( aCTSeq[nCTIdx], uno::UNO_QUERY ); + if( ! xDSCnt.is()) + return; + Reference< chart2::XChartType > xChartType( aCTSeq[nCTIdx], uno::UNO_QUERY ); + if( ! xChartType.is()) + continue; + // note: if xDSCnt.is() then also aCTSeq[nCTIdx] + OUString aChartType( xChartType->getChartType()); + sal_Int32 eChartType = lcl_getChartType( aChartType ); + switch( eChartType ) + { + case chart::TYPEID_BAR: + { + exportBarChart( xChartType ); + break; + } + case chart::TYPEID_AREA: + { + exportAreaChart( xChartType ); + break; + } + case chart::TYPEID_LINE: + { + exportLineChart( xChartType ); + break; + } + case chart::TYPEID_BUBBLE: + { + exportBubbleChart( xChartType ); + break; + } + case chart::TYPEID_DOUGHNUT: + { + exportDoughnutChart( xChartType ); + break; + } + case chart::TYPEID_OFPIE: + { + exportOfPieChart( xChartType ); + break; + } + case chart::TYPEID_PIE: + { + exportPieChart( xChartType ); + break; + } + case chart::TYPEID_RADARLINE: + case chart::TYPEID_RADARAREA: + { + exportRadarChart( xChartType ); + break; + } + case chart::TYPEID_SCATTER: + { + exportScatterChart( xChartType ); + break; + } + case chart::TYPEID_STOCK: + { + exportStockChart( xChartType ); + break; + } + case chart::TYPEID_SURFACE: + { + exportSuffaceChart( xChartType ); + break; + } + default: + { + OSL_TRACE("ChartExport::exportPlotArea -- not support chart type"); + break; + } + } + + } + } + //Axis Data + exportAxes( ); + + // shape properties + Reference< ::com::sun::star::chart::X3DDisplay > xWallFloorSupplier( mxDiagram, uno::UNO_QUERY ); + if( xWallFloorSupplier.is() ) + { + Reference< beans::XPropertySet > xWallPropSet( xWallFloorSupplier->getWall(), uno::UNO_QUERY ); + if( xWallPropSet.is() ) + { + exportShapeProps( xWallPropSet ); + } + } + + pFS->endElement( FSNS( XML_c, XML_plotArea ) ); + +} + +void ChartExport::exportAreaChart( Reference< chart2::XChartType > xChartType ) +{ + FSHelperPtr pFS = GetFS(); + sal_Int32 nTypeId = XML_areaChart; + if( mbIs3DChart ) + nTypeId = XML_area3DChart; + pFS->startElement( FSNS( XML_c, nTypeId ), + FSEND ); + + exportGrouping( ); + sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y; + exportSeries( xChartType, nAttachedAxis ); + exportAxesId( nAttachedAxis ); + + pFS->endElement( FSNS( XML_c, nTypeId ) ); +} + +void ChartExport::exportBarChart( Reference< chart2::XChartType > xChartType ) +{ + sal_Int32 nTypeId = XML_barChart; + if( mbIs3DChart ) + nTypeId = XML_bar3DChart; + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, nTypeId ), + FSEND ); + // bar direction + sal_Bool bVertical = sal_False; + Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY); + if( GetProperty( xPropSet, S( "Vertical" ) ) ) + mAny >>= bVertical; + + const char* bardir = bVertical? "bar":"col"; + pFS->singleElement( FSNS( XML_c, XML_barDir ), + XML_val, bardir, + FSEND ); + + exportGrouping( sal_True ); + sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y; + exportSeries( xChartType, nAttachedAxis ); + + Reference< XPropertySet > xTypeProp( xChartType, uno::UNO_QUERY ); + if( mbIs3DChart ) + { + // Shape + namespace cssc = ::com::sun::star::chart; + sal_Int32 nGeom3d = cssc::ChartSolidType::RECTANGULAR_SOLID; + if( xPropSet.is() && GetProperty( xPropSet, S("SolidType") ) ) + mAny >>= nGeom3d; + const char* sShapeType = NULL; + switch( nGeom3d ) + { + case cssc::ChartSolidType::RECTANGULAR_SOLID: + sShapeType = "box"; + break; + case cssc::ChartSolidType::CONE: + sShapeType = "cone"; + break; + case cssc::ChartSolidType::CYLINDER: + sShapeType = "cylinder"; + break; + case cssc::ChartSolidType::PYRAMID: + sShapeType = "pyramid"; + break; + } + pFS->singleElement( FSNS( XML_c, XML_shape ), + XML_val, sShapeType, + FSEND ); + } + + //overlap + if( xTypeProp.is() && GetProperty( xTypeProp, S("OverlapSequence") ) ) + { + uno::Sequence< sal_Int32 > aBarPositionSequence; + mAny >>= aBarPositionSequence; + if( aBarPositionSequence.getLength() ) + { + sal_Int32 nOverlap = aBarPositionSequence[0]; + if( nOverlap > 0 ) + pFS->singleElement( FSNS( XML_c, XML_overlap ), + XML_val, I32S( nOverlap ), + FSEND ); + } + } + if( xTypeProp.is() && GetProperty( xTypeProp, S("GapwidthSequence") ) ) + { + uno::Sequence< sal_Int32 > aBarPositionSequence; + mAny >>= aBarPositionSequence; + if( aBarPositionSequence.getLength() ) + { + sal_Int32 nGapWidth = aBarPositionSequence[0]; + pFS->singleElement( FSNS( XML_c, XML_gapWidth ), + XML_val, I32S( nGapWidth ), + FSEND ); + } + } + + exportAxesId( nAttachedAxis ); + + pFS->endElement( FSNS( XML_c, nTypeId ) ); +} + +void ChartExport::exportBubbleChart( Reference< chart2::XChartType > xChartType ) +{ + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_bubbleChart ), + FSEND ); + + sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y; + exportSeries( xChartType, nAttachedAxis ); + exportAxesId( nAttachedAxis ); + + pFS->endElement( FSNS( XML_c, XML_bubbleChart ) ); +} + +void ChartExport::exportDoughnutChart( Reference< chart2::XChartType > xChartType ) +{ + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_doughnutChart ), + FSEND ); + + sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y; + exportSeries( xChartType, nAttachedAxis ); + // firstSliceAng + exportFirstSliceAng( ); + //FIXME: holeSize + sal_Int32 nHoleSize = 50; + pFS->singleElement( FSNS( XML_c, XML_holeSize ), + XML_val, I32S( nHoleSize ), + FSEND ); + + exportAxesId( nAttachedAxis ); + + pFS->endElement( FSNS( XML_c, XML_doughnutChart ) ); +} + +void ChartExport::exportLineChart( Reference< chart2::XChartType > xChartType ) +{ + FSHelperPtr pFS = GetFS(); + sal_Int32 nTypeId = XML_lineChart; + if( mbIs3DChart ) + nTypeId = XML_line3DChart; + pFS->startElement( FSNS( XML_c, nTypeId ), + FSEND ); + + exportGrouping( ); + // TODO: show marker symbol in series? + sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y; + exportSeries( xChartType, nAttachedAxis ); + + // show marker? + sal_Int32 nSymbolType = ::com::sun::star::chart::ChartSymbolType::NONE; + Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY); + if( GetProperty( xPropSet, S( "SymbolType" ) ) ) + mAny >>= nSymbolType; + + const char* marker = nSymbolType == ::com::sun::star::chart::ChartSymbolType::NONE? "0":"1"; + pFS->singleElement( FSNS( XML_c, XML_marker ), + XML_val, marker, + FSEND ); + + exportAxesId( nAttachedAxis ); + + pFS->endElement( FSNS( XML_c, nTypeId ) ); +} + +void ChartExport::exportOfPieChart( Reference< chart2::XChartType > /*xChartType*/ ) +{ + // TODO: +} + +void ChartExport::exportPieChart( Reference< chart2::XChartType > xChartType ) +{ + FSHelperPtr pFS = GetFS(); + sal_Int32 nTypeId = XML_pieChart; + if( mbIs3DChart ) + nTypeId = XML_pie3DChart; + pFS->startElement( FSNS( XML_c, nTypeId ), + FSEND ); + // TODO: varyColors + const char* varyColors = "1"; + pFS->singleElement( FSNS( XML_c, XML_varyColors ), + XML_val, varyColors, + FSEND ); + + sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y; + exportSeries( xChartType, nAttachedAxis ); + + // firstSliceAng + exportFirstSliceAng( ); + + pFS->endElement( FSNS( XML_c, nTypeId ) ); +} + +void ChartExport::exportRadarChart( Reference< chart2::XChartType > xChartType) +{ + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_radarChart ), + FSEND ); + + // radarStyle + sal_Int32 eChartType = getChartType( ); + const char* radarStyle = NULL; + if( eChartType == chart::TYPEID_RADARAREA ) + radarStyle = "filled"; + else + radarStyle = "marker"; + pFS->singleElement( FSNS( XML_c, XML_radarStyle ), + XML_val, radarStyle, + FSEND ); + sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y; + exportSeries( xChartType, nAttachedAxis ); + exportAxesId( nAttachedAxis ); + + pFS->endElement( FSNS( XML_c, XML_radarChart ) ); +} + +void ChartExport::exportScatterChart( Reference< chart2::XChartType > xChartType ) +{ + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_scatterChart ), + FSEND ); + // TODO:scatterStyle + const char* scatterStyle = "lineMarker"; + pFS->singleElement( FSNS( XML_c, XML_scatterStyle ), + XML_val, scatterStyle, + FSEND ); + + // FIXME: should export xVal and yVal + sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y; + exportSeries( xChartType, nAttachedAxis ); + exportAxesId( nAttachedAxis ); + + pFS->endElement( FSNS( XML_c, XML_scatterChart ) ); +} + +void ChartExport::exportStockChart( Reference< chart2::XChartType > xChartType ) +{ + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_stockChart ), + FSEND ); + + sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y; + exportSeries( xChartType, nAttachedAxis ); + // export stock properties + Reference< ::com::sun::star::chart::XStatisticDisplay > xStockPropProvider( mxDiagram, uno::UNO_QUERY ); + if( xStockPropProvider.is()) + { + // stock-range-line + Reference< beans::XPropertySet > xStockPropSet = xStockPropProvider->getMinMaxLine(); + if( xStockPropSet.is() ) + { + pFS->startElement( FSNS( XML_c, XML_hiLowLines ), + FSEND ); + exportShapeProps( xStockPropSet ); + pFS->endElement( FSNS( XML_c, XML_hiLowLines ) ); + } + // stock updownbar + pFS->startElement( FSNS( XML_c, XML_upDownBars ), + FSEND ); + // TODO: gapWidth + sal_Int32 nGapWidth = 150; + pFS->singleElement( FSNS( XML_c, XML_gapWidth ), + XML_val, I32S( nGapWidth ), + FSEND ); + + xStockPropSet = xStockPropProvider->getUpBar(); + if( xStockPropSet.is() ) + { + pFS->startElement( FSNS( XML_c, XML_upBars ), + FSEND ); + exportShapeProps( xStockPropSet ); + pFS->endElement( FSNS( XML_c, XML_upBars ) ); + } + + xStockPropSet = xStockPropProvider->getDownBar(); + if( xStockPropSet.is() ) + { + pFS->startElement( FSNS( XML_c, XML_downBars ), + FSEND ); + exportShapeProps( xStockPropSet ); + pFS->endElement( FSNS( XML_c, XML_downBars ) ); + } + pFS->endElement( FSNS( XML_c, XML_upDownBars ) ); + } + + exportAxesId( nAttachedAxis ); + + pFS->endElement( FSNS( XML_c, XML_stockChart ) ); +} + +void ChartExport::exportSuffaceChart( Reference< chart2::XChartType > xChartType ) +{ + FSHelperPtr pFS = GetFS(); + sal_Int32 nTypeId = XML_surfaceChart; + if( mbIs3DChart ) + nTypeId = XML_surface3DChart; + pFS->startElement( FSNS( XML_c, nTypeId ), + FSEND ); + sal_Int32 nAttachedAxis = AXIS_PRIMARY_Y; + exportSeries( xChartType, nAttachedAxis ); + exportAxesId( nAttachedAxis ); + + pFS->endElement( FSNS( XML_c, nTypeId ) ); +} + +void ChartExport::exportSeries( Reference< chart2::XChartType > xChartType, sal_Int32& nAttachedAxis ) +{ + + OUString aLabelRole = xChartType->getRoleOfSequenceForSeriesLabel(); + Reference< chart2::XDataSeriesContainer > xDSCnt( xChartType, uno::UNO_QUERY ); + if( ! xDSCnt.is()) + return; + + OUString aChartType( xChartType->getChartType()); + sal_Int32 eChartType = lcl_getChartType( aChartType ); + + // special export for stock charts + if( eChartType == chart::TYPEID_STOCK ) + { + sal_Bool bJapaneseCandleSticks = sal_False; + Reference< beans::XPropertySet > xCTProp( xChartType, uno::UNO_QUERY ); + if( xCTProp.is()) + xCTProp->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Japanese"))) >>= bJapaneseCandleSticks; + exportCandleStickSeries( + xDSCnt->getDataSeries(), bJapaneseCandleSticks, nAttachedAxis ); + return; + } + + + // export dataseries for current chart-type + Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries()); + for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx ) + { + // export series + Reference< chart2::data::XDataSource > xSource( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ); + if( xSource.is()) + { + Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt( + xSource->getDataSequences()); + // search for main sequence and create a series element + { + sal_Int32 nMainSequenceIndex = -1; + sal_Int32 nSeriesLength = 0; + Reference< chart2::data::XDataSequence > xValuesSeq; + Reference< chart2::data::XDataSequence > xLabelSeq; + sal_Int32 nSeqIdx=0; + for( ; nSeqIdx<aSeqCnt.getLength(); ++nSeqIdx ) + { + OUString aRole; + Reference< chart2::data::XDataSequence > xTempValueSeq( aSeqCnt[nSeqIdx]->getValues() ); + if( nMainSequenceIndex==-1 ) + { + Reference< beans::XPropertySet > xSeqProp( xTempValueSeq, uno::UNO_QUERY ); + if( xSeqProp.is()) + xSeqProp->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("Role"))) >>= aRole; + // "main" sequence + if( aRole.equals( aLabelRole )) + { + xValuesSeq.set( xTempValueSeq ); + xLabelSeq.set( aSeqCnt[nSeqIdx]->getLabel()); + nMainSequenceIndex = nSeqIdx; + } + } + sal_Int32 nSequenceLength = (xTempValueSeq.is()? xTempValueSeq->getData().getLength() : sal_Int32(0)); + if( nSeriesLength < nSequenceLength ) + nSeriesLength = nSequenceLength; + } + + // have found the main sequence, then xValuesSeq and + // xLabelSeq contain those. Otherwise both are empty + { + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_ser ), + FSEND ); + + // TODO: idx and order + pFS->singleElement( FSNS( XML_c, XML_idx ), + XML_val, I32S(nSeriesIdx), + FSEND ); + pFS->singleElement( FSNS( XML_c, XML_order ), + XML_val, I32S(nSeriesIdx), + FSEND ); + + // export label + if( xLabelSeq.is() ) + exportSeriesText( xLabelSeq ); + + // export shape properties + Reference< XPropertySet > xPropSet = SchXMLSeriesHelper::createOldAPISeriesPropertySet( + aSeriesSeq[nSeriesIdx], getModel() ); + if( xPropSet.is() ) + { + if( GetProperty( xPropSet, S("Axis") ) ) + { + mAny >>= nAttachedAxis; + if( nAttachedAxis == ::com::sun::star::chart::ChartAxisAssign::SECONDARY_Y ) + nAttachedAxis = AXIS_SECONDARY_Y; + else + nAttachedAxis = AXIS_PRIMARY_Y; + } + exportShapeProps( xPropSet ); + } + + switch( eChartType ) + { + case chart::TYPEID_LINE: + { + exportMarker( ); + break; + } + case chart::TYPEID_PIE: + case chart::TYPEID_DOUGHNUT: + { + if( xPropSet.is() && GetProperty( xPropSet, S("SegmentOffset") ) ) + { + sal_Int32 nOffset = 0; + mAny >>= nOffset; + pFS->singleElement( FSNS( XML_c, XML_explosion ), + XML_val, I32S( nOffset ), + FSEND ); + } + break; + } + case chart::TYPEID_SCATTER: + { + exportMarker( ); + exportSmooth( ); + break; + } + case chart::TYPEID_RADARLINE: + { + exportMarker( ); + break; + } + } + + // TODO: Data Labels: show data lables + + // export data points + exportDataPoints( uno::Reference< beans::XPropertySet >( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ), nSeriesLength ); + + // export categories + if( mxCategoriesValues.is() ) + exportSeriesCategory( mxCategoriesValues ); + + if( (eChartType == chart::TYPEID_SCATTER) + || (eChartType == chart::TYPEID_BUBBLE) ) + { + // export xVal + Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString(RTL_CONSTASCII_USTRINGPARAM("values-x")) ) ); + if( xSequence.is() ) + { + Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() ); + if( xValues.is() ) + exportSeriesValues( xValues, XML_xVal ); + } + } + + + if( eChartType == chart::TYPEID_BUBBLE ) + { + // export yVal + Reference< chart2::data::XLabeledDataSequence > xSequence( lcl_getDataSequenceByRole( aSeqCnt, OUString(RTL_CONSTASCII_USTRINGPARAM("values-y")) ) ); + if( xSequence.is() ) + { + Reference< chart2::data::XDataSequence > xValues( xSequence->getValues() ); + if( xValues.is() ) + exportSeriesValues( xValues, XML_yVal ); + } + } + + // export values + if( xValuesSeq.is() ) + { + sal_Int32 nYValueType = XML_val; + if( eChartType == chart::TYPEID_SCATTER ) + nYValueType = XML_yVal; + else if( eChartType == chart::TYPEID_BUBBLE ) + nYValueType = XML_bubbleSize; + exportSeriesValues( xValuesSeq, nYValueType ); + } + + pFS->endElement( FSNS( XML_c, XML_ser ) ); + } + } + } + } +} + +void ChartExport::exportCandleStickSeries( + const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq, + sal_Bool /*bJapaneseCandleSticks*/, + sal_Int32& nAttachedAxis ) +{ + for( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeriesSeq.getLength(); ++nSeriesIdx ) + { + Reference< chart2::XDataSeries > xSeries( aSeriesSeq[nSeriesIdx] ); + nAttachedAxis = lcl_isSeriesAttachedToFirstAxis( xSeries ) ? AXIS_PRIMARY_Y : AXIS_SECONDARY_Y; + + Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); + if( xSource.is()) + { + // export series in correct order (as we don't store roles) + // with japanese candlesticks: open, low, high, close + // otherwise: low, high, close + Sequence< Reference< chart2::data::XLabeledDataSequence > > aSeqCnt( + xSource->getDataSequences()); + + Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY ); + const char* sSeries[] = {"values-first","values-max","values-min","values-last",0}; + for( sal_Int32 idx = 0; sSeries[idx] != 0 ; idx++ ) + { + Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( lcl_getDataSequenceByRole( aSeqCnt, OUString::createFromAscii(sSeries[idx]) ) ); + if( xLabeledSeq.is()) + { + Reference< chart2::data::XDataSequence > xLabelSeq( xLabeledSeq->getLabel()); + Reference< chart2::data::XDataSequence > xValueSeq( xLabeledSeq->getValues()); + { + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_ser ), + FSEND ); + + // TODO: idx and order + pFS->singleElement( FSNS( XML_c, XML_idx ), + XML_val, I32S(idx), + FSEND ); + pFS->singleElement( FSNS( XML_c, XML_order ), + XML_val, I32S(idx), + FSEND ); + + // export label + if( xLabelSeq.is() ) + exportSeriesText( xLabelSeq ); + + // TODO:export shape properties + + // export categories + if( mxCategoriesValues.is() ) + exportSeriesCategory( mxCategoriesValues ); + + // export values + if( xValueSeq.is() ) + exportSeriesValues( xValueSeq ); + + pFS->endElement( FSNS( XML_c, XML_ser ) ); + } + } + } + } + } +} + + + +void ChartExport::exportDataSeq( const Reference< chart2::data::XDataSequence > & xValueSeq, sal_Int32 elementTokenId ) +{ + FSHelperPtr pFS = GetFS(); + Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY ); + pFS->startElement( FSNS( XML_c, elementTokenId ), + FSEND ); + + sal_Int32 eTokenId1 = elementTokenId == XML_val ? XML_numRef:XML_strRef; + OUString aCellRange = lcl_ConvertRange( xValueSeq->getSourceRangeRepresentation(), xNewDoc ); + pFS->startElement( FSNS( XML_c, eTokenId1 ), + FSEND ); + + pFS->startElement( FSNS( XML_c, XML_f ), + FSEND ); + pFS->writeEscaped( aCellRange ); + pFS->endElement( FSNS( XML_c, XML_f ) ); + + pFS->endElement( FSNS( XML_c, eTokenId1 ) ); + pFS->endElement( FSNS( XML_c, elementTokenId ) ); +} + +void ChartExport::exportSeriesText( const Reference< chart2::data::XDataSequence > & xValueSeq ) +{ + FSHelperPtr pFS = GetFS(); + Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY ); + pFS->startElement( FSNS( XML_c, XML_tx ), + FSEND ); + + OUString aCellRange = xValueSeq->getSourceRangeRepresentation(); + aCellRange = parseFormula( aCellRange ); + pFS->startElement( FSNS( XML_c, XML_strRef ), + FSEND ); + + pFS->startElement( FSNS( XML_c, XML_f ), + FSEND ); + pFS->writeEscaped( aCellRange ); + pFS->endElement( FSNS( XML_c, XML_f ) ); + + OUString aLabelString = lcl_getLabelString( xValueSeq ); + pFS->startElement( FSNS( XML_c, XML_strCache ), + FSEND ); + pFS->singleElement( FSNS( XML_c, XML_ptCount ), + XML_val, "1", + FSEND ); + pFS->startElement( FSNS( XML_c, XML_pt ), + XML_idx, "0", + FSEND ); + pFS->startElement( FSNS( XML_c, XML_v ), + FSEND ); + pFS->writeEscaped( aLabelString ); + pFS->endElement( FSNS( XML_c, XML_v ) ); + pFS->endElement( FSNS( XML_c, XML_pt ) ); + pFS->endElement( FSNS( XML_c, XML_strCache ) ); + pFS->endElement( FSNS( XML_c, XML_strRef ) ); + pFS->endElement( FSNS( XML_c, XML_tx ) ); +} + +void ChartExport::exportSeriesCategory( const Reference< chart2::data::XDataSequence > & xValueSeq ) +{ + FSHelperPtr pFS = GetFS(); + Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY ); + pFS->startElement( FSNS( XML_c, XML_cat ), + FSEND ); + + OUString aCellRange = xValueSeq->getSourceRangeRepresentation(); + aCellRange = parseFormula( aCellRange ); + // TODO: need to handle XML_multiLvlStrRef according to aCellRange + pFS->startElement( FSNS( XML_c, XML_strRef ), + FSEND ); + + pFS->startElement( FSNS( XML_c, XML_f ), + FSEND ); + pFS->writeEscaped( aCellRange ); + pFS->endElement( FSNS( XML_c, XML_f ) ); + + ::std::vector< OUString > aCategories; + lcl_fillCategoriesIntoStringVector( xValueSeq, aCategories ); + sal_Int32 ptCount = aCategories.size(); + pFS->startElement( FSNS( XML_c, XML_strCache ), + FSEND ); + pFS->singleElement( FSNS( XML_c, XML_ptCount ), + XML_val, I32S( ptCount ), + FSEND ); + for( sal_Int32 i = 0; i < ptCount; i++ ) + { + pFS->startElement( FSNS( XML_c, XML_pt ), + XML_idx, I32S( i ), + FSEND ); + pFS->startElement( FSNS( XML_c, XML_v ), + FSEND ); + pFS->writeEscaped( aCategories[i] ); + pFS->endElement( FSNS( XML_c, XML_v ) ); + pFS->endElement( FSNS( XML_c, XML_pt ) ); + } + + pFS->endElement( FSNS( XML_c, XML_strCache ) ); + pFS->endElement( FSNS( XML_c, XML_strRef ) ); + pFS->endElement( FSNS( XML_c, XML_cat ) ); +} + +void ChartExport::exportSeriesValues( const Reference< chart2::data::XDataSequence > & xValueSeq, sal_Int32 nValueType ) +{ + FSHelperPtr pFS = GetFS(); + Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY ); + pFS->startElement( FSNS( XML_c, nValueType ), + FSEND ); + + OUString aCellRange = xValueSeq->getSourceRangeRepresentation(); + aCellRange = parseFormula( aCellRange ); + // TODO: need to handle XML_multiLvlStrRef according to aCellRange + pFS->startElement( FSNS( XML_c, XML_numRef ), + FSEND ); + + pFS->startElement( FSNS( XML_c, XML_f ), + FSEND ); + pFS->writeEscaped( aCellRange ); + pFS->endElement( FSNS( XML_c, XML_f ) ); + + ::std::vector< double > aValues; + aValues = lcl_getAllValuesFromSequence( xValueSeq ); + sal_Int32 ptCount = aValues.size(); + pFS->startElement( FSNS( XML_c, XML_numCache ), + FSEND ); + pFS->startElement( FSNS( XML_c, XML_formatCode ), + FSEND ); + // TODO: what format code? + pFS->writeEscaped( "General" ); + pFS->endElement( FSNS( XML_c, XML_formatCode ) ); + pFS->singleElement( FSNS( XML_c, XML_ptCount ), + XML_val, I32S( ptCount ), + FSEND ); + for( sal_Int32 i = 0; i < ptCount; i++ ) + { + pFS->startElement( FSNS( XML_c, XML_pt ), + XML_idx, I32S( i ), + FSEND ); + pFS->startElement( FSNS( XML_c, XML_v ), + FSEND ); + pFS->write( aValues[i] ); + pFS->endElement( FSNS( XML_c, XML_v ) ); + pFS->endElement( FSNS( XML_c, XML_pt ) ); + } + + pFS->endElement( FSNS( XML_c, XML_numCache ) ); + pFS->endElement( FSNS( XML_c, XML_numRef ) ); + pFS->endElement( FSNS( XML_c, nValueType ) ); +} + +void ChartExport::exportShapeProps( Reference< XPropertySet > xPropSet ) +{ + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_spPr ), + FSEND ); + + WriteFill( xPropSet ); + WriteOutline( xPropSet ); + pFS->endElement( FSNS( XML_c, XML_spPr ) ); +} + +void ChartExport::InitPlotArea( ) +{ + Reference< XPropertySet > xDiagramProperties (mxDiagram, uno::UNO_QUERY); + + // Check for supported services and then the properties provided by this service. + Reference<lang::XServiceInfo> xServiceInfo (mxDiagram, uno::UNO_QUERY); + if (xServiceInfo.is()) + { + if (xServiceInfo->supportsService( + OUString(RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.chart.ChartAxisXSupplier")))) + { + xDiagramProperties->getPropertyValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasXAxis"))) >>= mbHasXAxis; + } + if (xServiceInfo->supportsService( + OUString(RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.chart.ChartAxisYSupplier")))) + { + xDiagramProperties->getPropertyValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasYAxis"))) >>= mbHasYAxis; + } + if (xServiceInfo->supportsService( + OUString(RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.chart.ChartAxisZSupplier")))) + { + xDiagramProperties->getPropertyValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasZAxis"))) >>= mbHasZAxis; + } + if (xServiceInfo->supportsService( + OUString(RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.chart.ChartTwoAxisXSupplier")))) + { + xDiagramProperties->getPropertyValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryXAxis"))) >>= mbHasSecondaryXAxis; + } + if (xServiceInfo->supportsService( + OUString(RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.chart.ChartTwoAxisYSupplier")))) + { + xDiagramProperties->getPropertyValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("HasSecondaryYAxis"))) >>= mbHasSecondaryYAxis; + } + } + + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("Dim3D"))) >>= mbIs3DChart; + + Reference< chart2::XChartDocument > xNewDoc( getModel(), uno::UNO_QUERY ); + if( mbHasCategoryLabels && mxNewDiagram.is()) + { + Reference< chart2::data::XLabeledDataSequence > xCategories( lcl_getCategories( mxNewDiagram ) ); + if( xCategories.is() ) + { + mxCategoriesValues.set( xCategories->getValues() ); + } + } +} + +void ChartExport::exportAxes( ) +{ + sal_Int32 nSize = maAxes.size(); + for( sal_Int32 nIdx = 0; nIdx < nSize; nIdx++ ) + { + exportAxis( maAxes[nIdx] ); + } +} + +void ChartExport::exportAxis( AxisIdPair aAxisIdPair ) +{ + // get some properties from document first + sal_Bool bHasXAxisTitle = sal_False, + bHasYAxisTitle = sal_False, + bHasZAxisTitle = sal_False, + bHasSecondaryXAxisTitle = sal_False, + bHasSecondaryYAxisTitle = sal_False; + sal_Bool bHasXAxisMajorGrid = sal_False, + bHasXAxisMinorGrid = sal_False, + bHasYAxisMajorGrid = sal_False, + bHasYAxisMinorGrid = sal_False, + bHasZAxisMajorGrid = sal_False, + bHasZAxisMinorGrid = sal_False; + + Reference< XPropertySet > xDiagramProperties (mxDiagram, uno::UNO_QUERY); + + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisTitle"))) >>= bHasXAxisTitle; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisTitle"))) >>= bHasYAxisTitle; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisTitle"))) >>= bHasZAxisTitle; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasSecondaryXAxisTitle"))) >>= bHasSecondaryXAxisTitle; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasSecondaryYAxisTitle"))) >>= bHasSecondaryYAxisTitle; + + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisGrid"))) >>= bHasXAxisMajorGrid; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisGrid"))) >>= bHasYAxisMajorGrid; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisGrid"))) >>= bHasZAxisMajorGrid; + + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisHelpGrid"))) >>= bHasXAxisMinorGrid; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisHelpGrid"))) >>= bHasYAxisMinorGrid; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasZAxisHelpGrid"))) >>= bHasZAxisMinorGrid; + + Reference< XPropertySet > xAxisProp; + Reference< drawing::XShape > xAxisTitle; + Reference< beans::XPropertySet > xMajorGrid; + Reference< beans::XPropertySet > xMinorGrid; + sal_Int32 nAxisType = XML_catAx; + const char* sAxPos = NULL; + + switch( aAxisIdPair.nAxisType ) + { + case AXIS_PRIMARY_X: + { + Reference< ::com::sun::star::chart::XAxisXSupplier > xAxisXSupp( mxDiagram, uno::UNO_QUERY ); + if( xAxisXSupp.is()) + xAxisProp = xAxisXSupp->getXAxis(); + if( bHasXAxisTitle ) + xAxisTitle.set( xAxisXSupp->getXAxisTitle(), uno::UNO_QUERY ); + if( bHasXAxisMajorGrid ) + xMajorGrid.set( xAxisXSupp->getXMainGrid(), uno::UNO_QUERY ); + if( bHasXAxisMinorGrid ) + xMinorGrid.set( xAxisXSupp->getXHelpGrid(), uno::UNO_QUERY ); + + sal_Int32 eChartType = getChartType( ); + if( (eChartType == chart::TYPEID_SCATTER) + || (eChartType == chart::TYPEID_BUBBLE) ) + nAxisType = XML_valAx; + else if( eChartType == chart::TYPEID_STOCK ) + nAxisType = XML_dateAx; + // FIXME: axPos, need to check axis direction + sAxPos = "b"; + break; + } + case AXIS_PRIMARY_Y: + { + Reference< ::com::sun::star::chart::XAxisYSupplier > xAxisYSupp( mxDiagram, uno::UNO_QUERY ); + if( xAxisYSupp.is()) + xAxisProp = xAxisYSupp->getYAxis(); + if( bHasYAxisTitle ) + xAxisTitle.set( xAxisYSupp->getYAxisTitle(), uno::UNO_QUERY ); + if( bHasYAxisMajorGrid ) + xMajorGrid.set( xAxisYSupp->getYMainGrid(), uno::UNO_QUERY ); + if( bHasYAxisMinorGrid ) + xMinorGrid.set( xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY ); + + nAxisType = XML_valAx; + // FIXME: axPos, need to check axis direction + sAxPos = "l"; + break; + } + case AXIS_PRIMARY_Z: + { + Reference< ::com::sun::star::chart::XAxisZSupplier > xAxisZSupp( mxDiagram, uno::UNO_QUERY ); + if( xAxisZSupp.is()) + xAxisProp = xAxisZSupp->getZAxis(); + if( bHasZAxisTitle ) + xAxisTitle.set( xAxisZSupp->getZAxisTitle(), uno::UNO_QUERY ); + if( bHasZAxisMajorGrid ) + xMajorGrid.set( xAxisZSupp->getZMainGrid(), uno::UNO_QUERY ); + if( bHasZAxisMinorGrid ) + xMinorGrid.set( xAxisZSupp->getZHelpGrid(), uno::UNO_QUERY ); + + sal_Int32 eChartType = getChartType( ); + if( (eChartType == chart::TYPEID_SCATTER) + || (eChartType == chart::TYPEID_BUBBLE) ) + nAxisType = XML_valAx; + else if( eChartType == chart::TYPEID_STOCK ) + nAxisType = XML_dateAx; + // FIXME: axPos, need to check axis direction + sAxPos = "b"; + break; + } + case AXIS_SECONDARY_Y: + { + Reference< ::com::sun::star::chart::XTwoAxisYSupplier > xAxisTwoYSupp( mxDiagram, uno::UNO_QUERY ); + if( xAxisTwoYSupp.is()) + xAxisProp = xAxisTwoYSupp->getSecondaryYAxis(); + if( bHasSecondaryYAxisTitle ) + { + Reference< ::com::sun::star::chart::XSecondAxisTitleSupplier > xAxisSupp( mxDiagram, uno::UNO_QUERY ); + xAxisTitle.set( xAxisSupp->getSecondYAxisTitle(), uno::UNO_QUERY ); + } + + nAxisType = XML_valAx; + // FIXME: axPos, need to check axis direction + sAxPos = "l"; + break; + } + } + + + _exportAxis( xAxisProp, xAxisTitle, xMajorGrid, xMinorGrid, nAxisType, sAxPos, aAxisIdPair ); +} + +void ChartExport::exportXAxis( AxisIdPair aAxisIdPair ) +{ + // get some properties from document first + sal_Bool bHasXAxisTitle = sal_False, + bHasSecondaryXAxisTitle = sal_False; + sal_Bool bHasXAxisMajorGrid = sal_False, + bHasXAxisMinorGrid = sal_False; + + Reference< XPropertySet > xDiagramProperties (mxDiagram, uno::UNO_QUERY); + + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisTitle"))) >>= bHasXAxisTitle; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasSecondaryXAxisTitle"))) >>= bHasSecondaryXAxisTitle; + + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisGrid"))) >>= bHasXAxisMajorGrid; + + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasXAxisHelpGrid"))) >>= bHasXAxisMinorGrid; + + // catAx + Reference< ::com::sun::star::chart::XAxisXSupplier > xAxisXSupp( mxDiagram, uno::UNO_QUERY ); + if( !xAxisXSupp.is()) + return; + + Reference< XPropertySet > xAxisProp = xAxisXSupp->getXAxis(); + if( !xAxisProp.is() ) + return; + + sal_Int32 nAxisType = XML_catAx; + sal_Int32 eChartType = getChartType( ); + if( (eChartType == chart::TYPEID_SCATTER) + || (eChartType == chart::TYPEID_BUBBLE) ) + nAxisType = XML_valAx; + else if( eChartType == chart::TYPEID_STOCK ) + nAxisType = XML_dateAx; + + Reference< drawing::XShape > xAxisTitle; + if( bHasXAxisTitle ) + xAxisTitle.set( xAxisXSupp->getXAxisTitle(), uno::UNO_QUERY ); + + // FIXME: axPos, need to check axis direction + const char* sAxPos = "b"; + // major grid line + Reference< beans::XPropertySet > xMajorGrid; + if( bHasXAxisMajorGrid ) + xMajorGrid.set( xAxisXSupp->getXMainGrid(), uno::UNO_QUERY ); + + // minor grid line + Reference< beans::XPropertySet > xMinorGrid; + if( bHasXAxisMinorGrid ) + xMinorGrid.set( xAxisXSupp->getXHelpGrid(), uno::UNO_QUERY ); + + _exportAxis( xAxisProp, xAxisTitle, xMajorGrid, xMinorGrid, nAxisType, sAxPos, aAxisIdPair ); +} + +void ChartExport::exportYAxis( AxisIdPair aAxisIdPair ) +{ + // get some properties from document first + sal_Bool bHasYAxisTitle = sal_False, + bHasSecondaryYAxisTitle = sal_False; + sal_Bool bHasYAxisMajorGrid = sal_False, + bHasYAxisMinorGrid = sal_False; + + Reference< XPropertySet > xDiagramProperties (mxDiagram, uno::UNO_QUERY); + + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisTitle"))) >>= bHasYAxisTitle; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasSecondaryYAxisTitle"))) >>= bHasSecondaryYAxisTitle; + + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisGrid"))) >>= bHasYAxisMajorGrid; + xDiagramProperties->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("HasYAxisHelpGrid"))) >>= bHasYAxisMinorGrid; + + Reference< ::com::sun::star::chart::XAxisYSupplier > xAxisYSupp( mxDiagram, uno::UNO_QUERY ); + if( !xAxisYSupp.is()) + return; + + Reference< XPropertySet > xAxisProp = xAxisYSupp->getYAxis(); + if( !xAxisProp.is() ) + return; + + sal_Int32 nAxisType = XML_valAx; + + Reference< drawing::XShape > xAxisTitle; + if( bHasYAxisTitle ) + xAxisTitle.set( xAxisYSupp->getYAxisTitle(), uno::UNO_QUERY ); + + // FIXME: axPos + const char* sAxPos = "l"; + + // major grid line + Reference< beans::XPropertySet > xMajorGrid; + if( bHasYAxisMajorGrid ) + xMajorGrid.set( xAxisYSupp->getYMainGrid(), uno::UNO_QUERY ); + + // minor grid line + Reference< beans::XPropertySet > xMinorGrid;( xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY ); + if( bHasYAxisMinorGrid ) + xMinorGrid.set( xAxisYSupp->getYHelpGrid(), uno::UNO_QUERY ); + + _exportAxis( xAxisProp, xAxisTitle, xMajorGrid, xMinorGrid, nAxisType, sAxPos, aAxisIdPair ); +} + +void ChartExport::_exportAxis( + const Reference< XPropertySet >& xAxisProp, + const Reference< drawing::XShape >& xAxisTitle, + const Reference< XPropertySet >& xMajorGrid, + const Reference< XPropertySet >& xMinorGrid, + sal_Int32 nAxisType, + const char* sAxisPos, + AxisIdPair aAxisIdPair ) +{ + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, nAxisType ), + FSEND ); + pFS->singleElement( FSNS( XML_c, XML_axId ), + XML_val, I32S( aAxisIdPair.nAxisId ), + FSEND ); + + pFS->startElement( FSNS( XML_c, XML_scaling ), + FSEND ); + // orientation: minMax, maxMin + sal_Bool bReverseDirection = sal_False; + if(GetProperty( xAxisProp, S( "ReverseDirection" ) ) ) + mAny >>= bReverseDirection; + + const char* orientation = bReverseDirection ? "maxMin":"minMax"; + pFS->singleElement( FSNS( XML_c, XML_orientation ), + XML_val, orientation, + FSEND ); + // logBase, min, max + if(GetProperty( xAxisProp, S( "Logarithmic" ) ) ) + { + sal_Bool bLogarithmic = sal_False; + mAny >>= bLogarithmic; + if( bLogarithmic ) + { + // default value is 10? + sal_Int32 nLogBase = 10; + pFS->singleElement( FSNS( XML_c, XML_logBase ), + XML_val, I32S( nLogBase ), + FSEND ); + } + } + sal_Bool bAutoMax = sal_False; + if(GetProperty( xAxisProp, S( "AutoMax" ) ) ) + mAny >>= bAutoMax; + + if( !bAutoMax && (GetProperty( xAxisProp, S( "Max" ) ) )) + { + double dMax = 0; + mAny >>= dMax; + pFS->singleElement( FSNS( XML_c, XML_max ), + XML_val, IS( dMax ), + FSEND ); + } + + sal_Bool bAutoMin = sal_False; + if(GetProperty( xAxisProp, S( "AutoMin" ) ) ) + mAny >>= bAutoMin; + + if( !bAutoMin && (GetProperty( xAxisProp, S( "Min" ) ) )) + { + double dMin = 0; + mAny >>= dMin; + pFS->singleElement( FSNS( XML_c, XML_min ), + XML_val, IS( dMin ), + FSEND ); + } + + pFS->endElement( FSNS( XML_c, XML_scaling ) ); + + // title + if( xAxisTitle.is() ) + exportTitle( xAxisTitle ); + + sal_Bool bVisible = sal_True; + if( xAxisProp.is() ) + { + xAxisProp->getPropertyValue( + OUString (RTL_CONSTASCII_USTRINGPARAM ("Visible"))) >>= bVisible; + } + + if( !bVisible ) + { + // other value? + pFS->singleElement( FSNS( XML_c, XML_delete ), + XML_val, "1", + FSEND ); + } + + // FIXME: axPos, need to check the property "ReverseDirection" + pFS->singleElement( FSNS( XML_c, XML_axPos ), + XML_val, sAxisPos, + FSEND ); + // major grid line + if( xMajorGrid.is()) + { + pFS->startElement( FSNS( XML_c, XML_majorGridlines ), + FSEND ); + exportShapeProps( xMajorGrid ); + pFS->endElement( FSNS( XML_c, XML_majorGridlines ) ); + } + + // minor grid line + if( xMinorGrid.is()) + { + pFS->startElement( FSNS( XML_c, XML_minorGridlines ), + FSEND ); + exportShapeProps( xMajorGrid ); + pFS->endElement( FSNS( XML_c, XML_minorGridlines ) ); + } + + // majorTickMark + sal_Int32 nValue = 0; + if(GetProperty( xAxisProp, S( "Marks" ) ) ) + { + mAny >>= nValue; + sal_Bool bInner = nValue & ::com::sun::star::chart::ChartAxisMarks::INNER; + sal_Bool bOuter = nValue & ::com::sun::star::chart::ChartAxisMarks::OUTER; + const char* majorTickMark = NULL; + if( bInner && bOuter ) + majorTickMark = "cross"; + else if( bInner ) + majorTickMark = "in"; + else if( bOuter ) + majorTickMark = "out"; + else + majorTickMark = "none"; + pFS->singleElement( FSNS( XML_c, XML_majorTickMark ), + XML_val, majorTickMark, + FSEND ); + } + // minorTickMark + if(GetProperty( xAxisProp, S( "HelpMarks" ) ) ) + { + mAny >>= nValue; + sal_Bool bInner = nValue & ::com::sun::star::chart::ChartAxisMarks::INNER; + sal_Bool bOuter = nValue & ::com::sun::star::chart::ChartAxisMarks::OUTER; + const char* minorTickMark = NULL; + if( bInner && bOuter ) + minorTickMark = "cross"; + else if( bInner ) + minorTickMark = "in"; + else if( bOuter ) + minorTickMark = "out"; + else + minorTickMark = "none"; + pFS->singleElement( FSNS( XML_c, XML_minorTickMark ), + XML_val, minorTickMark, + FSEND ); + } + // tickLblPos + const char* sTickLblPos = NULL; + sal_Bool bDisplayLabel = sal_True; + if(GetProperty( xAxisProp, S( "DisplayLabels" ) ) ) + mAny >>= bDisplayLabel; + if( bDisplayLabel && (GetProperty( xAxisProp, S( "LabelPosition" ) ) )) + { + ::com::sun::star::chart::ChartAxisLabelPosition eLabelPosition = ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS; + mAny >>= eLabelPosition; + switch( eLabelPosition ) + { + case ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS: + case ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS_OTHER_SIDE: + sTickLblPos = "nextTo"; + break; + case ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START: + sTickLblPos = "low"; + break; + case ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END: + sTickLblPos = "high"; + break; + default: + sTickLblPos = "nextTo"; + break; + } + } + else + { + sTickLblPos = "none"; + } + pFS->singleElement( FSNS( XML_c, XML_tickLblPos ), + XML_val, sTickLblPos, + FSEND ); + + pFS->singleElement( FSNS( XML_c, XML_crossAx ), + XML_val, I32S( aAxisIdPair.nCrossAx ), + FSEND ); + + // crosses & crossesAt + sal_Bool bCrossesValue = sal_False; + const char* sCrosses = NULL; + if(GetProperty( xAxisProp, S( "CrossoverPosition" ) ) ) + { + ::com::sun::star::chart::ChartAxisPosition ePosition( ::com::sun::star::chart::ChartAxisPosition_ZERO ); + mAny >>= ePosition; + switch( ePosition ) + { + case ::com::sun::star::chart::ChartAxisPosition_START: + sCrosses = "min"; + break; + case ::com::sun::star::chart::ChartAxisPosition_END: + sCrosses = "max"; + break; + case ::com::sun::star::chart::ChartAxisPosition_ZERO: + sCrosses = "autoZero"; + break; + default: + bCrossesValue = sal_True; + break; + } + } + + if( bCrossesValue && GetProperty( xAxisProp, S("CrossoverValue" ) ) ) + { + double dValue = 0; + mAny >>= dValue; + pFS->singleElement( FSNS( XML_c, XML_crossesAt ), + XML_val, IS( dValue ), + FSEND ); + } + else + { + pFS->singleElement( FSNS( XML_c, XML_crosses ), + XML_val, sCrosses, + FSEND ); + } + + if( nAxisType == XML_catAx ) + { + // FIXME: seems not support? lblAlgn + const char* sLblAlgn = "ctr"; + pFS->singleElement( FSNS( XML_c, XML_lblAlgn ), + XML_val, sLblAlgn, + FSEND ); + } + if( ( nAxisType == XML_catAx ) + || ( nAxisType == XML_dateAx ) ) + { + // FIXME: seems not support? use default value, + const char* isAuto = "1"; + pFS->singleElement( FSNS( XML_c, XML_auto ), + XML_val, isAuto, + FSEND ); + + // FIXME: seems not support? lblOffset + sal_Int32 nLblOffset = 100; + pFS->singleElement( FSNS( XML_c, XML_lblOffset ), + XML_val, I32S( nLblOffset ), + FSEND ); + } + + // majorUnit + sal_Bool bAutoStepMain = sal_False; + if(GetProperty( xAxisProp, S( "AutoStepMain" ) ) ) + mAny >>= bAutoStepMain; + + if( !bAutoStepMain && (GetProperty( xAxisProp, S( "StepMain" ) ) )) + { + double dMajorUnit = 0; + mAny >>= dMajorUnit; + pFS->singleElement( FSNS( XML_c, XML_majorUnit ), + XML_val, IS( dMajorUnit ), + FSEND ); + } + // minorUnit + sal_Bool bAutoStepHelp = sal_False; + if(GetProperty( xAxisProp, S( "AutoStepHelp" ) ) ) + mAny >>= bAutoStepHelp; + + if( !bAutoStepHelp && (GetProperty( xAxisProp, S( "StepHelp" ) ) )) + { + double dMinorUnit = 0; + mAny >>= dMinorUnit; + pFS->singleElement( FSNS( XML_c, XML_minorUnit ), + XML_val, IS( dMinorUnit ), + FSEND ); + } + + // shape properties + exportShapeProps( xAxisProp ); + // TODO: text properties + + pFS->endElement( FSNS( XML_c, nAxisType ) ); +} + +void ChartExport::exportDataPoints( + const uno::Reference< beans::XPropertySet > & xSeriesProperties, + sal_Int32 nSeriesLength ) +{ + uno::Reference< chart2::XDataSeries > xSeries( xSeriesProperties, uno::UNO_QUERY ); + bool bVaryColorsByPoint = false; + Sequence< sal_Int32 > aDataPointSeq; + if( xSeriesProperties.is()) + { + Any aAny = xSeriesProperties->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "AttributedDataPoints" ))); + aAny >>= aDataPointSeq; + xSeriesProperties->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM( "VaryColorsByPoint" ))) >>= bVaryColorsByPoint; + } + + const sal_Int32 * pPoints = aDataPointSeq.getConstArray(); + sal_Int32 nElement; + Reference< chart2::XColorScheme > xColorScheme; + if( mxNewDiagram.is()) + xColorScheme.set( mxNewDiagram->getDefaultColorScheme()); + + if( bVaryColorsByPoint && xColorScheme.is() ) + { + ::std::set< sal_Int32 > aAttrPointSet; + ::std::copy( pPoints, pPoints + aDataPointSeq.getLength(), + ::std::inserter( aAttrPointSet, aAttrPointSet.begin())); + const ::std::set< sal_Int32 >::const_iterator aEndIt( aAttrPointSet.end()); + for( nElement = 0; nElement < nSeriesLength; ++nElement ) + { + uno::Reference< beans::XPropertySet > xPropSet; + if( aAttrPointSet.find( nElement ) != aEndIt ) + { + try + { + xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet( + xSeries, nElement, getModel() ); + } + catch( uno::Exception & rEx ) + { + (void)rEx; // avoid warning for pro build + OSL_TRACE( "Exception caught during Export of data point: %s", + rtl::OUStringToOString( rEx.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + } + } + else + { + // property set only containing the color + xPropSet.set( new ColorPropertySet( xColorScheme->getColorByIndex( nElement ))); + } + + if( xPropSet.is() ) + { + OSL_TRACE("ChartExport::exportDataPoints -- writer data points "); + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_dPt ), + FSEND ); + pFS->singleElement( FSNS( XML_c, XML_idx ), + XML_val, I32S(nElement), + FSEND ); + exportShapeProps( xPropSet ); + + pFS->endElement( FSNS( XML_c, XML_dPt ) ); + } + } + } +} + +void ChartExport::exportAxesId( sal_Int32 nAttachedAxis ) +{ + sal_Int32 nAxisIdx = lcl_generateRandomValue(); + sal_Int32 nAxisIdy = lcl_generateRandomValue(); + maAxes.push_back( AxisIdPair( AXIS_PRIMARY_X, nAxisIdx, nAxisIdy ) ); + maAxes.push_back( AxisIdPair( nAttachedAxis, nAxisIdy, nAxisIdx ) ); + FSHelperPtr pFS = GetFS(); + pFS->singleElement( FSNS( XML_c, XML_axId ), + XML_val, I32S( nAxisIdx ), + FSEND ); + pFS->singleElement( FSNS( XML_c, XML_axId ), + XML_val, I32S( nAxisIdy ), + FSEND ); + if( mbHasZAxis ) + { + sal_Int32 nAxisIdz = 0; + if( isDeep3dChart() ) + { + nAxisIdz = lcl_generateRandomValue(); + maAxes.push_back( AxisIdPair( AXIS_PRIMARY_Z, nAxisIdz, nAxisIdy ) ); + } + pFS->singleElement( FSNS( XML_c, XML_axId ), + XML_val, I32S( nAxisIdz ), + FSEND ); + } +} + +void ChartExport::exportGrouping( sal_Bool isBar ) +{ + FSHelperPtr pFS = GetFS(); + Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY); + // grouping + sal_Bool bStacked = sal_False; + if( GetProperty( xPropSet, S( "Stacked" ) ) ) + mAny >>= bStacked; + sal_Bool bPercentage = sal_False; + if( GetProperty( xPropSet, S( "Percent" ) ) ) + mAny >>= bPercentage; + + const char* grouping = NULL; + if( bStacked ) + grouping = "stacked"; + else if( bPercentage ) + grouping = "percentStacked"; + else + { + if( isBar && !isDeep3dChart() ) + grouping = "clustered"; + else + grouping = "standard"; + } + pFS->singleElement( FSNS( XML_c, XML_grouping ), + XML_val, grouping, + FSEND ); +} + +void ChartExport::exportMarker() +{ + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_marker ), + FSEND ); + Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY ); + sal_Int32 nSymbolType = ::com::sun::star::chart::ChartSymbolType::NONE; + if( GetProperty( xPropSet, S( "SymbolType" ) ) ) + mAny >>= nSymbolType; + // TODO: more properties support for marker + if( nSymbolType == ::com::sun::star::chart::ChartSymbolType::NONE ) + { + pFS->singleElement( FSNS( XML_c, XML_symbol ), + XML_val, "none", + FSEND ); + } + pFS->endElement( FSNS( XML_c, XML_marker ) ); +} + +void ChartExport::exportSmooth() +{ + FSHelperPtr pFS = GetFS(); + Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY ); + sal_Int32 nSplineType = 0; + if( GetProperty( xPropSet, S( "SplineType" ) ) ) + mAny >>= nSplineType; + if( nSplineType != 0 ) + { + pFS->singleElement( FSNS( XML_c, XML_smooth ), + XML_val, "1", + FSEND ); + } +} + +void ChartExport::exportFirstSliceAng( ) +{ + FSHelperPtr pFS = GetFS(); + sal_Int32 nStartingAngle = 0; + Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY); + if( GetProperty( xPropSet, S( "StartingAngle" ) ) ) + mAny >>= nStartingAngle; + + // convert to ooxml angle + nStartingAngle = (450 - nStartingAngle ) % 360; + pFS->singleElement( FSNS( XML_c, XML_firstSliceAng ), + XML_val, I32S( nStartingAngle ), + FSEND ); +} + +void ChartExport::exportView3D() +{ + Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY); + if( !xPropSet.is() ) + return; + FSHelperPtr pFS = GetFS(); + pFS->startElement( FSNS( XML_c, XML_view3D ), + FSEND ); + // rotX + if( GetProperty( xPropSet, S( "RotationHorizontal" ) ) ) + { + sal_Int32 nRotationX = 0; + mAny >>= nRotationX; + // X rotation (map Chart2 [-179,180] to OOXML [0..359]) + if( nRotationX < 0 ) + nRotationX += 360; + pFS->singleElement( FSNS( XML_c, XML_rotX ), + XML_val, I32S( nRotationX ), + FSEND ); + } + // rotY + if( GetProperty( xPropSet, S( "RotationVertical" ) ) ) + { + sal_Int32 nRotationY = 0; + mAny >>= nRotationY; + // Y rotation (map Chart2 [-179,180] to OOXML [0..359]) + if( nRotationY < 0 ) + nRotationY += 360; + pFS->singleElement( FSNS( XML_c, XML_rotY ), + XML_val, I32S( nRotationY ), + FSEND ); + } + // perspective + if( GetProperty( xPropSet, S( "Perspective" ) ) ) + { + sal_Int32 nPerspective = 0; + mAny >>= nPerspective; + // map Chart2 [0,100] to OOXML [0..200] + nPerspective *= 2; + pFS->singleElement( FSNS( XML_c, XML_perspective ), + XML_val, I32S( nPerspective ), + FSEND ); + } + // rAngAx + if( GetProperty( xPropSet, S( "RightAngledAxes" ) ) ) + { + sal_Bool bRightAngled = sal_False; + mAny >>= bRightAngled; + const char* sRightAngled = bRightAngled ? "1":"0"; + pFS->singleElement( FSNS( XML_c, XML_rAngAx ), + XML_val, sRightAngled, + FSEND ); + } + pFS->endElement( FSNS( XML_c, XML_view3D ) ); +} + +sal_Bool ChartExport::isDeep3dChart() +{ + sal_Bool isDeep = sal_False; + if( mbIs3DChart ) + { + Reference< XPropertySet > xPropSet( mxDiagram , uno::UNO_QUERY); + if( GetProperty( xPropSet, S( "Deep" ) ) ) + mAny >>= isDeep; + } + return isDeep; +} + +}// drawingml +}// oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 85ef2519f029..7cf8d98d8016 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,6 +29,7 @@ #include "oox/core/xmlfilterbase.hxx" #include "oox/export/drawingml.hxx" #include "oox/export/utils.hxx" +#include <oox/token/tokens.hxx> #include <cstdio> #include <com/sun/star/awt/CharSet.hpp> @@ -38,7 +40,10 @@ #include <com/sun/star/awt/Gradient.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/beans/Property.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/drawing/BitmapMode.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> #include <com/sun/star/drawing/LineDash.hpp> @@ -46,9 +51,15 @@ #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/BitmapMode.hpp> #include <com/sun/star/i18n/ScriptType.hpp> #include <com/sun/star/io/XOutputStream.hpp> +#include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/style/LineSpacingMode.hpp> #include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/text/WritingMode.hpp> #include <com/sun/star/text/XText.hpp> #include <com/sun/star/text/XTextContent.hpp> #include <com/sun/star/text/XTextField.hpp> @@ -57,18 +68,22 @@ #include <tools/string.hxx> #include <vcl/cvtgrf.hxx> #include <unotools/fontcvt.hxx> +#include <unotools/fontdefs.hxx> #include <vcl/graph.hxx> #include <svtools/grfmgr.hxx> #include <rtl/strbuf.hxx> #include <sfx2/app.hxx> #include <svl/languageoptions.hxx> -#include <svx/escherex.hxx> -#include <svx/svxenum.hxx> +#include <filter/msfilter/escherex.hxx> +#include <editeng/svxenum.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::i18n; +using namespace ::com::sun::star::style; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::uno; using ::com::sun::star::beans::PropertyState; using ::com::sun::star::beans::PropertyValue; using ::com::sun::star::beans::XPropertySet; @@ -77,6 +92,7 @@ using ::com::sun::star::container::XEnumeration; using ::com::sun::star::container::XEnumerationAccess; using ::com::sun::star::container::XIndexAccess; using ::com::sun::star::io::XOutputStream; +using ::com::sun::star::style::LineSpacing; using ::com::sun::star::text::XText; using ::com::sun::star::text::XTextContent; using ::com::sun::star::text::XTextField; @@ -101,6 +117,41 @@ namespace drawingml { #define GET(variable, propName) \ if ( GETA(propName) ) \ mAny >>= variable; +DBG( +void lcl_dump_pset(Reference< XPropertySet > rXPropSet) +{ + Reference< XPropertySetInfo > info = rXPropSet->getPropertySetInfo (); + Sequence< beans::Property > props = info->getProperties (); + + for (int i=0; i < props.getLength (); i++) { + OString name = OUStringToOString( props [i].Name, RTL_TEXTENCODING_UTF8); + fprintf (stderr,"%30s = ", name.getStr() ); + + try { + Any value = rXPropSet->getPropertyValue( props [i].Name ); + + OUString strValue; + sal_Int32 intValue; + bool boolValue; + LineSpacing spacing; + + if( value >>= strValue ) + fprintf (stderr,"\"%s\"\n", USS( strValue ) ); + else if( value >>= intValue ) + fprintf (stderr,"%" SAL_PRIdINT32 " (hex: %" SAL_PRIxUINT32 ")\n", intValue, intValue); + else if( value >>= boolValue ) + fprintf (stderr,"%d (bool)\n", boolValue); + else if( value >>= spacing ) { + fprintf (stderr, "mode: %d value: %d\n", spacing.Mode, spacing.Height); + } + else + fprintf (stderr,"??? <unhandled type>\n"); + } catch(const Exception &) { + fprintf (stderr,"unable to get '%s' value\n", USS(props [i].Name)); + } + } +} +); // not thread safe int DrawingML::mnImageCounter = 1; @@ -118,7 +169,7 @@ bool DrawingML::GetProperty( Reference< XPropertySet > rXPropSet, String aName ) mAny = rXPropSet->getPropertyValue( aName ); if ( mAny.hasValue() ) bRetValue = true; - } catch( Exception& ) { /* printf ("exception when trying to get value of property: %s\n", ST(aName)); */ } + } catch( const Exception& ) { /* printf ("exception when trying to get value of property: %s\n", ST(aName)); */ } return bRetValue; } @@ -133,7 +184,7 @@ bool DrawingML::GetPropertyAndState( Reference< XPropertySet > rXPropSet, Refere bRetValue = true; eState = rXPropState->getPropertyState( aName ); } - } catch( Exception& ) { /* printf ("exception when trying to get value of property: %s\n", ST(aName)); */ } + } catch( const Exception& ) { /* printf ("exception when trying to get value of property: %s\n", ST(aName)); */ } return bRetValue; } @@ -317,10 +368,10 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) sal_uInt32 nLineWidth = 0; sal_uInt32 nColor = 0; - sal_Bool bColorSet = FALSE; + sal_Bool bColorSet = sal_False; const char* cap = NULL; drawing::LineDash aLineDash; - sal_Bool bDashSet = FALSE; + sal_Bool bDashSet = sal_False; GET( nLineWidth, LineWidth ); @@ -328,7 +379,7 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) case drawing::LineStyle_DASH: if( GETA( LineDash ) ) { aLineDash = *(drawing::LineDash*) mAny.getValue(); - bDashSet = TRUE; + bDashSet = sal_True; if( aLineDash.Style == DashStyle_ROUND || aLineDash.Style == DashStyle_ROUNDRELATIVE ) cap = "rnd"; @@ -340,7 +391,7 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) default: if ( GETA( LineColor ) ) { nColor = *((sal_uInt32*) mAny.getValue()) & 0xffffff; - bColorSet = TRUE; + bColorSet = sal_True; } break; } @@ -418,7 +469,7 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic ) { GfxLink aLink = rGraphic.GetLink (); OUString sMediaType; - const char* sExtension = NULL; + const char* pExtension = ""; OUString sRelId; SvMemoryStream aStream; @@ -428,54 +479,54 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic ) switch ( aLink.GetType() ) { case GFX_LINK_TYPE_NATIVE_GIF: sMediaType = US( "image/gif" ); - sExtension = ".gif"; + pExtension = ".gif"; break; case GFX_LINK_TYPE_NATIVE_JPG: sMediaType = US( "image/jpeg" ); - sExtension = ".jpeg"; + pExtension = ".jpeg"; break; case GFX_LINK_TYPE_NATIVE_PNG: sMediaType = US( "image/png" ); - sExtension = ".png"; + pExtension = ".png"; break; case GFX_LINK_TYPE_NATIVE_TIF: sMediaType = US( "image/tiff" ); - sExtension = ".tiff"; + pExtension = ".tiff"; break; case GFX_LINK_TYPE_NATIVE_WMF: sMediaType = US( "image/x-wmf" ); - sExtension = ".wmf"; + pExtension = ".wmf"; break; case GFX_LINK_TYPE_NATIVE_MET: sMediaType = US( "image/x-met" ); - sExtension = ".met"; + pExtension = ".met"; break; case GFX_LINK_TYPE_NATIVE_PCT: sMediaType = US( "image/x-pict" ); - sExtension = ".pct"; + pExtension = ".pct"; break; default: { GraphicType aType = rGraphic.GetType(); if ( aType == GRAPHIC_BITMAP ) { GraphicConverter::Export( aStream, rGraphic, CVT_PNG ); sMediaType = US( "image/png" ); - sExtension = ".png"; + pExtension = ".png"; } else if ( aType == GRAPHIC_GDIMETAFILE ) { GraphicConverter::Export( aStream, rGraphic, CVT_EMF ); sMediaType = US( "image/x-emf" ); - sExtension = ".emf"; + pExtension = ".emf"; } else { OSL_TRACE( "unhandled graphic type" ); break; } aData = aStream.GetData(); - nDataSize = aStream.GetSize(); + nDataSize = aStream.GetEndOfData(); break; } } - const char *pComponent = NULL; + const char *pComponent = ""; switch ( meDocumentType ) { case DOCUMENT_DOCX: pComponent = "word"; break; @@ -483,17 +534,17 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic ) case DOCUMENT_XLSX: pComponent = "xl"; break; } - Reference< XOutputStream > xOutStream = mpFB->openOutputStream( OUStringBuffer() - .appendAscii( pComponent ) - .appendAscii( "/media/image" ) - .append( (sal_Int32) mnImageCounter ) - .appendAscii( sExtension ) - .makeStringAndClear(), - sMediaType ); + Reference< XOutputStream > xOutStream = mpFB->openFragmentStream( OUStringBuffer() + .appendAscii( pComponent ) + .appendAscii( "/media/image" ) + .append( (sal_Int32) mnImageCounter ) + .appendAscii( pExtension ) + .makeStringAndClear(), + sMediaType ); xOutStream->writeBytes( Sequence< sal_Int8 >( (const sal_Int8*) aData, nDataSize ) ); xOutStream->closeOutput(); - const char *pImagePrefix = NULL; + const char *pImagePrefix = ""; switch ( meDocumentType ) { case DOCUMENT_DOCX: @@ -510,21 +561,33 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic ) OUStringBuffer() .appendAscii( pImagePrefix ) .append( (sal_Int32) mnImageCounter ++ ) - .appendAscii( sExtension ) + .appendAscii( pExtension ) .makeStringAndClear() ); return sRelId; } -OUString DrawingML::WriteBlip( OUString& rURL ) +OUString DrawingML::WriteBlip( Reference< XPropertySet > rXPropSet, OUString& rURL ) { OUString sRelId = WriteImage( rURL ); + sal_Int16 nBright = 0; + sal_Int32 nContrast = 0; - mpFS->singleElementNS( XML_a, XML_blip, - FSNS( XML_r, XML_embed), OUStringToOString( sRelId, RTL_TEXTENCODING_UTF8 ).getStr(), - FSEND ); + GET( nBright, AdjustLuminance ); + GET( nContrast, AdjustContrast ); + + mpFS->startElementNS( XML_a, XML_blip, + FSNS( XML_r, XML_embed), OUStringToOString( sRelId, RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND ); + if( nBright || nContrast ) + mpFS->singleElementNS( XML_a, XML_lum, + XML_bright, nBright ? I32S( nBright*1000 ) : NULL, + XML_contrast, nContrast ? I32S( nContrast*1000 ) : NULL, + FSEND ); + + mpFS->endElementNS( XML_a, XML_blip ); - return sRelId; + return sRelId; } void DrawingML::WriteBlipMode( Reference< XPropertySet > rXPropSet ) @@ -562,7 +625,7 @@ void DrawingML::WriteBlipFill( Reference< XPropertySet > rXPropSet, String sURLP mpFS->startElementNS( nXmlNamespace , XML_blipFill, FSEND ); - WriteBlip( aURL ); + WriteBlip( rXPropSet, aURL ); if( sURLPropName == S( "FillBitmapURL" ) ) WriteBlipMode( rXPropSet ); @@ -586,9 +649,9 @@ void DrawingML::WriteStretch() } void DrawingML::WriteTransformation( const Rectangle& rRect, - sal_Bool bFlipH, sal_Bool bFlipV, sal_Int32 nRotation ) + sal_Int32 nXmlNamespace, sal_Bool bFlipH, sal_Bool bFlipV, sal_Int32 nRotation ) { - mpFS->startElementNS( XML_a, XML_xfrm, + mpFS->startElementNS( nXmlNamespace, XML_xfrm, XML_flipH, bFlipH ? "1" : NULL, XML_flipV, bFlipV ? "1" : NULL, XML_rot, nRotation ? I32S( nRotation ) : NULL, @@ -597,20 +660,20 @@ void DrawingML::WriteTransformation( const Rectangle& rRect, mpFS->singleElementNS( XML_a, XML_off, XML_x, IS( MM100toEMU( rRect.Left() ) ), XML_y, IS( MM100toEMU( rRect.Top() ) ), FSEND ); mpFS->singleElementNS( XML_a, XML_ext, XML_cx, IS( MM100toEMU( rRect.GetWidth() ) ), XML_cy, IS( MM100toEMU( rRect.GetHeight() ) ), FSEND ); - mpFS->endElementNS( XML_a, XML_xfrm ); + mpFS->endElementNS( nXmlNamespace, XML_xfrm ); } -void DrawingML::WriteShapeTransformation( Reference< XShape > rXShape, sal_Bool bFlipH, sal_Bool bFlipV, sal_Int32 nRotation ) +void DrawingML::WriteShapeTransformation( Reference< XShape > rXShape, sal_Int32 nXmlNamespace, sal_Bool bFlipH, sal_Bool bFlipV, sal_Int32 nRotation ) { DBG(printf( "write shape transformation\n" )); awt::Point aPos = rXShape->getPosition(); awt::Size aSize = rXShape->getSize(); - WriteTransformation( Rectangle( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ), bFlipH, bFlipV, nRotation ); + WriteTransformation( Rectangle( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ), nXmlNamespace, bFlipH, bFlipV, nRotation ); } -void DrawingML::WriteRunProperties( Reference< XTextRange > rRun ) +void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, sal_Bool bIsField ) { Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY ); Reference< XPropertyState > rXPropState( rRun, UNO_QUERY ); @@ -746,8 +809,6 @@ void DrawingML::WriteRunProperties( Reference< XTextRange > rRun ) else typeface = USS( usTypeface ); - - mpFS->singleElementNS( XML_a, XML_latin, XML_typeface, typeface, XML_pitchFamily, pitch, @@ -775,10 +836,33 @@ void DrawingML::WriteRunProperties( Reference< XTextRange > rRun ) FSEND ); } + if( bIsField ) { + Reference< XTextField > rXTextField; + GET( rXTextField, TextField ); + if( rXTextField.is() ) + rXPropSet.set( rXTextField, UNO_QUERY ); + } + + // field properties starts here + if( GETA( URL ) ) { + OUString sURL; + + mAny >>= sURL; + if( sURL.getLength() ) { + OUString sRelId = mpFB->addRelation( mpFS->getOutputStream(), + US( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" ), + sURL, true ); + + mpFS->singleElementNS( XML_a, XML_hlinkClick, + FSNS( XML_r,XML_id ), USS( sRelId ), + FSEND ); + } + } + mpFS->endElementNS( XML_a, XML_rPr ); } -const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun ) +const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun, sal_Bool& bIsField ) { const char* sType = NULL; Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY ); @@ -793,13 +877,18 @@ const char* DrawingML::GetFieldType( ::com::sun::star::uno::Reference< ::com::su Reference< XTextField > rXTextField; GET( rXTextField, TextField ); if( rXTextField.is() ) { + bIsField = sal_True; rXPropSet.set( rXTextField, UNO_QUERY ); if( rXPropSet.is() ) { - String aFieldKind( rXTextField->getPresentation( TRUE ) ); + String aFieldKind( rXTextField->getPresentation( sal_True ) ); DBG(printf ("field kind: %s\n", ST(aFieldKind) )); if( aFieldKind == S( "Page" ) ) { return "slidenum"; } + // else if( aFieldKind == S( "URL" ) ) { + // do not return here + // and make URL field text run with hyperlink property later + // } } } } @@ -845,13 +934,24 @@ void DrawingML::GetUUID( OStringBuffer& rBuffer ) void DrawingML::WriteRun( Reference< XTextRange > rRun ) { const char* sFieldType; - bool bIsField = false; + sal_Bool bIsField = sal_False; OUString sText = rRun->getString(); - if( sText.getLength() < 1) - return; + if( sText.getLength() < 1) { + Reference< XPropertySet > xPropSet( rRun, UNO_QUERY ); + + try { + if( !xPropSet.is() || !( xPropSet->getPropertyValue( S( "PlaceholderText" ) ) >>= sText ) ) + return; + if( sText.getLength() < 1 ) + return; + } + catch (const Exception &) { + return; + } + } - if( ( sFieldType = GetFieldType( rRun ) ) ) { + if( ( sFieldType = GetFieldType( rRun, bIsField ) ) ) { OStringBuffer sUUID(39); GetUUID( sUUID ); @@ -859,17 +959,17 @@ void DrawingML::WriteRun( Reference< XTextRange > rRun ) XML_id, sUUID.getStr(), XML_type, sFieldType, FSEND ); - bIsField = true; } else mpFS->startElementNS( XML_a, XML_r, FSEND ); - WriteRunProperties( rRun ); + Reference< XPropertySet > xPropSet( rRun, uno::UNO_QUERY ); + WriteRunProperties( xPropSet, bIsField ); mpFS->startElementNS( XML_a, XML_t, FSEND ); mpFS->writeEscaped( sText ); mpFS->endElementNS( XML_a, XML_t ); - if( bIsField ) + if( sFieldType ) mpFS->endElementNS( XML_a, XML_fld ); else mpFS->endElementNS( XML_a, XML_r ); @@ -883,7 +983,6 @@ void DrawingML::WriteRun( Reference< XTextRange > rRun ) else if( bSDot ) \ pAutoNumType = #x "Period"; - inline static const char* GetAutoNumType( sal_Int16 nNumberingType, bool bSDot, bool bPBehind, bool bPBoth ) { const char* pAutoNumType = NULL; @@ -929,7 +1028,6 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa Sequence< PropertyValue > aPropertySequence; rXIndexAccess->getByIndex( nLevel ) >>= aPropertySequence; - const PropertyValue* pPropValue = aPropertySequence.getArray(); sal_Int32 nPropertyCount = aPropertySequence.getLength(); @@ -1051,10 +1149,23 @@ const char* DrawingML::GetAlignment( sal_Int32 nAlignment ) return sAlignment; } +void DrawingML::WriteLinespacing( LineSpacing& rSpacing ) +{ + if( rSpacing.Mode == LineSpacingMode::PROP ) + mpFS->singleElementNS( XML_a, XML_spcPct, + XML_val, I32S( ((sal_Int32)rSpacing.Height)*1000 ), + FSEND ); + else + mpFS->singleElementNS( XML_a, XML_spcPts, + XML_val, I32S( rSpacing.Height ), + FSEND ); +} + void DrawingML::WriteParagraphProperties( Reference< XTextContent > rParagraph ) { Reference< XPropertySet > rXPropSet( rParagraph, UNO_QUERY ); Reference< XPropertyState > rXPropState( rParagraph, UNO_QUERY ); + PropertyState eState; if( !rXPropSet.is() || !rXPropState.is() ) return; @@ -1062,22 +1173,29 @@ void DrawingML::WriteParagraphProperties( Reference< XTextContent > rParagraph ) sal_Int16 nLevel = -1; GET( nLevel, NumberingLevel ); - sal_Int32 nLeftMargin = 0; - // fix coordinates - //GET( nLeftMargin, ParaLeftMargin ); - sal_Int16 nAlignment( style::ParagraphAdjust_LEFT ); GET( nAlignment, ParaAdjust ); + sal_Bool bHasLinespacing = sal_False; + LineSpacing aLineSpacing; + if( GETAD( ParaLineSpacing ) ) + bHasLinespacing = ( mAny >>= aLineSpacing ); + if( nLevel != -1 - || nLeftMargin > 0 - || nAlignment != style::ParagraphAdjust_LEFT ) { + || nAlignment != style::ParagraphAdjust_LEFT + || bHasLinespacing ) { mpFS->startElementNS( XML_a, XML_pPr, XML_lvl, nLevel > 0 ? I32S( nLevel ) : NULL, - XML_marL, nLeftMargin > 0 ? IS( nLeftMargin ) : NULL, + XML_marL, NULL, XML_algn, GetAlignment( nAlignment ), FSEND ); + if( bHasLinespacing ) { + mpFS->startElementNS( XML_a, XML_lnSpc, FSEND ); + WriteLinespacing( aLineSpacing ); + mpFS->endElementNS( XML_a, XML_lnSpc ); + } + WriteParagraphNumbering( rXPropSet, nLevel ); mpFS->endElementNS( XML_a, XML_pPr ); @@ -1096,15 +1214,15 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph ) mpFS->startElementNS( XML_a, XML_p, FSEND ); - sal_Bool bPropertiesWritten = FALSE; + sal_Bool bPropertiesWritten = sal_False; while( enumeration->hasMoreElements() ) { Reference< XTextRange > run; Any any ( enumeration->nextElement() ); if (any >>= run) { - if( !bPropertiesWritten && run->getString().getLength() ) { + if( !bPropertiesWritten ) { WriteParagraphProperties( rParagraph ); - bPropertiesWritten = TRUE; + bPropertiesWritten = sal_True; } WriteRun( run ); } @@ -1114,10 +1232,10 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph ) mpFS->endElementNS( XML_a, XML_p ); } -void DrawingML::WriteText( Reference< XShape > rXShape ) +void DrawingML::WriteText( Reference< XInterface > rXIface ) { - Reference< XText > xXText( rXShape, UNO_QUERY ); - Reference< XPropertySet > rXPropSet( rXShape, UNO_QUERY ); + Reference< XText > xXText( rXIface, UNO_QUERY ); + Reference< XPropertySet > rXPropSet( rXIface, UNO_QUERY ); if( !xXText.is() ) return; @@ -1150,18 +1268,30 @@ void DrawingML::WriteText( Reference< XShape > rXShape ) ; } + const char* sWritingMode = NULL; + sal_Bool bVertical = sal_False; + if( GETA( TextWritingMode ) ) { + WritingMode eMode; + + if( ( mAny >>= eMode ) && eMode == WritingMode_TB_RL ) { + sWritingMode = "vert"; + bVertical = sal_True; + } + } + TextHorizontalAdjust eHorizontalAlignment( TextHorizontalAdjust_CENTER ); bool bHorizontalCenter = false; GET( eHorizontalAlignment, TextHorizontalAdjust ); if( eHorizontalAlignment == TextHorizontalAdjust_CENTER ) bHorizontalCenter = true; + else if( bVertical && eHorizontalAlignment == TextHorizontalAdjust_LEFT ) + sVerticalAlignment = "b"; - sal_Bool bHasWrap = FALSE; - sal_Bool bWrap = FALSE; + sal_Bool bHasWrap = sal_False; + sal_Bool bWrap = sal_False; if( GETA( TextWordWrap ) ) { mAny >>= bWrap; - bHasWrap = TRUE; - //DBG(printf("wrap: %d\n", bWrap)); + bHasWrap = sal_True; } mpFS->singleElementNS( XML_a, XML_bodyPr, @@ -1172,6 +1302,7 @@ void DrawingML::WriteText( Reference< XShape > rXShape ) XML_bIns, (nBottom != DEFTBINS) ? IS( MM100toEMU( nBottom ) ) : NULL, XML_anchor, sVerticalAlignment, XML_anchorCtr, bHorizontalCenter ? "1" : NULL, + XML_vert, sWritingMode, FSEND ); Reference< XEnumerationAccess > access( xXText, UNO_QUERY ); @@ -1209,7 +1340,10 @@ void DrawingML::WritePresetShape( const char* pShape, MSO_SPT eShapeType, sal_Bo mpFS->startElementNS( XML_a, XML_avLst, FSEND ); Sequence< drawing::EnhancedCustomShapeAdjustmentValue > aAdjustmentSeq; - if ( rProp.Value >>= aAdjustmentSeq ) { + if ( ( rProp.Value >>= aAdjustmentSeq ) + && eShapeType != mso_sptActionButtonForwardNext // we have adjustments values for these type of shape, but MSO doesn't like them + && eShapeType != mso_sptActionButtonBackPrevious // so they are now disabled + ) { DBG(printf("adj seq len: %d\n", int( aAdjustmentSeq.getLength() ))); if ( bPredefinedHandlesUsed ) EscherPropertyContainer::LookForPolarHandles( eShapeType, nAdjustmentsWhichNeedsToBeConverted ); @@ -1245,11 +1379,11 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon ) mpFS->startElementNS( XML_a, XML_pathLst, FSEND ); - for( USHORT i = 0; i < rPolyPolygon.Count(); i ++ ) { + for( sal_uInt16 i = 0; i < rPolyPolygon.Count(); i ++ ) { const Polygon& rPoly = rPolyPolygon[ i ]; Rectangle aRect( rPoly.GetBoundRect() ); - sal_Bool bBezier = FALSE; + sal_Bool bBezier = sal_False; mpFS->startElementNS( XML_a, XML_path, XML_w, I64S( aRect.GetWidth() ), @@ -1268,13 +1402,13 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon ) mpFS->endElementNS( XML_a, XML_moveTo ); } - for( USHORT j = 1; j < rPoly.GetSize(); j ++ ) + for( sal_uInt16 j = 1; j < rPoly.GetSize(); j ++ ) { enum PolyFlags flags = rPoly.GetFlags(j); if( flags == POLY_CONTROL && !bBezier ) { mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND ); - bBezier = TRUE; + bBezier = sal_True; } else if( flags == POLY_NORMAL && !bBezier ) mpFS->startElementNS( XML_a, XML_lnTo, FSEND ); @@ -1287,7 +1421,7 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon ) if( ( flags == POLY_NORMAL || flags == POLY_SYMMTR ) && bBezier ) { mpFS->endElementNS( XML_a, XML_cubicBezTo ); - bBezier = FALSE; + bBezier = sal_False; } else if( flags == POLY_NORMAL && !bBezier ) mpFS->endElementNS( XML_a, XML_lnTo ); @@ -1298,21 +1432,6 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon ) mpFS->endElementNS( XML_a, XML_cubicBezTo ); mpFS->startElementNS( XML_a, XML_cubicBezTo, FSEND ); } -// switch( rPoly.GetFlags(j) ) { -// case POLY_NORMAL: -// DBG(printf("normal\n")); -// break; -// case POLY_SMOOTH: -// DBG(printf("smooth\n")); -// break; -// case POLY_CONTROL: -// DBG(printf("control\n")); -// break; -// case POLY_SYMMTR: -// DBG(printf("symmtr\n")); -// break; -// } -// DBG(printf("point %ld %ld\n", rPoly[j].X() - aRect.Left(), rPoly[j].Y() - aRect.Top())); } mpFS->endElementNS( XML_a, XML_path ); @@ -1325,14 +1444,16 @@ void DrawingML::WritePolyPolygon( const PolyPolygon& rPolyPolygon ) void DrawingML::WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID ) { - mpFS->singleElementNS( XML_a, XML_stCxn, - XML_id, I32S( nStartID ), - XML_idx, I64S( rConnectorEntry.GetConnectorRule( TRUE ) ), - FSEND ); - mpFS->singleElementNS( XML_a, XML_endCxn, - XML_id, I32S( nEndID ), - XML_idx, I64S( rConnectorEntry.GetConnectorRule( FALSE ) ), - FSEND ); + if( nStartID != -1 ) + mpFS->singleElementNS( XML_a, XML_stCxn, + XML_id, I32S( nStartID ), + XML_idx, I64S( rConnectorEntry.GetConnectorRule( sal_True ) ), + FSEND ); + if( nEndID != -1 ) + mpFS->singleElementNS( XML_a, XML_endCxn, + XML_id, I32S( nEndID ), + XML_idx, I64S( rConnectorEntry.GetConnectorRule( sal_False ) ), + FSEND ); } // from sw/source/filter/ww8/wrtw8num.cxx for default bullets to export to MS intact @@ -1389,5 +1510,58 @@ sal_Unicode DrawingML::SubstituteBullet( sal_Unicode cBulletId, ::com::sun::star return sNumStr.GetChar( 0 ); } +sax_fastparser::FSHelperPtr DrawingML::CreateOutputStream ( + const OUString& sFullStream, + const OUString& sRelativeStream, + const Reference< XOutputStream >& xParentRelation, + const char* sContentType, + const char* sRelationshipType, + ::rtl::OUString* pRelationshipId ) +{ + OUString sRelationshipId; + if (xParentRelation.is()) + sRelationshipId = GetFB()->addRelation( xParentRelation, OUString::createFromAscii( sRelationshipType), sRelativeStream ); + else + sRelationshipId = GetFB()->addRelation( OUString::createFromAscii( sRelationshipType ), sRelativeStream ); + + if( pRelationshipId ) + *pRelationshipId = sRelationshipId; + + sax_fastparser::FSHelperPtr p = GetFB()->openFragmentStreamWithSerializer( sFullStream, OUString::createFromAscii( sContentType ) ); + + return p; +} + +void DrawingML::WriteFill( Reference< XPropertySet > xPropSet ) +{ + if ( !GetProperty( xPropSet, S( "FillStyle" ) ) ) + return; + FillStyle aFillStyle( FillStyle_NONE ); + xPropSet->getPropertyValue( S( "FillStyle" ) ) >>= aFillStyle; + + if( aFillStyle == FillStyle_NONE || + aFillStyle == FillStyle_HATCH ) + return; + + switch( aFillStyle ) + { + case ::com::sun::star::drawing::FillStyle_SOLID : + WriteSolidFill( xPropSet ); + break; + case ::com::sun::star::drawing::FillStyle_GRADIENT : + WriteGradientFill( xPropSet ); + break; + case ::com::sun::star::drawing::FillStyle_BITMAP : + WriteBlipFill( xPropSet, S( "FillBitmapURL" ) ); + break; + default: + ; + } + + return; +} + } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/export/makefile.mk b/oox/source/export/makefile.mk deleted file mode 100644 index 08fa7a09dff8..000000000000 --- a/oox/source/export/makefile.mk +++ /dev/null @@ -1,27 +0,0 @@ -PRJ=..$/.. - -PRJNAME=oox -TARGET=export -AUTOSEG=true - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.INCLUDE: $(PRJ)$/util$/makefile.pmk - -# --- Files -------------------------------------------------------- - -SLOFILES = \ - $(SLO)$/drawingml.obj \ - $(SLO)$/shapes.obj \ - $(SLO)$/vmlexport.obj \ - $(SLO)$/vmlexport-shape-types.obj - -# --- Targets ------------------------------------------------------- - -.INCLUDE : target.mk - -$(MISC)$/vmlexport-shape-types.cxx : preset-definitions-to-shape-types.pl presetShapeDefinitions.xml presetTextWarpDefinitions.xml - $(PERL) $< > $@.in_progress 2> $(MISC)$/vmlexport-shape-types.log && mv $@.in_progress $@ diff --git a/oox/source/export/preset-definitions-to-shape-types.pl b/oox/source/export/preset-definitions-to-shape-types.pl index 5ecb82f814de..be53eb88d756 100644 --- a/oox/source/export/preset-definitions-to-shape-types.pl +++ b/oox/source/export/preset-definitions-to-shape-types.pl @@ -288,7 +288,7 @@ $path_h = 1; 201 => 'hostControl', # should not be used 202 => 'textBox' ); -# An error occured, we have to ignore this shape +# An error occurred, we have to ignore this shape sub error( $ ) { my ( $msg ) = @_; @@ -853,7 +853,7 @@ sub start_element( $% ) $path .= "x"; } elsif ( $element eq "pt" ) { - # rememeber the last position for the arcTo + # remember the last position for the arcTo $last_pos_x = value( $attr{'x'} ); $last_pos_y = value( $attr{'y'} ); @@ -1204,7 +1204,7 @@ print <<EOF; // '$src_text' // which are part of the OOXML documentation -#include <svx/escherex.hxx> +#include <filter/msfilter/escherex.hxx> const char* pShapeTypes[ ESCHER_ShpInst_COUNT ] = { diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 0d07e6cf5226..be720432624c 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,6 +29,7 @@ #include "oox/core/xmlfilterbase.hxx" #include "oox/export/shapes.hxx" #include "oox/export/utils.hxx" +#include <oox/token/tokens.hxx> #include <cstdio> #include <com/sun/star/awt/CharSet.hpp> @@ -37,6 +39,7 @@ #include <com/sun/star/awt/FontUnderline.hpp> #include <com/sun/star/awt/Gradient.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/drawing/FillStyle.hpp> @@ -55,6 +58,12 @@ #include <com/sun/star/text/XTextContent.hpp> #include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/table/XTable.hpp> +#include <com/sun/star/table/XColumnRowRange.hpp> +#include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/table/XMergeableCell.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/frame/XModel.hpp> #include <tools/stream.hxx> #include <tools/string.hxx> #include <vcl/cvtgrf.hxx> @@ -65,15 +74,18 @@ #include <rtl/strbuf.hxx> #include <sfx2/app.hxx> #include <svl/languageoptions.hxx> -#include <svx/escherex.hxx> +#include <filter/msfilter/escherex.hxx> #include <svx/svdoashp.hxx> -#include <svx/svxenum.hxx> +#include <editeng/svxenum.hxx> #include <svx/unoapi.hxx> +#include <oox/export/chartexport.hxx> using namespace ::com::sun::star; +using namespace ::com::sun::star::beans; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::i18n; +using namespace ::com::sun::star::table; using ::com::sun::star::beans::PropertyState; using ::com::sun::star::beans::PropertyValue; using ::com::sun::star::beans::XPropertySet; @@ -88,16 +100,19 @@ using ::com::sun::star::text::XText; using ::com::sun::star::text::XTextContent; using ::com::sun::star::text::XTextField; using ::com::sun::star::text::XTextRange; +using ::oox::core::XmlFilterBase; +using ::com::sun::star::chart2::XChartDocument; +using ::com::sun::star::frame::XModel; +using ::oox::core::XmlFilterBase; using ::rtl::OString; using ::rtl::OStringBuffer; using ::rtl::OUString; using ::rtl::OUStringBuffer; using ::sax_fastparser::FSHelperPtr; -DBG(extern void dump_pset(Reference< XPropertySet > rXPropSet)); - #define IDS(x) (OString(#x " ") + OString::valueOf( mnShapeIdMax++ )).getStr() + struct CustomShapeTypeTranslationTable { const char* sOOo; @@ -311,6 +326,14 @@ static const CustomShapeTypeTranslationTable pCustomShapeTypeTranslationTable[] { "mso-spt202", "rect" } }; +struct StringHash +{ + size_t operator()( const char* s ) const + { + return rtl_str_hashCode(s); + } +}; + struct StringCheck { bool operator()( const char* s1, const char* s2 ) const @@ -319,7 +342,7 @@ struct StringCheck } }; -typedef std::hash_map< const char*, const char*, std::hash<const char*>, StringCheck> CustomShapeTypeTranslationHashMap; +typedef boost::unordered_map< const char*, const char*, StringHash, StringCheck> CustomShapeTypeTranslationHashMap; static CustomShapeTypeTranslationHashMap* pCustomShapeTypeTranslationHashMap = NULL; static const char* lcl_GetPresetGeometry( const char* sShapeType ) @@ -356,14 +379,15 @@ namespace oox { namespace drawingml { if ( GETA(propName) ) \ mAny >>= variable; -ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB, DocumentType eDocumentType ) +ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ShapeHashMap* pShapeMap, XmlFilterBase* pFB, DocumentType eDocumentType ) : DrawingML( pFS, pFB, eDocumentType ) - , mnXmlNamespace( nXmlNamespace ) , mnShapeIdMax( 1 ) , mnPictureIdMax( 1 ) + , mnXmlNamespace( nXmlNamespace ) , maFraction( 1, 576 ) , maMapModeSrc( MAP_100TH_MM ) , maMapModeDest( MAP_INCH, Point(), maFraction, maFraction ) + , mpShapeMap( pShapeMap ? pShapeMap : &maShapeMap ) { } @@ -389,11 +413,45 @@ awt::Size ShapeExport::MapSize( const awt::Size& rSize ) const return awt::Size( aRetSize.Width(), aRetSize.Height() ); } -sal_Bool ShapeExport::NonEmptyText( Reference< XShape > xShape ) +sal_Bool ShapeExport::NonEmptyText( Reference< XInterface > xIface ) { - Reference< XSimpleText > xText( xShape, UNO_QUERY ); + Reference< XPropertySet > xPropSet( xIface, UNO_QUERY ); + + if( xPropSet.is() ) + { + Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo(); + if ( xPropSetInfo.is() ) + { + if ( xPropSetInfo->hasPropertyByName( S( "IsEmptyPresentationObject" ) ) ) + { + sal_Bool bIsEmptyPresObj = sal_False; + if ( xPropSet->getPropertyValue( S( "IsEmptyPresentationObject" ) ) >>= bIsEmptyPresObj ) + { + DBG(printf("empty presentation object %d, props:\n", bIsEmptyPresObj)); + if( bIsEmptyPresObj ) + return sal_True; + } + } + + if ( xPropSetInfo->hasPropertyByName( S( "IsPresentationObject" ) ) ) + { + sal_Bool bIsPresObj = sal_False; + if ( xPropSet->getPropertyValue( S( "IsPresentationObject" ) ) >>= bIsPresObj ) + { + DBG(printf("presentation object %d, props:\n", bIsPresObj)); + if( bIsPresObj ) + return sal_True; + } + } + } + } + + Reference< XSimpleText > xText( xIface, UNO_QUERY ); - return ( xText.is() && xText->getString().getLength() ); + if( xText.is() ) + return xText->getString().getLength(); + + return sal_False; } ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, sal_Bool bClosed ) @@ -405,9 +463,11 @@ ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, sal_Bool PolyPolygon aPolyPolygon = EscherPropertyContainer::GetPolyPolygon( xShape ); Rectangle aRect( aPolyPolygon.GetBoundRect() ); - awt::Size size = MapSize( awt::Size( aRect.GetWidth(), aRect.GetHeight() ) ); +#if OSL_DEBUG_LEVEL > 0 + awt::Size size = MapSize( awt::Size( aRect.GetWidth(), aRect.GetHeight() ) ); DBG(printf("poly count %d\nsize: %d x %d", aPolyPolygon.Count(), int( size.Width ), int( size.Height ))); +#endif // non visual shape properties pFS->startElementNS( mnXmlNamespace, XML_nvSpPr, FSEND ); @@ -421,7 +481,7 @@ ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, sal_Bool // visual shape properties pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND ); - WriteTransformation( aRect ); + WriteTransformation( aRect, XML_a ); WritePolyPolygon( aPolyPolygon ); Reference< XPropertySet > xProps( xShape, UNO_QUERY ); if( xProps.is() ) { @@ -433,7 +493,7 @@ ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, sal_Bool pFS->endElementNS( mnXmlNamespace, XML_spPr ); // write text - WriteTextBox( xShape ); + WriteTextBox( xShape, mnXmlNamespace ); pFS->endElementNS( mnXmlNamespace, XML_sp ); @@ -442,12 +502,12 @@ ShapeExport& ShapeExport::WriteBezierShape( Reference< XShape > xShape, sal_Bool ShapeExport& ShapeExport::WriteClosedBezierShape( Reference< XShape > xShape ) { - return WriteBezierShape( xShape, TRUE ); + return WriteBezierShape( xShape, sal_True ); } ShapeExport& ShapeExport::WriteOpenBezierShape( Reference< XShape > xShape ) { - return WriteBezierShape( xShape, FALSE ); + return WriteBezierShape( xShape, sal_False ); } ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape ) @@ -457,7 +517,7 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape ) Reference< XPropertySet > rXPropSet( xShape, UNO_QUERY ); SdrObjCustomShape* pShape = (SdrObjCustomShape*) GetSdrObjectFromXShape( xShape ); sal_Bool bIsDefaultObject = EscherPropertyContainer::IsDefaultObject( pShape ); - sal_Bool bPredefinedHandlesUsed = TRUE; + sal_Bool bPredefinedHandlesUsed = sal_True; OUString sShapeType; sal_uInt32 nMirrorFlags = 0; MSO_SPT eShapeType = EscherPropertyContainer::GetCustomShapeType( xShape, nMirrorFlags, sShapeType ); @@ -476,11 +536,11 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape ) const PropertyValue& rProp = aGeometrySeq[ i ]; DBG(printf("geometry property: %s\n", USS( rProp.Name ))); - if( rProp.Name.equalsAscii( "AdjustmentValues" )) + if( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "AdjustmentValues" ) )) nAdjustmentValuesIndex = i; - else if( rProp.Name.equalsAscii( "Handles" )) { + else if( rProp.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Handles" ) )) { if( !bIsDefaultObject ) - bPredefinedHandlesUsed = FALSE; + bPredefinedHandlesUsed = sal_False; // TODO: update nAdjustmentsWhichNeedsToBeConverted here } } @@ -502,7 +562,7 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape ) // visual shape properties pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND ); - WriteShapeTransformation( xShape ); + WriteShapeTransformation( xShape, XML_a ); if( nAdjustmentValuesIndex != -1 ) WritePresetShape( sPresetShape, eShapeType, bPredefinedHandlesUsed, nAdjustmentsWhichNeedsToBeConverted, aGeometrySeq[ nAdjustmentValuesIndex ] ); else @@ -516,7 +576,7 @@ ShapeExport& ShapeExport::WriteCustomShape( Reference< XShape > xShape ) pFS->endElementNS( mnXmlNamespace, XML_spPr ); // write text - WriteTextBox( xShape ); + WriteTextBox( xShape, mnXmlNamespace ); pFS->endElementNS( mnXmlNamespace, XML_sp ); @@ -545,7 +605,7 @@ ShapeExport& ShapeExport::WriteEllipseShape( Reference< XShape > xShape ) // visual shape properties pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND ); - WriteShapeTransformation( xShape ); + WriteShapeTransformation( xShape, XML_a ); WritePresetShape( "ellipse" ); Reference< XPropertySet > xProps( xShape, UNO_QUERY ); if( xProps.is() ) @@ -556,46 +616,13 @@ ShapeExport& ShapeExport::WriteEllipseShape( Reference< XShape > xShape ) pFS->endElementNS( mnXmlNamespace, XML_spPr ); // write text - WriteTextBox( xShape ); + WriteTextBox( xShape, mnXmlNamespace ); pFS->endElementNS( mnXmlNamespace, XML_sp ); return *this; } -ShapeExport& ShapeExport::WriteFill( Reference< XPropertySet > xPropSet ) -{ - FillStyle aFillStyle( FillStyle_NONE ); - xPropSet->getPropertyValue( S( "FillStyle" ) ) >>= aFillStyle; - - if( aFillStyle == FillStyle_BITMAP ) - { - //DBG(printf ("FillStyle_BITMAP properties\n")); - //DBG(dump_pset(rXPropSet)); - } - - if( aFillStyle == FillStyle_NONE || - aFillStyle == FillStyle_HATCH ) - return *this; - - switch( aFillStyle ) - { - case ::com::sun::star::drawing::FillStyle_SOLID : - WriteSolidFill( xPropSet ); - break; - case ::com::sun::star::drawing::FillStyle_GRADIENT : - WriteGradientFill( xPropSet ); - break; - case ::com::sun::star::drawing::FillStyle_BITMAP : - WriteBlipFill( xPropSet, S( "FillBitmapURL" ) ); - break; - default: - ; - } - - return *this; -} - ShapeExport& ShapeExport::WriteGraphicObjectShape( Reference< XShape > xShape ) { DBG(printf("write graphic object shape\n")); @@ -646,7 +673,7 @@ ShapeExport& ShapeExport::WriteGraphicObjectShape( Reference< XShape > xShape ) pFS->startElementNS( mnXmlNamespace, XML_blipFill, FSEND ); - WriteBlip( sGraphicURL ); + WriteBlip( xShapeProps, sGraphicURL ); bool bStretch = false; if( ( xShapeProps->getPropertyValue( S( "FillBitmapStretch" ) ) >>= bStretch ) && bStretch ) @@ -658,8 +685,10 @@ ShapeExport& ShapeExport::WriteGraphicObjectShape( Reference< XShape > xShape ) // visual shape properties pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND ); - WriteShapeTransformation( xShape ); + WriteShapeTransformation( xShape, XML_a ); WritePresetShape( "rect" ); + // graphic object can come with the frame (bnc#654525) + WriteOutline( xShapeProps ); pFS->endElementNS( mnXmlNamespace, XML_spPr ); pFS->endElementNS( mnXmlNamespace, XML_pic ); @@ -714,13 +743,13 @@ ShapeExport& ShapeExport::WriteConnectorShape( Reference< XShape > xShape ) Rectangle aRect( Point( aStartPoint.X, aStartPoint.Y ), Point( aEndPoint.X, aEndPoint.Y ) ); if( aRect.getWidth() < 0 ) { - bFlipH = TRUE; + bFlipH = sal_True; aRect.setX( aEndPoint.X ); aRect.setWidth( aStartPoint.X - aEndPoint.X ); } if( aRect.getHeight() < 0 ) { - bFlipV = TRUE; + bFlipV = sal_True; aRect.setY( aEndPoint.Y ); aRect.setHeight( aStartPoint.Y - aEndPoint.Y ); } @@ -751,7 +780,7 @@ ShapeExport& ShapeExport::WriteConnectorShape( Reference< XShape > xShape ) pFS->endElementNS( mnXmlNamespace, XML_spPr ); // write text - WriteTextBox( xShape ); + WriteTextBox( xShape, mnXmlNamespace ); pFS->endElementNS( mnXmlNamespace, XML_cxnSp ); @@ -790,7 +819,7 @@ ShapeExport& ShapeExport::WriteLineShape( Reference< XShape > xShape ) // visual shape properties pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND ); - WriteShapeTransformation( xShape, bFlipH, bFlipV ); + WriteShapeTransformation( xShape, XML_a, bFlipH, bFlipV ); WritePresetShape( "line" ); Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY ); if( xShapeProps.is() ) @@ -798,7 +827,7 @@ ShapeExport& ShapeExport::WriteLineShape( Reference< XShape > xShape ) pFS->endElementNS( mnXmlNamespace, XML_spPr ); // write text - WriteTextBox( xShape ); + WriteTextBox( xShape, mnXmlNamespace ); pFS->endElementNS( mnXmlNamespace, XML_sp ); @@ -854,7 +883,7 @@ ShapeExport& ShapeExport::WriteRectangleShape( Reference< XShape > xShape ) // visual shape properties pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND ); - WriteShapeTransformation( xShape ); + WriteShapeTransformation( xShape, XML_a ); WritePresetShape( "rect" ); Reference< XPropertySet > xProps( xShape, UNO_QUERY ); if( xProps.is() ) @@ -865,7 +894,7 @@ ShapeExport& ShapeExport::WriteRectangleShape( Reference< XShape > xShape ) pFS->endElementNS( mnXmlNamespace, XML_spPr ); // write text - WriteTextBox( xShape ); + WriteTextBox( xShape, mnXmlNamespace ); pFS->endElementNS( mnXmlNamespace, XML_sp ); @@ -873,7 +902,7 @@ ShapeExport& ShapeExport::WriteRectangleShape( Reference< XShape > xShape ) } typedef ShapeExport& (ShapeExport::*ShapeConverter)( Reference< XShape > ); -typedef std::hash_map< const char*, ShapeConverter, std::hash<const char*>, StringCheck> NameToConvertMapType; +typedef boost::unordered_map< const char*, ShapeConverter, StringHash, StringCheck> NameToConvertMapType; static const NameToConvertMapType& lcl_GetConverters() { @@ -892,6 +921,8 @@ static const NameToConvertMapType& lcl_GetConverters() shape_converters[ "com.sun.star.drawing.LineShape" ] = &ShapeExport::WriteLineShape; shape_converters[ "com.sun.star.drawing.OpenBezierShape" ] = &ShapeExport::WriteOpenBezierShape; shape_converters[ "com.sun.star.drawing.RectangleShape" ] = &ShapeExport::WriteRectangleShape; + shape_converters[ "com.sun.star.drawing.OLE2Shape" ] = &ShapeExport::WriteOLE2Shape; + shape_converters[ "com.sun.star.drawing.TableShape" ] = &ShapeExport::WriteTableShape; shape_converters[ "com.sun.star.drawing.TextShape" ] = &ShapeExport::WriteTextShape; shape_converters[ "com.sun.star.presentation.DateTimeShape" ] = &ShapeExport::WriteTextShape; shape_converters[ "com.sun.star.presentation.FooterShape" ] = &ShapeExport::WriteTextShape; @@ -920,17 +951,119 @@ ShapeExport& ShapeExport::WriteShape( Reference< XShape > xShape ) return *this; } -ShapeExport& ShapeExport::WriteTextBox( Reference< XShape > xShape ) +ShapeExport& ShapeExport::WriteTextBox( Reference< XInterface > xIface, sal_Int32 nXmlNamespace ) { - if( NonEmptyText( xShape ) ) + if( NonEmptyText( xIface ) ) { FSHelperPtr pFS = GetFS(); - pFS->startElementNS( mnXmlNamespace, XML_txBody, FSEND ); - WriteText( xShape ); - pFS->endElementNS( mnXmlNamespace, XML_txBody ); + pFS->startElementNS( nXmlNamespace, XML_txBody, FSEND ); + WriteText( xIface ); + pFS->endElementNS( nXmlNamespace, XML_txBody ); + } + + return *this; +} + +void ShapeExport::WriteTable( Reference< XShape > rXShape ) +{ + OSL_TRACE("write table"); + + Reference< XTable > xTable; + Reference< XPropertySet > xPropSet( rXShape, UNO_QUERY ); + + mpFS->startElementNS( XML_a, XML_graphic, FSEND ); + mpFS->startElementNS( XML_a, XML_graphicData, XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/table", FSEND ); + + if ( xPropSet.is() && ( xPropSet->getPropertyValue( S("Model") ) >>= xTable ) ) + { + mpFS->startElementNS( XML_a, XML_tbl, FSEND ); + mpFS->singleElementNS( XML_a, XML_tblPr, FSEND ); + + Reference< XColumnRowRange > xColumnRowRange( xTable, UNO_QUERY_THROW ); + Reference< container::XIndexAccess > xColumns( xColumnRowRange->getColumns(), UNO_QUERY_THROW ); + Reference< container::XIndexAccess > xRows( xColumnRowRange->getRows(), UNO_QUERY_THROW ); + sal_uInt16 nRowCount = static_cast< sal_uInt16 >( xRows->getCount() ); + sal_uInt16 nColumnCount = static_cast< sal_uInt16 >( xColumns->getCount() ); + + std::vector< std::pair< sal_Int32, sal_Int32 > > aColumns; + std::vector< std::pair< sal_Int32, sal_Int32 > > aRows; + + mpFS->startElementNS( XML_a, XML_tblGrid, FSEND ); + + for ( sal_Int32 x = 0; x < nColumnCount; x++ ) + { + Reference< XPropertySet > xColPropSet( xColumns->getByIndex( x ), UNO_QUERY_THROW ); + sal_Int32 nWidth(0); + xColPropSet->getPropertyValue( S("Width") ) >>= nWidth; + + mpFS->singleElementNS( XML_a, XML_gridCol, XML_w, I64S(MM100toEMU(nWidth)), FSEND ); + } + + mpFS->endElementNS( XML_a, XML_tblGrid ); + + Reference< XCellRange > xCellRange( xTable, UNO_QUERY_THROW ); + for( sal_Int32 nRow = 0; nRow < nRowCount; nRow++ ) + { + Reference< XPropertySet > xRowPropSet( xRows->getByIndex( nRow ), UNO_QUERY_THROW ); + sal_Int32 nRowHeight(0); + + xRowPropSet->getPropertyValue( S("Height") ) >>= nRowHeight; + + mpFS->startElementNS( XML_a, XML_tr, XML_h, I64S( MM100toEMU( nRowHeight ) ), FSEND ); + + for( sal_Int32 nColumn = 0; nColumn < nColumnCount; nColumn++ ) + { + Reference< XMergeableCell > xCell( xCellRange->getCellByPosition( nColumn, nRow ), UNO_QUERY_THROW ); + if ( !xCell->isMerged() ) + { + mpFS->startElementNS( XML_a, XML_tc, FSEND ); + + WriteTextBox( xCell, XML_a ); + + mpFS->singleElementNS( XML_a, XML_tcPr, FSEND ); + mpFS->endElementNS( XML_a, XML_tc ); + } + } + + mpFS->endElementNS( XML_a, XML_tr ); + } + + mpFS->endElementNS( XML_a, XML_tbl ); } + mpFS->endElementNS( XML_a, XML_graphicData ); + mpFS->endElementNS( XML_a, XML_graphic ); +} + +ShapeExport& ShapeExport::WriteTableShape( Reference< XShape > xShape ) +{ + FSHelperPtr pFS = GetFS(); + + OSL_TRACE("write table shape"); + + pFS->startElementNS( mnXmlNamespace, XML_graphicFrame, FSEND ); + + pFS->startElementNS( mnXmlNamespace, XML_nvGraphicFramePr, FSEND ); + + pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, + XML_id, I32S( GetNewShapeID( xShape ) ), + XML_name, IDS(Table), + FSEND ); + + pFS->singleElementNS( mnXmlNamespace, XML_cNvGraphicFramePr, + FSEND ); + + if( GetDocumentType() == DOCUMENT_PPTX ) + pFS->singleElementNS( mnXmlNamespace, XML_nvPr, + FSEND ); + pFS->endElementNS( mnXmlNamespace, XML_nvGraphicFramePr ); + + WriteShapeTransformation( xShape, mnXmlNamespace ); + WriteTable( xShape ); + + pFS->endElementNS( mnXmlNamespace, XML_graphicFrame ); + return *this; } @@ -949,46 +1082,83 @@ ShapeExport& ShapeExport::WriteTextShape( Reference< XShape > xShape ) // visual shape properties pFS->startElementNS( mnXmlNamespace, XML_spPr, FSEND ); - WriteShapeTransformation( xShape ); + WriteShapeTransformation( xShape, XML_a ); WritePresetShape( "rect" ); WriteBlipFill( Reference< XPropertySet >(xShape, UNO_QUERY ), S( "GraphicURL" ) ); pFS->endElementNS( mnXmlNamespace, XML_spPr ); - WriteTextBox( xShape ); + WriteTextBox( xShape, mnXmlNamespace ); pFS->endElementNS( mnXmlNamespace, XML_sp ); return *this; } +ShapeExport& ShapeExport::WriteOLE2Shape( Reference< XShape > xShape ) +{ + Reference< XPropertySet > xPropSet( xShape, UNO_QUERY ); + if( xPropSet.is() && GetProperty( xPropSet, S("Model") ) ) + { + Reference< XChartDocument > xChartDoc; + mAny >>= xChartDoc; + if( xChartDoc.is() ) + { + //export the chart + Reference< XModel > xModel( xChartDoc, UNO_QUERY ); + ChartExport aChartExport( mnXmlNamespace, GetFS(), xModel, GetFB(), GetDocumentType() ); + static sal_Int32 nChartCount = 0; + aChartExport.WriteChartObj( xShape, ++nChartCount ); + } + } + return *this; +} + ShapeExport& ShapeExport::WriteUnknownShape( Reference< XShape > ) { // Override this method to do something useful. return *this; } -size_t ShapeExport::ShapeHash::operator()( const ::com::sun::star::uno::Reference < ::com::sun::star::drawing::XShape > rXShape ) const +size_t ShapeExport::ShapeHash::operator()( const Reference < XShape > rXShape ) const { - return maHashFunction( USS( rXShape->getShapeType() ) ); + return rXShape->getShapeType().hashCode(); } sal_Int32 ShapeExport::GetNewShapeID( const Reference< XShape > rXShape ) { - sal_Int32 nID = GetFB()->GetUniqueId(); + return GetNewShapeID( rXShape, GetFB() ); +} + +sal_Int32 ShapeExport::GetNewShapeID( const Reference< XShape > rXShape, XmlFilterBase* pFB ) +{ + if( !rXShape.is() ) + return -1; + + sal_Int32 nID = pFB->GetUniqueId(); - maShapeMap[ rXShape ] = nID; + (*mpShapeMap)[ rXShape ] = nID; return nID; } sal_Int32 ShapeExport::GetShapeID( const Reference< XShape > rXShape ) { - ShapeHashMap::const_iterator aIter = maShapeMap.find( rXShape ); + return GetShapeID( rXShape, mpShapeMap ); +} + +sal_Int32 ShapeExport::GetShapeID( const Reference< XShape > rXShape, ShapeHashMap* pShapeMap ) +{ + if( !rXShape.is() ) + return -1; + + ShapeHashMap::const_iterator aIter = pShapeMap->find( rXShape ); - if( aIter == maShapeMap.end() ) + if( aIter == pShapeMap->end() ) return -1; return aIter->second; } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx index a629d89639fa..554d49faae53 100644 --- a/oox/source/export/vmlexport.cxx +++ b/oox/source/export/vmlexport.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,7 +28,7 @@ #include <oox/export/vmlexport.hxx> -#include <tokens.hxx> +#include <oox/token/tokens.hxx> #include <rtl/strbuf.hxx> #include <rtl/ustring.hxx> @@ -64,7 +65,7 @@ public: }; VMLExport::VMLExport( ::sax_fastparser::FSHelperPtr pSerializer ) - : EscherEx( *( new SvNullStream ), 0 ), + : EscherEx( EscherExGlobalRef(new EscherExGlobal(0)), *( new SvNullStream ) ), m_pSerializer( pSerializer ), m_pShapeAttrList( NULL ), m_nShapeType( ESCHER_ShpInst_Nil ), @@ -82,7 +83,7 @@ VMLExport::~VMLExport() delete[] m_pShapeTypeWritten, m_pShapeTypeWritten = NULL; } -void VMLExport::OpenContainer( UINT16 nEscherContainer, int nRecInstance ) +void VMLExport::OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance ) { EscherEx::OpenContainer( nEscherContainer, nRecInstance ); @@ -101,7 +102,7 @@ void VMLExport::OpenContainer( UINT16 nEscherContainer, int nRecInstance ) m_pShapeStyle->ensureCapacity( 200 ); - // postpone the ouput so that we are able to write even the elements + // postpone the output so that we are able to write even the elements // that we learn inside Commit() m_pSerializer->mark(); } @@ -126,9 +127,9 @@ void VMLExport::CloseContainer() EscherEx::CloseContainer(); } -UINT32 VMLExport::EnterGroup( const String& rShapeName, const Rectangle* pRect ) +sal_uInt32 VMLExport::EnterGroup( const String& rShapeName, const Rectangle* pRect ) { - UINT32 nShapeId = GetShapeID(); + sal_uInt32 nShapeId = GenerateShapeId(); OStringBuffer aStyle( 200 ); FastAttributeList *pAttrList = m_pSerializer->createAttrList(); @@ -171,7 +172,7 @@ void VMLExport::LeaveGroup() m_pSerializer->endElementNS( XML_v, XML_group ); } -void VMLExport::AddShape( UINT32 nShapeType, UINT32 nShapeFlags, UINT32 nShapeId ) +void VMLExport::AddShape( sal_uInt32 nShapeType, sal_uInt32 nShapeFlags, sal_uInt32 nShapeId ) { m_nShapeType = nShapeType; m_nShapeFlags = nShapeFlags; @@ -362,8 +363,8 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect case ESCHER_WrapThrough: pWrapType = "through"; break; } if ( pWrapType ) - m_pSerializer->singleElementNS( XML_w10, XML_wrap, - FSNS( XML_w10, XML_type ), pWrapType, + m_pSerializer->singleElementNS( XML_v, XML_wrap, + FSNS( XML_v, XML_type ), pWrapType, FSEND ); } bAlreadyWritten[ ESCHER_Prop_WrapText ] = true; @@ -665,7 +666,7 @@ void VMLExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect break; default: #if OSL_DEBUG_LEVEL > 0 - fprintf( stderr, "TODO VMLExport::Commit(), unimplemented id: %d, value: %d, data: [%d, %p]\n", + fprintf( stderr, "TODO VMLExport::Commit(), unimplemented id: %d, value: %" SAL_PRIuUINT32 ", data: [%" SAL_PRIuUINT32 ", %p]\n", it->nPropId, it->nPropValue, it->nPropSize, it->pBuf ); if ( it->nPropSize ) { @@ -835,3 +836,5 @@ void VMLExport::EndShape( sal_Int32 nShapeElement ) m_pSerializer->endElementNS( XML_v, nShapeElement ); } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/attributelist.cxx b/oox/source/helper/attributelist.cxx index ae10c290b425..767c5711371e 100644 --- a/oox/source/helper/attributelist.cxx +++ b/oox/source/helper/attributelist.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -323,3 +324,5 @@ DateTime AttributeList::getDateTime( sal_Int32 nAttrToken, const DateTime& rDefa // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/binaryinputstream.cxx b/oox/source/helper/binaryinputstream.cxx index 58c7cca37008..541b3196de13 100644 --- a/oox/source/helper/binaryinputstream.cxx +++ b/oox/source/helper/binaryinputstream.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -168,13 +169,13 @@ BinaryXInputStream::~BinaryXInputStream() void BinaryXInputStream::close() { OSL_ENSURE( !mbAutoClose || mxInStrm.is(), "BinaryXInputStream::close - invalid call" ); - if( mbAutoClose && mxInStrm.is() ) try + if( mxInStrm.is() ) try { mxInStrm->closeInput(); } catch( Exception& ) { - OSL_ENSURE( false, "BinaryXInputStream::close - closing input stream failed" ); + OSL_FAIL( "BinaryXInputStream::close - closing input stream failed" ); } mxInStrm.clear(); mbAutoClose = false; @@ -355,3 +356,5 @@ void RelativeInputStream::skip( sal_Int32 nBytes, size_t nAtomSize ) // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx index 2f894ccf1bf2..76f08ed67ff8 100644 --- a/oox/source/helper/binaryoutputstream.cxx +++ b/oox/source/helper/binaryoutputstream.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -68,12 +69,11 @@ void BinaryXOutputStream::close() if( mxOutStrm.is() ) try { mxOutStrm->flush(); - if( mbAutoClose ) - mxOutStrm->closeOutput(); + mxOutStrm->closeOutput(); } catch( Exception& ) { - OSL_ENSURE( false, "BinaryXOutputStream::close - closing output stream failed" ); + OSL_FAIL( "BinaryXOutputStream::close - closing output stream failed" ); } mxOutStrm.clear(); mbAutoClose = false; @@ -88,7 +88,7 @@ void BinaryXOutputStream::writeData( const StreamDataSequence& rData, size_t /*n } catch( Exception& ) { - OSL_ENSURE( false, "BinaryXOutputStream::writeData - stream read error" ); + OSL_FAIL( "BinaryXOutputStream::writeData - stream read error" ); } } @@ -139,3 +139,4 @@ void SequenceOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes, size } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/binarystreambase.cxx b/oox/source/helper/binarystreambase.cxx index f189a37f97f5..083c5e27633f 100644 --- a/oox/source/helper/binarystreambase.cxx +++ b/oox/source/helper/binarystreambase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -85,7 +86,7 @@ sal_Int64 BinaryXSeekableStream::size() const } catch( Exception& ) { - OSL_ENSURE( false, "BinaryXSeekableStream::size - exception caught" ); + OSL_FAIL( "BinaryXSeekableStream::size - exception caught" ); } return -1; } @@ -98,7 +99,7 @@ sal_Int64 BinaryXSeekableStream::tell() const } catch( Exception& ) { - OSL_ENSURE( false, "BinaryXSeekableStream::tell - exception caught" ); + OSL_FAIL( "BinaryXSeekableStream::tell - exception caught" ); } return -1; } @@ -159,3 +160,5 @@ void SequenceSeekableStream::close() // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/containerhelper.cxx b/oox/source/helper/containerhelper.cxx index 264deb366878..b4af73591530 100644 --- a/oox/source/helper/containerhelper.cxx +++ b/oox/source/helper/containerhelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -205,7 +206,7 @@ OUString ContainerHelper::insertByUnusedName( } catch( Exception& ) { - OSL_ENSURE( false, "ContainerHelper::insertByUnusedName - cannot rename old object" ); + OSL_FAIL( "ContainerHelper::insertByUnusedName - cannot rename old object" ); } } @@ -217,3 +218,5 @@ OUString ContainerHelper::insertByUnusedName( // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx index aeed0322b536..aa7e6f08e7ad 100755..100644 --- a/oox/source/helper/graphichelper.cxx +++ b/oox/source/helper/graphichelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -135,7 +136,7 @@ GraphicHelper::GraphicHelper( const Reference< XComponentContext >& rxContext, c } catch( Exception& ) { - OSL_ENSURE( false, "GraphicHelper::GraphicHelper - cannot get output device info" ); + OSL_FAIL( "GraphicHelper::GraphicHelper - cannot get output device info" ); } mfPixelPerHmmX = maDeviceInfo.PixelPerMeterX / 100000.0; mfPixelPerHmmY = maDeviceInfo.PixelPerMeterY / 100000.0; @@ -154,13 +155,13 @@ sal_Int32 GraphicHelper::getSystemColor( sal_Int32 nToken, sal_Int32 nDefaultRgb sal_Int32 GraphicHelper::getSchemeColor( sal_Int32 /*nToken*/ ) const { - OSL_ENSURE( false, "GraphicHelper::getSchemeColor - scheme colors not implemented" ); + OSL_FAIL( "GraphicHelper::getSchemeColor - scheme colors not implemented" ); return API_RGB_TRANSPARENT; } sal_Int32 GraphicHelper::getPaletteColor( sal_Int32 /*nPaletteIdx*/ ) const { - OSL_ENSURE( false, "GraphicHelper::getPaletteColor - palette colors not implemented" ); + OSL_FAIL( "GraphicHelper::getPaletteColor - palette colors not implemented" ); return API_RGB_TRANSPARENT; } @@ -363,3 +364,5 @@ Size GraphicHelper::getOriginalSize( const Reference< XGraphic >& xGraphic ) con // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/modelobjecthelper.cxx b/oox/source/helper/modelobjecthelper.cxx index d9c5bddff0f2..81a5447ed8af 100644 --- a/oox/source/helper/modelobjecthelper.cxx +++ b/oox/source/helper/modelobjecthelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -151,3 +152,5 @@ OUString ModelObjectHelper::insertFillBitmapUrl( const OUString& rGraphicUrl ) // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/progressbar.cxx b/oox/source/helper/progressbar.cxx index 1ef6531d3fb0..0a4c4ca29990 100644 --- a/oox/source/helper/progressbar.cxx +++ b/oox/source/helper/progressbar.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -184,3 +185,5 @@ ISegmentProgressBarRef SegmentProgressBar::createSegment( double fLength ) // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/propertymap.cxx b/oox/source/helper/propertymap.cxx index aada69cfb888..2ac3b3fdfc4b 100644 --- a/oox/source/helper/propertymap.cxx +++ b/oox/source/helper/propertymap.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,21 +27,79 @@ ************************************************************************/ #include "oox/helper/propertymap.hxx" +#include "oox/helper/helper.hxx" + +#if OSL_DEBUG_LEVEL > 0 +# include <cstdio> +# include <com/sun/star/style/LineSpacing.hpp> +# include <com/sun/star/style/LineSpacingMode.hpp> +# include <com/sun/star/text/WritingMode.hpp> +# define USS(x) OUStringToOString( x, RTL_TEXTENCODING_UTF8 ).getStr() +using ::com::sun::star::style::LineSpacing; +using ::com::sun::star::text::WritingMode; +#endif #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/container/XIndexReplace.hpp> +#include <com/sun/star/awt/Rectangle.hpp> +#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp> +#include <com/sun/star/drawing/HomogenMatrix3.hpp> #include <cppuhelper/implbase2.hxx> #include <osl/mutex.hxx> #include "oox/token/propertynames.hxx" +using ::rtl::OUString; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::lang::IllegalArgumentException; +using ::com::sun::star::lang::WrappedTargetException; +using ::com::sun::star::beans::Property; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::beans::PropertyVetoException; +using ::com::sun::star::beans::UnknownPropertyException; +using ::com::sun::star::beans::XPropertyChangeListener; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::beans::XPropertySetInfo; +using ::com::sun::star::beans::XVetoableChangeListener; +using ::com::sun::star::container::XIndexReplace; + +#if OSL_DEBUG_LEVEL > 0 +#include <cstdio> +#include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/style/LineSpacingMode.hpp> +#include <com/sun/star/text/WritingMode.hpp> +#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#define USS(x) OUStringToOString( x, RTL_TEXTENCODING_UTF8 ).getStr() +using namespace ::com::sun::star; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::uno; +using ::rtl::OString; +using ::com::sun::star::style::LineSpacing; +using ::com::sun::star::text::WritingMode; +using ::com::sun::star::drawing::TextHorizontalAdjust; +using ::com::sun::star::drawing::TextVerticalAdjust; +#endif namespace oox { +using ::com::sun::star::container::XIndexReplace; // ============================================================================ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::drawing; using namespace ::com::sun::star::uno; +using ::com::sun::star::drawing::TextHorizontalAdjust; +using ::com::sun::star::drawing::TextVerticalAdjust; using ::rtl::OString; using ::rtl::OUString; @@ -184,7 +243,7 @@ Sequence< PropertyValue > PropertyMap::makePropertyValueSequence() const OSL_ENSURE( (0 <= aIt->first) && (aIt->first < PROP_COUNT), "PropertyMap::makePropertyValueSequence - invalid property identifier" ); pValues->Name = (*mpPropNames)[ aIt->first ]; pValues->Value = aIt->second; - pValues->State = ::com::sun::star::beans::PropertyState_DIRECT_VALUE; + pValues->State = PropertyState_DIRECT_VALUE; } } return aSeq; @@ -212,6 +271,546 @@ Reference< XPropertySet > PropertyMap::makePropertySet() const return new GenericPropertySet( *this ); } +#if OSL_DEBUG_LEVEL > 0 +static void lclDumpAnyValue( Any value) +{ + OUString strValue; + Sequence< OUString > strArray; + Sequence< Any > anyArray; + Sequence< PropertyValue > propArray; + Sequence< Sequence< PropertyValue > > propArrayArray; + Sequence< EnhancedCustomShapeAdjustmentValue > adjArray; + Sequence< EnhancedCustomShapeSegment > segArray; + Sequence< EnhancedCustomShapeParameterPair > ppArray; + EnhancedCustomShapeSegment segment; + EnhancedCustomShapeParameterPair pp; + EnhancedCustomShapeParameter par; + HomogenMatrix3 aMatrix; + sal_Int32 intValue = 0; + sal_uInt32 uintValue = 0; + sal_Int16 int16Value = 0; + sal_uInt16 uint16Value = 0; + float floatValue = 0; + bool boolValue = false; + LineSpacing spacing; +// RectanglePoint pointValue; + WritingMode aWritingMode; + TextVerticalAdjust aTextVertAdj; + TextHorizontalAdjust aTextHorizAdj; + Reference< XIndexReplace > xNumRule; + + if( value >>= strValue ) + fprintf (stderr,"\"%s\"\n", USS( strValue ) ); + else if( value >>= strArray ) { + fprintf (stderr,"%s\n", USS(value.getValueTypeName())); + for( int i=0; i<strArray.getLength(); i++ ) + fprintf (stderr,"\t\t\t[%3d] \"%s\"\n", i, USS( strArray[i] ) ); + } else if( value >>= propArray ) { + fprintf (stderr,"%s\n", USS(value.getValueTypeName())); + for( int i=0; i<propArray.getLength(); i++ ) { + fprintf (stderr,"\t\t\t[%3d] %s (%s) ", i, USS( propArray[i].Name ), USS(propArray[i].Value.getValueTypeName()) ); + lclDumpAnyValue( propArray[i].Value ); + } + } else if( value >>= propArrayArray ) { + fprintf (stderr,"%s\n", USS(value.getValueTypeName())); + for( int i=0; i<propArrayArray.getLength(); i++ ) { + fprintf (stderr,"\t\t\t[%3d] ", i); + lclDumpAnyValue( makeAny (propArrayArray[i]) ); + } + } else if( value >>= anyArray ) { + fprintf (stderr,"%s\n", USS(value.getValueTypeName())); + for( int i=0; i<anyArray.getLength(); i++ ) { + fprintf (stderr,"\t\t\t[%3d] (%s) ", i, USS(value.getValueTypeName()) ); + lclDumpAnyValue( anyArray[i] ); + } + } else if( value >>= adjArray ) { + fprintf (stderr,"%s\n", USS(value.getValueTypeName())); + for( int i=0; i<adjArray.getLength(); i++ ) { + fprintf (stderr,"\t\t\t[%3d] (%s) ", i, USS(adjArray[i].Value.getValueTypeName()) ); + lclDumpAnyValue( adjArray[i].Value ); + } + } else if( value >>= segArray ) { + fprintf (stderr,"%s\n", USS(value.getValueTypeName())); + for( int i=0; i<segArray.getLength(); i++ ) { + fprintf (stderr,"\t\t\t[%3d] ", i ); + lclDumpAnyValue( makeAny( segArray[i] ) ); + } + } else if( value >>= ppArray ) { + fprintf (stderr,"%s\n", USS(value.getValueTypeName())); + for( int i=0; i<ppArray.getLength(); i++ ) { + fprintf (stderr,"\t\t\t[%3d] ", i ); + lclDumpAnyValue( makeAny( ppArray[i] ) ); + } + } else if( value >>= segment ) { + fprintf (stderr,"Command: %d Count: %d\n", segment.Command, segment.Count); + } else if( value >>= pp ) { + fprintf (stderr,"First: "); + lclDumpAnyValue( makeAny (pp.First) ); + fprintf (stderr,"\t\t\t Second: "); + lclDumpAnyValue( makeAny (pp.Second) ); + } else if( value >>= par ) { + fprintf (stderr,"Parameter (%s): ", USS(par.Value.getValueTypeName())); + lclDumpAnyValue( par.Value ); + } else if( value >>= aMatrix ) { + fprintf (stderr,"Matrix\n%f %f %f\n%f %f %f\n%f %f %f\n", aMatrix.Line1.Column1, aMatrix.Line1.Column2, aMatrix.Line1.Column3, aMatrix.Line2.Column1, aMatrix.Line2.Column2, aMatrix.Line2.Column3, aMatrix.Line3.Column1, aMatrix.Line3.Column2, aMatrix.Line3.Column3); + } else if( value >>= intValue ) + fprintf (stderr,"%"SAL_PRIdINT32" (hex: %"SAL_PRIxUINT32")\n", intValue, intValue); + else if( value >>= uintValue ) + fprintf (stderr,"%"SAL_PRIdINT32" (hex: %"SAL_PRIxUINT32")\n", uintValue, uintValue); + else if( value >>= int16Value ) + fprintf (stderr,"%d (hex: %x)\n", int16Value, int16Value); + else if( value >>= uint16Value ) + fprintf (stderr,"%d (hex: %x)\n", uint16Value, uint16Value); + else if( value >>= floatValue ) + fprintf (stderr,"%f\n", floatValue); + else if( value >>= boolValue ) + fprintf (stderr,"%d (bool)\n", boolValue); + else if( value >>= xNumRule ) { + fprintf (stderr, "XIndexReplace\n"); + if (xNumRule.is()) { + for (int k=0; k<xNumRule->getCount(); k++) { + Sequence< PropertyValue > aBulletPropSeq; + fprintf (stderr, "level %d\n", k); + if (xNumRule->getByIndex (k) >>= aBulletPropSeq) { + for (int j=0; j<aBulletPropSeq.getLength(); j++) { + fprintf(stderr, "%46s = ", USS (aBulletPropSeq[j].Name)); + lclDumpAnyValue (aBulletPropSeq[j].Value); + } + } + } + } else { + fprintf (stderr, "empty reference\n"); + } + } else if( value >>= aWritingMode ) + fprintf (stderr, "%d writing mode\n", aWritingMode); + else if( value >>= aTextVertAdj ) { + const char* s = "uknown"; + switch( aTextVertAdj ) { + case TextVerticalAdjust_TOP: + s = "top"; + break; + case TextVerticalAdjust_CENTER: + s = "center"; + break; + case TextVerticalAdjust_BOTTOM: + s = "bottom"; + break; + case TextVerticalAdjust_BLOCK: + s = "block"; + break; + case TextVerticalAdjust_MAKE_FIXED_SIZE: + s = "make_fixed_size"; + break; + } + fprintf (stderr, "%s\n", s); + } else if( value >>= aTextHorizAdj ) { + const char* s = "uknown"; + switch( aTextHorizAdj ) { + case TextHorizontalAdjust_LEFT: + s = "left"; + break; + case TextHorizontalAdjust_CENTER: + s = "center"; + break; + case TextHorizontalAdjust_RIGHT: + s = "right"; + break; + case TextHorizontalAdjust_BLOCK: + s = "block"; + break; + case TextHorizontalAdjust_MAKE_FIXED_SIZE: + s = "make_fixed_size"; + break; + } + fprintf (stderr, "%s\n", s); + } else if( value >>= spacing ) { + fprintf (stderr, "mode: %d value: %d\n", spacing.Mode, spacing.Height); + } else if( value.isExtractableTo(::getCppuType((const sal_Int32*)0))) { + fprintf (stderr,"is extractable to int32\n"); + } +// else if( value >>= pointValue ) +// fprintf (stderr,"%d (RectanglePoint)\n", pointValue); + else + fprintf (stderr,"??? <unhandled type %s>\n", USS(value.getValueTypeName())); +} + +void PropertyMap::dump( Reference< XPropertySet > rXPropSet ) +{ + Reference< XPropertySetInfo > info = rXPropSet->getPropertySetInfo (); + Sequence< Property > props = info->getProperties (); + + OSL_TRACE("dump props, len: %d", props.getLength ()); + + for (int i=0; i < props.getLength (); i++) { + OString name = OUStringToOString( props [i].Name, RTL_TEXTENCODING_UTF8); + fprintf (stderr,"%30s = ", name.getStr() ); + + try { + lclDumpAnyValue (rXPropSet->getPropertyValue( props [i].Name )); + } catch (const Exception& e) { + fprintf (stderr,"unable to get '%s' value\n", USS(props [i].Name)); + } + } +} + +void PropertyMap::dump() +{ + dump( Reference< XPropertySet >( makePropertySet(), UNO_QUERY ) ); +} + +static void printLevel (int level) +{ + for (int i=0; i<level; i++) + fprintf (stderr, " "); +} + +static const char* lclDumpAnyValueCode( Any value, int level = 0) +{ + static OUString sVoid = CREATE_OUSTRING("void"); + OUString strValue; + Sequence< OUString > strArray; + Sequence< Any > anyArray; + Sequence< PropertyValue > propArray; + Sequence< Sequence< PropertyValue > > propArrayArray; + Sequence< EnhancedCustomShapeAdjustmentValue > adjArray; + Sequence< EnhancedCustomShapeSegment > segArray; + Sequence< EnhancedCustomShapeParameterPair > ppArray; + EnhancedCustomShapeSegment segment; + EnhancedCustomShapeParameterPair pp; + EnhancedCustomShapeParameter par; + awt::Rectangle rect; + sal_Int32 intValue = 0; + sal_uInt32 uintValue = 0; + sal_Int16 int16Value = 0; + sal_uInt16 uint16Value = 0; + long longValue; + float floatValue = 0; + bool boolValue = false; + LineSpacing spacing; +// RectanglePoint pointValue; + WritingMode aWritingMode; + TextVerticalAdjust aTextVertAdj; + TextHorizontalAdjust aTextHorizAdj; + Reference< XIndexReplace > xNumRule; + + if( value >>= strValue ) { + printLevel (level); + fprintf (stderr,"OUString str = CREATE_OUSTRING (\"%s\");\n", USS( strValue ) ); + return "str"; + } else if( value >>= strArray ) { + printLevel (level); + fprintf (stderr,"Sequence< OUString > aStringSequence (%"SAL_PRIdINT32");\n", strArray.getLength()); + for( int i=0; i<strArray.getLength(); i++ ) { + printLevel (level); + fprintf (stderr,"aStringSequence[%d] = CREATE_OUSTRING (\"%s\");\n", i, USS( strArray[i] ) ); + } + return "aStringSequence"; + } else if( value >>= propArray ) { + printLevel (level); + fprintf (stderr,"Sequence< PropertyValue > aPropSequence (%"SAL_PRIdINT32");\n", propArray.getLength()); + for( int i=0; i<propArray.getLength(); i++ ) { + printLevel (level); + fprintf (stderr, "{\n"); + printLevel (level + 1); + fprintf (stderr, "aPropSequence [%d].Name = CREATE_OUSTRING (\"%s\");\n", i, USS( propArray[i].Name )); + const char *var = lclDumpAnyValueCode( propArray[i].Value, level + 1 ); + printLevel (level + 1); + fprintf (stderr, "aPropSequence [%d].Value = makeAny (%s);\n", i, var); + printLevel (level); + fprintf (stderr, "}\n"); + } + return "aPropSequence"; + } else if( value >>= propArrayArray ) { + printLevel (level); + fprintf (stderr,"Sequence< Sequence < PropertyValue > > aPropSequenceSequence (%"SAL_PRIdINT32");\n", propArrayArray.getLength()); + for( int i=0; i<propArrayArray.getLength(); i++ ) { + printLevel (level); + fprintf (stderr, "{\n"); + const char *var = lclDumpAnyValueCode( makeAny (propArrayArray[i]), level + 1 ); + printLevel (level + 1); + fprintf (stderr, "aPropSequenceSequence [%d] = %s;\n", i, var); + printLevel (level); + fprintf (stderr, "}\n"); + } + return "aPropSequenceSequence"; + } else if( value >>= anyArray ) { + fprintf (stderr,"%s\n", USS(value.getValueTypeName())); + for( int i=0; i<anyArray.getLength(); i++ ) { + fprintf (stderr,"\t\t\t[%3d] (%s) ", i, USS(value.getValueTypeName()) ); + lclDumpAnyValue( anyArray[i] ); + } + } else if( value >>= adjArray ) { + printLevel (level); + fprintf (stderr,"Sequence< EnhancedCustomShapeAdjustmentValue > aAdjSequence (%"SAL_PRIdINT32");\n", adjArray.getLength()); + for( int i=0; i<adjArray.getLength(); i++ ) { + printLevel (level); + fprintf (stderr, "{\n"); + const char *var = lclDumpAnyValueCode( makeAny (adjArray[i].Value), level + 1 ); + printLevel (level + 1); + fprintf (stderr, "aAdjSequence [%d].Value = %s;\n", i, var); + printLevel (level); + fprintf (stderr, "}\n"); + } + return "aAdjSequence"; + } else if( value >>= segArray ) { + printLevel (level); + fprintf (stderr, "Sequence< EnhancedCustomShapeSegment > aSegmentSeq (%"SAL_PRIdINT32");\n", segArray.getLength()); + for( int i=0; i<segArray.getLength(); i++ ) { + printLevel (level); + fprintf (stderr, "{\n"); + const char *var = lclDumpAnyValueCode (makeAny (segArray[i]), level + 1); + printLevel (level + 1); + fprintf (stderr, "aSegmentSeq [%d] = %s;\n", i, var); + printLevel (level); + fprintf (stderr, "}\n"); + } + return "aSegmentSeq"; + } else if( value >>= ppArray ) { + printLevel (level); + fprintf (stderr, "Sequence< EnhancedCustomShapeParameterPair > aParameterPairSeq (%"SAL_PRIdINT32");\n", ppArray.getLength()); + for( int i=0; i<ppArray.getLength(); i++ ) { + printLevel (level); + fprintf (stderr, "{\n"); + const char *var = lclDumpAnyValueCode (makeAny (ppArray[i]), level + 1); + printLevel (level + 1); + fprintf (stderr, "aParameterPairSeq [%d] = %s;\n", i, var); + printLevel (level); + fprintf (stderr, "}\n"); + } + return "aParameterPairSeq"; + } else if( value >>= segment ) { + printLevel (level); + fprintf (stderr, "EnhancedCustomShapeSegment aSegment;\n"); + printLevel (level); + // TODO: use EnhancedCustomShapeSegmentCommand constants + fprintf (stderr, "aSegment.Command = %d;\n", segment.Command); + printLevel (level); + fprintf (stderr, "aSegment.Count = %d;\n", segment.Count); + return "aSegment"; + } else if( value >>= pp ) { + printLevel (level); + fprintf (stderr, "EnhancedCustomShapeParameterPair aParameterPair;\n"); + printLevel (level); + fprintf (stderr, "{\n"); + if (!pp.First.Value.getValueTypeName().equals(sVoid)) { + const char* var = lclDumpAnyValueCode( makeAny (pp.First), level + 1 ); + printLevel (level + 1); + fprintf (stderr, "aParameterPair.First = %s;\n", var); + } else { + printLevel (level + 1); + fprintf (stderr, "EnhancedCustomShapeParameter aParameter;\n"); + printLevel (level + 1); + fprintf (stderr, "aParameterPair.First = aParameter;\n"); + } + printLevel (level); + fprintf (stderr, "}\n"); + + printLevel (level); + fprintf (stderr, "{\n"); + if (!pp.Second.Value.getValueTypeName().equals(sVoid)) { + const char* var = lclDumpAnyValueCode( makeAny (pp.Second), level + 1 ); + printLevel (level + 1); + fprintf (stderr, "aParameterPair.Second = %s;\n", var); + } else { + printLevel (level + 1); + fprintf (stderr, "EnhancedCustomShapeParameter aParameter;\n"); + printLevel (level + 1); + fprintf (stderr, "aParameterPair.Second = aParameter;\n"); + } + printLevel (level); + fprintf (stderr, "}\n"); + return "aParameterPair"; + } else if( value >>= par ) { + printLevel (level); + fprintf (stderr,"EnhancedCustomShapeParameter aParameter;\n"); + const char* var = lclDumpAnyValueCode( par.Value, level ); + printLevel (level); + fprintf (stderr,"aParameter.Value = %s;\n", var); + const char* type; + switch (par.Type) { + case EnhancedCustomShapeParameterType::NORMAL: + type = "EnhancedCustomShapeParameterType::NORMAL"; + break; + case EnhancedCustomShapeParameterType::EQUATION: + type = "EnhancedCustomShapeParameterType::EQUATION"; + break; + case EnhancedCustomShapeParameterType::ADJUSTMENT: + type = "EnhancedCustomShapeParameterType::ADJUSTMENT"; + break; + case EnhancedCustomShapeParameterType::LEFT: + type = "EnhancedCustomShapeParameterType::LEFT"; + break; + case EnhancedCustomShapeParameterType::TOP: + type = "EnhancedCustomShapeParameterType::TOP"; + break; + case EnhancedCustomShapeParameterType::RIGHT: + type = "EnhancedCustomShapeParameterType::RIGHT"; + break; + case EnhancedCustomShapeParameterType::BOTTOM: + type = "EnhancedCustomShapeParameterType::BOTTOM"; + break; + case EnhancedCustomShapeParameterType::XSTRETCH: + type = "EnhancedCustomShapeParameterType::XSTRETCH"; + break; + case EnhancedCustomShapeParameterType::YSTRETCH: + type = "EnhancedCustomShapeParameterType::YSTRETCH"; + break; + case EnhancedCustomShapeParameterType::HASSTROKE: + type = "EnhancedCustomShapeParameterType::HASSTROKE"; + break; + case EnhancedCustomShapeParameterType::HASFILL: + type = "EnhancedCustomShapeParameterType::HASFILL"; + break; + case EnhancedCustomShapeParameterType::WIDTH: + type = "EnhancedCustomShapeParameterType::WIDTH"; + break; + case EnhancedCustomShapeParameterType::HEIGHT: + type = "EnhancedCustomShapeParameterType::HEIGHT"; + break; + case EnhancedCustomShapeParameterType::LOGWIDTH: + type = "EnhancedCustomShapeParameterType::LOGWIDTH"; + break; + case EnhancedCustomShapeParameterType::LOGHEIGHT: + type = "EnhancedCustomShapeParameterType::LOGHEIGHT"; + break; + default: + type = "unknown"; + break; + } + printLevel (level); + fprintf (stderr,"aParameter.Type = %s;\n", type); + return "aParameter"; + } else if( value >>= longValue ) { + printLevel (level); + fprintf (stderr,"Any aAny ((sal_Int32) %ld);\n", longValue); + return "aAny"; + } else if( value >>= intValue ) + fprintf (stderr,"%"SAL_PRIdINT32" (hex: %"SAL_PRIxUINT32")\n", intValue, intValue); + else if( value >>= uintValue ) + fprintf (stderr,"%"SAL_PRIdINT32" (hex: %"SAL_PRIxUINT32")\n", uintValue, uintValue); + else if( value >>= int16Value ) + fprintf (stderr,"%d (hex: %x)\n", int16Value, int16Value); + else if( value >>= uint16Value ) + fprintf (stderr,"%d (hex: %x)\n", uint16Value, uint16Value); + else if( value >>= floatValue ) + fprintf (stderr,"%f\n", floatValue); + else if( value >>= boolValue ) { + if (boolValue) + return "Any ((sal_Bool) sal_True)"; + else + return "Any ((sal_Bool) sal_False)"; + } else if( value >>= xNumRule ) { + fprintf (stderr, "XIndexReplace\n"); + for (int k=0; k<xNumRule->getCount(); k++) { + Sequence< PropertyValue > aBulletPropSeq; + fprintf (stderr, "level %d\n", k); + if (xNumRule->getByIndex (k) >>= aBulletPropSeq) { + for (int j=0; j<aBulletPropSeq.getLength(); j++) { + fprintf(stderr, "%46s = ", USS (aBulletPropSeq[j].Name)); + lclDumpAnyValue (aBulletPropSeq[j].Value); + } + } + } + } else if( value >>= aWritingMode ) + fprintf (stderr, "%d writing mode\n", aWritingMode); + else if( value >>= aTextVertAdj ) { + const char* s = "uknown"; + switch( aTextVertAdj ) { + case TextVerticalAdjust_TOP: + s = "top"; + break; + case TextVerticalAdjust_CENTER: + s = "center"; + break; + case TextVerticalAdjust_BOTTOM: + s = "bottom"; + break; + case TextVerticalAdjust_BLOCK: + s = "block"; + break; + case TextVerticalAdjust_MAKE_FIXED_SIZE: + s = "make_fixed_size"; + break; + } + fprintf (stderr, "%s\n", s); + } else if( value >>= aTextHorizAdj ) { + const char* s = "uknown"; + switch( aTextHorizAdj ) { + case TextHorizontalAdjust_LEFT: + s = "left"; + break; + case TextHorizontalAdjust_CENTER: + s = "center"; + break; + case TextHorizontalAdjust_RIGHT: + s = "right"; + break; + case TextHorizontalAdjust_BLOCK: + s = "block"; + break; + case TextHorizontalAdjust_MAKE_FIXED_SIZE: + s = "make_fixed_size"; + break; + } + fprintf (stderr, "%s\n", s); + } else if( value >>= spacing ) { + fprintf (stderr, "mode: %d value: %d\n", spacing.Mode, spacing.Height); + } else if( value >>= rect ) { + printLevel (level); + fprintf (stderr, "awt::Rectangle aRectangle;\n"); + printLevel (level); + fprintf (stderr, "aRectangle.X = %"SAL_PRIdINT32";\n", rect.X); + printLevel (level); + fprintf (stderr, "aRectangle.Y = %"SAL_PRIdINT32";\n", rect.Y); + printLevel (level); + fprintf (stderr, "aRectangle.Width = %"SAL_PRIdINT32";\n", rect.Width); + printLevel (level); + fprintf (stderr, "aRectangle.Height = %"SAL_PRIdINT32";\n", rect.Height); + return "aRectangle"; + } else if( value.isExtractableTo(::getCppuType((const sal_Int32*)0))) { + fprintf (stderr,"is extractable to int32\n"); + } + else + fprintf (stderr,"??? <unhandled type %s>\n", USS(value.getValueTypeName())); + + return ""; +} + +void PropertyMap::dumpCode( Reference< XPropertySet > rXPropSet ) +{ + Reference< XPropertySetInfo > info = rXPropSet->getPropertySetInfo (); + Sequence< Property > props = info->getProperties (); + const OUString sType = CREATE_OUSTRING( "Type" ); + + OSL_TRACE("dump props, len: %d", props.getLength ()); + + for (int i=0; i < props.getLength (); i++) { + + // ignore Type, it is set elsewhere + if (props[i].Name.equals (sType)) + continue; + + OString name = OUStringToOString( props [i].Name, RTL_TEXTENCODING_UTF8); + int level = 1; + + try { + const char* var = lclDumpAnyValueCode (rXPropSet->getPropertyValue (props [i].Name), level); + printLevel (level); + fprintf (stderr,"aPropertyMap [PROP_%s] <<= %s;\n\n", name.getStr(), var); + } catch (const Exception& e) { + fprintf (stderr,"unable to get '%s' value\n", USS(props [i].Name)); + } + } +} + +void PropertyMap::dumpCode() +{ + dumpCode( Reference< XPropertySet >( makePropertySet(), UNO_QUERY ) ); +} +#endif + // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/propertyset.cxx b/oox/source/helper/propertyset.cxx index c21b8959e2bc..71f0d4e0c76b 100644 --- a/oox/source/helper/propertyset.cxx +++ b/oox/source/helper/propertyset.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -87,7 +88,7 @@ void PropertySet::getProperties( Sequence< Any >& orValues, const Sequence< OUSt } catch( Exception& ) { - OSL_ENSURE( false, "PropertySet::getProperties - cannot get all property values - fallback to single mode" ); + OSL_FAIL( "PropertySet::getProperties - cannot get all property values - fallback to single mode" ); } if( mxPropSet.is() ) @@ -121,7 +122,7 @@ void PropertySet::setProperties( const Sequence< OUString >& rPropNames, const S } catch( Exception& ) { - OSL_ENSURE( false, "PropertySet::setProperties - cannot set all property values, fallback to single mode" ); + OSL_FAIL( "PropertySet::setProperties - cannot set all property values, fallback to single mode" ); } if( mxPropSet.is() ) @@ -156,7 +157,7 @@ bool PropertySet::implGetPropertyValue( Any& orValue, const OUString& rPropName } catch( Exception& ) { - OSL_ENSURE( false, OStringBuffer( "PropertySet::implGetPropertyValue - cannot get property \"" ). + OSL_FAIL( OStringBuffer( "PropertySet::implGetPropertyValue - cannot get property \"" ). append( OUStringToOString( rPropName, RTL_TEXTENCODING_ASCII_US ) ).append( '"' ).getStr() ); } return false; @@ -171,12 +172,21 @@ bool PropertySet::implSetPropertyValue( const OUString& rPropName, const Any& rV } catch( Exception& ) { - OSL_ENSURE( false, OStringBuffer( "PropertySet::implSetPropertyValue - cannot set property \"" ). + OSL_FAIL( OStringBuffer( "PropertySet::implSetPropertyValue - cannot set property \"" ). append( OUStringToOString( rPropName, RTL_TEXTENCODING_ASCII_US ) ).append( '"' ).getStr() ); } return false; } +#if OSL_DEBUG_LEVEL > 0 +void PropertySet::dump() +{ + PropertyMap::dump( Reference< XPropertySet >( getXPropertySet(), UNO_QUERY ) ); +} +#endif + // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/storagebase.cxx b/oox/source/helper/storagebase.cxx index eee2b5c5d9b2..2201320fad1a 100644 --- a/oox/source/helper/storagebase.cxx +++ b/oox/source/helper/storagebase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -271,3 +272,5 @@ StorageRef StorageBase::getSubStorage( const OUString& rElementName, bool bCreat // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/textinputstream.cxx b/oox/source/helper/textinputstream.cxx index 9087dea7b26f..e98ed861ed83 100755 --- a/oox/source/helper/textinputstream.cxx +++ b/oox/source/helper/textinputstream.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -235,3 +236,5 @@ void TextInputStream::init( const Reference< XComponentContext >& rxContext, con // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/helper/zipstorage.cxx b/oox/source/helper/zipstorage.cxx index c190f39d1e43..2428596d5420 100644 --- a/oox/source/helper/zipstorage.cxx +++ b/oox/source/helper/zipstorage.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -94,7 +95,7 @@ ZipStorage::ZipStorage( const Reference< XComponentContext >& rxContext, const R } catch( Exception& ) { - OSL_ENSURE( false, "ZipStorage::ZipStorage - cannot open output storage" ); + OSL_FAIL( "ZipStorage::ZipStorage - cannot open output storage" ); } } @@ -207,3 +208,5 @@ void ZipStorage::implCommit() const // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/axbinaryreader.cxx b/oox/source/ole/axbinaryreader.cxx index 58610e419f32..af3076477c56 100644 --- a/oox/source/ole/axbinaryreader.cxx +++ b/oox/source/ole/axbinaryreader.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -183,7 +184,7 @@ bool AxFontData::importGuidAndFont( BinaryInputStream& rInStrm ) OUString aGuid = OleHelper::importGuid( rInStrm ); if( aGuid.equalsAscii( AX_GUID_CFONT ) ) return importBinaryModel( rInStrm ); - if( aGuid.equalsAscii( OLE_GUID_STDFONT ) ) + if( aGuid.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(OLE_GUID_STDFONT) ) ) return importStdFont( rInStrm ); return false; } @@ -371,3 +372,5 @@ bool AxBinaryPropertyReader::startNextProperty() } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index 40dfdf1ca84e..9e971e602da6 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -446,7 +447,7 @@ void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamData case AX_PICPOS_BELOWCENTER: nImagePos = ImagePosition::BelowCenter; break; case AX_PICPOS_BELOWRIGHT: nImagePos = ImagePosition::BelowRight; break; case AX_PICPOS_CENTER: nImagePos = ImagePosition::Centered; break; - default: OSL_ENSURE( false, "ControlConverter::convertAxPicture - unknown picture position" ); + default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture position" ); } rPropMap.setProperty( PROP_ImagePosition, nImagePos ); } @@ -464,7 +465,7 @@ void ControlConverter::convertAxPicture( PropertyMap& rPropMap, const StreamData case AX_PICSIZE_CLIP: nScaleMode = ImageScaleMode::None; break; case AX_PICSIZE_STRETCH: nScaleMode = ImageScaleMode::Anisotropic; break; case AX_PICSIZE_ZOOM: nScaleMode = ImageScaleMode::Isotropic; break; - default: OSL_ENSURE( false, "ControlConverter::convertAxPicture - unknown picture size mode" ); + default: OSL_FAIL( "ControlConverter::convertAxPicture - unknown picture size mode" ); } rPropMap.setProperty( PROP_ScaleMode, nScaleMode ); } @@ -503,7 +504,7 @@ void ControlConverter::convertAxOrientation( PropertyMap& rPropMap, case AX_ORIENTATION_AUTO: bHorizontal = rSize.first > rSize.second; break; case AX_ORIENTATION_VERTICAL: bHorizontal = false; break; case AX_ORIENTATION_HORIZONTAL: bHorizontal = true; break; - default: OSL_ENSURE( false, "ControlConverter::convertAxOrientation - unknown orientation" ); + default: OSL_FAIL( "ControlConverter::convertAxOrientation - unknown orientation" ); } convertOrientation( rPropMap, bHorizontal ); } @@ -529,17 +530,19 @@ OUString ControlModelBase::getServiceName() const case API_CONTROL_FIXEDTEXT: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlFixedTextModel" ); case API_CONTROL_IMAGE: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlImageControlModel" ); case API_CONTROL_CHECKBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlCheckBoxModel" ); - case API_CONTROL_RADIOBUTTON: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlRadioButtonModel" ); + case API_CONTROL_RADIOBUTTON: return CREATE_OUSTRING( "com.sun.star.form.component.RadioButton" ); case API_CONTROL_EDIT: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlEditModel" ); case API_CONTROL_NUMERIC: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlNumericFieldModel" ); - case API_CONTROL_LISTBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlListBoxModel" ); - case API_CONTROL_COMBOBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlComboBoxModel" ); - case API_CONTROL_SPINBUTTON: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlSpinButtonModel" ); - case API_CONTROL_SCROLLBAR: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlScrollBarModel" ); + case API_CONTROL_LISTBOX: return CREATE_OUSTRING( "com.sun.star.form.component.ListBox" ); + case API_CONTROL_COMBOBOX: return CREATE_OUSTRING( "com.sun.star.form.component.ComboBox" ); + case API_CONTROL_SPINBUTTON: return CREATE_OUSTRING( "com.sun.star.form.component.SpinButton" ); + case API_CONTROL_SCROLLBAR: return CREATE_OUSTRING( "com.sun.star.form.component.ScrollBar" ); case API_CONTROL_PROGRESSBAR: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlProgressBarModel" ); - case API_CONTROL_GROUPBOX: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlGroupBoxModel" ); + case API_CONTROL_FRAME: return CREATE_OUSTRING( "com.sun.star.awt.UnoFrameModel" ); + case API_CONTROL_PAGE: return CREATE_OUSTRING( "com.sun.star.awt.UnoPageModel" ); + case API_CONTROL_MULTIPAGE: return CREATE_OUSTRING( "com.sun.star.awt.UnoMultiPageModel" ); case API_CONTROL_DIALOG: return CREATE_OUSTRING( "com.sun.star.awt.UnoControlDialogModel" ); - default: OSL_ENSURE( false, "ControlModelBase::getServiceName - no AWT model service supported" ); + default: OSL_FAIL( "ControlModelBase::getServiceName - no AWT model service supported" ); } else switch( eCtrlType ) { @@ -555,7 +558,7 @@ OUString ControlModelBase::getServiceName() const case API_CONTROL_SPINBUTTON: return CREATE_OUSTRING( "com.sun.star.form.component.SpinButton" ); case API_CONTROL_SCROLLBAR: return CREATE_OUSTRING( "com.sun.star.form.component.ScrollBar" ); case API_CONTROL_GROUPBOX: return CREATE_OUSTRING( "com.sun.star.form.component.GroupBox" ); - default: OSL_ENSURE( false, "ControlModelBase::getServiceName - no form component service supported" ); + default: OSL_FAIL( "ControlModelBase::getServiceName - no form component service supported" ); } return OUString(); } @@ -633,7 +636,7 @@ sal_uInt32 ComCtlModelBase::getDataPartId() const case COMCTL_VERSION_50: return mnDataPartId5; case COMCTL_VERSION_60: return mnDataPartId6; } - OSL_ENSURE( false, "ComCtlObjectBase::getDataPartId - unxpected version" ); + OSL_FAIL( "ComCtlObjectBase::getDataPartId - unxpected version" ); return SAL_MAX_UINT32; } @@ -835,7 +838,7 @@ void AxFontDataModel::convertProperties( PropertyMap& rPropMap, const ControlCon case AX_FONTDATA_LEFT: nAlign = TextAlign::LEFT; break; case AX_FONTDATA_RIGHT: nAlign = TextAlign::RIGHT; break; case AX_FONTDATA_CENTER: nAlign = TextAlign::CENTER; break; - default: OSL_ENSURE( false, "AxFontDataModel::convertProperties - unknown text alignment" ); + default: OSL_FAIL( "AxFontDataModel::convertProperties - unknown text alignment" ); } // form controls expect short value rPropMap.setProperty( PROP_Align, static_cast< sal_Int16 >( nAlign ) ); @@ -1549,7 +1552,8 @@ ApiControlType AxTabStripModel::getControlType() const void AxTabStripModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const { rPropMap.setProperty( PROP_Decoration, mnTabStyle != AX_TABSTRIP_NONE ); - rPropMap.setProperty( PROP_MultiPageValue, mnSelectedTab ); + // adjust for openoffice ( 1 based ) + rPropMap.setProperty( PROP_MultiPageValue, mnSelectedTab + 1); rConv.convertColor( rPropMap, PROP_BackgroundColor, mnBackColor ); AxFontDataModel::convertProperties( rPropMap, rConv ); } @@ -1673,7 +1677,7 @@ AxFrameModel::AxFrameModel() : ApiControlType AxFrameModel::getControlType() const { - return API_CONTROL_GROUPBOX; + return mbAwtModel ? API_CONTROL_FRAME : API_CONTROL_GROUPBOX; } void AxFrameModel::convertProperties( PropertyMap& rPropMap, const ControlConverter& rConv ) const @@ -1863,3 +1867,5 @@ Reference< XIndexContainer > EmbeddedForm::createXForm() } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/axcontrolfragment.cxx b/oox/source/ole/axcontrolfragment.cxx index a81ae99f0c11..7b985c5badec 100644 --- a/oox/source/ole/axcontrolfragment.cxx +++ b/oox/source/ole/axcontrolfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -158,3 +159,5 @@ ContextHandlerRef AxControlFragment::onCreateContext( sal_Int32 nElement, const } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index 8dfe02283cb0..95678f147cd4 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -68,8 +69,8 @@ inline sal_Int32 lclDecodeBgrColor( sal_uInt32 nOleColor ) // ---------------------------------------------------------------------------- -const sal_Char* const OLE_GUID_URLMONIKER = "{79EAC9E0-BAF9-11CE-8C82-00AA004BA90B}"; -const sal_Char* const OLE_GUID_FILEMONIKER = "{00000303-0000-0000-C000-000000000046}"; +const sal_Char OLE_GUID_URLMONIKER[] = "{79EAC9E0-BAF9-11CE-8C82-00AA004BA90B}"; +const sal_Char OLE_GUID_FILEMONIKER[] = "{00000303-0000-0000-C000-000000000046}"; const sal_uInt32 OLE_STDPIC_ID = 0x0000746C; @@ -166,7 +167,7 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, case OLE_COLORTYPE_SYSCOLOR: return rGraphicHelper.getSystemColor( STATIC_ARRAY_SELECT( spnSystemColors, nOleColor & OLE_SYSTEMCOLOR_MASK, XML_TOKEN_INVALID ), API_RGB_WHITE ); } - OSL_ENSURE( false, "OleHelper::decodeOleColor - unknown color type" ); + OSL_FAIL( "OleHelper::decodeOleColor - unknown color type" ); return API_RGB_BLACK; } @@ -198,7 +199,7 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, { if( bWithGuid ) { - bool bIsStdFont = importGuid( rInStrm ).equalsAscii( OLE_GUID_STDFONT ); + bool bIsStdFont = importGuid( rInStrm ).equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(OLE_GUID_STDFONT)); OSL_ENSURE( bIsStdFont, "OleHelper::importStdFont - unexpected header GUID, expected StdFont" ); if( !bIsStdFont ) return false; @@ -216,7 +217,7 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, { if( bWithGuid ) { - bool bIsStdPic = importGuid( rInStrm ).equalsAscii( OLE_GUID_STDPIC ); + bool bIsStdPic = importGuid( rInStrm ).equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(OLE_GUID_STDPIC)); OSL_ENSURE( bIsStdPic, "OleHelper::importStdPic - unexpected header GUID, expected StdPic" ); if( !bIsStdPic ) return false; @@ -233,7 +234,7 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, { if( bWithGuid ) { - bool bIsStdHlink = importGuid( rInStrm ).equalsAscii( OLE_GUID_STDHLINK ); + bool bIsStdHlink = importGuid( rInStrm ).equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(OLE_GUID_STDHLINK)); OSL_ENSURE( bIsStdHlink, "OleHelper::importStdHlink - unexpected header GUID, expected StdHlink" ); if( !bIsStdHlink ) return false; @@ -263,7 +264,7 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, else // hyperlink moniker { OUString aGuid = importGuid( rInStrm ); - if( aGuid.equalsAscii( OLE_GUID_FILEMONIKER ) ) + if( aGuid.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(OLE_GUID_FILEMONIKER)) ) { // file name, maybe relative and with directory up-count sal_Int16 nUpLevels; @@ -284,7 +285,7 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, for( sal_Int16 nLevel = 0; nLevel < nUpLevels; ++nLevel ) orHlinkInfo.maTarget = CREATE_OUSTRING( "../" ) + orHlinkInfo.maTarget; } - else if( aGuid.equalsAscii( OLE_GUID_URLMONIKER ) ) + else if( aGuid.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(OLE_GUID_URLMONIKER)) ) { // URL, maybe relative and with leading '../' sal_Int32 nBytes = rInStrm.readInt32(); @@ -294,7 +295,7 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, } else { - OSL_ENSURE( false, "OleHelper::importStdHlink - unsupported hyperlink moniker" ); + OSL_FAIL( "OleHelper::importStdHlink - unsupported hyperlink moniker" ); return false; } } @@ -311,3 +312,5 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/oleobjecthelper.cxx b/oox/source/ole/oleobjecthelper.cxx index 5a38d9316a36..7a5c7650e6a8 100644 --- a/oox/source/ole/oleobjecthelper.cxx +++ b/oox/source/ole/oleobjecthelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -138,3 +139,5 @@ bool OleObjectHelper::importOleObject( PropertyMap& rPropMap, const OleObjectInf } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/olestorage.cxx b/oox/source/ole/olestorage.cxx index 2db4aed76834..6255def97b02 100755 --- a/oox/source/ole/olestorage.cxx +++ b/oox/source/ole/olestorage.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -247,7 +248,7 @@ void OleStorage::initStorage( const Reference< XInputStream >& rxInStream ) } catch( Exception& ) { - OSL_ENSURE( false, "OleStorage::initStorage - cannot create temporary copy of input stream" ); + OSL_FAIL( "OleStorage::initStorage - cannot create temporary copy of input stream" ); } // create base storage object @@ -302,7 +303,7 @@ bool OleStorage::implIsStorage() const Reference< XStorage > OleStorage::implGetXStorage() const { - OSL_ENSURE( false, "OleStorage::getXStorage - not implemented" ); + OSL_FAIL( "OleStorage::getXStorage - not implemented" ); return Reference< XStorage >(); } @@ -408,3 +409,5 @@ void OleStorage::implCommit() const } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx index 45a2b9c70ee3..fc750ca53821 100644 --- a/oox/source/ole/vbacontrol.cxx +++ b/oox/source/ole/vbacontrol.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -224,12 +225,6 @@ bool VbaSiteModel::importBinaryModel( BinaryInputStream& rInStrm ) return aReader.finalizeImport(); } -void VbaSiteModel::moveRelative( const AxPairData& rDistance ) -{ - maPos.first += rDistance.first; - maPos.second += rDistance.second; -} - bool VbaSiteModel::isVisible() const { return getFlag( mnFlags, VBA_SITE_VISIBLE ); @@ -277,13 +272,13 @@ ControlModelRef VbaSiteModel::createControlModel( const AxClassTable& rClassTabl case VBA_SITE_TEXTBOX: xCtrlModel.reset( new AxTextBoxModel ); break; case VBA_SITE_LISTBOX: xCtrlModel.reset( new AxListBoxModel ); break; case VBA_SITE_COMBOBOX: xCtrlModel.reset( new AxComboBoxModel ); break; - case VBA_SITE_SPINBUTTON: /*xCtrlModel.reset( new AxSpinButtonModel );*/ break; // not supported (?) + case VBA_SITE_SPINBUTTON: xCtrlModel.reset( new AxSpinButtonModel ); break; case VBA_SITE_SCROLLBAR: xCtrlModel.reset( new AxScrollBarModel ); break; - case VBA_SITE_TABSTRIP: break; // not supported + case VBA_SITE_TABSTRIP: xCtrlModel.reset( new AxTabStripModel ); break; case VBA_SITE_FRAME: xCtrlModel.reset( new AxFrameModel ); break; - case VBA_SITE_MULTIPAGE: break; // not supported - case VBA_SITE_FORM: break; // not supported - default: OSL_ENSURE( false, "VbaSiteModel::createControlModel - unknown type index" ); + case VBA_SITE_MULTIPAGE: xCtrlModel.reset( new AxMultiPageModel ); break; + case VBA_SITE_FORM: xCtrlModel.reset( new AxFormPageModel ); break; + default: OSL_FAIL( "VbaSiteModel::createControlModel - unknown type index" ); } } else @@ -292,11 +287,11 @@ ControlModelRef VbaSiteModel::createControlModel( const AxClassTable& rClassTabl OSL_ENSURE( pGuid, "VbaSiteModel::createControlModel - invalid class table index" ); if( pGuid ) { - if( pGuid->equalsAscii( COMCTL_GUID_SCROLLBAR_60 ) ) + if( pGuid->equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(COMCTL_GUID_SCROLLBAR_60)) ) xCtrlModel.reset( new ComCtlScrollBarModel( 6 ) ); - else if( pGuid->equalsAscii( COMCTL_GUID_PROGRESSBAR_50 ) ) + else if( pGuid->equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(COMCTL_GUID_PROGRESSBAR_50)) ) xCtrlModel.reset( new ComCtlProgressBarModel( 5 ) ); - else if( pGuid->equalsAscii( COMCTL_GUID_PROGRESSBAR_60 ) ) + else if( pGuid->equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(COMCTL_GUID_PROGRESSBAR_60)) ) xCtrlModel.reset( new ComCtlProgressBarModel( 6 ) ); } } @@ -447,11 +442,9 @@ void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rCla maControls.forEachMem( &VbaFormControl::importModelOrStorage, ::boost::ref( aOStrm ), ::boost::ref( rStrg ), ::boost::cref( maClassTable ) ); - /* Reorder the controls (sorts all option buttons of an option - group together), and move all children of all embedded frames - (group boxes) to this control (UNO group boxes cannot contain - other controls). */ - finalizeEmbeddedControls(); + /** Final processing on the control and all embedded controls, + depending on the type of this control. */ + finalizeEmbeddedControls( rStrg ); } } } @@ -473,6 +466,9 @@ bool VbaFormControl::convertProperties( const Reference< XControlModel >& rxCtrl PropertySet aPropSet( rxCtrlModel ); aPropSet.setProperties( aPropMap ); + // bind to control source and row source range + mxSiteModel->bindToSources( rxCtrlModel, rConv ); + // create and convert all embedded controls if( !maControls.empty() ) try { @@ -484,7 +480,7 @@ bool VbaFormControl::convertProperties( const Reference< XControlModel >& rxCtrl } catch( Exception& ) { - OSL_ENSURE( false, "VbaFormControl::convertProperties - cannot get control container interface" ); + OSL_FAIL( "VbaFormControl::convertProperties - cannot get control container interface" ); } return true; @@ -555,138 +551,182 @@ bool VbaFormControl::importEmbeddedSiteModels( BinaryInputStream& rInStrm ) return bValid; } -void VbaFormControl::finalizeEmbeddedControls() -{ - /* This function performs two tasks: - - 1) Reorder the controls appropriately (sort all option buttons of an - option group together to make grouping work). - 2) Move all children of all embedded frames (group boxes) to this - control (UNO group boxes cannot contain other controls). - */ - - // first, sort all controls by original tab index - ::std::sort( maControls.begin(), maControls.end(), &compareByTabIndex ); - - /* Collect the programmatical names of all embedded controls (needed to be - able to set unused names to new dummy controls created below). Also - collect the names of all children of embedded frames (group boxes). - Luckily, names of controls must be unique in the entire form, not just - in the current container. */ - VbaControlNamesSet aControlNames; - VbaControlNameInserter aInserter( aControlNames ); - maControls.forEach( aInserter ); - for( VbaFormControlVector::iterator aIt = maControls.begin(), aEnd = maControls.end(); aIt != aEnd; ++aIt ) - if( (*aIt)->mxCtrlModel.get() && ((*aIt)->mxCtrlModel->getControlType() == API_CONTROL_GROUPBOX) ) - (*aIt)->maControls.forEach( aInserter ); - - /* Reprocess the sorted list and collect all option button controls that - are part of the same option group (determined by group name). All - controls will be stored in a vector of vectors, that collects every - option button group in one vector element, and other controls between - these option groups (or leading or trailing controls) in other vector - elements. If an option button group follows another group, a dummy - separator control has to be inserted. */ - typedef RefVector< VbaFormControlVector > VbaFormControlVectorVector; - VbaFormControlVectorVector aControlGroups; - - typedef RefMap< OUString, VbaFormControlVector > VbaFormControlVectorMap; - VbaFormControlVectorMap aOptionGroups; - - typedef VbaFormControlVectorMap::mapped_type VbaFormControlVectorRef; - bool bLastWasOptionButton = false; - for( VbaFormControlVector::iterator aIt = maControls.begin(), aEnd = maControls.end(); aIt != aEnd; ++aIt ) +void VbaFormControl::finalizeEmbeddedControls( StorageBase& rStrg ) +{ + /* Store all embedded controls in a temporary vector, so "exit on error" + will leave this control empty. */ + VbaFormControlVector aControls; + aControls.swap( maControls ); + + /* If this is a multipage control, it stores additional data in the 'x' + stream of its storage. It contains the control identifiers of the form + page controls that contain the embedded controls of each page. + Additionally, the order of these pages is stored there (they are not + nessecarily in the order they are persisted in). */ + if( AxMultiPageModel* pMultiPageModel = dynamic_cast< AxMultiPageModel* >( mxCtrlModel.get() ) ) { - VbaFormControlRef xControl = *aIt; - const ControlModelBase* pCtrlModel = xControl->mxCtrlModel.get(); + // read additional attributes from the 'x' stream + BinaryXInputStream aXStrm( rStrg.openInputStream( CREATE_OUSTRING( "x" ) ), true ); + OSL_ENSURE( !aXStrm.isEof(), "VbaFormControl::finalizeEmbeddedControls - missing 'x' stream" ); + if( aXStrm.isEof() ) return; - if( const AxOptionButtonModel* pOptButtonModel = dynamic_cast< const AxOptionButtonModel* >( pCtrlModel ) ) + // skip the page property structures related to all controls + for( size_t nSiteIdx = 0, nSiteCount = aControls.size(); nSiteIdx < nSiteCount; ++nSiteIdx ) { - // check if a new option group needs to be created - const OUString& rGroupName = pOptButtonModel->getGroupName(); - VbaFormControlVectorRef& rxOptionGroup = aOptionGroups[ rGroupName ]; - if( !rxOptionGroup ) - { - /* If last control was an option button too, we have two - option groups following each other, so a dummy separator - control is needed. */ - if( bLastWasOptionButton ) - { - VbaFormControlVectorRef xDummyGroup( new VbaFormControlVector ); - aControlGroups.push_back( xDummyGroup ); - OUString aName = aControlNames.generateDummyName(); - VbaFormControlRef xDummyControl( new VbaDummyFormControl( aName ) ); - xDummyGroup->push_back( xDummyControl ); - } - rxOptionGroup.reset( new VbaFormControlVector ); - aControlGroups.push_back( rxOptionGroup ); - } - /* Append the option button to the control group (which is now - referred by the vector aControlGroups and by the map - aOptionGroups). */ - rxOptionGroup->push_back( xControl ); - bLastWasOptionButton = true; + AxBinaryPropertyReader aReader( aXStrm ); + aReader.skipUndefinedProperty(); + aReader.skipIntProperty< sal_uInt32 >(); // transition effect + aReader.skipIntProperty< sal_uInt32 >(); // transition period + if( !aReader.finalizeImport() ) return; } - else - { - // open a new control group, if the last group is an option group - if( bLastWasOptionButton || aControlGroups.empty() ) - { - VbaFormControlVectorRef xControlGroup( new VbaFormControlVector ); - aControlGroups.push_back( xControlGroup ); - } - // append the control to the last control group - VbaFormControlVector& rLastGroup = *aControlGroups.back(); - rLastGroup.push_back( xControl ); - bLastWasOptionButton = false; - // if control is a group box, move all its children to this control - if( pCtrlModel && (pCtrlModel->getControlType() == API_CONTROL_GROUPBOX) ) + // read the multipage property structure containing a list of page IDs + sal_Int32 nPageCount = 0; + sal_Int32 nTabStripId = 0; + AxBinaryPropertyReader aReader( aXStrm ); + aReader.skipUndefinedProperty(); + aReader.readIntProperty< sal_Int32 >( nPageCount ); + aReader.readIntProperty< sal_Int32 >( nTabStripId ); + if( !aReader.finalizeImport() ) return; + // read the array containing all page identifiers in current order + typedef ::std::vector< sal_Int32 > AxPageIdVector; + AxPageIdVector aPageIds; + for( sal_Int32 nPage = 0; !aXStrm.isEof() && (nPage < nPageCount); ++nPage ) + aPageIds.push_back( aXStrm.readInt32() ); + if( aXStrm.isEof() ) return; + + // check the page count value + bool bValidPageCount = (0 < nPageCount) && (static_cast< size_t >( nPageCount + 1 ) == aControls.size()); + OSL_ENSURE( bValidPageCount, "VbaFormControl::finalizeEmbeddedControls - invalid number of pages" ); + if( !bValidPageCount ) return; + + /* Check that this multipage contains the expected controls: + - a tabstrip control, specified by nTabStripId, + - form page controls (containing the embedded controls of each page). */ + + // the controls may be in arbitrary order, first map them by ID + RefMap< sal_Int32, VbaFormControl > aControlsById; + for( VbaFormControlVector::iterator aIt = aControls.begin(), aEnd = aControls.end(); aIt != aEnd; ++aIt ) + { + VbaFormControlRef xControl = *aIt; + sal_Int32 nId = xControl->getControlId(); + OSL_ENSURE( (nId > 0) && !aControlsById.has( nId ), "VbaFormControl::finalizeEmbeddedControls - invalid control ID" ); + aControlsById[ nId ] = xControl; + } + // store tabstrip in the multipage, it will care about property conversion + AxTabStripModelRef xTabStripModel; + VbaFormControlRef xControl = aControlsById.get( nTabStripId ); + if( xControl.get() ) + xTabStripModel = ::boost::dynamic_pointer_cast< AxTabStripModel >( xControl->mxCtrlModel ); + OSL_ENSURE( xTabStripModel.get(), "VbaFormControl::finalizeEmbeddedControls - missing tabstrip control" ); + if( !xTabStripModel ) return; + pMultiPageModel->setTabStripModel( xTabStripModel ); + aControlsById.erase( nTabStripId ); + // store all pages in maControls in the correct order specified by aPageIds + sal_Int32 nTabIndex = 0; + for( AxPageIdVector::iterator aIt = aPageIds.begin(), aEnd = aPageIds.end(); aIt != aEnd; ++aIt, ++nTabIndex ) + { + VbaFormControlRef rControl = aControlsById.get( *aIt ); + AxFormPageModel* pFormPageModel = rControl.get() ? dynamic_cast< AxFormPageModel* >( rControl->mxCtrlModel.get() ) : 0; + OSL_ENSURE( pFormPageModel, "VbaFormControl::finalizeEmbeddedControls - missing formpage control" ); + // do not exit on error but try to collect as much pages as possible + if( pFormPageModel ) { - /* Move all embedded controls of the group box relative to the - position of the group box. */ - xControl->moveEmbeddedToAbsoluteParent(); - /* Insert all children of the group box into the last control - group (following the group box). */ - rLastGroup.insert( rLastGroup.end(), xControl->maControls.begin(), xControl->maControls.end() ); - xControl->maControls.clear(); - // check if last control of the group box is an option button - bLastWasOptionButton = dynamic_cast< const AxOptionButtonModel* >( rLastGroup.back()->mxCtrlModel.get() ) != 0; + // get the tab caption from tabstrip control and set it at the formpage + OUString aCaption = xTabStripModel->getCaption( nTabIndex ); + pFormPageModel->importProperty( XML_Caption, aCaption ); + // store the control in maControls + maControls.push_back( rControl ); + aControlsById.erase( *aIt ); } } } - - // flatten the vector of vectors of form controls to a single vector - maControls.clear(); - for( VbaFormControlVectorVector::iterator aIt = aControlGroups.begin(), aEnd = aControlGroups.end(); aIt != aEnd; ++aIt ) - maControls.insert( maControls.end(), (*aIt)->begin(), (*aIt)->end() ); -} - -void VbaFormControl::moveRelative( const AxPairData& rDistance ) -{ - if( mxSiteModel.get() ) - mxSiteModel->moveRelative( rDistance ); -} - -void VbaFormControl::moveEmbeddedToAbsoluteParent() -{ - if( mxSiteModel.get() && !maControls.empty() ) + else { - // distance to move is equal to position of this control in its parent - AxPairData aDistance = mxSiteModel->getPosition(); - - /* For group boxes: add half of the font height to Y position (VBA - positions relative to frame border line, not to 'top' of frame). */ - const AxFontDataModel* pFontModel = dynamic_cast< const AxFontDataModel* >( mxCtrlModel.get() ); - if( pFontModel && (pFontModel->getControlType() == API_CONTROL_GROUPBOX) ) + /* Reorder the controls appropriately (sort all option buttons of an + option group together to make grouping work), and erase all plain + tabstrip controls (currently not supported in UNO dialogs). */ + + // first, sort all controls by original tab index + ::std::sort( aControls.begin(), aControls.end(), &compareByTabIndex ); + + /* Collect the programmatical names of all embedded controls (needed to be + able to set unused names to new dummy controls created below). */ + VbaControlNamesSet aControlNames; + VbaControlNameInserter aInserter( aControlNames ); + aControls.forEach( aInserter ); + + /* Reprocess the sorted list and collect all option button controls that + are part of the same option group (determined by group name). All + controls will be stored in a vector of vectors, that collects every + option button group in one vector element, and other controls between + these option groups (or leading or trailing controls) in other vector + elements. If an option button group follows another group, a dummy + separator control has to be inserted. */ + typedef RefVector< VbaFormControlVector > VbaFormControlVectorVector; + VbaFormControlVectorVector aControlGroups; + + typedef RefMap< OUString, VbaFormControlVector > VbaFormControlVectorMap; + VbaFormControlVectorMap aOptionGroups; + + typedef VbaFormControlVectorMap::mapped_type VbaFormControlVectorRef; + bool bLastWasOptionButton = false; + for( VbaFormControlVector::iterator aIt = aControls.begin(), aEnd = aControls.end(); aIt != aEnd; ++aIt ) { - // convert points to 1/100 mm (1 pt = 1/72 inch = 2.54/72 cm = 2540/72 1/100 mm) - sal_Int32 nFontHeight = static_cast< sal_Int32 >( pFontModel->getFontHeight() * 2540 / 72 ); - aDistance.second += nFontHeight / 2; + VbaFormControlRef xControl = *aIt; + const ControlModelBase* pCtrlModel = xControl->mxCtrlModel.get(); + if ( !pCtrlModel ) // skip unsupported controls + continue; + if( const AxOptionButtonModel* pOptButtonModel = dynamic_cast< const AxOptionButtonModel* >( pCtrlModel ) ) + { + // check if a new option group needs to be created + const OUString& rGroupName = pOptButtonModel->getGroupName(); + VbaFormControlVectorRef& rxOptionGroup = aOptionGroups[ rGroupName ]; + if( !rxOptionGroup ) + { + /* If last control was an option button too, we have two + option groups following each other, so a dummy separator + control is needed. */ + if( bLastWasOptionButton ) + { + VbaFormControlVectorRef xDummyGroup( new VbaFormControlVector ); + aControlGroups.push_back( xDummyGroup ); + OUString aName = aControlNames.generateDummyName(); + VbaFormControlRef xDummyControl( new VbaDummyFormControl( aName ) ); + xDummyGroup->push_back( xDummyControl ); + } + rxOptionGroup.reset( new VbaFormControlVector ); + aControlGroups.push_back( rxOptionGroup ); + } + /* Append the option button to the control group (which is now + referred by the vector aControlGroups and by the map + aOptionGroups). */ + rxOptionGroup->push_back( xControl ); + bLastWasOptionButton = true; + } + else + { + // skip unsupported controls (tabstrips and page controls) + ApiControlType eCtrlType = pCtrlModel->getControlType(); + if( (eCtrlType != API_CONTROL_TABSTRIP) && (eCtrlType != API_CONTROL_PAGE) ) + { + // open a new control group, if the last group is an option group + if( bLastWasOptionButton || aControlGroups.empty() ) + { + VbaFormControlVectorRef xControlGroup( new VbaFormControlVector ); + aControlGroups.push_back( xControlGroup ); + } + // append the control to the last control group + VbaFormControlVector& rLastGroup = *aControlGroups.back(); + rLastGroup.push_back( xControl ); + bLastWasOptionButton = false; + } + } } - // move the embedded controls - maControls.forEachMem( &VbaFormControl::moveRelative, ::boost::cref( aDistance ) ); + // flatten the vector of vectors of form controls to a single vector + for( VbaFormControlVectorVector::iterator aIt = aControlGroups.begin(), aEnd = aControlGroups.end(); aIt != aEnd; ++aIt ) + maControls.insert( maControls.end(), (*aIt)->begin(), (*aIt)->end() ); } } @@ -764,8 +804,10 @@ VbaUserForm::VbaUserForm( const Reference< XComponentContext >& rxContext, OSL_ENSURE( mxDocModel.is(), "VbaUserForm::VbaUserForm - missing document model" ); } -void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib, - StorageBase& rVbaFormStrg, const OUString& rModuleName, rtl_TextEncoding eTextEnc ) +void VbaUserForm::importForm( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, + const Reference< XNameContainer >& rxDialogLib, + StorageBase& rVbaFormStrg, const OUString& rModuleName, rtl_TextEncoding eTextEnc ) { OSL_ENSURE( rxDialogLib.is(), "VbaUserForm::importForm - missing dialog library" ); if( !mxContext.is() || !mxDocModel.is() || !rxDialogLib.is() ) @@ -834,7 +876,7 @@ void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib, if( convertProperties( xDialogModel, maConverter, 0 ) ) { // export the dialog to XML and insert it into the dialog library - Reference< XInputStreamProvider > xDialogSource( ::xmlscript::exportDialogModel( xDialogNC, mxContext ), UNO_SET_THROW ); + Reference< XInputStreamProvider > xDialogSource( ::xmlscript::exportDialogModel( xDialogNC, mxContext, rxDocModel ), UNO_SET_THROW ); OSL_ENSURE( !rxDialogLib->hasByName( aFormName ), "VbaUserForm::importForm - multiple dialogs with equal name" ); ContainerHelper::insertByName( rxDialogLib, aFormName, Any( xDialogSource ) ); } @@ -848,3 +890,5 @@ void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib, } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/vbahelper.cxx b/oox/source/ole/vbahelper.cxx index 82d38d83610c..47bbacb40bae 100644 --- a/oox/source/ole/vbahelper.cxx +++ b/oox/source/ole/vbahelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -86,3 +87,5 @@ using ::rtl::OUStringBuffer; } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/vbainputstream.cxx b/oox/source/ole/vbainputstream.cxx index 7e2c88dc480f..9926081f60b4 100644 --- a/oox/source/ole/vbainputstream.cxx +++ b/oox/source/ole/vbainputstream.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -206,3 +207,4 @@ bool VbaInputStream::updateChunk() } // namespace ole } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/vbamodule.cxx b/oox/source/ole/vbamodule.cxx index 628c2abb8441..45a21df0e6f8 100644 --- a/oox/source/ole/vbamodule.cxx +++ b/oox/source/ole/vbamodule.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,11 +27,13 @@ ************************************************************************/ #include "oox/ole/vbamodule.hxx" - +#include <boost/unordered_map.hpp> #include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/script/ModuleInfo.hpp> #include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/vba/XVBAModuleInfo.hpp> +#include <cppuhelper/implbase1.hxx> #include "oox/helper/binaryinputstream.hxx" #include "oox/helper/storagebase.hxx" #include "oox/helper/textinputstream.hxx" @@ -51,8 +54,74 @@ using namespace ::com::sun::star::uno; using ::rtl::OUString; using ::rtl::OUStringBuffer; - // ============================================================================ +typedef ::cppu::WeakImplHelper1< XIndexContainer > OleIdToNameContainer_BASE; +typedef boost::unordered_map< sal_Int32, rtl::OUString > ObjIdToName; + +class OleIdToNameContainer : public OleIdToNameContainer_BASE +{ + ObjIdToName ObjIdToNameHash; + ::osl::Mutex m_aMutex; + bool hasByIndex( ::sal_Int32 Index ) + { + ::osl::MutexGuard aGuard( m_aMutex ); + return ( ObjIdToNameHash.find( Index ) != ObjIdToNameHash.end() ); + } +public: + OleIdToNameContainer() {} + // XIndexContainer Methods + virtual void SAL_CALL insertByIndex( ::sal_Int32 Index, const Any& Element ) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + rtl::OUString sOleName; + if ( !( Element >>= sOleName ) ) + throw IllegalArgumentException(); + ObjIdToNameHash[ Index ] = sOleName; + } + virtual void SAL_CALL removeByIndex( ::sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !hasByIndex( Index ) ) + throw IndexOutOfBoundsException(); + ObjIdToNameHash.erase( ObjIdToNameHash.find( Index ) ); + } + // XIndexReplace Methods + virtual void SAL_CALL replaceByIndex( ::sal_Int32 Index, const Any& Element ) throw (IllegalArgumentException, IndexOutOfBoundsException, WrappedTargetException, RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !hasByIndex( Index ) ) + throw IndexOutOfBoundsException(); + rtl::OUString sOleName; + if ( !( Element >>= sOleName ) ) + throw IllegalArgumentException(); + ObjIdToNameHash[ Index ] = sOleName; + } + // XIndexAccess Methods + virtual ::sal_Int32 SAL_CALL getCount( ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + return ObjIdToNameHash.size(); + } + virtual Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !hasByIndex( Index ) ) + throw IndexOutOfBoundsException(); + return makeAny( ObjIdToNameHash[ Index ] ); + } + // XElementAccess Methods + virtual Type SAL_CALL getElementType( ) throw (RuntimeException) + { + return ::getCppuType( static_cast< const ::rtl::OUString* >( 0 ) ); + } + virtual ::sal_Bool SAL_CALL hasElements( ) throw (RuntimeException) + { + ::osl::MutexGuard aGuard( m_aMutex ); + return ( getCount() > 0 ); + } +}; + + // ============================================================================ VbaModule::VbaModule( const Reference< XComponentContext >& rxContext, const Reference< XModel >& rxDocModel, const OUString& rName, rtl_TextEncoding eTextEnc, bool bExecutable ) : @@ -80,7 +149,7 @@ void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) { #define OOX_ENSURE_RECORDSIZE( cond ) OSL_ENSURE( cond, "VbaModule::importDirRecords - invalid record size" ) case VBA_ID_MODULENAME: - OSL_ENSURE( false, "VbaModule::importDirRecords - unexpected MODULENAME record" ); + OSL_FAIL( "VbaModule::importDirRecords - unexpected MODULENAME record" ); maName = aRecStrm.readCharArrayUC( nRecSize, meTextEnc ); break; case VBA_ID_MODULENAMEUNICODE: @@ -124,7 +193,7 @@ void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) mbPrivate = true; break; default: - OSL_ENSURE( false, "VbaModule::importDirRecords - unknown module record" ); + OSL_FAIL( "VbaModule::importDirRecords - unknown module record" ); #undef OOX_ENSURE_RECORDSIZE } } @@ -135,9 +204,9 @@ void VbaModule::importDirRecords( BinaryInputStream& rDirStrm ) } void VbaModule::createAndImportModule( StorageBase& rVbaStrg, const Reference< XNameContainer >& rxBasicLib, - const Reference< XNameAccess >& rxDocObjectNA ) const + const Reference< XNameAccess >& rxDocObjectNA, const Reference< XNameContainer >& rxOleNameOverrides ) const { - OUString aVBASourceCode = readSourceCode( rVbaStrg ); + OUString aVBASourceCode = readSourceCode( rVbaStrg, rxOleNameOverrides ); createModule( aVBASourceCode, rxBasicLib, rxDocObjectNA ); } @@ -146,9 +215,7 @@ void VbaModule::createEmptyModule( const Reference< XNameContainer >& rxBasicLib createModule( OUString(), rxBasicLib, rxDocObjectNA ); } -// private -------------------------------------------------------------------- - -OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const +OUString VbaModule::readSourceCode( StorageBase& rVbaStrg, const Reference< XNameContainer >& rxOleNameOverrides ) const { OUStringBuffer aSourceCode; if( (maStreamName.getLength() > 0) && (mnOffset != SAL_MAX_UINT32) ) @@ -167,7 +234,12 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const while( !aVbaTextStrm.isEof() ) { OUString aCodeLine = aVbaTextStrm.readLine(); - if( !aCodeLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "Attribute " ) ) ) + if( aCodeLine.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "Attribute " ) ) ) + { + // attribute + extractOleOverrideFromAttr( aCodeLine, rxOleNameOverrides ); + } + else { // normal source code line if( !mbExecutable ) @@ -180,6 +252,31 @@ OUString VbaModule::readSourceCode( StorageBase& rVbaStrg ) const return aSourceCode.makeStringAndClear(); } +void VbaModule::extractOleOverrideFromAttr( const OUString& rAttribute, const Reference< XNameContainer >& rxOleNameOverrides ) const +{ + // format of the attribute we are interested in is + // Attribute VB_Control = "ControlName", intString, MSForms, ControlTypeAsString + // e.g. + // Attribute VB_Control = "CommandButton1, 201, 19, MSForms, CommandButton" + OUString sControlAttribute = CREATE_OUSTRING( "Attribute VB_Control = \"" ); + if ( rxOleNameOverrides.is() && rAttribute.indexOf( sControlAttribute ) != -1 ) + { + OUString sRest = rAttribute.copy( sControlAttribute.getLength() ); + sal_Int32 nPos = sRest.indexOf( ',' ); + OUString sCntrlName = sRest.copy( 0, nPos ); + + sal_Int32 nCntrlId = sRest.copy( nPos + 1 ).copy( 0, sRest.indexOf( ',', nPos + 1) ).toInt32(); + OSL_TRACE("In module %s, assiging %d controlname %s", + rtl::OUStringToOString( maName, RTL_TEXTENCODING_UTF8 ).getStr(), nCntrlId, + rtl::OUStringToOString( sCntrlName, RTL_TEXTENCODING_UTF8 ).getStr() ); + if ( !rxOleNameOverrides->hasByName( maName ) ) + rxOleNameOverrides->insertByName( maName, Any( Reference< XIndexContainer> ( new OleIdToNameContainer ) ) ); + Reference< XIndexContainer > xIdToOleName; + if ( rxOleNameOverrides->getByName( maName ) >>= xIdToOleName ) + xIdToOleName->insertByIndex( nCntrlId, makeAny( sCntrlName ) ); + } +} + void VbaModule::createModule( const OUString& rVBASourceCode, const Reference< XNameContainer >& rxBasicLib, const Reference< XNameAccess >& rxDocObjectNA ) const { @@ -256,7 +353,7 @@ void VbaModule::createModule( const OUString& rVBASourceCode, } catch( Exception& ) { - OSL_ENSURE( false, "VbaModule::createModule - cannot insert module into library" ); + OSL_FAIL( "VbaModule::createModule - cannot insert module into library" ); } } @@ -264,3 +361,5 @@ void VbaModule::createModule( const OUString& rVBASourceCode, } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx index 57979f6c72d4..cf9af559e9b3 100644 --- a/oox/source/ole/vbaproject.cxx +++ b/oox/source/ole/vbaproject.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -161,8 +162,6 @@ VbaProject::VbaProject( const Reference< XComponentContext >& rxContext, { OSL_ENSURE( mxContext.is(), "VbaProject::VbaProject - missing component context" ); OSL_ENSURE( mxDocModel.is(), "VbaProject::VbaProject - missing document model" ); - mxBasicLib = openLibrary( PROP_BasicLibraries, false ); - mxDialogLib = openLibrary( PROP_DialogLibraries, false ); } VbaProject::~VbaProject() @@ -239,9 +238,9 @@ Reference< XNameContainer > VbaProject::openLibrary( sal_Int32 nPropId, bool bCr try { Reference< XLibraryContainer > xLibContainer( getLibraryContainer( nPropId ), UNO_SET_THROW ); - if( bCreateMissing && !xLibContainer->hasByName( CREATE_OUSTRING( "Standard" ) /*maPrjName*/ ) ) - xLibContainer->createLibrary( CREATE_OUSTRING( "Standard" ) /*maPrjName*/ ); - xLibrary.set( xLibContainer->getByName( CREATE_OUSTRING( "Standard" ) /*maPrjName*/ ), UNO_QUERY_THROW ); + if( bCreateMissing && !xLibContainer->hasByName( maPrjName ) ) + xLibContainer->createLibrary( maPrjName ); + xLibrary.set( xLibContainer->getByName( maPrjName ), UNO_QUERY_THROW ); } catch( Exception& ) { @@ -432,7 +431,10 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap document. */ try { - Reference< XVBACompatibility >( getLibraryContainer( PROP_BasicLibraries ), UNO_QUERY_THROW )->setVBACompatibilityMode( sal_True ); + Reference< XVBACompatibility > xVBACompat( getLibraryContainer( PROP_BasicLibraries ), UNO_QUERY_THROW ); + xVBACompat->setVBACompatibilityMode( sal_True ); + xVBACompat->setProjectName( maPrjName ); + } catch( Exception& ) { @@ -454,7 +456,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap // call Basic source code import for each module, boost::[c]ref enforces pass-by-ref aModules.forEachMem( &VbaModule::createAndImportModule, ::boost::ref( *xVbaStrg ), ::boost::cref( xBasicLib ), - ::boost::cref( xDocObjectNA ) ); + ::boost::cref( xDocObjectNA ), ::boost::cref( mxOleOverridesSink ) ); // create empty dummy modules aDummyModules.forEachMem( &VbaModule::createEmptyModule, @@ -490,7 +492,7 @@ void VbaProject::importVba( StorageBase& rVbaPrjStrg, const GraphicHelper& rGrap // create and import the form Reference< XNameContainer > xDialogLib( createDialogLibrary(), UNO_SET_THROW ); VbaUserForm aForm( mxContext, mxDocModel, rGraphicHelper, bDefaultColorBgr ); - aForm.importForm( xDialogLib, *xSubStrg, aModuleName, eTextEnc ); + aForm.importForm( mxDocModel, xDialogLib, *xSubStrg, aModuleName, eTextEnc ); } catch( Exception& ) { @@ -545,3 +547,5 @@ void VbaProject::copyStorage( StorageBase& rVbaPrjStrg ) } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ole/vbaprojectfilter.cxx b/oox/source/ole/vbaprojectfilter.cxx index ee5b3bf7a715..e1525984149f 100755..100644 --- a/oox/source/ole/vbaprojectfilter.cxx +++ b/oox/source/ole/vbaprojectfilter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,6 +35,7 @@ namespace ole { // ============================================================================ +using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using ::rtl::OUString; @@ -104,3 +106,5 @@ OUString WordVbaProjectFilter::implGetImplementationName() const } // namespace ole } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/animationspersist.cxx b/oox/source/ppt/animationspersist.cxx index fdee865251af..03557e5fefab 100644 --- a/oox/source/ppt/animationspersist.cxx +++ b/oox/source/ppt/animationspersist.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -186,7 +187,7 @@ namespace oox { namespace ppt { { Any aAny; for( AnimationConditionList::const_iterator iter = l.begin(); - iter != l.end(); iter++) + iter != l.end(); ++iter) { aAny = addToSequence( aAny, iter->convert(pSlide) ); } @@ -196,3 +197,4 @@ namespace oox { namespace ppt { } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/animationtypes.cxx b/oox/source/ppt/animationtypes.cxx index 6346a8058c5d..764468785016 100644 --- a/oox/source/ppt/animationtypes.cxx +++ b/oox/source/ppt/animationtypes.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -70,3 +71,5 @@ Any GetTimeAnimateValueTime( const ::rtl::OUString & val ) } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/animationtypes.hxx b/oox/source/ppt/animationtypes.hxx index a2c57b53267f..6159903dcb57 100644 --- a/oox/source/ppt/animationtypes.hxx +++ b/oox/source/ppt/animationtypes.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -45,3 +46,5 @@ namespace oox { namespace ppt { } } #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/animvariantcontext.cxx b/oox/source/ppt/animvariantcontext.cxx index 449c4ef73d11..7d0c9a6c153e 100644 --- a/oox/source/ppt/animvariantcontext.cxx +++ b/oox/source/ppt/animvariantcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -120,3 +121,5 @@ namespace oox { namespace ppt { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/animvariantcontext.hxx b/oox/source/ppt/animvariantcontext.hxx index 48fff797744f..7508cbef40b9 100644 --- a/oox/source/ppt/animvariantcontext.hxx +++ b/oox/source/ppt/animvariantcontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -58,3 +59,5 @@ namespace oox { namespace ppt { #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/backgroundproperties.cxx b/oox/source/ppt/backgroundproperties.cxx index 65664bdd3691..e3a3714417ff 100644 --- a/oox/source/ppt/backgroundproperties.cxx +++ b/oox/source/ppt/backgroundproperties.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -61,3 +62,5 @@ Reference< XFastContextHandler > BackgroundPropertiesContext::createFastChildCon } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/buildlistcontext.cxx b/oox/source/ppt/buildlistcontext.cxx index 3352e202e057..11c07c484a91 100644 --- a/oox/source/ppt/buildlistcontext.cxx +++ b/oox/source/ppt/buildlistcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -110,3 +111,5 @@ namespace oox { namespace ppt { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/buildlistcontext.hxx b/oox/source/ppt/buildlistcontext.hxx index 8b8d5c52b068..1c4e3949fa7b 100644 --- a/oox/source/ppt/buildlistcontext.hxx +++ b/oox/source/ppt/buildlistcontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -62,3 +63,5 @@ namespace oox { namespace ppt { } } #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/commonbehaviorcontext.cxx b/oox/source/ppt/commonbehaviorcontext.cxx index a4e3951228ae..72c59f730053 100644 --- a/oox/source/ppt/commonbehaviorcontext.cxx +++ b/oox/source/ppt/commonbehaviorcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -79,7 +80,7 @@ namespace oox { namespace ppt { { OUStringBuffer sAttributes; std::list< Attribute >::const_iterator iter; - for(iter = maAttributes.begin(); iter != maAttributes.end(); iter++) + for(iter = maAttributes.begin(); iter != maAttributes.end(); ++iter) { if( sAttributes.getLength() ) { @@ -176,3 +177,5 @@ namespace oox { namespace ppt { } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/commonbehaviorcontext.hxx b/oox/source/ppt/commonbehaviorcontext.hxx index 95e47342a76e..e047bbc46c7f 100644 --- a/oox/source/ppt/commonbehaviorcontext.hxx +++ b/oox/source/ppt/commonbehaviorcontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -80,3 +81,5 @@ namespace oox { namespace ppt { #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/commontimenodecontext.cxx b/oox/source/ppt/commontimenodecontext.cxx index 1057deb70c5d..ac88c8c67a1a 100644 --- a/oox/source/ppt/commontimenodecontext.cxx +++ b/oox/source/ppt/commontimenodecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -517,11 +518,9 @@ static OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId // ST_TLTimeNodePresetClassType nInt = xAttribs->getOptionalValueToken( XML_presetClass, 0 ); - sal_Int16 nEffectPresetClass = 0; - sal_Int32 nPresetId = 0; - sal_Int32 nPresetSubType = 0; if( nInt != 0 ) { + sal_Int16 nEffectPresetClass = 0; // TODO put that in a function switch( nInt ) { @@ -551,14 +550,14 @@ static OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId aUserData[ CREATE_OUSTRING( "preset-class" ) ] = makeAny( nEffectPresetClass ); if( attribs.hasAttribute( XML_presetID ) ) { - nPresetId = attribs.getInteger( XML_presetID, 0 ); + sal_Int32 nPresetId = attribs.getInteger( XML_presetID, 0 ); const preset_maping* p = gPresetMaping; while( p->mpStrPresetId && ((p->mnPresetClass != nEffectPresetClass) || (p->mnPresetId != nPresetId )) ) p++; aUserData[ CREATE_OUSTRING( "preset-id" ) ] = makeAny( OUString::createFromAscii( p->mpStrPresetId ) ); - nPresetSubType = attribs.getInteger( XML_presetSubtype, 0 ); + sal_Int32 nPresetSubType = attribs.getInteger( XML_presetSubtype, 0 ); if( nPresetSubType ) { aUserData[ CREATE_OUSTRING( "preset-sub-type" ) ] @@ -706,3 +705,5 @@ static OUString getConvertedSubType( sal_Int16 nPresetClass, sal_Int32 nPresetId } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/commontimenodecontext.hxx b/oox/source/ppt/commontimenodecontext.hxx index e8c55fa2d944..cb67433ee398 100644 --- a/oox/source/ppt/commontimenodecontext.hxx +++ b/oox/source/ppt/commontimenodecontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -60,3 +61,5 @@ namespace oox { namespace ppt { #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/conditioncontext.cxx b/oox/source/ppt/conditioncontext.cxx index 5b622b6ef602..97dd7f9bfcd5 100644 --- a/oox/source/ppt/conditioncontext.cxx +++ b/oox/source/ppt/conditioncontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -210,3 +211,4 @@ namespace oox { namespace ppt { } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/conditioncontext.hxx b/oox/source/ppt/conditioncontext.hxx index b89e587a9571..3abd050da006 100644 --- a/oox/source/ppt/conditioncontext.hxx +++ b/oox/source/ppt/conditioncontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -82,3 +83,5 @@ namespace oox { namespace ppt { #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/customshowlistcontext.cxx b/oox/source/ppt/customshowlistcontext.cxx index f66ccb0f6084..76bac5b7467c 100644 --- a/oox/source/ppt/customshowlistcontext.cxx +++ b/oox/source/ppt/customshowlistcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -25,7 +26,7 @@ * ************************************************************************/ -#include "customshowlistcontext.hxx" +#include "oox/ppt/customshowlistcontext.hxx" using namespace ::oox::core; using namespace ::com::sun::star::uno; @@ -116,3 +117,5 @@ Reference< XFastContextHandler > SAL_CALL CustomShowListContext::createFastChild } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/customshowlistcontext.hxx b/oox/source/ppt/customshowlistcontext.hxx deleted file mode 100644 index a423b18f2f5d..000000000000 --- a/oox/source/ppt/customshowlistcontext.hxx +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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_POWERPOINT_CUSTOMSHOWLISTCONTEXT_HXX -#define OOX_POWERPOINT_CUSTOMSHOWLISTCONTEXT_HXX - -#include "oox/core/contexthandler.hxx" -#include <vector> - -namespace oox { namespace ppt { - - - struct CustomShow - { - ::rtl::OUString maName; - ::rtl::OUString mnId; - std::vector< rtl::OUString >maSldLst; - }; - - /** CT_ */ - class CustomShowListContext : public ::oox::core::ContextHandler - { - std::vector< CustomShow >& mrCustomShowList; - - public: - CustomShowListContext( ::oox::core::ContextHandler& rParent, - std::vector< CustomShow >& rCustomShowList ); - - ~CustomShowListContext( ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL - createFastChildContext( ::sal_Int32 aElementToken, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& /*xAttribs*/ ) - throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); - }; - -} } - -#endif diff --git a/oox/source/ppt/headerfootercontext.cxx b/oox/source/ppt/headerfootercontext.cxx index 2089b019c58c..88a1e7c60894 100644 --- a/oox/source/ppt/headerfootercontext.cxx +++ b/oox/source/ppt/headerfootercontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -62,3 +63,5 @@ namespace oox { namespace ppt { } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/headerfootercontext.hxx b/oox/source/ppt/headerfootercontext.hxx index 52e5bb9ab55e..7cd83b5f53e4 100644 --- a/oox/source/ppt/headerfootercontext.hxx +++ b/oox/source/ppt/headerfootercontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -48,3 +49,5 @@ namespace oox { namespace ppt { } } #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/layoutfragmenthandler.cxx b/oox/source/ppt/layoutfragmenthandler.cxx index 152beb280bd7..19a9e6ead026 100644 --- a/oox/source/ppt/layoutfragmenthandler.cxx +++ b/oox/source/ppt/layoutfragmenthandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -84,3 +85,4 @@ void SAL_CALL LayoutFragmentHandler::endDocument() } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptfilterhelpers.cxx b/oox/source/ppt/pptfilterhelpers.cxx index 40040e985a4c..45a01380cbdb 100644 --- a/oox/source/ppt/pptfilterhelpers.cxx +++ b/oox/source/ppt/pptfilterhelpers.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -138,3 +139,5 @@ namespace oox { namespace ppt { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptfilterhelpers.hxx b/oox/source/ppt/pptfilterhelpers.hxx index c36c66df5ae7..23e9199418ee 100644 --- a/oox/source/ppt/pptfilterhelpers.hxx +++ b/oox/source/ppt/pptfilterhelpers.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -102,3 +103,5 @@ namespace oox { namespace ppt { #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptgraphicshapecontext.cxx b/oox/source/ppt/pptgraphicshapecontext.cxx new file mode 100644 index 000000000000..dd5820aa9925 --- /dev/null +++ b/oox/source/ppt/pptgraphicshapecontext.cxx @@ -0,0 +1,239 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 + * + * 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 <com/sun/star/xml/sax/FastToken.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/container/XNamed.hpp> + +#include "oox/ppt/pptshape.hxx" +#include "oox/ppt/pptgraphicshapecontext.hxx" +#include "oox/ppt/pptshapepropertiescontext.hxx" +#include "oox/ppt/slidepersist.hxx" +#include "oox/drawingml/shapestylecontext.hxx" +#include "oox/token/namespaces.hxx" +#include "oox/drawingml/fillpropertiesgroupcontext.hxx" +#include "oox/drawingml/lineproperties.hxx" +#include "oox/drawingml/drawingmltypes.hxx" +#include "oox/drawingml/customshapegeometry.hxx" +#include "oox/drawingml/textbodycontext.hxx" +#include <oox/token/tokens.hxx> + +using rtl::OUString; +using namespace oox::core; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::xml::sax; + +namespace oox { namespace ppt { + +// CT_Shape +PPTGraphicShapeContext::PPTGraphicShapeContext( ContextHandler& rParent, const SlidePersistPtr pSlidePersistPtr, oox::drawingml::ShapePtr pMasterShapePtr, oox::drawingml::ShapePtr pShapePtr ) +: oox::drawingml::GraphicShapeContext( rParent, pMasterShapePtr, pShapePtr ) +, mpSlidePersistPtr( pSlidePersistPtr ) +{ +} + +static oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes ) +{ + oox::drawingml::ShapePtr aShapePtr; + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); + while( aRevIter != rShapes.rend() ) + { + if ( (*aRevIter)->getSubType() == nMasterPlaceholder ) + { + aShapePtr = *aRevIter; + break; + } + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren(); + aShapePtr = findPlaceholder( nMasterPlaceholder, rChildren ); + if ( aShapePtr.get() ) + break; + ++aRevIter; + } + return aShapePtr; +} + +static oox::drawingml::ShapePtr findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes ) +{ + oox::drawingml::ShapePtr aShapePtr; + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); + while( aRevIter != rShapes.rend() ) + { + if ( (*aRevIter)->getSubTypeIndex() == nIdx ) + { + aShapePtr = *aRevIter; + break; + } + std::vector< oox::drawingml::ShapePtr >& rChildren = (*aRevIter)->getChildren(); + aShapePtr = findPlaceholderByIndex( nIdx, rChildren ); + if ( aShapePtr.get() ) + break; + ++aRevIter; + } + return aShapePtr; +} + +// if nFirstPlaceholder can't be found, it will be searched for nSecondPlaceholder +static oox::drawingml::ShapePtr findPlaceholder( sal_Int32 nFirstPlaceholder, sal_Int32 nSecondPlaceholder, std::vector< oox::drawingml::ShapePtr >& rShapes ) +{ + oox::drawingml::ShapePtr pPlaceholder = findPlaceholder( nFirstPlaceholder, rShapes ); + return !nSecondPlaceholder || pPlaceholder.get() ? pPlaceholder : findPlaceholder( nSecondPlaceholder, rShapes ); +} + +Reference< XFastContextHandler > PPTGraphicShapeContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException) +{ + Reference< XFastContextHandler > xRet; + + switch( aElementToken ) + { + // nvSpPr CT_ShapeNonVisual begin +// case NMSP_PPT|XML_drElemPr: +// break; + case PPT_TOKEN(cNvPr): + mpShapePtr->setId( xAttribs->getOptionalValue( XML_id ) ); + mpShapePtr->setName( xAttribs->getOptionalValue( XML_name ) ); + break; + case PPT_TOKEN(ph): + { + sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); + mpShapePtr->setSubType( nSubType ); + OUString sIdx( xAttribs->getOptionalValue( XML_idx ) ); + sal_Bool bHasIdx = sIdx.getLength() > 0; + sal_Int32 nIdx = sIdx.toInt32(); + if( xAttribs->hasAttribute( XML_idx ) ) + mpShapePtr->setSubTypeIndex( nIdx ); + + if ( nSubType || bHasIdx ) + { + PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() ); + if ( pPPTShapePtr ) + { + oox::ppt::ShapeLocation eShapeLocation = pPPTShapePtr->getShapeLocation(); + oox::drawingml::ShapePtr pPlaceholder; + + if ( bHasIdx && eShapeLocation == Slide ) + { + // TODO: use id to shape map + SlidePersistPtr pMasterPersist( mpSlidePersistPtr->getMasterPersist() ); + if ( pMasterPersist.get() ) + pPlaceholder = findPlaceholderByIndex( nIdx, pMasterPersist->getShapes()->getChildren() ); + } + if ( !pPlaceholder.get() && ( ( eShapeLocation == Slide ) || ( eShapeLocation == Layout ) ) ) + { + // inheriting properties from placeholder objects by cloning shape + + sal_Int32 nFirstPlaceholder = 0; + sal_Int32 nSecondPlaceholder = 0; + switch( nSubType ) + { + case XML_ctrTitle : // slide/layout + nFirstPlaceholder = XML_ctrTitle; + nSecondPlaceholder = XML_title; + break; + case XML_subTitle : // slide/layout + nFirstPlaceholder = XML_subTitle; + nSecondPlaceholder = XML_title; + break; + case XML_obj : // slide/layout + nFirstPlaceholder = XML_body; + break; + case XML_dt : // slide/layout/master/notes/notesmaster/handoutmaster + case XML_sldNum : // slide/layout/master/notes/notesmaster/handoutmaster + case XML_ftr : // slide/layout/master/notes/notesmaster/handoutmaster + case XML_hdr : // notes/notesmaster/handoutmaster + case XML_body : // slide/layout/master/notes/notesmaster + case XML_title : // slide/layout/master/ + case XML_chart : // slide/layout + case XML_tbl : // slide/layout + case XML_clipArt : // slide/layout + case XML_dgm : // slide/layout + case XML_media : // slide/layout + case XML_sldImg : // notes/notesmaster + case XML_pic : // slide/layout + nFirstPlaceholder = nSubType; + default: + break; + } + if ( nFirstPlaceholder ) + { + if ( eShapeLocation == Layout ) // for layout objects the referenced object can be found within the same shape tree + pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, 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() ); + } + } + } + if ( pPlaceholder.get() ) + { + mpShapePtr->applyShapeReference( *pPlaceholder.get() ); + PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() ); + if ( pPPTShape ) + pPPTShape->setReferenced( sal_True ); + pPPTShapePtr->setPlaceholder( pPlaceholder ); + } + } + } + break; + } + // nvSpPr CT_ShapeNonVisual end + + case PPT_TOKEN(spPr): + xRet = new PPTShapePropertiesContext( *this, *mpShapePtr ); + break; + + case PPT_TOKEN(style): + xRet = new oox::drawingml::ShapeStyleContext( *this, *mpShapePtr ); + break; + + case PPT_TOKEN(txBody): + { + oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody ); + mpShapePtr->setTextBody( xTextBody ); + xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody ); + break; + } + } + + if( !xRet.is() ) + xRet.set( GraphicShapeContext::createFastChildContext( aElementToken, xAttribs ) ); + + return xRet; +} + + +} } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx index 625e4e662e3c..2672170d2131 100644 --- a/oox/source/ppt/pptimport.cxx +++ b/oox/source/ppt/pptimport.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -38,6 +39,9 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::xml::sax; using namespace oox::core; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::lang::XComponent; + namespace oox { namespace ppt { OUString SAL_CALL PowerPointImport_getImplementationName() throw() @@ -58,10 +62,18 @@ uno::Reference< uno::XInterface > SAL_CALL PowerPointImport_createInstance( cons return static_cast< ::cppu::OWeakObject* >( new PowerPointImport( rxContext ) ); } +#if OSL_DEBUG_LEVEL > 0 +XmlFilterBase* PowerPointImport::mpDebugFilterBase = NULL; +#endif + PowerPointImport::PowerPointImport( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) : XmlFilterBase( rxContext ), mxChartConv( new ::oox::drawingml::chart::ChartConverter ) + { +#if OSL_DEBUG_LEVEL > 0 + mpDebugFilterBase = this; +#endif } PowerPointImport::~PowerPointImport() @@ -132,6 +144,29 @@ const ::oox::drawingml::Theme* PowerPointImport::getCurrentTheme() const return mpActualSlidePersist ? mpActualSlidePersist->getTheme().get() : 0; } +sal_Bool SAL_CALL PowerPointImport::filter( const Sequence< PropertyValue >& rDescriptor ) throw( RuntimeException ) +{ + if( XmlFilterBase::filter( rDescriptor ) ) + return true; + + if( isExportFilter() ) { + Reference< XExporter > xExporter( getServiceFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.comp.Impress.oox.PowerPointExport" ) ), UNO_QUERY ); + + if( xExporter.is() ) { + Reference< XComponent > xDocument( getModel(), UNO_QUERY ); + Reference< XFilter > xFilter( xExporter, UNO_QUERY ); + + if( xFilter.is() ) { + xExporter->setSourceDocument( xDocument ); + if( xFilter->filter( rDescriptor ) ) + return true; + } + } + } + + return false; +} + ::oox::vml::Drawing* PowerPointImport::getVmlDrawing() { return mpActualSlidePersist ? mpActualSlidePersist->getDrawing() : 0; @@ -193,3 +228,5 @@ OUString PowerPointImport::implGetImplementationName() const } }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx index 7437b378b324..fc3abfc51f62 100644 --- a/oox/source/ppt/pptshape.cxx +++ b/oox/source/ppt/pptshape.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -61,14 +62,71 @@ PPTShape::~PPTShape() { } +static const char* lclDebugSubType( sal_Int32 nType ) +{ + switch (nType) { + case XML_ctrTitle : + return "ctrTitle"; + case XML_title : + return "title"; + case XML_subTitle : + return "subTitle"; + case XML_obj : + return "obj"; + case XML_body : + return "body"; + case XML_dt : + return "dt"; + case XML_hdr : + return "hdr"; + case XML_ftr : + return "frt"; + case XML_sldNum : + return "sldNum"; + case XML_sldImg : + return "sldImg"; + } + + return "unknown - please extend lclDebugSubType"; +} + +oox::drawingml::TextListStylePtr PPTShape::getSubTypeTextListStyle( const SlidePersist& rSlidePersist, sal_Int32 nSubType ) +{ + oox::drawingml::TextListStylePtr pTextListStyle; + + OSL_TRACE( "subtype style: %s", lclDebugSubType( nSubType ) ); + + switch( nSubType ) + { + case XML_ctrTitle : + case XML_title : + case XML_subTitle : + pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getTitleTextStyle() : rSlidePersist.getTitleTextStyle(); + break; + case XML_obj : + pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle(); + break; + case XML_body : + if ( rSlidePersist.isNotesPage() ) + pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getNotesTextStyle() : rSlidePersist.getNotesTextStyle(); + else + pTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getBodyTextStyle() : rSlidePersist.getBodyTextStyle(); + break; + } + + return pTextListStyle; +} + void PPTShape::addShape( oox::core::XmlFilterBase& rFilterBase, const SlidePersist& rSlidePersist, const oox::drawingml::Theme* pTheme, const Reference< XShapes >& rxShapes, + basegfx::B2DHomMatrix& aTransformation, const awt::Rectangle* pShapeRect, ::oox::drawingml::ShapeIdMap* pShapeMap ) { + OSL_TRACE("add shape id: %s location: %s", rtl::OUStringToOString(msId, RTL_TEXTENCODING_UTF8 ).getStr(), meShapeLocation == Master ? "master" : meShapeLocation == Slide ? "slide" : "other"); // only placeholder from layout are being inserted if ( mnSubType && ( meShapeLocation == Master ) ) return; @@ -81,7 +139,8 @@ void PPTShape::addShape( Reference< lang::XMultiServiceFactory > xServiceFact( rFilterBase.getModel(), UNO_QUERY_THROW ); sal_Bool bClearText = sal_False; - if ( sServiceName != OUString::createFromAscii( "com.sun.star.drawing.GraphicObjectShape" ) ) + if ( sServiceName != OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GraphicObjectShape")) && + sServiceName != OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape")) ) { switch( mnSubType ) { @@ -167,28 +226,74 @@ void PPTShape::addShape( } } -/* + OSL_TRACE("shape service: %s", rtl::OUStringToOString(sServiceName, RTL_TEXTENCODING_UTF8 ).getStr()); + + if( mnSubType && aMasterTextListStyle && getSubTypeIndex() != -1 ) + aMasterTextListStyle.reset(); + // use placeholder index if possible - if( mnSubType && getSubTypeIndex() && rSlidePersist.getMasterPersist().get() ) { + if( mnSubType && getSubTypeIndex() && getSubTypeIndex() != -1 && rSlidePersist.getMasterPersist().get() ) { oox::drawingml::ShapePtr pPlaceholder = PPTShape::findPlaceholderByIndex( getSubTypeIndex(), rSlidePersist.getMasterPersist()->getShapes()->getChildren() ); - if( pPlaceholder.get() && pPlaceholder->getTextBody() ) { - TextListStylePtr pNewTextListStyle ( new TextListStyle() ); + if( pPlaceholder.get()) { + OSL_TRACE("found placeholder with index: %d and type: %s", getSubTypeIndex(), lclDebugSubType( mnSubType )); + } + if( pPlaceholder.get() ) { + PPTShape* pPPTPlaceholder = dynamic_cast< PPTShape* >( pPlaceholder.get() ); + TextListStylePtr pNewTextListStyle ( new TextListStyle() ); + + if( pPlaceholder->getTextBody() ) { - pNewTextListStyle->apply( pPlaceholder->getTextBody()->getTextListStyle() ); - if( pPlaceholder->getMasterTextListStyle().get() ) - pNewTextListStyle->apply( *pPlaceholder->getMasterTextListStyle() ); + pNewTextListStyle->apply( pPlaceholder->getTextBody()->getTextListStyle() ); + if( pPlaceholder->getMasterTextListStyle().get() ) + pNewTextListStyle->apply( *pPlaceholder->getMasterTextListStyle() ); - aMasterTextListStyle = pNewTextListStyle; + // OSL_TRACE("placeholder body style"); + // pPlaceholder->getTextBody()->getTextListStyle().dump(); + // OSL_TRACE("master text list style"); + // pPlaceholder->getMasterTextListStyle()->dump(); + + aMasterTextListStyle = pNewTextListStyle; + } + if( pPPTPlaceholder->mpPlaceholder.get() ) { + OSL_TRACE("placeholder has parent placeholder: %s type: %s index: %d", + rtl::OUStringToOString( pPPTPlaceholder->mpPlaceholder->getId(), RTL_TEXTENCODING_UTF8 ).getStr(), + lclDebugSubType( pPPTPlaceholder->mpPlaceholder->getSubType() ), + pPPTPlaceholder->mpPlaceholder->getSubTypeIndex() ); + OSL_TRACE("has textbody %d", pPPTPlaceholder->mpPlaceholder->getTextBody() != NULL ); + TextListStylePtr pPlaceholderStyle = getSubTypeTextListStyle( rSlidePersist, pPPTPlaceholder->mpPlaceholder->getSubType() ); + if( pPPTPlaceholder->mpPlaceholder->getTextBody() ) + pNewTextListStyle->apply( pPPTPlaceholder->mpPlaceholder->getTextBody()->getTextListStyle() ); + if( pPlaceholderStyle.get() ) { + pNewTextListStyle->apply( *pPlaceholderStyle ); + //pPlaceholderStyle->dump(); + } + } + } else if( !mpPlaceholder.get() ) { + aMasterTextListStyle.reset(); } + OSL_TRACE("placeholder id: %s", pPlaceholder.get() ? rtl::OUStringToOString(pPlaceholder->getId(), RTL_TEXTENCODING_UTF8 ).getStr() : "not found"); } -*/ + if ( sServiceName.getLength() ) { + // use style from master slide for placeholders only, otherwise use slide's style, which might be the default style from presentation if ( !aMasterTextListStyle.get() ) - aMasterTextListStyle = rSlidePersist.getMasterPersist().get() ? rSlidePersist.getMasterPersist()->getOtherTextStyle() : rSlidePersist.getOtherTextStyle(); + aMasterTextListStyle = ( mnSubType && rSlidePersist.getMasterPersist().get() ) ? rSlidePersist.getMasterPersist()->getOtherTextStyle() : rSlidePersist.getOtherTextStyle(); + + if( aMasterTextListStyle.get() && getTextBody().get() ) { + TextListStylePtr aCombinedTextListStyle (new TextListStyle()); + + aCombinedTextListStyle->apply( *aMasterTextListStyle.get() ); + + if( mpPlaceholder.get() && mpPlaceholder->getTextBody().get() ) + aCombinedTextListStyle->apply( mpPlaceholder->getTextBody()->getTextListStyle() ); + aCombinedTextListStyle->apply( getTextBody()->getTextListStyle() ); + + setMasterTextListStyle( aCombinedTextListStyle ); + } else setMasterTextListStyle( aMasterTextListStyle ); - Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, bClearText ) ); + Reference< XShape > xShape( createAndInsert( rFilterBase, sServiceName, pTheme, rxShapes, pShapeRect, bClearText, aTransformation ) ); if ( !rSlidePersist.isMasterPage() && rSlidePersist.getPage().is() && ( (sal_Int32)mnSubType == XML_title ) ) { try @@ -215,7 +320,7 @@ void PPTShape::addShape( // 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 ); + addChildren( rFilterBase, *this, pTheme, xShapes, pShapeRect ? *pShapeRect : awt::Rectangle( maPosition.X, maPosition.Y, maSize.Width, maSize.Height ), pShapeMap, aTransformation ); } } } @@ -244,7 +349,7 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholder( const sal_Int32 nMasterPlace aShapePtr = findPlaceholder( nMasterPlaceholder, rChildren ); if ( aShapePtr.get() ) break; - aRevIter++; + ++aRevIter; } return aShapePtr; } @@ -252,6 +357,10 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholder( const sal_Int32 nMasterPlace oox::drawingml::ShapePtr PPTShape::findPlaceholderByIndex( const sal_Int32 nIdx, std::vector< oox::drawingml::ShapePtr >& rShapes ) { oox::drawingml::ShapePtr aShapePtr; + + if( nIdx == -1) + return aShapePtr; + std::vector< oox::drawingml::ShapePtr >::reverse_iterator aRevIter( rShapes.rbegin() ); while( aRevIter != rShapes.rend() ) { @@ -264,7 +373,7 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholderByIndex( const sal_Int32 nIdx, aShapePtr = findPlaceholderByIndex( nIdx, rChildren ); if ( aShapePtr.get() ) break; - aRevIter++; + ++aRevIter; } return aShapePtr; } @@ -277,3 +386,5 @@ oox::drawingml::ShapePtr PPTShape::findPlaceholder( sal_Int32 nFirstPlaceholder, } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx index 7df41ac3d714..cde75734b258 100644 --- a/oox/source/ppt/pptshapecontext.cxx +++ b/oox/source/ppt/pptshapecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -79,7 +80,7 @@ oox::drawingml::ShapePtr findPlaceholder( const sal_Int32 nMasterPlaceholder, sa aShapePtr = findPlaceholder( nMasterPlaceholder, nSubTypeIndex, rChildren ); if ( aShapePtr.get() ) break; - aRevIter++; + ++aRevIter; } return aShapePtr; } @@ -113,7 +114,8 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In { sal_Int32 nSubType( xAttribs->getOptionalValueToken( XML_type, XML_obj ) ); mpShapePtr->setSubType( nSubType ); - mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + if( xAttribs->hasAttribute( XML_idx ) ) + mpShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); if ( nSubType ) { PPTShape* pPPTShapePtr = dynamic_cast< PPTShape* >( mpShapePtr.get() ); @@ -163,20 +165,30 @@ 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, -1, mpSlidePersistPtr->getShapes()->getChildren() ); + { + pPlaceholder = PPTShape::findPlaceholderByIndex( pPPTShapePtr->getSubTypeIndex(), mpSlidePersistPtr->getShapes()->getChildren() ); + if ( !pPlaceholder.get() ) + pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, pPPTShapePtr->getSubTypeIndex(), + 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, - pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() ); + if ( pMasterPersist.get() ) { + pPlaceholder = PPTShape::findPlaceholderByIndex( pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() ); + if ( !pPlaceholder.get() ) + pPlaceholder = findPlaceholder( nFirstPlaceholder, nSecondPlaceholder, + pPPTShapePtr->getSubTypeIndex(), pMasterPersist->getShapes()->getChildren() ); + } } if ( pPlaceholder.get() ) { + OSL_TRACE("shape %s will get shape reference %s applied", rtl::OUStringToOString(mpShapePtr->getId(), RTL_TEXTENCODING_UTF8 ).getStr(), rtl::OUStringToOString(pPlaceholder->getId(), RTL_TEXTENCODING_UTF8 ).getStr()); mpShapePtr->applyShapeReference( *pPlaceholder.get() ); PPTShape* pPPTShape = dynamic_cast< PPTShape* >( pPlaceholder.get() ); if ( pPPTShape ) pPPTShape->setReferenced( sal_True ); + pPPTShapePtr->setPlaceholder( pPlaceholder ); } } } @@ -198,7 +210,7 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In case PPT_TOKEN( txBody ): { - oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody ); + oox::drawingml::TextBodyPtr xTextBody( new oox::drawingml::TextBody( mpShapePtr->getTextBody() ) ); xTextBody->getTextProperties().maPropertyMap[ PROP_FontIndependentLineSpacing ] <<= static_cast< sal_Bool >( sal_True ); mpShapePtr->setTextBody( xTextBody ); xRet = new oox::drawingml::TextBodyContext( *this, *xTextBody ); @@ -214,3 +226,5 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx index 0ba36ee99417..0a03e44f03f8 100644 --- a/oox/source/ppt/pptshapegroupcontext.cxx +++ b/oox/source/ppt/pptshapegroupcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -31,6 +32,7 @@ #include "oox/helper/attributelist.hxx" #include "oox/ppt/pptshape.hxx" +#include "oox/ppt/pptgraphicshapecontext.hxx" #include "oox/ppt/pptshapecontext.hxx" #include "oox/ppt/pptshapegroupcontext.hxx" #include "oox/drawingml/graphicshapecontext.hxx" @@ -79,7 +81,8 @@ Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( s } case PPT_TOKEN( ph ): mpGroupShapePtr->setSubType( xAttribs->getOptionalValueToken( XML_type, FastToken::DONTKNOW ) ); - mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); + if( xAttribs->hasAttribute( XML_idx ) ) + mpGroupShapePtr->setSubTypeIndex( xAttribs->getOptionalValue( XML_idx ).toInt32() ); break; // nvSpPr CT_ShapeNonVisual end @@ -104,7 +107,7 @@ Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( s xRet.set( new PPTShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.CustomShape" ) ) ) ); break; case PPT_TOKEN( pic ): // CT_Picture - xRet.set( new oox::drawingml::GraphicShapeContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) ) ); + xRet.set( new PPTGraphicShapeContext( *this, mpSlidePersistPtr, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.GraphicObjectShape" ) ) ) ); break; case PPT_TOKEN( graphicFrame ): // CT_GraphicalObjectFrame xRet.set( new oox::drawingml::GraphicalObjectFrameContext( *this, mpGroupShapePtr, oox::drawingml::ShapePtr( new PPTShape( meShapeLocation, "com.sun.star.drawing.OLE2Shape" ) ), true ) ); @@ -119,3 +122,5 @@ Reference< XFastContextHandler > PPTShapeGroupContext::createFastChildContext( s } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/pptshapepropertiescontext.cxx b/oox/source/ppt/pptshapepropertiescontext.cxx index bddd74f4837a..46e776cb62d4 100644 --- a/oox/source/ppt/pptshapepropertiescontext.cxx +++ b/oox/source/ppt/pptshapepropertiescontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -81,3 +82,5 @@ Reference< XFastContextHandler > PPTShapePropertiesContext::createFastChildConte } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx index 6976c965ad83..31a2781d845b 100644 --- a/oox/source/ppt/presentationfragmenthandler.cxx +++ b/oox/source/ppt/presentationfragmenthandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -198,7 +199,7 @@ void PresentationFragmentHandler::endDocument() throw (SAXException, RuntimeExce pMasterPersistPtr = *aIter; break; } - aIter++; + ++aIter; } if ( aIter == rMasterPages.end() ) { // masterpersist not found, we have to load it @@ -245,11 +246,13 @@ void PresentationFragmentHandler::endDocument() throw (SAXException, RuntimeExce } // importing slide page - pSlidePersistPtr->setMasterPersist( pMasterPersistPtr ); - pSlidePersistPtr->setTheme( pMasterPersistPtr->getTheme() ); - Reference< drawing::XMasterPageTarget > xMasterPageTarget( pSlidePersistPtr->getPage(), UNO_QUERY ); - if( xMasterPageTarget.is() ) - xMasterPageTarget->setMasterPage( pMasterPersistPtr->getPage() ); + if (pMasterPersistPtr.get()) { + pSlidePersistPtr->setMasterPersist( pMasterPersistPtr ); + pSlidePersistPtr->setTheme( pMasterPersistPtr->getTheme() ); + Reference< drawing::XMasterPageTarget > xMasterPageTarget( pSlidePersistPtr->getPage(), UNO_QUERY ); + if( xMasterPageTarget.is() ) + xMasterPageTarget->setMasterPage( pMasterPersistPtr->getPage() ); + } rFilter.getDrawPages().push_back( pSlidePersistPtr ); rFilter.setActualSlidePersist( pSlidePersistPtr ); importSlide( xSlideFragmentHandler, pSlidePersistPtr ); @@ -283,8 +286,7 @@ void PresentationFragmentHandler::endDocument() throw (SAXException, RuntimeExce } catch( uno::Exception& ) { - OSL_ENSURE( false, - (rtl::OString("oox::ppt::PresentationFragmentHandler::EndDocument(), " + OSL_FAIL( (rtl::OString("oox::ppt::PresentationFragmentHandler::EndDocument(), " "exception caught: ") + rtl::OUStringToOString( comphelper::anyToString( cppu::getCaughtException() ), @@ -388,3 +390,4 @@ bool PresentationFragmentHandler::importSlide( const FragmentHandlerRef& rxSlide } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx index 66b2a9323d31..48a53a5f7e1f 100644 --- a/oox/source/ppt/slidefragmenthandler.cxx +++ b/oox/source/ppt/slidefragmenthandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -192,8 +193,7 @@ void SAL_CALL SlideFragmentHandler::endDocument( ) throw (::com::sun::star::xml } catch( uno::Exception& ) { - OSL_ENSURE( false, - (rtl::OString("oox::ppt::SlideFragmentHandler::EndElement(), " + OSL_FAIL( (rtl::OString("oox::ppt::SlideFragmentHandler::EndElement(), " "exception caught: ") + rtl::OUStringToOString( comphelper::anyToString( cppu::getCaughtException() ), @@ -203,3 +203,4 @@ void SAL_CALL SlideFragmentHandler::endDocument( ) throw (::com::sun::star::xml } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/slidemastertextstylescontext.cxx b/oox/source/ppt/slidemastertextstylescontext.cxx index d4c777102a0a..08b7aaf4af7c 100644 --- a/oox/source/ppt/slidemastertextstylescontext.cxx +++ b/oox/source/ppt/slidemastertextstylescontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -86,3 +87,5 @@ Reference< XFastContextHandler > SlideMasterTextStylesContext::createFastChildCo } } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx index 622dd5dfc929..d8eb8758bb1a 100644 --- a/oox/source/ppt/slidepersist.cxx +++ b/oox/source/ppt/slidepersist.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -73,8 +74,15 @@ SlidePersist::SlidePersist( XmlFilterBase& rFilter, sal_Bool bMaster, sal_Bool b */ maOtherTextStylePtr->apply( *pDefaultTextStyle.get() ); } +#if OSL_DEBUG_LEVEL > 0 + mxDebugPage = mxPage; +#endif } +#if OSL_DEBUG_LEVEL > 0 + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SlidePersist::mxDebugPage; +#endif + SlidePersist::~SlidePersist() { @@ -143,10 +151,11 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase ) while( aChildIter != rChildren.end() ) { PPTShape* pPPTShape = dynamic_cast< PPTShape* >( (*aChildIter).get() ); + basegfx::B2DHomMatrix aTransformation; if ( pPPTShape ) - pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, 0, &getShapeMap() ); + pPPTShape->addShape( rFilterBase, *this, getTheme().get(), xShapes, aTransformation, 0, &getShapeMap() ); else - (*aChildIter)->addShape( rFilterBase, getTheme().get(), xShapes, 0, &getShapeMap() ); + (*aChildIter)->addShape( rFilterBase, getTheme().get(), xShapes, aTransformation, 0, &getShapeMap() ); aChildIter++; } } @@ -296,7 +305,7 @@ void SlidePersist::applyTextStyles( const XmlFilterBase& rFilterBase ) } } } - catch( Exception& ) + catch( const Exception& ) { } } @@ -304,3 +313,4 @@ void SlidePersist::applyTextStyles( const XmlFilterBase& rFilterBase ) } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/slidetimingcontext.cxx b/oox/source/ppt/slidetimingcontext.cxx index 4357e14ea08e..6c4fcf76a9d2 100644 --- a/oox/source/ppt/slidetimingcontext.cxx +++ b/oox/source/ppt/slidetimingcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -99,3 +100,4 @@ void SAL_CALL SlideTimingContext::endDocument( ) throw (::com::sun::star::xml:: } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/slidetransition.cxx b/oox/source/ppt/slidetransition.cxx index a380a4d945e1..482a35e09762 100644 --- a/oox/source/ppt/slidetransition.cxx +++ b/oox/source/ppt/slidetransition.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -55,6 +56,7 @@ namespace oox { namespace ppt { , mnAnimationSpeed( AnimationSpeed_FAST ) , mnFadeColor( 0 ) , mbMode( true ) + , mnAdvanceTime( -1 ) { } @@ -67,6 +69,7 @@ namespace oox { namespace ppt { , mnAnimationSpeed( AnimationSpeed_FAST ) , mnFadeColor( 0 ) , mbMode( true ) + , mnAdvanceTime( -1 ) { const transition *p = transition::find( sFilterName ); if( p ) @@ -87,11 +90,15 @@ namespace oox { namespace ppt { aProps[ PROP_TransitionDirection ] <<= mbTransitionDirectionNormal; aProps[ PROP_Speed ] <<= mnAnimationSpeed; aProps[ PROP_TransitionFadeColor ] <<= mnFadeColor; + if( mnAdvanceTime != -1 ) { + aProps[ PROP_Duration ] <<= mnAdvanceTime/1000; + aProps[ PROP_Change ] <<= static_cast<sal_Int32>(1); + } } catch( Exception& ) { // should not happen - OSL_ENSURE( false, "exception raised" ); + OSL_FAIL( "exception raised" ); } } @@ -108,7 +115,7 @@ namespace oox { namespace ppt { catch( Exception& ) { // should not happen - OSL_ENSURE( false, "exception raised" ); + OSL_FAIL( "exception raised" ); } } @@ -137,8 +144,6 @@ namespace oox { namespace ppt { } } - - sal_Int16 SlideTransition::ooxToOdpEightDirections( ::sal_Int32 nOoxType ) { sal_Int16 nOdpDirection; @@ -416,3 +421,5 @@ namespace oox { namespace ppt { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/slidetransitioncontext.cxx b/oox/source/ppt/slidetransitioncontext.cxx index 4c5ae7dcc65f..c7f61912f44e 100644 --- a/oox/source/ppt/slidetransitioncontext.cxx +++ b/oox/source/ppt/slidetransitioncontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -64,12 +65,9 @@ SlideTransitionContext::SlideTransitionContext( ContextHandler& rParent, const R attribs.getBool( XML_advClick, true ); // careful. if missing, no auto advance... 0 looks like a valid value - // for auto advance + // for auto advance if(attribs.hasAttribute( XML_advTm )) - { - // TODO - xAttribs->getOptionalValue( XML_advTm ); - } + maTransition.setOoxAdvanceTime( attribs.getInteger( XML_advTm, -1 ) ); } SlideTransitionContext::~SlideTransitionContext() throw() @@ -198,3 +196,4 @@ void SlideTransitionContext::endFastElement( sal_Int32 aElement ) throw (::com:: } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/soundactioncontext.cxx b/oox/source/ppt/soundactioncontext.cxx index e9b955a73e15..64a24963ab66 100644 --- a/oox/source/ppt/soundactioncontext.cxx +++ b/oox/source/ppt/soundactioncontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -132,3 +133,5 @@ namespace oox { namespace ppt { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/timeanimvaluecontext.cxx b/oox/source/ppt/timeanimvaluecontext.cxx index 185897f2e101..fd247de41a86 100644 --- a/oox/source/ppt/timeanimvaluecontext.cxx +++ b/oox/source/ppt/timeanimvaluecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -96,3 +97,5 @@ namespace oox { namespace ppt { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/timeanimvaluecontext.hxx b/oox/source/ppt/timeanimvaluecontext.hxx index 0c6391e4c175..10041e2ac413 100644 --- a/oox/source/ppt/timeanimvaluecontext.hxx +++ b/oox/source/ppt/timeanimvaluecontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -62,3 +63,5 @@ namespace oox { namespace ppt { } } #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx index 6887bcfdf3a3..fc28f72e7028 100644 --- a/oox/source/ppt/timenode.cxx +++ b/oox/source/ppt/timenode.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -628,3 +629,5 @@ namespace oox { namespace ppt { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/timenodelistcontext.cxx b/oox/source/ppt/timenodelistcontext.cxx index 6a82dc29c1de..9aa72213dfe6 100644 --- a/oox/source/ppt/timenodelistcontext.cxx +++ b/oox/source/ppt/timenodelistcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -202,7 +203,7 @@ namespace oox { namespace ppt { if( maTo >>= aString ) { OSL_TRACE( "Magic conversion %s", OUSTRING_TO_CSTR( aString ) ); - maTo = makeAny( aString.equalsAscii( "visible" ) ? sal_True : sal_False ); + maTo = makeAny( aString.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "visible" ) ) ? sal_True : sal_False ); if( !maTo.has<sal_Bool>() ) OSL_TRACE( "conversion failed" ); } @@ -646,7 +647,7 @@ namespace oox { namespace ppt { NodePropertyMap & aProps( mpNode->getNodeProperties() ); end = maTavList.end(); - for(iter = maTavList.begin(), i=0; iter != end; iter++,i++) + for(iter = maTavList.begin(), i=0; iter != end; ++iter,++i) { // TODO what to do if it is Timing_INFINITE ? Any aTime = GetTimeAnimateValueTime( iter->msTime ); @@ -938,6 +939,7 @@ namespace oox { namespace ppt { // CT_TLPoint Point p = GetPointPercent( xAttribs ); // TODO push + (void)p; break; } default: @@ -1161,3 +1163,5 @@ namespace oox { namespace ppt { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/timetargetelementcontext.cxx b/oox/source/ppt/timetargetelementcontext.cxx index 81320bef5e89..2a0f61c0c4a3 100644 --- a/oox/source/ppt/timetargetelementcontext.cxx +++ b/oox/source/ppt/timetargetelementcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -172,3 +173,5 @@ namespace oox { namespace ppt { } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/ppt/timetargetelementcontext.hxx b/oox/source/ppt/timetargetelementcontext.hxx index 05295e4298ea..8ee22fd26aae 100644 --- a/oox/source/ppt/timetargetelementcontext.hxx +++ b/oox/source/ppt/timetargetelementcontext.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -51,3 +52,5 @@ namespace oox { namespace ppt { #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx index 31ab343e0ebc..de27734a89d8 100644 --- a/oox/source/shape/ShapeContextHandler.cxx +++ b/oox/source/shape/ShapeContextHandler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -240,15 +241,19 @@ ShapeContextHandler::getShape() throw (uno::RuntimeException) if (mxFilterBase.is() && xShapes.is()) { - if (mpDrawing.get() != NULL) + if ( getContextHandler() == getDrawingShapeContext() ) { mpDrawing->finalizeFragmentImport(); if( const ::oox::vml::ShapeBase* pShape = mpDrawing->getShapes().getFirstShape() ) + { xResult = pShape->convertAndInsert( xShapes ); + mpDrawing->getShapes( ).clearShapes( ); + } } else if (mpShape.get() != NULL) { - mpShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes); + basegfx::B2DHomMatrix aTransformation; + mpShape->addShape(*mxFilterBase, mpThemePtr.get(), xShapes, aTransformation); xResult.set(mpShape->getXShape()); mxGraphicShapeContext.clear( ); } @@ -350,3 +355,5 @@ uno::Sequence< ::rtl::OUString > ShapeContextHandler::getSupportedServiceNames() } }} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/ShapeContextHandler.hxx b/oox/source/shape/ShapeContextHandler.hxx index b794c2f879c1..df9c3987a2c9 100644 --- a/oox/source/shape/ShapeContextHandler.hxx +++ b/oox/source/shape/ShapeContextHandler.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -173,3 +174,5 @@ private: }} #endif // OOX_SHAPE_SHAPE_CONTEXT_HANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/ShapeFilterBase.cxx b/oox/source/shape/ShapeFilterBase.cxx index 68e0d0002392..f67be3d0de23 100644 --- a/oox/source/shape/ShapeFilterBase.cxx +++ b/oox/source/shape/ShapeFilterBase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -76,3 +77,5 @@ const ::oox::drawingml::table::TableStyleListPtr ShapeFilterBase::getTableStyles } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/shape/ShapeFilterBase.hxx b/oox/source/shape/ShapeFilterBase.hxx index a21357c16079..e49e98913ff3 100644 --- a/oox/source/shape/ShapeFilterBase.hxx +++ b/oox/source/shape/ShapeFilterBase.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -78,3 +79,4 @@ private: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/token/namespacemap.cxx b/oox/source/token/namespacemap.cxx index d021f2a3a353..915cbe9855b8 100755..100644 --- a/oox/source/token/namespacemap.cxx +++ b/oox/source/token/namespacemap.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -44,6 +45,7 @@ NamespaceMap::NamespaceMap() operator[]( pNamespaceUrl->mnId ) = ::rtl::OUString::createFromAscii( pNamespaceUrl->mpcUrl ); } +} // ============================================================================ -} // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/token/namespaces.hxx.head b/oox/source/token/namespaces.hxx.head index 351bf2558303..351bf2558303 100755..100644 --- a/oox/source/token/namespaces.hxx.head +++ b/oox/source/token/namespaces.hxx.head diff --git a/oox/source/token/namespaces.hxx.tail b/oox/source/token/namespaces.hxx.tail index 60ce5b18305d..47702d9cb00d 100755..100644 --- a/oox/source/token/namespaces.hxx.tail +++ b/oox/source/token/namespaces.hxx.tail @@ -1,8 +1,8 @@ // ============================================================================ -const sal_Int32 TOKEN_MASK = static_cast< sal_Int32 >( (1 << NMSP_SHIFT) - 1 ); -const sal_Int32 NMSP_MASK = static_cast< sal_Int32 >( SAL_MAX_INT16 & ~TOKEN_MASK ); +const sal_Int32 TOKEN_MASK = static_cast< sal_Int32 >( (1 << NMSP_SHIFT) - 1 ); +const sal_Int32 NMSP_MASK = static_cast< sal_Int32 >( SAL_MAX_INT32 & ~TOKEN_MASK ); /** Returns the raw token identifier without namespace of the passed token. */ inline sal_Int32 getBaseToken( sal_Int32 nToken ) { return nToken & TOKEN_MASK; } @@ -19,6 +19,7 @@ inline sal_Int32 getNamespace( sal_Int32 nToken ) { return nToken & NMSP_MASK; } #define C_TOKEN( token ) OOX_TOKEN( dmlChart, token ) #define CDR_TOKEN( token ) OOX_TOKEN( dmlChartDr, token ) #define DGM_TOKEN( token ) OOX_TOKEN( dmlDiagram, token ) +#define MCE_TOKEN( token ) OOX_TOKEN( mce, token) #define O_TOKEN( token ) OOX_TOKEN( vmlOffice, token ) #define PC_TOKEN( token ) OOX_TOKEN( packageContentTypes, token ) #define PPT_TOKEN( token ) OOX_TOKEN( ppt, token ) diff --git a/oox/source/token/namespaces.txt b/oox/source/token/namespaces.txt index 81b568067470..9251fe053111 100644 --- a/oox/source/token/namespaces.txt +++ b/oox/source/token/namespaces.txt @@ -50,3 +50,5 @@ dc http://purl.org/dc/elements/1.1/ dcTerms http://purl.org/dc/terms/ xm http://schemas.microsoft.com/office/excel/2006/main sprm http://sprm +mce http://schemas.openxmlformats.org/markup-compatibility/2006 +mceTest http://schemas.openxmlformats.org/spreadsheetml/2006/main/v2 diff --git a/oox/source/token/properties.hxx.head b/oox/source/token/properties.hxx.head index 25817b5e72f3..25817b5e72f3 100755..100644 --- a/oox/source/token/properties.hxx.head +++ b/oox/source/token/properties.hxx.head diff --git a/oox/source/token/properties.hxx.tail b/oox/source/token/properties.hxx.tail index f647337e529c..f647337e529c 100755..100644 --- a/oox/source/token/properties.hxx.tail +++ b/oox/source/token/properties.hxx.tail diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 553af0d723f8..d3bf0b776c25 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -7,6 +7,7 @@ Adjust AdjustContrast AdjustLuminance AdjustmentValues +Address Align AnchorPosition ApplyFormDesignMode @@ -44,6 +45,7 @@ CellProtection CellStyle CenterHorizontally CenterVertically +Change CharCaseMap CharColor CharContoured @@ -125,6 +127,7 @@ DisableDataTableDialog DisplayLabels DrillDownOnDoubleClick Dropdown +Duration EchoChar EnableVisible Enabled @@ -209,6 +212,7 @@ Height HelpText HideInactiveSelection HoriJustify +HoriJustifyMethod HorizontalSplitMode HorizontalSplitPositionTwips IgnoreBlankCells @@ -279,6 +283,7 @@ MirroredY MissingValueTreatment Model ModifyPasswordHash +MoveProtect MultiLine MultiPageValue MultiSelection @@ -404,6 +409,7 @@ ShrinkToFit Size Size100thMM SizePixel +SizeProtect SkipDuplicates SortInfo Sound @@ -462,6 +468,7 @@ TransitionType Transparency TriState Type +UnnamedDatabaseRanges URL Url UseFilterCriteriaSource @@ -473,6 +480,7 @@ Validation Value VaryColorsByPoint VertJustify +VertJustifyMethod VerticalAlign VerticalSplitMode VerticalSplitPositionTwips diff --git a/oox/source/token/propertynames.cxx b/oox/source/token/propertynames.cxx index b8f06496c7ff..4a6d54cd6e63 100644 --- a/oox/source/token/propertynames.cxx +++ b/oox/source/token/propertynames.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -48,3 +49,5 @@ PropertyNameVector::PropertyNameVector() // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/token/tokenmap.cxx b/oox/source/token/tokenmap.cxx index 0be0a1c4c470..9d106731dc53 100644 --- a/oox/source/token/tokenmap.cxx +++ b/oox/source/token/tokenmap.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -33,7 +34,6 @@ #include "oox/token/tokens.hxx" namespace oox { - // ============================================================================ using ::com::sun::star::uno::Sequence; @@ -119,3 +119,5 @@ sal_Int32 TokenMap::getTokenFromUtf8( const Sequence< sal_Int8 >& rUtf8Name ) co // ============================================================================ } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/token/tokens.hxx.head b/oox/source/token/tokens.hxx.head index dd201caeb1d9..dd201caeb1d9 100755..100644 --- a/oox/source/token/tokens.hxx.head +++ b/oox/source/token/tokens.hxx.head diff --git a/oox/source/token/tokens.hxx.tail b/oox/source/token/tokens.hxx.tail index df4b5ef1a955..df4b5ef1a955 100755..100644 --- a/oox/source/token/tokens.hxx.tail +++ b/oox/source/token/tokens.hxx.tail diff --git a/oox/source/token/tokens.txt b/oox/source/token/tokens.txt index 13c1a10ff9b4..c168532dfb74 100644 --- a/oox/source/token/tokens.txt +++ b/oox/source/token/tokens.txt @@ -37,6 +37,7 @@ AbbreviatedCaseNumber Accel Accel2 AlbumTitle +AlternateContent Always Anchor AppVersion @@ -79,6 +80,7 @@ Characters CharactersWithSpaces Checkbox Checked +Choice City ClientData ColHidden @@ -142,6 +144,7 @@ EnhancedMetaFile Extend Extension External +Fallback False FieldCodes FileBinding @@ -183,6 +186,7 @@ IDREF IDREFS Icon Id +Ignorable Inc Institution Internal @@ -324,6 +328,7 @@ Relationships RelationshipsGroupReference Report Reporter +Requires Right RootElement Row @@ -495,6 +500,7 @@ alg algIdExt algIdExtSource algn +algorithmName alias aliases aliceBlue @@ -665,11 +671,13 @@ autoCaptions autoCompressPictures autoEnd autoExp +autoFill autoFilter autoFilterDateGrouping autoFormatId autoFormatOverride autoHyphenation +autoLine autoLoad autoNoTable autoPage @@ -678,6 +686,7 @@ autoRecover autoRedefine autoRepublish autoRev +autoScale autoShow autoSortScope autoSpaceDE @@ -1111,6 +1120,7 @@ char charRg charSpace character +characterSet characterSpacingControl characteristic charset @@ -1221,6 +1231,7 @@ colFields colFirst colGrandTotals colHeaderCaption +colHidden colHierarchiesUsage colHierarchyUsage colId @@ -1259,6 +1270,7 @@ command commandType comment commentList +commentPr commentRangeEnd commentRangeStart commentReference @@ -1290,6 +1302,7 @@ confettiGrays confettiOutline confettiStreamers confettiWhite +conformance conn connDist connRout @@ -1596,6 +1609,7 @@ date date1904 dateAx dateBetween +dateCompatibility dateEqual dateFormat dateGroupItem @@ -1659,6 +1673,7 @@ defaultGridColor defaultMemberUniqueName defaultPivotStyle defaultRowHeight +defaultSize defaultSubtotal defaultTabStop defaultTableStyle @@ -2002,6 +2017,7 @@ encoding end endA endAngle +endChars endChr endCnv endCondLst @@ -2517,6 +2533,7 @@ harsh hasCustomPrompt hash hashData +hashValue hc hd2 hd4 @@ -3358,6 +3375,7 @@ moveTo moveToRangeEnd moveToRangeStart moveWith +moveWithCells movie movingAvg mp @@ -3729,8 +3747,11 @@ panose panose1 papayaWhip paperClips +paperHeight paperSize paperSrc +paperUnits +paperWidth papyrus par parOf @@ -4246,6 +4267,7 @@ rowDrillCount rowFields rowGrandTotals rowHeaderCaption +rowHidden rowHierarchiesUsage rowHierarchyUsage rowItems @@ -4306,6 +4328,7 @@ saka salmon salt saltData +saltValue sameClick sameDir sampData @@ -4605,6 +4628,7 @@ singleclick size sizeAuto sizeRepresents +sizeWithCells skew skewamt skewangle @@ -4797,6 +4821,7 @@ starsTop start startAngle startAt +startChars startDate startNum startOverride @@ -5065,6 +5090,7 @@ textField textFields textFile textFit +textHAlign textInflate textInflateBottom textInflateTop @@ -5081,6 +5107,7 @@ textSlantUp textStop textTriangle textTriangleInverted +textVAlign textWave1 textWave2 textWave4 @@ -5433,6 +5460,7 @@ userhidden users uturnArrow v +v2 v3 v3v4 v4 diff --git a/oox/source/vml/vmldrawing.cxx b/oox/source/vml/vmldrawing.cxx index 44eb8106ee8e..6483f2053a42 100644 --- a/oox/source/vml/vmldrawing.cxx +++ b/oox/source/vml/vmldrawing.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -279,3 +280,5 @@ void Drawing::notifyXShapeInserted( const Reference< XShape >& /*rxShape*/, } // namespace vml } // namespave oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/vml/vmldrawingfragment.cxx b/oox/source/vml/vmldrawingfragment.cxx index 591e85482448..12dd0a42fabf 100644 --- a/oox/source/vml/vmldrawingfragment.cxx +++ b/oox/source/vml/vmldrawingfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -63,7 +64,7 @@ ContextHandlerRef DrawingFragment::onCreateContext( sal_Int32 nElement, const At { // DOCX filter handles plain shape elements with this fragment handler case VMLDRAWING_WORD: - if( isRootElement() ) + if ( getNamespace( nElement ) == NMSP_vml ) return ShapeContextBase::createShapeContext( *this, mrDrawing.getShapes(), nElement, rAttribs ); break; @@ -93,3 +94,5 @@ void DrawingFragment::finalizeImport() } // namespace vml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx index 3810fa010ac2..9faeb0463a39 100644 --- a/oox/source/vml/vmlformatting.cxx +++ b/oox/source/vml/vmlformatting.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -106,7 +107,7 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r if( (nEndPos + 1 == rValue.getLength()) && (rValue[ nEndPos ] == '%') ) return fValue / 100.0; - OSL_ENSURE( false, "ConversionHelper::decodePercent - unknown measure unit" ); + OSL_FAIL( "ConversionHelper::decodePercent - unknown measure unit" ); return fDefValue; } @@ -118,9 +119,9 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r return 0; // TODO: according to spec, value may contain "auto" - if( rValue.equalsAscii( "auto" ) ) + if( rValue.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "auto" ) ) ) { - OSL_ENSURE( false, "ConversionHelper::decodeMeasureToEmu - special value 'auto' must be handled by caller" ); + OSL_FAIL( "ConversionHelper::decodeMeasureToEmu - special value 'auto' must be handled by caller" ); return nRefValue; } @@ -165,7 +166,7 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r } else if( bDefaultAsPixel || (aUnit.getLength() > 0) ) // default as EMU and no unit -> do nothing { - OSL_ENSURE( false, "ConversionHelper::decodeMeasureToEmu - unknown measure unit" ); + OSL_FAIL( "ConversionHelper::decodeMeasureToEmu - unknown measure unit" ); fValue = nRefValue; } return static_cast< sal_Int64 >( fValue + 0.5 ); @@ -263,7 +264,7 @@ bool lclExtractDouble( double& orfValue, sal_Int32& ornEndPos, const OUString& r } } - OSL_ENSURE( false, OStringBuffer( "ConversionHelper::decodeColor - invalid VML color name '" ). + OSL_FAIL( OStringBuffer( "lclGetColor - invalid VML color name '" ). append( OUStringToOString( roVmlColor.get(), RTL_TEXTENCODING_ASCII_US ) ).append( '\'' ).getStr() ); aDmlColor.setSrgbClr( nDefaultRgb ); return aDmlColor; @@ -585,3 +586,5 @@ void FillModel::pushToPropMap( ShapePropertyMap& rPropMap, const GraphicHelper& } // namespace vml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/vml/vmlinputstream.cxx b/oox/source/vml/vmlinputstream.cxx index ef2f408d79b0..bec1654b2097 100644 --- a/oox/source/vml/vmlinputstream.cxx +++ b/oox/source/vml/vmlinputstream.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -93,7 +94,7 @@ inline void lclAppendToBuffer( OStringBuffer& rBuffer, const sal_Char* pcBeg, co void lclProcessAttribs( OStringBuffer& rBuffer, const sal_Char* pcBeg, const sal_Char* pcEnd ) { /* Map attribute names to char-pointer of all attributes. This map is used - to find multiple occurences of attributes with the same name. The + to find multiple occurrences of attributes with the same name. The mapped pointers are used as map key in the next map below. */ typedef ::std::map< OString, const sal_Char* > AttributeNameMap; AttributeNameMap aAttributeNames; @@ -144,7 +145,7 @@ void lclProcessAttribs( OStringBuffer& rBuffer, const sal_Char* pcBeg, const sal } } - // if no error has occured, build the resulting attribute list + // if no error has occurred, build the resulting attribute list if( bOk ) for( AttributeDataMap::iterator aIt = aAttributes.begin(), aEnd = aAttributes.end(); aIt != aEnd; ++aIt ) rBuffer.append( ' ' ).append( aIt->second ); @@ -399,3 +400,5 @@ OString InputStream::readToElementEnd() throw (IOException, RuntimeException) } // namespace vml } // namespave oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 5e1a9a8d3e1d..32f957cca9a3 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,16 +29,22 @@ #include "oox/vml/vmlshape.hxx" #include <com/sun/star/beans/PropertyValues.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/XControlModel.hpp> #include <com/sun/star/drawing/PointSequenceSequence.hpp> #include <com/sun/star/drawing/XEnhancedCustomShapeDefaulter.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/text/HoriOrientation.hpp> +#include <com/sun/star/text/RelOrientation.hpp> +#include <com/sun/star/text/SizeType.hpp> +#include <com/sun/star/text/VertOrientation.hpp> +#include <com/sun/star/text/XTextContent.hpp> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/text/XTextFrame.hpp> #include <rtl/math.hxx> #include <rtl/ustrbuf.hxx> -#include "oox/core/xmlfilterbase.hxx" #include "oox/drawingml/shapepropertymap.hxx" -#include "oox/helper/containerhelper.hxx" #include "oox/helper/graphichelper.hxx" #include "oox/helper/propertyset.hxx" #include "oox/ole/axcontrol.hxx" @@ -46,6 +53,13 @@ #include "oox/vml/vmldrawing.hxx" #include "oox/vml/vmlshapecontainer.hxx" #include "oox/vml/vmltextbox.hxx" +#include "oox/core/xmlfilterbase.hxx" +#include "oox/helper/containerhelper.hxx" + +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::uno::Any; + +using namespace ::com::sun::star::text; namespace oox { namespace vml { @@ -92,6 +106,65 @@ Rectangle lclGetAbsRect( const Rectangle& rRelRect, const Rectangle& rShapeRect, return aAbsRect; } +void lclInsertTextFrame( const XmlFilterBase& rFilter, const Reference< XShape >& rxShape ) +{ + OSL_ENSURE( rxShape.is(), "lclInsertTextFrame - missing XShape" ); + if ( rxShape.is( ) ) + { + try + { + Reference< XTextDocument > xDoc( rFilter.getModel( ), UNO_QUERY_THROW ); + Reference< XTextContent > xCtnt( rxShape, UNO_QUERY_THROW ); + xCtnt->attach( xDoc->getText( )->getStart( ) ); + } + catch( Exception& ) + { + } + } +} + +void lclSetXShapeRect( const Reference< XShape >& rxShape, const Rectangle& rShapeRect ) +{ + OSL_ENSURE( rxShape.is(), "lclSetXShapeRect - missing XShape" ); + if( rxShape.is() ) + { + Reference< XTextFrame > xTextFrame( rxShape, UNO_QUERY ); + if ( !xTextFrame.is( ) ) + { + rxShape->setPosition( Point( rShapeRect.X, rShapeRect.Y ) ); + rxShape->setSize( Size( rShapeRect.Width, rShapeRect.Height ) ); + } + else + { + Reference< XPropertySet > xProps( xTextFrame, UNO_QUERY_THROW ); + try + { + // The size + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("SizeType")), Any( SizeType::FIX ) ); + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("FrameIsAutomaticHeight")), Any( sal_False ) ); + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Height")), Any( rShapeRect.Height ) ); + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("Width")), Any( rShapeRect.Width ) ); + + // The position + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition")), Any( rShapeRect.X ) ); + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrientRelation")), + Any( RelOrientation::FRAME ) ); + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("HoriOrient")), + Any( HoriOrientation::NONE ) ); + + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition")), Any( rShapeRect.Y ) ); + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrientRelation")), + Any( RelOrientation::FRAME ) ); + xProps->setPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("VertOrient")), + Any( VertOrientation::NONE ) ); + } + catch ( Exception& ) + { + } + } + } +} + } // namespace // ============================================================================ @@ -151,11 +224,19 @@ Rectangle ShapeType::getRectangle( const ShapeParentAnchor* pParentAnchor ) cons Rectangle ShapeType::getAbsRectangle() const { const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper(); + + sal_Int32 nWidth = ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maWidth, 0, true, true ); + if ( nWidth == 0 ) + nWidth = 1; + + sal_Int32 nHeight = ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maHeight, 0, true, true ); + if ( nHeight == 0 ) + nHeight = 1; + return Rectangle( ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maLeft, 0, true, true ) + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maMarginLeft, 0, true, true ), ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maTop, 0, false, true ) + ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maMarginTop, 0, false, true ), - ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maWidth, 0, true, true ), - ConversionHelper::decodeMeasureToHmm( rGraphicHelper, maTypeModel.maHeight, 0, false, true ) ); + nWidth, nHeight ); } Rectangle ShapeType::getRelRectangle() const @@ -565,3 +646,5 @@ Reference< XShape > GroupShape::implConvertAndInsert( const Reference< XShapes > } // namespace vml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/vml/vmlshapecontainer.cxx b/oox/source/vml/vmlshapecontainer.cxx index 9589549be0d9..e8a8d025c7fd 100644 --- a/oox/source/vml/vmlshapecontainer.cxx +++ b/oox/source/vml/vmlshapecontainer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -134,3 +135,5 @@ void ShapeContainer::convertAndInsert( const Reference< XShapes >& rxShapes, con } // namespace vml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 54e0d1ac70bc..591fc2a91ce1 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -226,6 +227,7 @@ ShapeContextBase::ShapeContextBase( ContextHandler2Helper& rParent ) : case VML_TOKEN( shape ): return new ShapeContext( rParent, rShapes.createShape< ComplexShape >(), rAttribs ); case VML_TOKEN( rect ): + return new RectangleShapeContext( rParent, rAttribs, rShapes.createShape< RectangleShape >() ); case VML_TOKEN( roundrect ): return new ShapeContext( rParent, rShapes.createShape< RectangleShape >(), rAttribs ); case VML_TOKEN( oval ): @@ -310,7 +312,10 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const A mrTypeModel.maFillModel.moRotate = lclDecodeBool( rAttribs, XML_rotate ); break; case VML_TOKEN( imagedata ): - mrTypeModel.moGraphicPath = decodeFragmentPath( rAttribs, O_TOKEN( relid ) ); + // shapes in docx use r:id for the relationship id + // in xlsx it they use o:relid + bool bHasORelId = rAttribs.hasAttribute( O_TOKEN( relid ) ); + mrTypeModel.moGraphicPath = decodeFragmentPath( rAttribs, bHasORelId ? O_TOKEN( relid ) : R_TOKEN( id ) ); mrTypeModel.moGraphicTitle = rAttribs.getString( O_TOKEN( title ) ); break; } @@ -334,13 +339,13 @@ void ShapeTypeContext::setStyle( const OUString& rStyle ) OUString aName, aValue; if( ConversionHelper::separatePair( aName, aValue, rStyle.getToken( 0, ';', nIndex ), ':' ) ) { - if( aName.equalsAscii( "position" ) ) mrTypeModel.maPosition = aValue; - else if( aName.equalsAscii( "left" ) ) mrTypeModel.maLeft = aValue; - else if( aName.equalsAscii( "top" ) ) mrTypeModel.maTop = aValue; - else if( aName.equalsAscii( "width" ) ) mrTypeModel.maWidth = aValue; - else if( aName.equalsAscii( "height" ) ) mrTypeModel.maHeight = aValue; - else if( aName.equalsAscii( "margin-left" ) ) mrTypeModel.maMarginLeft = aValue; - else if( aName.equalsAscii( "margin-top" ) ) mrTypeModel.maMarginTop = aValue; + if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "position" ) ) ) mrTypeModel.maPosition = aValue; + else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "left" ) ) ) mrTypeModel.maLeft = aValue; + else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "top" ) ) ) mrTypeModel.maTop = aValue; + else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "width" ) ) ) mrTypeModel.maWidth = aValue; + else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "height" ) ) ) mrTypeModel.maHeight = aValue; + else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "margin-left" ) ) ) mrTypeModel.maMarginLeft = aValue; + else if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "margin-top" ) ) ) mrTypeModel.maMarginTop = aValue; } } } @@ -349,6 +354,7 @@ void ShapeTypeContext::setStyle( const OUString& rStyle ) ShapeContext::ShapeContext( ContextHandler2Helper& rParent, ShapeBase& rShape, const AttributeList& rAttribs ) : ShapeTypeContext( rParent, rShape, rAttribs ), + mrShape( rShape ), mrShapeModel( rShape.getShapeModel() ) { // collect shape specific attributes @@ -359,6 +365,11 @@ ShapeContext::ShapeContext( ContextHandler2Helper& rParent, ShapeBase& rShape, c ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) { + // Custom shape in Writer with a textbox are transformed into a frame + if ( nElement == ( NMSP_vml + XML_textbox ) ) + dynamic_cast<SimpleShape&>( mrShape ).setService( + OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")) ); + // Excel specific shape client data if( isRootElement() ) switch( nElement ) { @@ -401,6 +412,23 @@ ContextHandlerRef GroupShapeContext::onCreateContext( sal_Int32 nElement, const // ============================================================================ +RectangleShapeContext::RectangleShapeContext( ContextHandler2Helper& rParent, const AttributeList& rAttribs, RectangleShape& rShape ) : + ShapeContext( rParent, rShape, rAttribs ) +{ +} + +ContextHandlerRef RectangleShapeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) +{ + if ( nElement == ( NMSP_vml + XML_textbox ) ) + dynamic_cast< SimpleShape &>( mrShape ).setService( + OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame")) ); + + // The parent class's context is fine + return ShapeContext::onCreateContext( nElement, rAttribs ); +} +// ============================================================================ + } // namespace vml } // namespace oox +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx index f56eb387d5b2..8bb1c39bbe1f 100755..100644 --- a/oox/source/vml/vmltextbox.cxx +++ b/oox/source/vml/vmltextbox.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -79,3 +80,5 @@ OUString TextBox::getText() const } // namespace vml } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx index 6feae68127e7..6feae68127e7 100755..100644 --- a/oox/source/vml/vmltextboxcontext.cxx +++ b/oox/source/vml/vmltextboxcontext.cxx diff --git a/oox/source/xls/addressconverter.cxx b/oox/source/xls/addressconverter.cxx index ca216bb8a84f..fd7217afac89 100644 --- a/oox/source/xls/addressconverter.cxx +++ b/oox/source/xls/addressconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -773,7 +774,7 @@ void AddressConverter::initializeMaxPos( } catch( Exception& ) { - OSL_ENSURE( false, "AddressConverter::AddressConverter - cannot get sheet limits" ); + OSL_FAIL( "AddressConverter::AddressConverter - cannot get sheet limits" ); } } @@ -781,3 +782,5 @@ void AddressConverter::initializeMaxPos( } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/autofilterbuffer.cxx b/oox/source/xls/autofilterbuffer.cxx index bfc33e82056b..987e7bcf7604 100755..100644 --- a/oox/source/xls/autofilterbuffer.cxx +++ b/oox/source/xls/autofilterbuffer.cxx @@ -772,8 +772,7 @@ void AutoFilterBuffer::finalizeImport( sal_Int16 nSheet ) if( pFilterDBName->getAbsoluteRange( aFilterRange ) && (aFilterRange.Sheet == nSheet) ) { // use the same name for the database range as used for the defined name '_FilterDatabase' - OUString aDBRangeName = pFilterDBName->getCalcName(); - Reference< XDatabaseRange > xDatabaseRange = createDatabaseRangeObject( aDBRangeName, aFilterRange ); + Reference< XDatabaseRange > xDatabaseRange = createUnnamedDatabaseRangeObject( aFilterRange ); // first, try to create an auto filter bool bHasAutoFilter = finalizeImport( xDatabaseRange ); // no success: try to create an advanced filter diff --git a/oox/source/xls/autofiltercontext.cxx b/oox/source/xls/autofiltercontext.cxx index 81327944fc05..88de30b6de65 100644 --- a/oox/source/xls/autofiltercontext.cxx +++ b/oox/source/xls/autofiltercontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -181,3 +182,5 @@ void BiffAutoFilterContext::importRecord( BiffInputStream& rStrm ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/biffcodec.cxx b/oox/source/xls/biffcodec.cxx index cb4829973fcc..19d4b7e47ce3 100644 --- a/oox/source/xls/biffcodec.cxx +++ b/oox/source/xls/biffcodec.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -328,13 +329,13 @@ BiffDecoderRef lclReadFilePassBiff8( BiffInputStream& rStrm ) xDecoder = lclReadFilePass_CryptoApi( rStrm ); break; default: - OSL_ENSURE( false, "lclReadFilePassBiff8 - unknown BIFF8 encryption sub mode" ); + OSL_FAIL( "lclReadFilePassBiff8 - unknown BIFF8 encryption sub mode" ); } } break; default: - OSL_ENSURE( false, "lclReadFilePassBiff8 - unknown encryption mode" ); + OSL_FAIL( "lclReadFilePassBiff8 - unknown encryption mode" ); } return xDecoder; } @@ -377,3 +378,5 @@ void BiffCodecHelper::cloneDecoder( BiffInputStream& rStrm ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/biffdetector.cxx b/oox/source/xls/biffdetector.cxx index 9c8267f8d84d..d55a2b3d0715 100644 --- a/oox/source/xls/biffdetector.cxx +++ b/oox/source/xls/biffdetector.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -117,8 +118,7 @@ BiffDetector::~BiffDetector() case BIFF_BOF_BIFF4: eBiff = BIFF4; break; case BIFF_BOF_BIFF5: eBiff = BIFF5; break; case BIFF_BOF_BIFF8: eBiff = BIFF8; break; - default: OSL_ENSURE( false, - OStringBuffer( "lclDetectStreamBiffVersion - unknown BIFF version: 0x" ). + default: OSL_FAIL( OStringBuffer( "lclDetectStreamBiffVersion - unknown BIFF version: 0x" ). append( static_cast< sal_Int32 >( nVersion ), 16 ).getStr() ); } } @@ -228,3 +228,5 @@ OUString SAL_CALL BiffDetector::detect( Sequence< PropertyValue >& rDescriptor ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/biffhelper.cxx b/oox/source/xls/biffhelper.cxx index b4a3a982b50c..f1a54e0fe589 100644 --- a/oox/source/xls/biffhelper.cxx +++ b/oox/source/xls/biffhelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -237,7 +238,7 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, case BIFF_ERR_NAME: nApiError = 525; break; case BIFF_ERR_NUM: nApiError = 503; break; case BIFF_ERR_NA: nApiError = 0x7FFF; break; - default: OSL_ENSURE( false, "BiffHelper::calcDoubleFromError - unknown error code" ); + default: OSL_FAIL( "BiffHelper::calcDoubleFromError - unknown error code" ); } DecodedDouble aDecDbl; ::rtl::math::setNan( &aDecDbl.mfValue ); @@ -320,7 +321,7 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, // case BIFF_IMGDATA_WMF: /* TODO */ break; case BIFF_IMGDATA_DIB: lclImportImgDataDib( orDataSeq, rStrm, nBytes, eBiff ); break; // case BIFF_IMGDATA_NATIVE: /* TODO */ break; - default: OSL_ENSURE( false, "BiffHelper::importImgData - unknown image format" ); + default: OSL_FAIL( "BiffHelper::importImgData - unknown image format" ); } } } @@ -329,3 +330,5 @@ void lclImportImgDataDib( StreamDataSequence& orDataSeq, BiffInputStream& rStrm, } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/biffinputstream.cxx b/oox/source/xls/biffinputstream.cxx index b11137aab6b9..5634ae421898 100644 --- a/oox/source/xls/biffinputstream.cxx +++ b/oox/source/xls/biffinputstream.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -590,3 +591,5 @@ BiffInputStreamPosGuard::~BiffInputStreamPosGuard() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/biffoutputstream.cxx b/oox/source/xls/biffoutputstream.cxx index 14608414c91d..df28b6e27379 100644 --- a/oox/source/xls/biffoutputstream.cxx +++ b/oox/source/xls/biffoutputstream.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -207,3 +208,5 @@ sal_uInt16 BiffOutputStream::prepareWriteBlock( sal_Int32 nTotalSize, size_t nAt } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/chartsheetfragment.cxx b/oox/source/xls/chartsheetfragment.cxx index c7a74c155a3c..3cf8114e08b3 100644 --- a/oox/source/xls/chartsheetfragment.cxx +++ b/oox/source/xls/chartsheetfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -287,3 +288,5 @@ bool BiffChartsheetFragment::importFragment() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/commentsbuffer.cxx b/oox/source/xls/commentsbuffer.cxx index f11aa89bca53..06a77df7685d 100644 --- a/oox/source/xls/commentsbuffer.cxx +++ b/oox/source/xls/commentsbuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -25,6 +26,9 @@ * ************************************************************************/ +#include <oox/token/properties.hxx> +#include <oox/token/tokens.hxx> + #include "oox/xls/commentsbuffer.hxx" #include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp> @@ -36,8 +40,18 @@ #include "oox/xls/addressconverter.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/drawingfragment.hxx" +#include "svx/sdtaitm.hxx" +#include "oox/xls/unitconverter.hxx" #include "oox/xls/drawingmanager.hxx" +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/text/XTextRange.hpp> + +using ::com::sun::star::text::XText; +using ::com::sun::star::text::XTextRange; +using ::com::sun::star::awt::Size; +using ::com::sun::star::awt::Point; + namespace oox { namespace xls { @@ -51,6 +65,38 @@ using namespace ::com::sun::star::uno; using ::rtl::OUString; +static sal_Int32 lcl_ToHorizAlign( sal_Int32 nAlign ) +{ + switch( nAlign ) + { + case XML_left: + return SDRTEXTHORZADJUST_LEFT; + case XML_right: + return SDRTEXTHORZADJUST_RIGHT; + case XML_center: + return SDRTEXTHORZADJUST_CENTER; + default: + return SDRTEXTHORZADJUST_BLOCK; + } + return SDRTEXTHORZADJUST_LEFT; +} + +static sal_Int32 lcl_ToVertAlign( sal_Int32 nAlign ) +{ + switch( nAlign ) + { + case XML_top: + return SDRTEXTVERTADJUST_TOP; + case XML_center: + return SDRTEXTVERTADJUST_CENTER; + case XML_bottom: + return SDRTEXTVERTADJUST_BOTTOM; + default: + return SDRTEXTVERTADJUST_BLOCK; + } + return SDRTEXTVERTADJUST_TOP; +} + // ============================================================================ namespace { @@ -82,6 +128,61 @@ void Comment::importComment( const AttributeList& rAttribs ) getAddressConverter().convertToCellRangeUnchecked( maModel.maRange, rAttribs.getString( XML_ref, OUString() ), getSheetIndex() ); } +void Comment::importCommentPr( const AttributeList& rAttribs ) +{ + maModel.mbAutoFill = rAttribs.getBool( XML_autoFill, true ); + maModel.mbAutoScale = rAttribs.getBool( XML_autoScale, false ); + maModel.mbColHidden = rAttribs.getBool( XML_colHidden, false ); + maModel.mbLocked = rAttribs.getBool( XML_locked, false ); + maModel.mbRowHidden = rAttribs.getBool( XML_rowHidden, false ); + maModel.mnTHA = rAttribs.getToken( XML_textHAlign, XML_left ); + maModel.mnTVA = rAttribs.getToken( XML_textVAlign, XML_top ); +} + +void Comment::importAnchor( bool bFrom, sal_Int32 nWhich, const OUString &rChars ) +{ + sal_Int32 nRow, nCol; + Point aPoint; + UnitConverter& rUnitConv = getUnitConverter(); + if( bFrom ) + { + nCol = maModel.maAnchor.X; + nRow = maModel.maAnchor.Y; + } + else + { + nCol = maModel.maAnchor.Width + maModel.maAnchor.X ; + nRow = maModel.maAnchor.Height + maModel.maAnchor.Y; + } + switch( nWhich ) + { + case XDR_TOKEN( col ): + aPoint = getCellPosition( rChars.toInt32(), 1 ); + nCol = aPoint.X; + break; + case XDR_TOKEN( colOff ): + nCol += rUnitConv.scaleToMm100( static_cast< double >( rChars.toInt32() ), UNIT_SCREENX ); + break; + case XDR_TOKEN( row ): + aPoint = getCellPosition( 1, rChars.toInt32() ); + nRow = aPoint.Y; + break; + case XDR_TOKEN( rowOff ): + nRow += rUnitConv.scaleToMm100( static_cast< double >( rChars.toInt32() ), UNIT_SCREENY ); + break; + } + if( bFrom ) + { + maModel.maAnchor.X = nCol; + maModel.maAnchor.Y = nRow; + } + else + { + maModel.maAnchor.Width = nCol - maModel.maAnchor.X; + maModel.maAnchor.Height = nRow - maModel.maAnchor.Y; + } +} + void Comment::importComment( SequenceInputStream& rStrm ) { BinRange aBinRange; @@ -150,13 +251,28 @@ void Comment::finalizeImport() switch( getFilterType() ) { case FILTER_OOXML: - if( const ::oox::vml::ShapeBase* pNoteShape = getVmlDrawing().getNoteShape( aNotePos ) ) { - // position and formatting - pNoteShape->convertFormatting( xAnnoShape ); - // visibility - const ::oox::vml::ClientData* pClientData = pNoteShape->getClientData(); - bVisible = pClientData && pClientData->mbVisible; + // Add shape formatting properties (autoFill, colHidden and rowHidden are dropped) + PropertySet aCommentPr( xAnnoShape ); + aCommentPr.setProperty( PROP_TextFitToSize, maModel.mbAutoScale ); + aCommentPr.setProperty( PROP_MoveProtect, maModel.mbLocked ); + aCommentPr.setProperty( PROP_TextHorizontalAdjust, lcl_ToHorizAlign( maModel.mnTHA ) ); + aCommentPr.setProperty( PROP_TextVerticalAdjust, lcl_ToVertAlign( maModel.mnTVA ) ); + if( maModel.maAnchor.Width > 0 && maModel.maAnchor.Height > 0 ) + { + xAnnoShape->setPosition( Point( maModel.maAnchor.X, maModel.maAnchor.Y ) ); + xAnnoShape->setSize( Size( maModel.maAnchor.Width, maModel.maAnchor.Height ) ); + } + + // convert shape formatting + if( const ::oox::vml::ShapeBase* pNoteShape = getVmlDrawing().getNoteShape( aNotePos ) ) + { + // position and formatting + pNoteShape->convertFormatting( xAnnoShape ); + // visibility + const ::oox::vml::ClientData* pClientData = pNoteShape->getClientData(); + xAnno->setIsVisible( pClientData && pClientData->mbVisible ); + } } break; case FILTER_BIFF: @@ -251,3 +367,5 @@ void CommentsBuffer::finalizeImport() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/commentsfragment.cxx b/oox/source/xls/commentsfragment.cxx index b37860c4553e..c26485f2b171 100644 --- a/oox/source/xls/commentsfragment.cxx +++ b/oox/source/xls/commentsfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -62,9 +63,21 @@ ContextHandlerRef CommentsFragment::onCreateContext( sal_Int32 nElement, const A case XLS_TOKEN( commentList ): if( nElement == XLS_TOKEN( comment ) ) { importComment( rAttribs ); return this; } break; + case XLS_TOKEN( commentPr ): + if( nElement == XLS_TOKEN( anchor ) ) + return this; + break; + case XLS_TOKEN( anchor ): + if( nElement == XDR_TOKEN( from ) || nElement == XDR_TOKEN( to ) ) + return this; + break; + case XDR_TOKEN( from ): + case XDR_TOKEN( to ): + return this; case XLS_TOKEN( comment ): if( (nElement == XLS_TOKEN( text )) && mxComment.get() ) return new RichStringContext( *this, mxComment->createText() ); + if( nElement == XLS_TOKEN( commentPr ) ) { mxComment->importCommentPr( rAttribs ); return this; } break; } return 0; @@ -144,3 +157,5 @@ void CommentsFragment::importComment( SequenceInputStream& rStrm ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/condformatbuffer.cxx b/oox/source/xls/condformatbuffer.cxx index 1914ed233f46..26355dc2a1c2 100644 --- a/oox/source/xls/condformatbuffer.cxx +++ b/oox/source/xls/condformatbuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,7 +31,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> -#include <com/sun/star/sheet/ConditionOperator.hpp> +#include <com/sun/star/sheet/ConditionOperator2.hpp> #include <com/sun/star/sheet/XSheetCellRanges.hpp> #include <com/sun/star/sheet/XSheetConditionalEntries.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> @@ -390,7 +391,7 @@ void CondFormatRule::importCfRule( SequenceInputStream& rStrm ) maModel.mnType = XML_iconSet; break; default: - OSL_ENSURE( false, "CondFormatRule::importCfRule - unknown rule type" ); + OSL_FAIL( "CondFormatRule::importCfRule - unknown rule type" ); } } @@ -430,7 +431,7 @@ void CondFormatRule::importCfRule( BiffInputStream& rStrm, sal_Int32 nPriority ) void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries >& rxEntries ) { - ConditionOperator eOperator = ConditionOperator_NONE; + sal_Int32 eOperator = ::com::sun::star::sheet::ConditionOperator2::NONE; /* Replacement formula for unsupported rule types (text comparison rules, time period rules, cell type rules). The replacement formulas below may @@ -456,8 +457,12 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > case XML_cellIs: eOperator = CondFormatBuffer::convertToApiOperator( maModel.mnOperator ); break; + case XML_duplicateValues: + eOperator = CondFormatBuffer::convertToApiOperator( XML_duplicateValues ); + aReplaceFormula = CREATE_OUSTRING( " " ); + break; case XML_expression: - eOperator = ConditionOperator_FORMULA; + eOperator = ::com::sun::star::sheet::ConditionOperator2::FORMULA; break; case XML_containsText: OSL_ENSURE( maModel.mnOperator == XML_containsText, "CondFormatRule::finalizeImport - unexpected operator" ); @@ -510,7 +515,7 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > aReplaceFormula = CREATE_OUSTRING( "OR(AND(MONTH(#B)=MONTH(TODAY())+1,YEAR(#B)=YEAR(TODAY())),AND(MONTH(#B)=1,MONTH(TODAY())=12,YEAR(#B)=YEAR(TODAY())+1))" ); break; default: - OSL_ENSURE( false, "CondFormatRule::finalizeImport - unknown time period type" ); + OSL_FAIL( "CondFormatRule::finalizeImport - unknown time period type" ); } break; case XML_containsBlanks: @@ -581,17 +586,18 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > aReplaceFormula = aReplaceFormula.replaceAt( nStrPos, 2, aComp ); break; default: - OSL_ENSURE( false, "CondFormatRule::finalizeImport - unknown placeholder" ); + OSL_FAIL( "CondFormatRule::finalizeImport - unknown placeholder" ); } } // set the replacement formula maModel.maFormulas.clear(); appendFormula( aReplaceFormula ); - eOperator = ConditionOperator_FORMULA; + if( eOperator != ::com::sun::star::sheet::ConditionOperator2::DUPLICATE ) + eOperator = ::com::sun::star::sheet::ConditionOperator2::FORMULA; } - if( rxEntries.is() && (eOperator != ConditionOperator_NONE) && !maModel.maFormulas.empty() ) + if( rxEntries.is() && (eOperator != ::com::sun::star::sheet::ConditionOperator2::NONE) && !maModel.maFormulas.empty() ) { ::std::vector< PropertyValue > aProps; // create condition properties @@ -739,20 +745,21 @@ void CondFormatBuffer::finalizeImport() maCondFormats.forEachMem( &CondFormat::finalizeImport ); } -ConditionOperator CondFormatBuffer::convertToApiOperator( sal_Int32 nToken ) +sal_Int32 CondFormatBuffer::convertToApiOperator( sal_Int32 nToken ) { switch( nToken ) { - case XML_between: return ConditionOperator_BETWEEN; - case XML_equal: return ConditionOperator_EQUAL; - case XML_greaterThan: return ConditionOperator_GREATER; - case XML_greaterThanOrEqual: return ConditionOperator_GREATER_EQUAL; - case XML_lessThan: return ConditionOperator_LESS; - case XML_lessThanOrEqual: return ConditionOperator_LESS_EQUAL; - case XML_notBetween: return ConditionOperator_NOT_BETWEEN; - case XML_notEqual: return ConditionOperator_NOT_EQUAL; + case XML_between: return ConditionOperator2::BETWEEN; + case XML_equal: return ConditionOperator2::EQUAL; + case XML_greaterThan: return ConditionOperator2::GREATER; + case XML_greaterThanOrEqual: return ConditionOperator2::GREATER_EQUAL; + case XML_lessThan: return ConditionOperator2::LESS; + case XML_lessThanOrEqual: return ConditionOperator2::LESS_EQUAL; + case XML_notBetween: return ConditionOperator2::NOT_BETWEEN; + case XML_notEqual: return ConditionOperator2::NOT_EQUAL; + case XML_duplicateValues: return ConditionOperator2::DUPLICATE; } - return ConditionOperator_NONE; + return ConditionOperator2::NONE; } // private -------------------------------------------------------------------- @@ -768,3 +775,5 @@ CondFormatRef CondFormatBuffer::createCondFormat() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/condformatcontext.cxx b/oox/source/xls/condformatcontext.cxx index 091dc11fb614..20b3f9db88c7 100644 --- a/oox/source/xls/condformatcontext.cxx +++ b/oox/source/xls/condformatcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -100,3 +101,5 @@ void CondFormatContext::onStartRecord( SequenceInputStream& rStrm ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/connectionsbuffer.cxx b/oox/source/xls/connectionsbuffer.cxx index 6d0fcd65122f..6d0fcd65122f 100755..100644 --- a/oox/source/xls/connectionsbuffer.cxx +++ b/oox/source/xls/connectionsbuffer.cxx diff --git a/oox/source/xls/connectionsfragment.cxx b/oox/source/xls/connectionsfragment.cxx index 7aafcd84cd7e..82c998d585b9 100644 --- a/oox/source/xls/connectionsfragment.cxx +++ b/oox/source/xls/connectionsfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -177,3 +178,5 @@ void ConnectionsFragment::finalizeImport() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/defnamesbuffer.cxx b/oox/source/xls/defnamesbuffer.cxx index e69cc44c8a1d..fce1bfb589ef 100644 --- a/oox/source/xls/defnamesbuffer.cxx +++ b/oox/source/xls/defnamesbuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -694,3 +695,5 @@ DefinedNameRef DefinedNamesBuffer::createDefinedName() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/drawingbase.cxx b/oox/source/xls/drawingbase.cxx index fc2ab64059c8..a8629d3c0a54 100755 --- a/oox/source/xls/drawingbase.cxx +++ b/oox/source/xls/drawingbase.cxx @@ -168,8 +168,7 @@ void ShapeAnchor::setCellPos( sal_Int32 nElement, sal_Int32 nParentContext, cons void ShapeAnchor::importVmlAnchor( const OUString& rAnchor ) { - meAnchorType = ANCHOR_TWOCELL; /// VML uses two-cell anchors only - meCellAnchorType = CELLANCHOR_PIXEL; /// VML uses screen pixels for offset values + meAnchorType = ANCHOR_VML; ::std::vector< OUString > aTokens; sal_Int32 nIndex = 0; @@ -213,6 +212,7 @@ EmuRectangle ShapeAnchor::calcAnchorRectEmu( const Size& rPageSizeHmm ) const break; case ANCHOR_ONECELL: case ANCHOR_TWOCELL: + case ANCHOR_VML: OSL_ENSURE( maFrom.isValid(), "ShapeAnchor::calcAnchorRectEmu - invalid position" ); if( maFrom.isValid() && rAddrConv.checkCol( maFrom.mnCol, true ) && rAddrConv.checkRow( maFrom.mnRow, true ) ) { @@ -239,6 +239,7 @@ EmuRectangle ShapeAnchor::calcAnchorRectEmu( const Size& rPageSizeHmm ) const } break; case ANCHOR_TWOCELL: + case ANCHOR_VML: OSL_ENSURE( maTo.isValid(), "ShapeAnchor::calcAnchorRectEmu - invalid position" ); if( maTo.isValid() ) { diff --git a/oox/source/xls/drawingfragment.cxx b/oox/source/xls/drawingfragment.cxx index 47b7e6cb2565..248677573421 100644 --- a/oox/source/xls/drawingfragment.cxx +++ b/oox/source/xls/drawingfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -48,6 +49,8 @@ namespace oox { namespace xls { +using ::rtl::OUString; + // ============================================================================ using namespace ::com::sun::star::awt; @@ -72,6 +75,21 @@ using ::rtl::OUStringToOString; // DrawingML // ============================================================================ +namespace { + +/** Converts the passed 64-bit integer value from the passed unit to EMUs. */ +sal_Int64 lclCalcEmu( const UnitConverter& rUnitConv, sal_Int64 nValue, Unit eFromUnit ) +{ + return (eFromUnit == UNIT_EMU) ? nValue : + static_cast< sal_Int64 >( rUnitConv.scaleValue( static_cast< double >( nValue ), eFromUnit, UNIT_EMU ) + 0.5 ); +} + +} // namespace + +// ============================================================================ + +// ============================================================================ + ShapeMacroAttacher::ShapeMacroAttacher( const OUString& rMacroName, const Reference< XShape >& rxShape ) : VbaMacroAttacherBase( rMacroName ), mxShape( rxShape ) @@ -265,13 +283,11 @@ void DrawingFragment::onEndElement() getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Y, 0, SAL_MAX_INT32 ), getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Width, 0, SAL_MAX_INT32 ), getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Height, 0, SAL_MAX_INT32 ) ); - mxShape->addShape( getOoxFilter(), &getTheme(), mxDrawPage, &aShapeRectEmu32 ); - /* Collect all shape positions in the WorksheetHelper base - class. But first, scale EMUs to 1/100 mm. */ - Rectangle aShapeRectHmm( - convertEmuToHmm( aShapeRectEmu.X ), convertEmuToHmm( aShapeRectEmu.Y ), - convertEmuToHmm( aShapeRectEmu.Width ), convertEmuToHmm( aShapeRectEmu.Height ) ); - extendShapeBoundingBox( aShapeRectHmm ); + basegfx::B2DHomMatrix aTransformation; + mxShape->addShape( getOoxFilter(), &getTheme(), mxDrawPage, aTransformation, &aShapeRectEmu32 ); + + // collect all shape positions in the WorksheetHelper base class + extendShapeBoundingBox( aShapeRectEmu32 ); } } mxShape.reset(); @@ -759,3 +775,5 @@ void VmlDrawingFragment::finalizeImport() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/excelchartconverter.cxx b/oox/source/xls/excelchartconverter.cxx index e2538cbc3ebc..5c63ee5ee701 100644 --- a/oox/source/xls/excelchartconverter.cxx +++ b/oox/source/xls/excelchartconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -111,7 +112,7 @@ Reference< XDataSequence > ExcelChartConverter::createDataSequence( } catch( Exception& ) { - OSL_ENSURE( false, "ExcelChartConverter::createDataSequence - cannot create data sequence" ); + OSL_FAIL( "ExcelChartConverter::createDataSequence - cannot create data sequence" ); } } return xDataSeq; @@ -121,3 +122,5 @@ Reference< XDataSequence > ExcelChartConverter::createDataSequence( } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/excelfilter.cxx b/oox/source/xls/excelfilter.cxx index eb5183a4dd80..9dd3c9f979fc 100644 --- a/oox/source/xls/excelfilter.cxx +++ b/oox/source/xls/excelfilter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -129,7 +130,12 @@ bool ExcelFilter::importDocument() throw() the class WorkbookHelper, and execute the import filter by constructing an instance of WorkbookFragment and loading the file. */ WorkbookGlobalsRef xBookGlob = WorkbookHelper::constructGlobals( *this ); - return xBookGlob.get() && importFragment( new WorkbookFragment( *xBookGlob, aWorkbookPath ) ); + if ( xBookGlob.get() && importFragment( new WorkbookFragment( *xBookGlob, aWorkbookPath ) ) ) + { + importDocumentProperties(); + return true; + } + return false; } bool ExcelFilter::exportDocument() throw() @@ -167,6 +173,33 @@ GraphicHelper* ExcelFilter::implCreateGraphicHelper() const return new ExcelVbaProject( getComponentContext(), Reference< XSpreadsheetDocument >( getModel(), UNO_QUERY ) ); } + +sal_Bool SAL_CALL ExcelFilter::filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rDescriptor ) throw( ::com::sun::star::uno::RuntimeException ) +{ + if ( XmlFilterBase::filter( rDescriptor ) ) + return true; + + if ( isExportFilter() ) + { + Reference< XExporter > xExporter( getServiceFactory()->createInstance( CREATE_OUSTRING( "com.sun.star.comp.oox.ExcelFilterExport" ) ), UNO_QUERY ); + + if ( xExporter.is() ) + { + Reference< XComponent > xDocument( getModel(), UNO_QUERY ); + Reference< XFilter > xFilter( xExporter, UNO_QUERY ); + + if ( xFilter.is() ) + { + xExporter->setSourceDocument( xDocument ); + if ( xFilter->filter( rDescriptor ) ) + return true; + } + } + } + + return false; +} + OUString ExcelFilter::implGetImplementationName() const { return ExcelFilter_getImplementationName(); @@ -323,3 +356,5 @@ OUString ExcelVbaProjectFilter::implGetImplementationName() const } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/excelhandlers.cxx b/oox/source/xls/excelhandlers.cxx index 15f9d8297032..a2019edef585 100644 --- a/oox/source/xls/excelhandlers.cxx +++ b/oox/source/xls/excelhandlers.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -212,3 +213,5 @@ bool BiffSkipWorksheetFragment::importFragment() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/excelvbaproject.cxx b/oox/source/xls/excelvbaproject.cxx index 7fc8115cc680..7fc8115cc680 100755..100644 --- a/oox/source/xls/excelvbaproject.cxx +++ b/oox/source/xls/excelvbaproject.cxx diff --git a/oox/source/xls/externallinkbuffer.cxx b/oox/source/xls/externallinkbuffer.cxx index aa4d7a068530..df5eccff2bf8 100644 --- a/oox/source/xls/externallinkbuffer.cxx +++ b/oox/source/xls/externallinkbuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -374,7 +375,7 @@ bool ExternalName::getDdeLinkData( OUString& orDdeServer, OUString& orDdeTopic, } catch( Exception& ) { - OSL_ENSURE( false, "ExternalName::getDdeLinkData - cannot create DDE link" ); + OSL_FAIL( "ExternalName::getDdeLinkData - cannot create DDE link" ); } // get link data from created DDE link if( mxDdeLink.is() ) @@ -583,7 +584,7 @@ void ExternalLink::importExternalBook( const Relations& rRelations, SequenceInpu } break; default: - OSL_ENSURE( false, "ExternalLink::importExternalBook - unknown link type" ); + OSL_FAIL( "ExternalLink::importExternalBook - unknown link type" ); } } @@ -1137,3 +1138,5 @@ const RefSheetsModel* ExternalLinkBuffer::getRefSheets( sal_Int32 nRefId ) const } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/externallinkfragment.cxx b/oox/source/xls/externallinkfragment.cxx index 094b192b817c..04909ceb4166 100644 --- a/oox/source/xls/externallinkfragment.cxx +++ b/oox/source/xls/externallinkfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -495,7 +496,7 @@ void BiffExternalSheetDataContext::importCrn( BiffInputStream& rStrm ) rStrm.skip( 7 ); break; default: - OSL_ENSURE( false, "BiffExternalSheetDataContext::importCrn - unknown data type" ); + OSL_FAIL( "BiffExternalLinkFragment::importCrn - unknown data type" ); bLoop = false; } } @@ -546,3 +547,5 @@ bool BiffExternalLinkFragment::importFragment() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/formulabase.cxx b/oox/source/xls/formulabase.cxx index 25398f9aa133..abdfbf3ba1bb 100755..100644 --- a/oox/source/xls/formulabase.cxx +++ b/oox/source/xls/formulabase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -872,7 +873,7 @@ FunctionProviderImpl::FunctionProviderImpl( FilterType eFilter, BiffType eBiff, nMaxParam = BIFF_MAX_PARAMCOUNT; break; case FILTER_UNKNOWN: - OSL_ENSURE( false, "FunctionProviderImpl::FunctionProviderImpl - invalid filter type" ); + OSL_FAIL( "FunctionProviderImpl::FunctionProviderImpl - invalid filter type" ); break; } OSL_ENSURE( eBiff != BIFF_UNKNOWN, "FunctionProviderImpl::FunctionProviderImpl - invalid BIFF type" ); @@ -1120,7 +1121,7 @@ OpCodeProviderImpl::OpCodeProviderImpl( const FunctionInfoVector& rFuncInfos, } catch( Exception& ) { - OSL_ENSURE( false, "OpCodeProviderImpl::OpCodeProviderImpl - cannot receive formula opcode mapper" ); + OSL_FAIL( "OpCodeProviderImpl::OpCodeProviderImpl - cannot receive formula opcode mapper" ); } } @@ -1173,8 +1174,7 @@ bool OpCodeProviderImpl::initOpCode( sal_Int32& ornOpCode, const OpCodeEntrySequ ornOpCode = rEntrySeq[ nSpecialId ].Token.OpCode; return true; } - OSL_ENSURE( false, - OStringBuffer( "OpCodeProviderImpl::initOpCode - opcode for special offset " ). + OSL_FAIL( OStringBuffer( "OpCodeProviderImpl::initOpCode - opcode for special offset " ). append( nSpecialId ).append( " not found" ).getStr() ); return false; } @@ -1194,8 +1194,7 @@ bool OpCodeProviderImpl::initOpCode( sal_Int32& ornOpCode, const ApiTokenMap& rT } return true; } - OSL_ENSURE( false, - OStringBuffer( "OpCodeProviderImpl::initOpCode - opcode for \"" ). + OSL_FAIL( OStringBuffer( "OpCodeProviderImpl::initOpCode - opcode for \"" ). append( OUStringToOString( rOdfName, RTL_TEXTENCODING_ASCII_US ) ). append( "\" not found" ).getStr() ); return false; @@ -1698,3 +1697,5 @@ void FormulaProcessorBase::convertStringToStringList( } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/formulaparser.cxx b/oox/source/xls/formulaparser.cxx index 674f9a8e6320..fa96869afadc 100644 --- a/oox/source/xls/formulaparser.cxx +++ b/oox/source/xls/formulaparser.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -371,7 +372,7 @@ const ApiToken* FormulaFinalizer::findParameters( ParameterPosVector& rParams, void FormulaFinalizer::appendEmptyParameter( const FunctionInfo& rFuncInfo, size_t nParam ) { - // remeber old size of the token array + // remember old size of the token array size_t nTokenArraySize = maTokens.size(); switch( rFuncInfo.mnBiff12FuncId ) @@ -592,6 +593,7 @@ FormulaParserImpl::FormulaParserImpl( const FormulaParser& rParent ) : mnMaxXlsRow( rParent.getAddressConverter().getMaxXlsAddress().Row ), mbRelativeAsOffset( false ), mb2dRefsAs3dRefs( false ), + mbSpecialTokens( false ), mbAllowNulChars( false ) { // reserve enough space to make resize(), push_back() etc. cheap @@ -605,19 +607,19 @@ FormulaParserImpl::FormulaParserImpl( const FormulaParser& rParent ) : ApiTokenSequence FormulaParserImpl::importOoxFormula( const CellAddress&, const OUString& ) { - OSL_ENSURE( false, "FormulaParserImpl::importOoxFormula - not implemented" ); + OSL_FAIL( "FormulaParserImpl::importOoxFormula - not implemented" ); return ApiTokenSequence(); } ApiTokenSequence FormulaParserImpl::importBiff12Formula( const CellAddress&, FormulaType, SequenceInputStream& ) { - OSL_ENSURE( false, "FormulaParserImpl::importBiff12Formula - not implemented" ); + OSL_FAIL( "FormulaParserImpl::importBiff12Formula - not implemented" ); return ApiTokenSequence(); } ApiTokenSequence FormulaParserImpl::importBiffFormula( const CellAddress&, FormulaType, BiffInputStream&, const sal_uInt16* ) { - OSL_ENSURE( false, "FormulaParserImpl::importBiffFormula - not implemented" ); + OSL_FAIL( "FormulaParserImpl::importBiffFormula - not implemented" ); return ApiTokenSequence(); } @@ -1668,14 +1670,14 @@ bool OoxFormulaParserImpl::importArrayToken( SequenceInputStream& rStrm ) appendRawToken( OPCODE_PUSH ) <<= BiffHelper::readString( rStrm, false ); break; case BIFF_TOK_ARRAY_BOOL: - appendRawToken( OPCODE_PUSH ) <<= static_cast< double >( (rStrm.readuInt8() == BIFF_TOK_BOOL_FALSE) ? 0.0 : 1.0 ); + appendRawToken( OPCODE_PUSH ) <<= (static_cast< double >( (rStrm.readuInt8() == BIFF_TOK_BOOL_FALSE) ? 0.0 : 1.0 )); break; case BIFF_TOK_ARRAY_ERROR: appendRawToken( OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( rStrm.readuInt8() ); rStrm.skip( 3 ); break; default: - OSL_ENSURE( false, "OoxFormulaParserImpl::importArrayToken - unknown data type" ); + OSL_FAIL( "OoxFormulaParserImpl::importArrayToken - unknown data type" ); appendRawToken( OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( BIFF_ERR_NA ); } } @@ -2385,7 +2387,7 @@ bool BiffFormulaParserImpl::importArrayToken( BiffInputStream& rStrm ) rStrm.readByteStringUC( false, getTextEncoding(), mbAllowNulChars ); break; case BIFF_DATATYPE_BOOL: - appendRawToken( OPCODE_PUSH ) <<= static_cast< double >( (rStrm.readuInt8() == BIFF_TOK_BOOL_FALSE) ? 0.0 : 1.0 ); + appendRawToken( OPCODE_PUSH ) <<= (static_cast< double >( (rStrm.readuInt8() == BIFF_TOK_BOOL_FALSE) ? 0.0 : 1.0 )); rStrm.skip( 7 ); break; case BIFF_DATATYPE_ERROR: @@ -2393,7 +2395,7 @@ bool BiffFormulaParserImpl::importArrayToken( BiffInputStream& rStrm ) rStrm.skip( 7 ); break; default: - OSL_ENSURE( false, "BiffFormulaParserImpl::importArrayToken - unknown data type" ); + OSL_FAIL( "BiffFormulaParserImpl::importArrayToken - unknown data type" ); appendRawToken( OPCODE_PUSH ) <<= BiffHelper::calcDoubleFromError( BIFF_ERR_NA ); } } @@ -2974,3 +2976,5 @@ OUString FormulaParser::importMacroName( const OUString& rFormulaString ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/numberformatsbuffer.cxx b/oox/source/xls/numberformatsbuffer.cxx index 782c138d43e2..cde00392917c 100644 --- a/oox/source/xls/numberformatsbuffer.cxx +++ b/oox/source/xls/numberformatsbuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -1833,8 +1834,7 @@ sal_Int32 lclCreatePredefinedFormat( const Reference< XNumberFormats >& rxNumFmt } catch( Exception& ) { - OSL_ENSURE( false, - OStringBuffer( "lclCreatePredefinedFormat - cannot create predefined number format " ). + OSL_FAIL( OStringBuffer( "lclCreatePredefinedFormat - cannot create predefined number format " ). append( OString::valueOf( static_cast< sal_Int32 >( nPredefId ) ) ).getStr() ); } return nIndex; @@ -1858,8 +1858,7 @@ sal_Int32 lclCreateFormat( const Reference< XNumberFormats >& rxNumFmts, } else { - OSL_ENSURE( false, - OStringBuffer( "lclCreateFormat - cannot create number format '" ). + OSL_FAIL( OStringBuffer( "lclCreateFormat - cannot create number format '" ). append( OUStringToOString( rFmtCode, osl_getThreadTextEncoding() ) ). append( '\'' ).getStr() ); } @@ -1971,7 +1970,7 @@ NumberFormatsBuffer::NumberFormatsBuffer( const WorkbookHelper& rHelper ) : } catch( Exception& ) { - OSL_ENSURE( false, "NumberFormatsBuffer::NumberFormatsBuffer - cannot get system locale" ); + OSL_FAIL( "NumberFormatsBuffer::NumberFormatsBuffer - cannot get system locale" ); } // create built-in formats for current locale @@ -2114,3 +2113,5 @@ void NumberFormatsBuffer::insertBuiltinFormats() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/ooxformulaparser.cxx b/oox/source/xls/ooxformulaparser.cxx index a8860a8f2131..3363a654c4d0 100644 --- a/oox/source/xls/ooxformulaparser.cxx +++ b/oox/source/xls/ooxformulaparser.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -219,3 +220,5 @@ OUString SAL_CALL OOXMLFormulaParser::printFormula( } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/pagesettings.cxx b/oox/source/xls/pagesettings.cxx index 5c1770bd6463..9082c7342af6 100644 --- a/oox/source/xls/pagesettings.cxx +++ b/oox/source/xls/pagesettings.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -48,6 +49,8 @@ #include "oox/xls/excelhandlers.hxx" #include "oox/xls/stylesbuffer.hxx" #include "oox/xls/unitconverter.hxx" +#include "tools/mapunit.hxx" +#include "xmloff/xmluconv.hxx" namespace oox { namespace xls { @@ -125,6 +128,8 @@ PageSettingsModel::PageSettingsModel() : mfHeaderMargin( OOX_MARGIN_DEFAULT_HF ), mfFooterMargin( OOX_MARGIN_DEFAULT_HF ), mnPaperSize( 1 ), + mnPaperWidth( 0 ), + mnPaperHeight( 0 ), mnCopies( 1 ), mnScale( 100 ), mnFirstPage( 1 ), @@ -183,8 +188,13 @@ void PageSettings::importPageMargins( const AttributeList& rAttribs ) void PageSettings::importPageSetup( const Relations& rRelations, const AttributeList& rAttribs ) { + OUString aStr; maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); maModel.mnPaperSize = rAttribs.getInteger( XML_paperSize, 1 ); + aStr = rAttribs.getString ( XML_paperWidth, OUString() ); + SvXMLUnitConverter::convertMeasure( maModel.mnPaperWidth, aStr, MAP_100TH_MM ); + aStr = rAttribs.getString ( XML_paperHeight, OUString() ); + SvXMLUnitConverter::convertMeasure( maModel.mnPaperHeight, aStr, MAP_100TH_MM ); maModel.mnCopies = rAttribs.getInteger( XML_copies, 1 ); maModel.mnScale = rAttribs.getInteger( XML_scale, 100 ); maModel.mnFirstPage = rAttribs.getInteger( XML_firstPageNumber, 1 ); @@ -204,8 +214,13 @@ void PageSettings::importPageSetup( const Relations& rRelations, const Attribute void PageSettings::importChartPageSetup( const Relations& rRelations, const AttributeList& rAttribs ) { + OUString aStr; maModel.maBinSettPath = rRelations.getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) ); maModel.mnPaperSize = rAttribs.getInteger( XML_paperSize, 1 ); + aStr = rAttribs.getString ( XML_paperWidth, OUString() ); + SvXMLUnitConverter::convertMeasure( maModel.mnPaperWidth, aStr, MAP_100TH_MM ); + aStr = rAttribs.getString ( XML_paperHeight, OUString() ); + SvXMLUnitConverter::convertMeasure( maModel.mnPaperHeight, aStr, MAP_100TH_MM ); maModel.mnCopies = rAttribs.getInteger( XML_copies, 1 ); maModel.mnFirstPage = rAttribs.getInteger( XML_firstPageNumber, 1 ); maModel.mnHorPrintRes = rAttribs.getInteger( XML_horizontalDpi, 600 ); @@ -907,8 +922,7 @@ Reference< XTextContent > HeaderFooterParser::createField( const OUString& rServ } catch( Exception& ) { - OSL_ENSURE( false, - OStringBuffer( "HeaderFooterParser::createField - error while creating text field \"" ). + OSL_FAIL( OStringBuffer( "HeaderFooterParser::createField - error while creating text field \"" ). append( OUStringToOString( rServiceName, RTL_TEXTENCODING_ASCII_US ) ). append( '"' ).getStr() ); } @@ -1136,13 +1150,29 @@ void PageSettingsConverter::writePageSettingsProperties( bLandscape = bChartSheet; // paper size - if( rModel.mbValidSettings && (0 < rModel.mnPaperSize) && (rModel.mnPaperSize < static_cast< sal_Int32 >( STATIC_ARRAY_SIZE( spPaperSizeTable ) )) ) + if( !rModel.mbValidSettings ) { - const ApiPaperSize& rPaperSize = spPaperSizeTable[ rModel.mnPaperSize ]; - Size aSize( rPaperSize.mnWidth, rPaperSize.mnHeight ); - if( bLandscape ) - ::std::swap( aSize.Width, aSize.Height ); - rPropSet.setProperty( PROP_Size, aSize ); + Size aSize; + bool bValid = false; + + if( (0 < rModel.mnPaperSize) && (rModel.mnPaperSize < static_cast< sal_Int32 >( STATIC_ARRAY_SIZE( spPaperSizeTable ) )) ) + { + const ApiPaperSize& rPaperSize = spPaperSizeTable[ rModel.mnPaperSize ]; + aSize = Size( rPaperSize.mnWidth, rPaperSize.mnHeight ); + bValid = true; + } + if( rModel.mnPaperWidth > 0 && rModel.mnPaperHeight > 0 ) + { + aSize = Size( rModel.mnPaperWidth, rModel.mnPaperHeight ); + bValid = true; + } + + if( bValid ) + { + if( bLandscape ) + ::std::swap( aSize.Width, aSize.Height ); + rPropSet.setProperty( PROP_Size, aSize ); + } } // header/footer @@ -1247,3 +1277,5 @@ sal_Int32 PageSettingsConverter::writeHeaderFooter( } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/pivotcachebuffer.cxx b/oox/source/xls/pivotcachebuffer.cxx index 146f3b53df8a..49652dafe34a 100644 --- a/oox/source/xls/pivotcachebuffer.cxx +++ b/oox/source/xls/pivotcachebuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -312,7 +313,7 @@ OUString PivotCacheItem::getName() const case XML_b: return OUString::valueOf( static_cast< sal_Bool >( maValue.get< bool >() ) ); // !TODO case XML_e: return OUString(); // !TODO } - OSL_ENSURE( false, "PivotCacheItem::getName - invalid data type" ); + OSL_FAIL( "PivotCacheItem::getName - invalid data type" ); return OUString(); } @@ -334,7 +335,7 @@ void PivotCacheItemList::importItem( sal_Int32 nElement, const AttributeList& rA case XLS_TOKEN( d ): rItem.readDate( rAttribs ); break; case XLS_TOKEN( b ): rItem.readBool( rAttribs ); break; case XLS_TOKEN( e ): rItem.readError( rAttribs, getUnitConverter() ); break; - default: OSL_ENSURE( false, "PivotCacheItemList::importItem - unknown element type" ); + default: OSL_FAIL( "PivotCacheItemList::importItem - unknown element type" ); } } @@ -361,7 +362,7 @@ void PivotCacheItemList::importItem( sal_Int32 nRecId, SequenceInputStream& rStr case BIFF12_ID_PCITEMA_BOOL: rItem.readBool( rStrm ); break; case BIFF12_ID_PCITEM_ERROR: case BIFF12_ID_PCITEMA_ERROR: rItem.readError( rStrm ); break; - default: OSL_ENSURE( false, "PivotCacheItemList::importItem - unknown record type" ); + default: OSL_FAIL( "PivotCacheItemList::importItem - unknown record type" ); } } @@ -420,7 +421,7 @@ void PivotCacheItemList::importArray( SequenceInputStream& rStrm ) case BIFF12_PCITEM_ARRAY_ERROR: createItem().readError( rStrm ); break; case BIFF12_PCITEM_ARRAY_DATE: createItem().readDate( rStrm ); break; default: - OSL_ENSURE( false, "PivotCacheItemList::importArray - unknown data type" ); + OSL_FAIL( "PivotCacheItemList::importArray - unknown data type" ); nIdx = nCount; } } @@ -804,7 +805,7 @@ OUString PivotCacheField::createDateGroupField( const Reference< XDataPilotField case XML_hours: aGroupInfo.GroupBy = HOURS; break; case XML_minutes: aGroupInfo.GroupBy = MINUTES; break; case XML_seconds: aGroupInfo.GroupBy = SECONDS; break; - default: OSL_ENSURE( false, "PivotCacheField::convertRangeGrouping - unknown date/time interval" ); + default: OSL_FAIL( "PivotCacheField::convertRangeGrouping - unknown date/time interval" ); } try @@ -995,7 +996,7 @@ void PivotCacheField::writeItemToSourceDataCell( WorksheetHelper& rSheetHelper, case XML_d: rSheetData.setDateTimeCell( aModel, rItem.getValue().get< DateTime >() ); break; case XML_b: rSheetData.setBooleanCell( aModel, rItem.getValue().get< bool >() ); break; case XML_e: rSheetData.setErrorCell( aModel, static_cast< sal_uInt8 >( rItem.getValue().get< sal_Int32 >() ) ); break; - default: OSL_ENSURE( false, "PivotCacheField::writeItemToSourceDataCell - unexpected item data type" ); + default: OSL_FAIL( "PivotCacheField::writeItemToSourceDataCell - unexpected item data type" ); } } } @@ -1545,7 +1546,7 @@ PivotCache* PivotCacheBuffer::importPivotCacheFragment( sal_Int32 nCacheId ) } case FILTER_UNKNOWN: - OSL_ENSURE( false, "PivotCacheBuffer::importPivotCacheFragment - unknown filter type" ); + OSL_FAIL( "PivotCacheBuffer::importPivotCacheFragment - unknown filter type" ); } return 0; } @@ -1562,3 +1563,5 @@ PivotCache& PivotCacheBuffer::createPivotCache( sal_Int32 nCacheId ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/pivotcachefragment.cxx b/oox/source/xls/pivotcachefragment.cxx index f6948917701a..d86a15851735 100644 --- a/oox/source/xls/pivotcachefragment.cxx +++ b/oox/source/xls/pivotcachefragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -255,7 +256,7 @@ ContextHandlerRef PivotCacheRecordsFragment::onCreateContext( sal_Int32 nElement case XLS_TOKEN( b ): aItem.readBool( rAttribs ); break; case XLS_TOKEN( e ): aItem.readError( rAttribs, getUnitConverter() ); break; case XLS_TOKEN( x ): aItem.readIndex( rAttribs ); break; - default: OSL_ENSURE( false, "PivotCacheRecordsFragment::onCreateContext - unexpected element" ); + default: OSL_FAIL( "OoxPivotCacheRecordsFragment::onCreateContext - unexpected element" ); } mrPivotCache.writeSourceDataCell( *this, mnColIdx, mnRowIdx, aItem ); ++mnColIdx; @@ -325,7 +326,7 @@ void PivotCacheRecordsFragment::importPCRecordItem( sal_Int32 nRecId, SequenceIn case BIFF12_ID_PCITEM_BOOL: aItem.readBool( rStrm ); break; case BIFF12_ID_PCITEM_ERROR: aItem.readError( rStrm ); break; case BIFF12_ID_PCITEM_INDEX: aItem.readIndex( rStrm ); break; - default: OSL_ENSURE( false, "PivotCacheRecordsFragment::importPCRecordItem - unexpected record" ); + default: OSL_FAIL( "OoxPivotCacheRecordsFragment::importPCRecordItem - unexpected record" ); } mrPivotCache.writeSourceDataCell( *this, mnColIdx, mnRowIdx, aItem ); ++mnColIdx; @@ -473,3 +474,5 @@ void BiffPivotCacheRecordsContext::startNextRow() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/pivottablebuffer.cxx b/oox/source/xls/pivottablebuffer.cxx index 7cdeddaa879b..3a8ea647e781 100644 --- a/oox/source/xls/pivottablebuffer.cxx +++ b/oox/source/xls/pivottablebuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -690,7 +691,7 @@ void PivotTableField::convertDataField( const PTDataFieldModel& rDataField ) case XML_stdDevp: eAggFunc = GeneralFunction_STDEVP; break; case XML_var: eAggFunc = GeneralFunction_VAR; break; case XML_varp: eAggFunc = GeneralFunction_VARP; break; - default: OSL_ENSURE( false, "PivotTableField::convertDataField - unknown aggregation function" ); + default: OSL_FAIL( "PivotTableField::convertDataField - unknown aggregation function" ); } aPropSet.setProperty( PROP_Function, eAggFunc ); @@ -1437,7 +1438,7 @@ void PivotTable::finalizeImport() } catch( Exception& ) { - OSL_ENSURE( false, "PivotTable::finalizeImport - exception while creating the DataPilot table" ); + OSL_FAIL( "PivotTable::finalizeImport - exception while creating the DataPilot table" ); } } } @@ -1565,3 +1566,5 @@ void PivotTableBuffer::finalizeImport() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/pivottablefragment.cxx b/oox/source/xls/pivottablefragment.cxx index 6e28118711c9..9d8fc1ffef5f 100644 --- a/oox/source/xls/pivottablefragment.cxx +++ b/oox/source/xls/pivottablefragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -317,3 +318,5 @@ void BiffPivotTableContext::importRecord( BiffInputStream& rStrm ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/querytablefragment.cxx b/oox/source/xls/querytablefragment.cxx index c74aa53a581e..94a6d57c0608 100644 --- a/oox/source/xls/querytablefragment.cxx +++ b/oox/source/xls/querytablefragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -104,3 +105,5 @@ void BiffQueryTableContext::importRecord( BiffInputStream& rStrm ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/richstring.cxx b/oox/source/xls/richstring.cxx index 859280ddd548..6a2bbd9eab1a 100644 --- a/oox/source/xls/richstring.cxx +++ b/oox/source/xls/richstring.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -119,6 +120,17 @@ void RichStringPortion::convert( const Reference< XText >& rxText, const Font* p } } +void RichStringPortion::writeFontProperties( const Reference<XText>& rxText, const Font* pFont ) const +{ + PropertySet aPropSet(rxText); + + if (mxFont.get()) + mxFont->writeToPropertySet(aPropSet, FONT_PROPTYPE_TEXT); + + if (lclNeedsRichTextFormat(pFont)) + pFont->writeToPropertySet(aPropSet, FONT_PROPTYPE_TEXT); +} + // ---------------------------------------------------------------------------- void FontPortionModel::read( SequenceInputStream& rStrm ) @@ -529,6 +541,16 @@ bool RichString::extractPlainString( OUString& orString, const Font* pFirstPorti void RichString::convert( const Reference< XText >& rxText, const Font* pFirstPortionFont ) const { + if (maTextPortions.size() == 1) + { + // Set text directly to the cell when the string has only one portion. + // It's much faster this way. + RichStringPortion& rPtn = *maTextPortions.front(); + rxText->setString(rPtn.getText()); + rPtn.writeFontProperties(rxText, pFirstPortionFont); + return; + } + bool bReplace = true; for( PortionVector::const_iterator aIt = maTextPortions.begin(), aEnd = maTextPortions.end(); aIt != aEnd; ++aIt ) { @@ -642,3 +664,5 @@ void RichString::createPhoneticPortions( const ::rtl::OUString& rText, PhoneticP } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/richstringcontext.cxx b/oox/source/xls/richstringcontext.cxx index a3cfbe054406..6ea5720bb3ec 100644 --- a/oox/source/xls/richstringcontext.cxx +++ b/oox/source/xls/richstringcontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -103,3 +104,5 @@ void RichStringContext::onCharacters( const OUString& rChars ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/scenariobuffer.cxx b/oox/source/xls/scenariobuffer.cxx index 8915f1ae0c7b..23636dd0be7e 100644 --- a/oox/source/xls/scenariobuffer.cxx +++ b/oox/source/xls/scenariobuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -297,3 +298,5 @@ void ScenarioBuffer::finalizeImport() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/scenariocontext.cxx b/oox/source/xls/scenariocontext.cxx index be44bc8545f2..8584e914fa1e 100644 --- a/oox/source/xls/scenariocontext.cxx +++ b/oox/source/xls/scenariocontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -124,3 +125,5 @@ void ScenariosContext::onStartRecord( SequenceInputStream& rStrm ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/sharedformulabuffer.cxx b/oox/source/xls/sharedformulabuffer.cxx new file mode 100644 index 000000000000..b2861800f2dc --- /dev/null +++ b/oox/source/xls/sharedformulabuffer.cxx @@ -0,0 +1,213 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 <com/sun/star/sheet/XFormulaTokens.hpp> +#include <rtl/ustrbuf.hxx> +#include "oox/helper/propertyset.hxx" +#include "oox/xls/addressconverter.hxx" +#include "oox/xls/biffinputstream.hxx" +#include "oox/xls/formulaparser.hxx" + +namespace oox { +namespace xls { + +// ============================================================================ + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::sheet; +using namespace ::com::sun::star::table; + +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + +// ============================================================================ + +namespace { + +bool operator==( const CellAddress& rAddr1, const CellAddress& rAddr2 ) +{ + return + (rAddr1.Sheet == rAddr2.Sheet) && + (rAddr1.Column == rAddr2.Column) && + (rAddr1.Row == rAddr2.Row); +} + +bool lclContains( const CellRangeAddress& rRange, const CellAddress& rAddr ) +{ + return + (rRange.Sheet == rAddr.Sheet) && + (rRange.StartColumn <= rAddr.Column) && (rAddr.Column <= rRange.EndColumn) && + (rRange.StartRow <= rAddr.Row) && (rAddr.Row <= rRange.EndRow); +} + +} // namespace + +// ============================================================================ + +ExtCellFormulaContext::ExtCellFormulaContext( const WorksheetHelper& rHelper, + const Reference< XFormulaTokens >& rxTokens, const CellAddress& rCellPos ) : + SimpleFormulaContext( rxTokens, false, false ), + WorksheetHelper( rHelper ) +{ + setBaseAddress( rCellPos ); +} + +void ExtCellFormulaContext::setSharedFormula( const CellAddress& rBaseAddr ) +{ + getSharedFormulas().setSharedFormulaCell( *this, rBaseAddr ); +} + +// ============================================================================ + +SharedFormulaBuffer::SharedFormulaBuffer( const WorksheetHelper& rHelper ) : + WorksheetHelper( rHelper ) +{ +} + +void SharedFormulaBuffer::importSharedFmla( const OUString& rFormula, const OUString& rSharedRange, sal_Int32 nSharedId, const CellAddress& rBaseAddr ) +{ + CellRangeAddress aFmlaRange; + if( getAddressConverter().convertToCellRange( aFmlaRange, rSharedRange, getSheetIndex(), true, true ) ) + { + // create the defined name representing the shared formula + OSL_ENSURE( lclContains( aFmlaRange, rBaseAddr ), "SharedFormulaBuffer::importSharedFmla - invalid range for shared formula" ); + BinAddress aMapKey( nSharedId, 0 ); + Reference< XNamedRange > xNamedRange = createDefinedName( aMapKey ); + // convert the formula definition + Reference< XFormulaTokens > xTokens( xNamedRange, UNO_QUERY ); + if( xTokens.is() ) + { + SimpleFormulaContext aContext( xTokens, true, false ); + aContext.setBaseAddress( rBaseAddr ); + getFormulaParser().importFormula( aContext, rFormula ); + updateCachedCell( rBaseAddr, aMapKey ); + } + } +} + +void SharedFormulaBuffer::importSharedFmla( SequenceInputStream& rStrm, const CellAddress& rBaseAddr ) +{ + BinRange aRange; + rStrm >> aRange; + CellRangeAddress aFmlaRange; + if( getAddressConverter().convertToCellRange( aFmlaRange, aRange, getSheetIndex(), true, true ) ) + { + // create the defined name representing the shared formula + OSL_ENSURE( lclContains( aFmlaRange, rBaseAddr ), "SharedFormulaBuffer::importSharedFmla - invalid range for shared formula" ); + BinAddress aMapKey( rBaseAddr ); + Reference< XNamedRange > xNamedRange = createDefinedName( aMapKey ); + // load the formula definition + Reference< XFormulaTokens > xTokens( xNamedRange, UNO_QUERY ); + if( xTokens.is() ) + { + SimpleFormulaContext aContext( xTokens, true, false ); + aContext.setBaseAddress( rBaseAddr ); + getFormulaParser().importFormula( aContext, rStrm ); + updateCachedCell( rBaseAddr, aMapKey ); + } + } +} + +void SharedFormulaBuffer::importSharedFmla( BiffInputStream& rStrm, const CellAddress& rBaseAddr ) +{ + BinRange aRange; + aRange.read( rStrm, false ); // always 8bit column indexes + CellRangeAddress aFmlaRange; + if( getAddressConverter().convertToCellRange( aFmlaRange, aRange, getSheetIndex(), true, true ) ) + { + // create the defined name representing the shared formula + OSL_ENSURE( lclContains( aFmlaRange, rBaseAddr ), "SharedFormulaBuffer::importSharedFmla - invalid range for shared formula" ); + BinAddress aMapKey( rBaseAddr ); + Reference< XNamedRange > xNamedRange = createDefinedName( aMapKey ); + // load the formula definition + Reference< XFormulaTokens > xTokens( xNamedRange, UNO_QUERY ); + if( xTokens.is() ) + { + rStrm.skip( 2 ); // flags + SimpleFormulaContext aContext( xTokens, true, false ); + aContext.setBaseAddress( rBaseAddr ); + getFormulaParser().importFormula( aContext, rStrm ); + updateCachedCell( rBaseAddr, aMapKey ); + } + } +} + +void SharedFormulaBuffer::setSharedFormulaCell( ExtCellFormulaContext& rContext, const CellAddress& rBaseAddr ) +{ + if( !implSetSharedFormulaCell( rContext, BinAddress( rBaseAddr ) ) ) + if( rContext.getBaseAddress() == rBaseAddr ) + mxLastContext.reset( new ExtCellFormulaContext( rContext ) ); +} + +void SharedFormulaBuffer::setSharedFormulaCell( ExtCellFormulaContext& rContext, sal_Int32 nSharedId ) +{ + implSetSharedFormulaCell( rContext, BinAddress( nSharedId, 0 ) ); +} + +Reference< XNamedRange > SharedFormulaBuffer::createDefinedName( const BinAddress& rMapKey ) +{ + OSL_ENSURE( maIndexMap.count( rMapKey ) == 0, "SharedFormulaBuffer::createDefinedName - shared formula exists already" ); + // create the defined name representing the shared formula + OUString aName = OUStringBuffer().appendAscii( "__shared_" ). + append( static_cast< sal_Int32 >( getSheetIndex() + 1 ) ). + append( sal_Unicode( '_' ) ).append( rMapKey.mnRow ). + append( sal_Unicode( '_' ) ).append( rMapKey.mnCol ).makeStringAndClear(); + Reference< XNamedRange > xNamedRange = createNamedRangeObject( aName ); + PropertySet aNameProps( xNamedRange ); + aNameProps.setProperty( PROP_IsSharedFormula, true ); + sal_Int32 nTokenIndex = -1; + if( aNameProps.getProperty( nTokenIndex, PROP_TokenIndex ) && (nTokenIndex >= 0) ) + maIndexMap[ rMapKey ] = nTokenIndex; + return xNamedRange; +} + +bool SharedFormulaBuffer::implSetSharedFormulaCell( ExtCellFormulaContext& rContext, const BinAddress& rMapKey ) +{ + TokenIndexMap::const_iterator aIt = maIndexMap.find( rMapKey ); + sal_Int32 nTokenIndex = (aIt == maIndexMap.end()) ? -1 : aIt->second; + if( nTokenIndex >= 0 ) + { + getFormulaParser().convertNameToFormula( rContext, nTokenIndex ); + return true; + } + return false; +} + +void SharedFormulaBuffer::updateCachedCell( const CellAddress& rBaseAddr, const BinAddress& rMapKey ) +{ + if( mxLastContext.get() && (mxLastContext->getBaseAddress() == rBaseAddr) ) + implSetSharedFormulaCell( *mxLastContext, rMapKey ); + mxLastContext.reset(); +} + +// ============================================================================ + +} // namespace xls +} // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/sharedstringsbuffer.cxx b/oox/source/xls/sharedstringsbuffer.cxx index c2464e1cf36f..eee6a2bf8471 100644 --- a/oox/source/xls/sharedstringsbuffer.cxx +++ b/oox/source/xls/sharedstringsbuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -82,3 +83,5 @@ RichStringRef SharedStringsBuffer::getString( sal_Int32 nStringId ) const } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/sharedstringsfragment.cxx b/oox/source/xls/sharedstringsfragment.cxx index bdb60f6962b8..b9eed5478044 100644 --- a/oox/source/xls/sharedstringsfragment.cxx +++ b/oox/source/xls/sharedstringsfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -100,3 +101,5 @@ void SharedStringsFragment::finalizeImport() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/sheetdatabuffer.cxx b/oox/source/xls/sheetdatabuffer.cxx index 8bdcccca10cf..4eb1349e9438 100755 --- a/oox/source/xls/sheetdatabuffer.cxx +++ b/oox/source/xls/sheetdatabuffer.cxx @@ -545,11 +545,8 @@ void SheetDataBuffer::finalizeImport() // write default formatting of remaining row range writeXfIdRowRangeProperties( maXfIdRowRange ); - // try to merge remaining inserted ranges - mergeXfIdRanges(); - // write all formatting - for( XfIdRangeMap::const_iterator aIt = maXfIdRanges.begin(), aEnd = maXfIdRanges.end(); aIt != aEnd; ++aIt ) - writeXfIdRangeProperties( aIt->second ); + for( XfIdRangeListMap::const_iterator aIt = maXfIdRangeLists.begin(), aEnd = maXfIdRangeLists.end(); aIt != aEnd; ++aIt ) + writeXfIdRangeListProperties( aIt->first.first, aIt->first.second, aIt->second ); // merge all cached merged ranges and update right/bottom cell borders for( MergedRangeList::iterator aIt = maMergedRanges.begin(), aEnd = maMergedRanges.end(); aIt != aEnd; ++aIt ) @@ -786,35 +783,50 @@ void SheetDataBuffer::setCellFormat( const CellModel& rModel, sal_Int32 nNumFmtI { if( (rModel.mnXfId >= 0) || (nNumFmtId >= 0) ) { - // try to merge existing ranges and to write some formatting properties - if( !maXfIdRanges.empty() ) + ApiCellRangeList::reverse_iterator aIt = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rbegin(); + ApiCellRangeList::reverse_iterator aItEnd = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rend(); + /* The xlsx sheet data contains row wise information. + * It is sufficient to check if the row range size is one + */ + if( aIt != aItEnd && + aIt->Sheet == rModel.maCellAddr.Sheet && + aIt->StartRow == aIt->EndRow && + aIt->StartRow == rModel.maCellAddr.Row && + (aIt->EndColumn+1) == rModel.maCellAddr.Column ) { - // get row index of last inserted cell - sal_Int32 nLastRow = maXfIdRanges.rbegin()->second.maRange.StartRow; - // row changed - try to merge ranges of last row with existing ranges - if( rModel.maCellAddr.Row != nLastRow ) + aIt->EndColumn++; // Expand Column + } + else + { + maXfIdRangeLists[ XfIdNumFmtKey (rModel.mnXfId, nNumFmtId ) ].push_back( + CellRangeAddress( rModel.maCellAddr.Sheet, rModel.maCellAddr.Column, rModel.maCellAddr.Row, + rModel.maCellAddr.Column, rModel.maCellAddr.Row ) ); + } + + aIt = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rbegin(); + aItEnd = maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].rend(); + ApiCellRangeList::reverse_iterator aItM = aIt+1; + while( aItM != aItEnd ) + { + if( aIt->Sheet == aItM->Sheet ) { - mergeXfIdRanges(); - // write format properties of all ranges above last row and remove them - XfIdRangeMap::iterator aIt = maXfIdRanges.begin(), aEnd = maXfIdRanges.end(); - while( aIt != aEnd ) + /* Try to merge this with the previous range */ + if( aIt->StartRow == (aItM->EndRow + 1) && + aIt->StartColumn == aItM->StartColumn && + aIt->EndColumn == aItM->EndColumn) { - // check that range cannot be merged with current row, and that range is not in cached row range - if( (aIt->second.maRange.EndRow < nLastRow) && !maXfIdRowRange.intersects( aIt->second.maRange ) ) - { - writeXfIdRangeProperties( aIt->second ); - maXfIdRanges.erase( aIt++ ); - } - else - ++aIt; + aItM->EndRow = aIt->EndRow; + maXfIdRangeLists[ XfIdNumFmtKey( rModel.mnXfId, nNumFmtId ) ].pop_back(); + break; } + else if( aIt->StartRow > aItM->EndRow + 1 ) + break; // Un-necessary to check with any other rows } + else + break; + ++aItM; } - // try to expand last existing range, or create new range entry - if( maXfIdRanges.empty() || !maXfIdRanges.rbegin()->second.tryExpand( rModel.maCellAddr, rModel.mnXfId, nNumFmtId ) ) - maXfIdRanges[ BinAddress( rModel.maCellAddr ) ].set( rModel.maCellAddr, rModel.mnXfId, nNumFmtId ); - // update merged ranges for 'center across selection' and 'fill' if( const Xf* pXf = getStyles().getCellXf( rModel.mnXfId ).get() ) { @@ -846,38 +858,18 @@ void SheetDataBuffer::writeXfIdRowRangeProperties( const XfIdRowRange& rXfIdRowR } } -void SheetDataBuffer::writeXfIdRangeProperties( const XfIdRange& rXfIdRange ) const +void SheetDataBuffer::writeXfIdRangeListProperties( sal_Int32 nXfId, sal_Int32 nNumFmtId, const ApiCellRangeList& rRanges ) const { StylesBuffer& rStyles = getStyles(); PropertyMap aPropMap; - if( rXfIdRange.mnXfId >= 0 ) - rStyles.writeCellXfToPropertyMap( aPropMap, rXfIdRange.mnXfId ); - if( rXfIdRange.mnNumFmtId >= 0 ) - rStyles.writeNumFmtToPropertyMap( aPropMap, rXfIdRange.mnNumFmtId ); - PropertySet aPropSet( getCellRange( rXfIdRange.maRange ) ); + if( nXfId >= 0 ) + rStyles.writeCellXfToPropertyMap( aPropMap, nXfId ); + if( nNumFmtId >= 0 ) + rStyles.writeNumFmtToPropertyMap( aPropMap, nNumFmtId ); + PropertySet aPropSet( getCellRangeList( rRanges ) ); aPropSet.setProperties( aPropMap ); } -void SheetDataBuffer::mergeXfIdRanges() -{ - if( !maXfIdRanges.empty() ) - { - // get row index of last range - sal_Int32 nLastRow = maXfIdRanges.rbegin()->second.maRange.StartRow; - // process all ranges located in the same row of the last range - XfIdRangeMap::iterator aMergeIt = maXfIdRanges.end(); - while( (aMergeIt != maXfIdRanges.begin()) && ((--aMergeIt)->second.maRange.StartRow == nLastRow) ) - { - const XfIdRange& rMergeXfIdRange = aMergeIt->second; - // try to find a range that can be merged with rMergeRange - bool bFound = false; - for( XfIdRangeMap::iterator aIt = maXfIdRanges.begin(); !bFound && (aIt != aMergeIt); ++aIt ) - if( (bFound = aIt->second.tryMerge( rMergeXfIdRange )) == true ) - maXfIdRanges.erase( aMergeIt++ ); - } - } -} - void SheetDataBuffer::finalizeMergedRange( const CellRangeAddress& rRange ) { bool bMultiCol = rRange.StartColumn < rRange.EndColumn; diff --git a/oox/source/xls/sheetdatacontext.cxx b/oox/source/xls/sheetdatacontext.cxx index 00c4e21d82e7..569126e0ebad 100644 --- a/oox/source/xls/sheetdatacontext.cxx +++ b/oox/source/xls/sheetdatacontext.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -806,9 +807,10 @@ void BiffSheetDataContext::importBoolErr( BiffInputStream& rStrm ) mrSheetData.setErrorCell( maCellData, nValue ); break; default: - OSL_ENSURE( false, "BiffSheetDataContext::importBoolErr - unknown cell type" ); + OSL_FAIL( "BiffSheetDataContext::importBoolErr - unknown cell type" ); maCellData.mnCellType = XML_TOKEN_INVALID; mrSheetData.setBlankCell( maCellData ); + break; } } } @@ -972,7 +974,7 @@ void BiffSheetDataContext::importDataTable( BiffInputStream& rStrm ) } break; default: - OSL_ENSURE( false, "BiffSheetDataContext::importDataTable - unknown record id" ); + OSL_FAIL( "BiffSheetDataContext::importDataTable - unknown record id" ); } aModel.maRef1 = FormulaProcessorBase::generateAddress2dString( aRef1, false ); aModel.maRef2 = FormulaProcessorBase::generateAddress2dString( aRef2, false ); @@ -994,3 +996,5 @@ void BiffSheetDataContext::importSharedFmla( BiffInputStream& rStrm ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/stylesbuffer.cxx b/oox/source/xls/stylesbuffer.cxx index eddb5463be4e..df6d93c3f53c 100644 --- a/oox/source/xls/stylesbuffer.cxx +++ b/oox/source/xls/stylesbuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -42,6 +43,9 @@ #include <com/sun/star/style/XStyle.hpp> #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/XText.hpp> +#include <com/sun/star/table/CellVertJustify2.hpp> +#include <com/sun/star/table/CellJustifyMethod.hpp> +#include <com/sun/star/table/TableBorder.hpp> #include <rtl/tencinfo.h> #include <rtl/ustrbuf.hxx> #include "oox/core/filterbase.hxx" @@ -55,6 +59,7 @@ #include "oox/xls/themebuffer.hxx" #include "oox/xls/unitconverter.hxx" +using ::com::sun::star::table::BorderLine2; namespace oox { namespace xls { @@ -207,7 +212,7 @@ const sal_uInt8 BIFF_FONTUNDERL_DOUBLE_ACC = 34; const sal_uInt16 BIFF_XF_LOCKED = 0x0001; const sal_uInt16 BIFF_XF_HIDDEN = 0x0002; const sal_uInt16 BIFF_XF_STYLE = 0x0004; -const sal_uInt16 BIFF_XF_STYLEPARENT = 0x0FFF; /// Syles don't have a parent. +const sal_uInt16 BIFF_XF_STYLEPARENT = 0x0FFF; /// Styles don't have a parent. const sal_uInt16 BIFF_XF_WRAPTEXT = 0x0008; /// Automatic line break. const sal_uInt16 BIFF_XF_JUSTLASTLINE = 0x0080; const sal_uInt16 BIFF_XF_SHRINK = 0x0010; /// Shrink to fit into cell. @@ -361,7 +366,7 @@ void Color::importColor( const AttributeList& rAttribs ) setIndexed( rAttribs.getInteger( XML_indexed, -1 ), rAttribs.getDouble( XML_tint, 0.0 ) ); else { - OSL_ENSURE( false, "Color::importColor - unknown color type" ); + OSL_FAIL( "Color::importColor - unknown color type" ); setAuto(); } } @@ -397,7 +402,7 @@ void Color::importColor( SequenceInputStream& rStrm ) rStrm.skip( 4 ); break; default: - OSL_ENSURE( false, "Color::importColor - unknown color type" ); + OSL_FAIL( "Color::importColor - unknown color type" ); setAuto(); rStrm.skip( 4 ); } @@ -571,7 +576,7 @@ sal_Int32 ColorPalette::getColor( sal_Int32 nPaletteIdx ) const case OOX_COLOR_NOTEBACK: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_infoBk ); break; case OOX_COLOR_NOTETEXT: nColor = getBaseFilter().getGraphicHelper().getSystemColor( XML_infoText ); break; case OOX_COLOR_FONTAUTO: nColor = API_RGB_TRANSPARENT; break; - default: OSL_ENSURE( false, "ColorPalette::getColor - unknown color index" ); + default: OSL_FAIL( "ColorPalette::getColor - unknown color index" ); } return nColor; } @@ -888,7 +893,7 @@ void Font::importDxfFlag( sal_Int32 nElement, SequenceInputStream& rStrm ) maUsedFlags.mbShadowUsed = true; break; default: - OSL_ENSURE( false, "Font::importDxfFlag - unexpected element identifier" ); + OSL_FAIL( "Font::importDxfFlag - unexpected element identifier" ); } } @@ -1163,10 +1168,11 @@ void Font::writeToPropertyMap( PropertyMap& rPropMap, FontPropertyType ePropType if( maUsedFlags.mbShadowUsed ) rPropMap[ PROP_CharShadowed ] <<= maApiData.mbShadow; // escapement - if( maUsedFlags.mbEscapementUsed && (ePropType == FONT_PROPTYPE_TEXT) ) + if( maUsedFlags.mbEscapementUsed ) { rPropMap[ PROP_CharEscapement ] <<= maApiData.mnEscapement; - rPropMap[ PROP_CharEscapementHeight ] <<= maApiData.mnEscapeHeight; + if( ePropType == FONT_PROPTYPE_TEXT ) + rPropMap[ PROP_CharEscapementHeight ] <<= maApiData.mnEscapeHeight; } } @@ -1260,7 +1266,9 @@ void AlignmentModel::setBiffTextOrient( sal_uInt8 nTextOrient ) ApiAlignmentData::ApiAlignmentData() : meHorJustify( ::com::sun::star::table::CellHoriJustify_STANDARD ), - meVerJustify( ::com::sun::star::table::CellVertJustify_STANDARD ), + mnHorJustifyMethod( ::com::sun::star::table::CellJustifyMethod::AUTO ), + mnVerJustify( ::com::sun::star::table::CellVertJustify2::STANDARD ), + mnVerJustifyMethod( ::com::sun::star::table::CellJustifyMethod::AUTO ), meOrientation( ::com::sun::star::table::CellOrientation_STANDARD ), mnRotation( 0 ), mnWritingMode( ::com::sun::star::text::WritingMode2::PAGE ), @@ -1274,7 +1282,9 @@ bool operator==( const ApiAlignmentData& rLeft, const ApiAlignmentData& rRight ) { return (rLeft.meHorJustify == rRight.meHorJustify) && - (rLeft.meVerJustify == rRight.meVerJustify) && + (rLeft.mnHorJustifyMethod == rRight.mnHorJustifyMethod) && + (rLeft.mnVerJustify == rRight.mnVerJustify) && + (rLeft.mnVerJustifyMethod == rRight.mnVerJustifyMethod) && (rLeft.meOrientation == rRight.meOrientation) && (rLeft.mnRotation == rRight.mnRotation) && (rLeft.mnWritingMode == rRight.mnWritingMode) && @@ -1371,16 +1381,22 @@ void Alignment::finalizeImport() case XML_right: maApiData.meHorJustify = csstab::CellHoriJustify_RIGHT; break; } + if (maModel.mnHorAlign == XML_distributed) + maApiData.mnHorJustifyMethod = csstab::CellJustifyMethod::DISTRIBUTE; + // vertical alignment switch( maModel.mnVerAlign ) { - case XML_bottom: maApiData.meVerJustify = csstab::CellVertJustify_BOTTOM; break; - case XML_center: maApiData.meVerJustify = csstab::CellVertJustify_CENTER; break; - case XML_distributed: maApiData.meVerJustify = csstab::CellVertJustify_TOP; break; - case XML_justify: maApiData.meVerJustify = csstab::CellVertJustify_TOP; break; - case XML_top: maApiData.meVerJustify = csstab::CellVertJustify_TOP; break; + case XML_bottom: maApiData.mnVerJustify = csstab::CellVertJustify2::BOTTOM; break; + case XML_center: maApiData.mnVerJustify = csstab::CellVertJustify2::CENTER; break; + case XML_distributed: maApiData.mnVerJustify = csstab::CellVertJustify2::BLOCK; break; + case XML_justify: maApiData.mnVerJustify = csstab::CellVertJustify2::BLOCK; break; + case XML_top: maApiData.mnVerJustify = csstab::CellVertJustify2::TOP; break; } + if (maModel.mnVerAlign == XML_distributed) + maApiData.mnVerJustifyMethod = csstab::CellJustifyMethod::DISTRIBUTE; + /* indentation: expressed as number of blocks of 3 space characters in OOXML/BIFF12, and as multiple of 10 points in BIFF8. */ sal_Int32 nIndent = 0; @@ -1420,7 +1436,9 @@ void Alignment::finalizeImport() void Alignment::writeToPropertyMap( PropertyMap& rPropMap ) const { rPropMap[ PROP_HoriJustify ] <<= maApiData.meHorJustify; - rPropMap[ PROP_VertJustify ] <<= maApiData.meVerJustify; + rPropMap[ PROP_HoriJustifyMethod ] <<= maApiData.mnHorJustifyMethod; + rPropMap[ PROP_VertJustify ] <<= maApiData.mnVerJustify; + rPropMap[ PROP_VertJustifyMethod ] <<= maApiData.mnVerJustifyMethod; rPropMap[ PROP_WritingMode ] <<= maApiData.mnWritingMode; rPropMap[ PROP_RotateAngle ] <<= maApiData.mnRotation; rPropMap[ PROP_Orientation ] <<= maApiData.meOrientation; @@ -1497,6 +1515,15 @@ void Protection::writeToPropertyMap( PropertyMap& rPropMap ) const // ============================================================================ +namespace { + +bool lcl_isBorder(const ::com::sun::star::table::BorderLine& rBorder) +{ + return (rBorder.InnerLineWidth > 0) || (rBorder.OuterLineWidth > 0); +} + +} + BorderLineModel::BorderLineModel( bool bDxf ) : mnStyle( XML_none ), mbUsed( !bDxf ) @@ -1544,10 +1571,10 @@ 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)); + ( ( lcl_isBorder( maTop ) && maTop.OuterLineWidth > 0 ) ) || + ( ( lcl_isBorder( maBottom ) && maBottom.OuterLineWidth > 0 ) ) || + ( ( lcl_isBorder( maLeft ) && maLeft.OuterLineWidth > 0 ) ) || + ( ( lcl_isBorder( maRight ) && maRight.OuterLineWidth > 0 ) ); } namespace { @@ -1585,7 +1612,10 @@ bool operator==( const TableBorder& rLeft, const TableBorder& rRight ) bool operator==( const ApiBorderData& rLeft, const ApiBorderData& rRight ) { return - (rLeft.maBorder == rRight.maBorder) && + (rLeft.maLeft == rRight.maLeft) && + (rLeft.maRight == rRight.maRight) && + (rLeft.maTop == rRight.maTop) && + (rLeft.maBottom == rRight.maBottom) && (rLeft.maTLtoBR == rRight.maTLtoBR) && (rLeft.maBLtoTR == rRight.maBLtoTR) && (rLeft.mbBorderUsed == rRight.mbBorderUsed) && @@ -1609,7 +1639,7 @@ inline sal_Int32 lclGetBorderLineWidth( const BorderLine& rBorderLine ) return rBorderLine.OuterLineWidth + rBorderLine.LineDistance + rBorderLine.InnerLineWidth; } -const BorderLine* lclGetThickerLine( const BorderLine& rBorderLine1, sal_Bool bValid1, const BorderLine& rBorderLine2, sal_Bool bValid2 ) +const BorderLine2* lclGetThickerLine( const BorderLine2& rBorderLine1, sal_Bool bValid1, const BorderLine2& rBorderLine2, sal_Bool bValid2 ) { if( bValid1 && bValid2 ) return (lclGetBorderLineWidth( rBorderLine1 ) < lclGetBorderLineWidth( rBorderLine2 )) ? &rBorderLine2 : &rBorderLine1; @@ -1747,21 +1777,10 @@ void Border::finalizeImport() maApiData.mbBorderUsed = maModel.maLeft.mbUsed || maModel.maRight.mbUsed || maModel.maTop.mbUsed || maModel.maBottom.mbUsed; maApiData.mbDiagUsed = maModel.maDiagonal.mbUsed; - maApiData.maBorder.IsLeftLineValid = convertBorderLine( maApiData.maBorder.LeftLine, maModel.maLeft ); - maApiData.maBorder.IsRightLineValid = convertBorderLine( maApiData.maBorder.RightLine, maModel.maRight ); - maApiData.maBorder.IsTopLineValid = convertBorderLine( maApiData.maBorder.TopLine, maModel.maTop ); - maApiData.maBorder.IsBottomLineValid = convertBorderLine( maApiData.maBorder.BottomLine, maModel.maBottom ); - - if( !mbDxf ) - { - maApiData.maBorder.IsVerticalLineValid = maApiData.maBorder.IsLeftLineValid || maApiData.maBorder.IsRightLineValid; - if( const BorderLine* pVertLine = lclGetThickerLine( maApiData.maBorder.LeftLine, maApiData.maBorder.IsLeftLineValid, maApiData.maBorder.RightLine, maApiData.maBorder.IsRightLineValid ) ) - maApiData.maBorder.VerticalLine = *pVertLine; - - maApiData.maBorder.IsHorizontalLineValid = maApiData.maBorder.IsTopLineValid || maApiData.maBorder.IsBottomLineValid; - if( const BorderLine* pHorLine = lclGetThickerLine( maApiData.maBorder.TopLine, maApiData.maBorder.IsTopLineValid, maApiData.maBorder.BottomLine, maApiData.maBorder.IsBottomLineValid ) ) - maApiData.maBorder.HorizontalLine = *pHorLine; - } + convertBorderLine( maApiData.maLeft, maModel.maLeft ); + convertBorderLine( maApiData.maRight, maModel.maRight ); + convertBorderLine( maApiData.maTop, maModel.maTop ); + convertBorderLine( maApiData.maBottom, maModel.maBottom ); if( maModel.mbDiagTLtoBR ) convertBorderLine( maApiData.maTLtoBR, maModel.maDiagonal ); @@ -1772,7 +1791,12 @@ void Border::finalizeImport() void Border::writeToPropertyMap( PropertyMap& rPropMap ) const { if( maApiData.mbBorderUsed ) - rPropMap[ PROP_TableBorder ] <<= maApiData.maBorder; + { + rPropMap[ PROP_LeftBorder ] <<= maApiData.maLeft; + rPropMap[ PROP_RightBorder ] <<= maApiData.maRight; + rPropMap[ PROP_TopBorder ] <<= maApiData.maTop; + rPropMap[ PROP_BottomBorder ] <<= maApiData.maBottom; + } if( maApiData.mbDiagUsed ) { rPropMap[ PROP_DiagonalTLBR ] <<= maApiData.maTLtoBR; @@ -1780,6 +1804,23 @@ void Border::writeToPropertyMap( PropertyMap& rPropMap ) const } } +bool Border::hasBorder() const +{ + if (lcl_isBorder(maApiData.maBottom)) + return true; + + if (lcl_isBorder(maApiData.maTop)) + return true; + + if (lcl_isBorder(maApiData.maLeft)) + return true; + + if (lcl_isBorder(maApiData.maRight)) + return true; + + return false; +} + BorderLineModel* Border::getBorderLine( sal_Int32 nElement ) { switch( nElement ) @@ -1793,15 +1834,25 @@ BorderLineModel* Border::getBorderLine( sal_Int32 nElement ) return 0; } -bool Border::convertBorderLine( BorderLine& rBorderLine, const BorderLineModel& rModel ) +bool Border::convertBorderLine( BorderLine2& rBorderLine, const BorderLineModel& rModel ) { rBorderLine.Color = rModel.maColor.getColor( getBaseFilter().getGraphicHelper(), API_RGB_BLACK ); switch( rModel.mnStyle ) { case XML_dashDot: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break; case XML_dashDotDot: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break; - case XML_dashed: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break; - case XML_dotted: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); break; + case XML_dashed: + { + lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); + rBorderLine.LineStyle = API_LINE_DASHED; + break; + } + case XML_dotted: + { + lclSetBorderLineWidth( rBorderLine, API_LINE_THIN ); + rBorderLine.LineStyle = API_LINE_DOTTED; + break; + } case XML_double: lclSetBorderLineWidth( rBorderLine, API_LINE_THIN, API_LINE_THIN, API_LINE_THIN ); break; case XML_hair: lclSetBorderLineWidth( rBorderLine, API_LINE_HAIR ); break; case XML_medium: lclSetBorderLineWidth( rBorderLine, API_LINE_MEDIUM ); break; @@ -2475,6 +2526,11 @@ void Xf::writeToPropertyMap( PropertyMap& rPropMap ) const rStyles.writeFillToPropertyMap( rPropMap, maModel.mnFillId ); if( maModel.mbAlignUsed || maModel.mbBorderUsed ) rPropMap[ PROP_RotateReference ] <<= meRotationRef; + + ::com::sun::star::table::CellVertJustify eRotRef = ::com::sun::star::table::CellVertJustify_STANDARD; + if (maModel.mbBorderUsed && rStyles.hasBorder(maModel.mnBorderId) && maAlignment.getApiData().mnRotation) + eRotRef = ::com::sun::star::table::CellVertJustify_BOTTOM; + rPropMap[ PROP_RotateReference ] <<= eRotRef; } void Xf::writeToPropertySet( PropertySet& rPropSet ) const @@ -3043,6 +3099,9 @@ void CellStyleBuffer::finalizeImport() for( CellStyleVector::iterator aIt = maBuiltinStyles.begin(), aEnd = maBuiltinStyles.end(); aIt != aEnd; ++aIt ) { const CellStyleModel& rModel = (*aIt)->getModel(); + if (rModel.isDefaultStyle()) + continue; + OUString aStyleName = lclGetBuiltinStyleName( rModel.mnBuiltinId, rModel.maName, rModel.mnLevel ); OSL_ENSURE( bReserveAll || (aCellStyles.count( aStyleName ) == 0), "CellStyleBuffer::finalizeImport - multiple styles with equal built-in identifier" ); @@ -3083,6 +3142,16 @@ void CellStyleBuffer::finalizeImport() // set final names and create user-defined and modified built-in cell styles aCellStyles.forEachMemWithKey( &CellStyle::finalizeImport ); + + if (mxDefStyle) + { + Reference<XNameAccess> xNA(getStyleFamily(false), UNO_QUERY_THROW); + if (xNA->hasByName(CREATE_OUSTRING("Default"))) + { + PropertySet aPropSet(xNA->getByName(CREATE_OUSTRING("Default"))); + getStyles().writeStyleXfToPropertySet(aPropSet, mxDefStyle->getModel().mnXfId); + } + } } sal_Int32 CellStyleBuffer::getDefaultXfId() const @@ -3494,6 +3563,12 @@ void StylesBuffer::writeCellXfToPropertySet( PropertySet& rPropSet, sal_Int32 nX pXf->writeToPropertySet( rPropSet ); } +bool StylesBuffer::hasBorder( sal_Int32 nBorderId ) const +{ + Border* pBorder = maBorders.get( nBorderId ).get(); + return pBorder && pBorder->hasBorder(); +} + void StylesBuffer::writeStyleXfToPropertySet( PropertySet& rPropSet, sal_Int32 nXfId ) const { if( Xf* pXf = maStyleXfs.get( nXfId ).get() ) @@ -3504,3 +3579,5 @@ void StylesBuffer::writeStyleXfToPropertySet( PropertySet& rPropSet, sal_Int32 n } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/stylesfragment.cxx b/oox/source/xls/stylesfragment.cxx index c890196dc518..21e0db7287eb 100644 --- a/oox/source/xls/stylesfragment.cxx +++ b/oox/source/xls/stylesfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -327,3 +328,5 @@ void StylesFragment::finalizeImport() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/tablebuffer.cxx b/oox/source/xls/tablebuffer.cxx index 91fad31e6ee4..d3390204bce7 100644 --- a/oox/source/xls/tablebuffer.cxx +++ b/oox/source/xls/tablebuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -93,7 +94,7 @@ void Table::finalizeImport() if( (maModel.mnId > 0) && (maModel.maDisplayName.getLength() > 0) ) try { maDBRangeName = maModel.maDisplayName; - Reference< XDatabaseRange > xDatabaseRange( createDatabaseRangeObject( maDBRangeName, maModel.maRange ), UNO_SET_THROW ); + Reference< XDatabaseRange > xDatabaseRange( createUnnamedDatabaseRangeObject( maModel.maRange ), UNO_SET_THROW ); maDestRange = xDatabaseRange->getDataArea(); // get formula token index of the database range @@ -106,7 +107,7 @@ void Table::finalizeImport() } catch( Exception& ) { - OSL_ENSURE( false, "Table::finalizeImport - cannot create database range" ); + OSL_FAIL( "Table::finalizeImport - cannot create database range" ); } } @@ -162,3 +163,5 @@ void TableBuffer::insertTableToMaps( const TableRef& rxTable ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/tablefragment.cxx b/oox/source/xls/tablefragment.cxx index 37503f8577fb..874b370c1ded 100644 --- a/oox/source/xls/tablefragment.cxx +++ b/oox/source/xls/tablefragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -104,3 +105,5 @@ const RecordInfo* TableFragment::getRecordInfos() const } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/themebuffer.cxx b/oox/source/xls/themebuffer.cxx index c3e016327133..ac37d9eb4bcd 100644 --- a/oox/source/xls/themebuffer.cxx +++ b/oox/source/xls/themebuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -121,3 +122,5 @@ sal_Int32 ThemeBuffer::getColorByToken( sal_Int32 nToken ) const } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/unitconverter.cxx b/oox/source/xls/unitconverter.cxx index 1b5f1e9b072c..194c51d82beb 100644 --- a/oox/source/xls/unitconverter.cxx +++ b/oox/source/xls/unitconverter.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -257,3 +258,5 @@ double UnitConverter::getCoefficient( Unit eUnit ) const } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/viewsettings.cxx b/oox/source/xls/viewsettings.cxx index e23273b42b82..1eb07c76afc8 100644 --- a/oox/source/xls/viewsettings.cxx +++ b/oox/source/xls/viewsettings.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -774,7 +775,7 @@ void ViewSettings::finalizeImport() } catch( Exception& ) { - OSL_ENSURE( false, "ViewSettings::finalizeImport - cannot create document view settings" ); + OSL_FAIL( "ViewSettings::finalizeImport - cannot create document view settings" ); } /* Set visible area to be used if this document is an embedded OLE object. @@ -821,3 +822,5 @@ WorkbookViewModel& ViewSettings::createWorkbookView() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/workbookfragment.cxx b/oox/source/xls/workbookfragment.cxx index 13382787e958..96fd34f0c100 100644 --- a/oox/source/xls/workbookfragment.cxx +++ b/oox/source/xls/workbookfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -765,3 +766,5 @@ bool BiffWorkbookFragment::importSheetFragment( ISegmentProgressBar& rProgressBa } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/workbookhelper.cxx b/oox/source/xls/workbookhelper.cxx index a06001ca3971..d5936d68e57f 100644 --- a/oox/source/xls/workbookhelper.cxx +++ b/oox/source/xls/workbookhelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,6 +33,7 @@ #include <com/sun/star/document/XActionLockable.hpp> #include <com/sun/star/sheet/XDatabaseRange.hpp> #include <com/sun/star/sheet/XDatabaseRanges.hpp> +#include <com/sun/star/sheet/XUnnamedDatabaseRanges.hpp> #include <com/sun/star/sheet/XNamedRange.hpp> #include <com/sun/star/sheet/XNamedRanges.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> @@ -140,6 +142,8 @@ public: Reference< XNamedRange > createNamedRangeObject( OUString& orName, sal_Int32 nNameFlags ) const; /** Creates and returns a database range on-the-fly in the Calc document. */ Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr ) const; + /** Creates and returns an unnamed database range on-the-fly in the Calc document. */ + Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const; /** Creates and returns a com.sun.star.style.Style object for cells or pages. */ Reference< XStyle > createStyleObject( OUString& orStyleName, bool bPageStyle ) const; @@ -249,7 +253,7 @@ private: FilterType meFilterType; /// File type of the filter. ProgressBarPtr mxProgressBar; /// The progress bar. StorageRef mxVbaPrjStrg; /// Storage containing the VBA project. - sal_Int16 mnCurrSheet; /// Current sheet index in Calc dcument. + sal_Int16 mnCurrSheet; /// Current sheet index in Calc document. bool mbWorkbook; /// True = multi-sheet file. // buffers @@ -400,6 +404,28 @@ Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString return xDatabaseRange; } +Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const +{ + // validate cell range + CellRangeAddress aDestRange = rRangeAddr; + bool bValidRange = getAddressConverter().validateCellRange( aDestRange, true, true ); + + // create database range and insert it into the Calc document + Reference< XDatabaseRange > xDatabaseRange; + PropertySet aDocProps( mxDoc ); + Reference< XUnnamedDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_UnnamedDatabaseRanges ), UNO_QUERY_THROW ); + if( bValidRange ) try + { + xDatabaseRanges->setByTable( aDestRange ); + xDatabaseRange.set( xDatabaseRanges->getByTable( aDestRange.Sheet ), UNO_QUERY ); + } + catch( Exception& ) + { + } + OSL_ENSURE( xDatabaseRange.is(), "WorkbookData::createDatabaseRangeObject - cannot create database range" ); + return xDatabaseRange; +} + Reference< XStyle > WorkbookGlobals::createStyleObject( OUString& orStyleName, bool bPageStyle ) const { Reference< XStyle > xStyle; @@ -752,6 +778,11 @@ Reference< XDatabaseRange > WorkbookHelper::createDatabaseRangeObject( OUString& return mrBookGlob.createDatabaseRangeObject( orName, rRangeAddr ); } +Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const +{ + return mrBookGlob.createUnnamedDatabaseRangeObject( rRangeAddr ); +} + Reference< XStyle > WorkbookHelper::createStyleObject( OUString& orStyleName, bool bPageStyle ) const { return mrBookGlob.createStyleObject( orStyleName, bPageStyle ); @@ -916,3 +947,5 @@ BiffCodecHelper& WorkbookHelper::getCodecHelper() const } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/workbooksettings.cxx b/oox/source/xls/workbooksettings.cxx index 264555971ba0..f9eb011e01df 100644 --- a/oox/source/xls/workbooksettings.cxx +++ b/oox/source/xls/workbooksettings.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,6 +35,7 @@ #include "oox/core/filterbase.hxx" #include "oox/helper/attributelist.hxx" #include "oox/helper/propertyset.hxx" +#include "oox/core/xmlfilterbase.hxx" #include "oox/xls/biffinputstream.hxx" #include "oox/xls/unitconverter.hxx" @@ -137,7 +139,7 @@ void WorkbookSettings::importWorkbookPr( const AttributeList& rAttribs ) maBookSettings.mnUpdateLinksMode = rAttribs.getToken( XML_updateLinks, XML_userSet ); maBookSettings.mnDefaultThemeVer = rAttribs.getInteger( XML_defaultThemeVersion, -1 ); maBookSettings.mbSaveExtLinkValues = rAttribs.getBool( XML_saveExternalLinkValues, true ); - setDateMode( rAttribs.getBool( XML_date1904, false ) ); + setDateMode( rAttribs.getBool( XML_date1904, false ), rAttribs.getBool( XML_dateCompatibility, true ) ); } void WorkbookSettings::importCalcPr( const AttributeList& rAttribs ) @@ -350,13 +352,27 @@ sal_Int16 WorkbookSettings::getApiShowObjectMode() const Date WorkbookSettings::getNullDate() const { - static const Date saDate1900( 30, 12, 1899 ), saDate1904( 1, 1, 1904 ); + static const Date saDate1900 ( 30, 12, 1899 ); + static const Date saDate1904 ( 1, 1, 1904 ); + static const Date saDateBackCompatibility1900( 31, 12, 1899 ); + + if( getOoxFilter().getVersion() == oox::core::ISOIEC_29500_2008 ) + { + if( !maBookSettings.mbDateCompatibility ) + return saDate1900; + + return maBookSettings.mbDateMode1904 ? saDate1904 : + saDateBackCompatibility1900; + } + return maBookSettings.mbDateMode1904 ? saDate1904 : saDate1900; } -void WorkbookSettings::setDateMode( bool bDateMode1904 ) +void WorkbookSettings::setDateMode( bool bDateMode1904, bool bDateCompatibility ) { - maBookSettings.mbDateMode1904 = bDateMode1904; + maBookSettings.mbDateMode1904 = bDateMode1904; + maBookSettings.mbDateCompatibility = bDateCompatibility; + getUnitConverter().finalizeNullDate( getNullDate() ); } @@ -364,3 +380,5 @@ void WorkbookSettings::setDateMode( bool bDateMode1904 ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/worksheetbuffer.cxx b/oox/source/xls/worksheetbuffer.cxx index 6144c35d6a55..0214da3a286c 100644 --- a/oox/source/xls/worksheetbuffer.cxx +++ b/oox/source/xls/worksheetbuffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -237,7 +238,7 @@ WorksheetBuffer::IndexNamePair WorksheetBuffer::createSheet( const OUString& rPr } catch( Exception& ) { - OSL_ENSURE( false, "WorksheetBuffer::createSheet - cannot insert or rename worksheet" ); + OSL_FAIL( "WorksheetBuffer::createSheet - cannot insert or rename worksheet" ); } return IndexNamePair( -1, OUString() ); } @@ -256,3 +257,5 @@ void WorksheetBuffer::insertSheet( const SheetInfoModel& rModel ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/worksheetfragment.cxx b/oox/source/xls/worksheetfragment.cxx index 0b57d2621331..3832a1b034f6 100644 --- a/oox/source/xls/worksheetfragment.cxx +++ b/oox/source/xls/worksheetfragment.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -561,8 +562,8 @@ void WorksheetFragment::importBrk( const AttributeList& rAttribs, bool bRowBreak { PageBreakModel aModel; aModel.mnColRow = rAttribs.getInteger( XML_id, 0 ); - aModel.mnMin = rAttribs.getInteger( XML_id, 0 ); - aModel.mnMax = rAttribs.getInteger( XML_id, 0 ); + aModel.mnMin = rAttribs.getInteger( XML_min, aModel.mnColRow ); + aModel.mnMax = rAttribs.getInteger( XML_max, aModel.mnColRow ); aModel.mbManual = rAttribs.getBool( XML_man, false ); setPageBreak( aModel, bRowBreak ); } @@ -1218,3 +1219,5 @@ void BiffWorksheetFragment::importStandardWidth( BiffInputStream& rStrm ) } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/worksheethelper.cxx b/oox/source/xls/worksheethelper.cxx index 69d17b47a570..068c89cde2d9 100644 --- a/oox/source/xls/worksheethelper.cxx +++ b/oox/source/xls/worksheethelper.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -43,7 +44,7 @@ #include <com/sun/star/sheet/XLabelRanges.hpp> #include <com/sun/star/sheet/XMultiFormulaTokens.hpp> #include <com/sun/star/sheet/XSheetCellRangeContainer.hpp> -#include <com/sun/star/sheet/XSheetCondition.hpp> +#include <com/sun/star/sheet/XSheetCondition2.hpp> #include <com/sun/star/sheet/XSheetOutline.hpp> #include <com/sun/star/sheet/XSpreadsheet.hpp> #include <com/sun/star/table/XColumnRowRange.hpp> @@ -1041,7 +1042,7 @@ void WorksheetGlobals::insertHyperlink( const CellAddress& rAddress, const OUStr } catch( const Exception& ) { - OSL_ENSURE( false, "WorksheetGlobals::insertHyperlink - cannot insert text field" ); + OSL_FAIL( "WorksheetData::insertHyperlink - cannot insert text field" ); } } } @@ -1089,7 +1090,7 @@ void WorksheetGlobals::finalizeValidationRanges() const case XML_textLength: eType = ValidationType_TEXT_LEN; break; case XML_time: eType = ValidationType_TIME; break; case XML_whole: eType = ValidationType_WHOLE; break; - default: OSL_ENSURE( false, "WorksheetGlobals::finalizeValidationRanges - unknown validation type" ); + default: OSL_FAIL( "WorksheetData::finalizeValidationRanges - unknown validation type" ); } aValProps.setProperty( PROP_Type, eType ); @@ -1100,7 +1101,7 @@ void WorksheetGlobals::finalizeValidationRanges() const case XML_information: eAlertStyle = ValidationAlertStyle_INFO; break; case XML_stop: eAlertStyle = ValidationAlertStyle_STOP; break; case XML_warning: eAlertStyle = ValidationAlertStyle_WARNING; break; - default: OSL_ENSURE( false, "WorksheetGlobals::finalizeValidationRanges - unknown error style" ); + default: OSL_FAIL( "WorksheetData::finalizeValidationRanges - unknown error style" ); } aValProps.setProperty( PROP_ErrorAlertStyle, eAlertStyle ); @@ -1122,8 +1123,8 @@ void WorksheetGlobals::finalizeValidationRanges() const try { // condition operator - Reference< XSheetCondition > xSheetCond( xValidation, UNO_QUERY_THROW ); - xSheetCond->setOperator( CondFormatBuffer::convertToApiOperator( aIt->mnOperator ) ); + Reference< XSheetCondition2 > xSheetCond( xValidation, UNO_QUERY_THROW ); + xSheetCond->setConditionOperator( CondFormatBuffer::convertToApiOperator( aIt->mnOperator ) ); // condition formulas Reference< XMultiFormulaTokens > xTokens( xValidation, UNO_QUERY_THROW ); @@ -1689,3 +1690,5 @@ void WorksheetHelper::finalizeWorksheetImport() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/xls/worksheetsettings.cxx b/oox/source/xls/worksheetsettings.cxx index cc1aa45f2012..e415c2f35cd6 100644 --- a/oox/source/xls/worksheetsettings.cxx +++ b/oox/source/xls/worksheetsettings.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -346,3 +347,5 @@ void WorksheetSettings::finalizeImport() } // namespace xls } // namespace oox + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |