summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-03 11:09:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-03 12:18:17 +0200
commitb8f15244054aea276152494ee9f79318a70658e7 (patch)
tree679ffc12ec777a9d4fc201e8a2ad48c99f724a94 /oox
parent4f5b4d2a4f509a02581730a61fc9f52ea882cad8 (diff)
loplugin:flatten in oox
Change-Id: Ia57944653fa10e864822518372acab83555e0f20 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91618 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/core/filterbase.cxx34
-rw-r--r--oox/source/core/filterdetect.cxx32
-rw-r--r--oox/source/core/xmlfilterbase.cxx114
-rw-r--r--oox/source/docprop/docprophandler.cxx126
-rw-r--r--oox/source/docprop/ooxmldocpropimport.cxx42
-rw-r--r--oox/source/drawingml/chart/chartdrawingfragment.cxx42
-rw-r--r--oox/source/drawingml/chart/converterbase.cxx85
-rw-r--r--oox/source/drawingml/chart/objectformatter.cxx232
-rw-r--r--oox/source/drawingml/chart/plotareaconverter.cxx10
-rw-r--r--oox/source/drawingml/chart/seriesconverter.cxx86
-rw-r--r--oox/source/drawingml/chart/titleconverter.cxx62
-rw-r--r--oox/source/drawingml/chart/typegroupconverter.cxx158
-rw-r--r--oox/source/drawingml/fillproperties.cxx680
-rw-r--r--oox/source/drawingml/lineproperties.cxx108
-rw-r--r--oox/source/drawingml/shape.cxx36
-rw-r--r--oox/source/drawingml/textbodyproperties.cxx31
-rw-r--r--oox/source/dump/dumperbase.cxx48
-rw-r--r--oox/source/dump/oledumper.cxx96
-rw-r--r--oox/source/export/chartexport.cxx511
-rw-r--r--oox/source/export/drawingml.cxx380
-rw-r--r--oox/source/export/vmlexport.cxx64
-rw-r--r--oox/source/helper/binaryoutputstream.cxx24
-rw-r--r--oox/source/helper/propertymap.cxx22
-rw-r--r--oox/source/helper/storagebase.cxx36
-rw-r--r--oox/source/helper/zipstorage.cxx5
-rw-r--r--oox/source/ole/axcontrol.cxx5
-rw-r--r--oox/source/ole/olehelper.cxx92
-rw-r--r--oox/source/ole/vbacontrol.cxx225
-rw-r--r--oox/source/ole/vbaproject.cxx16
-rw-r--r--oox/source/ppt/pptimport.cxx35
-rw-r--r--oox/source/ppt/pptshapegroupcontext.cxx30
-rw-r--r--oox/source/ppt/presentationfragmenthandler.cxx84
-rw-r--r--oox/source/ppt/slidepersist.cxx174
-rw-r--r--oox/source/ppt/soundactioncontext.cxx40
-rw-r--r--oox/source/ppt/timenodelistcontext.cxx214
-rw-r--r--oox/source/shape/ShapeContextHandler.cxx26
-rw-r--r--oox/source/vml/vmlformatting.cxx80
-rw-r--r--oox/source/vml/vmlshape.cxx52
-rw-r--r--oox/source/vml/vmltextbox.cxx30
39 files changed, 2104 insertions, 2063 deletions
diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx
index 0cb7f2a264b1..94f7c08c9b20 100644
--- a/oox/source/core/filterbase.cxx
+++ b/oox/source/core/filterbase.cxx
@@ -407,25 +407,25 @@ void SAL_CALL FilterBase::initialize( const Sequence< Any >& rArgs )
{
}
- if (rArgs.hasElements())
+ if (!rArgs.hasElements())
+ return;
+
+ Sequence<css::beans::PropertyValue> aSeq;
+ rArgs[0] >>= aSeq;
+ for (const auto& rVal : std::as_const(aSeq))
{
- Sequence<css::beans::PropertyValue> aSeq;
- rArgs[0] >>= aSeq;
- for (const auto& rVal : std::as_const(aSeq))
+ if (rVal.Name == "UserData")
+ {
+ css::uno::Sequence<OUString> aUserDataSeq;
+ rVal.Value >>= aUserDataSeq;
+ if (comphelper::findValue(aUserDataSeq, "macro-enabled") != -1)
+ mxImpl->mbExportVBA = true;
+ }
+ else if (rVal.Name == "Flags")
{
- if (rVal.Name == "UserData")
- {
- css::uno::Sequence<OUString> aUserDataSeq;
- rVal.Value >>= aUserDataSeq;
- if (comphelper::findValue(aUserDataSeq, "macro-enabled") != -1)
- mxImpl->mbExportVBA = true;
- }
- else if (rVal.Name == "Flags")
- {
- sal_Int32 nFlags(0);
- rVal.Value >>= nFlags;
- mxImpl->mbExportTemplate = bool(static_cast<SfxFilterFlags>(nFlags) & SfxFilterFlags::TEMPLATE);
- }
+ sal_Int32 nFlags(0);
+ rVal.Value >>= nFlags;
+ mxImpl->mbExportTemplate = bool(static_cast<SfxFilterFlags>(nFlags) & SfxFilterFlags::TEMPLATE);
}
}
}
diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx
index b63d355ed506..c8ce03acb75c 100644
--- a/oox/source/core/filterdetect.cxx
+++ b/oox/source/core/filterdetect.cxx
@@ -142,25 +142,25 @@ void SAL_CALL FilterDetectDocHandler::characters( const OUString& /*aChars*/ )
void FilterDetectDocHandler::parseRelationship( const AttributeList& rAttribs )
{
OUString aType = rAttribs.getString( XML_Type, OUString() );
- if ( aType == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" // OOXML Transitional
- || aType == "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument" ) //OOXML strict
+ if ( !(aType == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" // OOXML Transitional
+ || aType == "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument") ) //OOXML strict
+ return;
+
+ Reference<XUriReferenceFactory> xFactory = UriReferenceFactory::create( mxContext );
+ try
{
- Reference<XUriReferenceFactory> xFactory = 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< XUriReference > xBase = xFactory->parse( "file:///" );
+ // use '/' to representent the root of the zip package ( and provide a 'file' scheme to
+ // keep the XUriReference implementation happy )
+ Reference< XUriReference > xBase = xFactory->parse( "file:///" );
- Reference< XUriReference > xPart = xFactory->parse( rAttribs.getString( XML_Target, OUString() ) );
- Reference< XUriReference > xAbs = xFactory->makeAbsolute( xBase, xPart, true, RelativeUriExcessParentSegments_RETAIN );
+ Reference< XUriReference > xPart = xFactory->parse( rAttribs.getString( XML_Target, OUString() ) );
+ Reference< XUriReference > xAbs = xFactory->makeAbsolute( xBase, xPart, true, RelativeUriExcessParentSegments_RETAIN );
- if ( xAbs.is() )
- maTargetPath = xAbs->getPath();
- }
- catch( const Exception& )
- {
- }
+ if ( xAbs.is() )
+ maTargetPath = xAbs->getPath();
+ }
+ catch( const Exception& )
+ {
}
}
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index f59b0cbc5821..84aaef6af9db 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -963,76 +963,76 @@ OUString XmlFilterBase::getNamespaceURL(sal_Int32 nNSID) const
void XmlFilterBase::importCustomFragments(css::uno::Reference<css::embed::XStorage> const & xDocumentStorage)
{
Reference<XRelationshipAccess> xRelations(xDocumentStorage, UNO_QUERY);
- if (xRelations.is())
- {
- const uno::Sequence<uno::Sequence<beans::StringPair>> aSeqs = xRelations->getAllRelationships();
+ if (!xRelations.is())
+ return;
+
+ const uno::Sequence<uno::Sequence<beans::StringPair>> aSeqs = xRelations->getAllRelationships();
- std::vector<StreamDataSequence> aCustomFragments;
- std::vector<OUString> aCustomFragmentTypes;
- std::vector<OUString> aCustomFragmentTargets;
- for (const uno::Sequence<beans::StringPair>& aSeq : aSeqs)
+ std::vector<StreamDataSequence> aCustomFragments;
+ std::vector<OUString> aCustomFragmentTypes;
+ std::vector<OUString> aCustomFragmentTargets;
+ for (const uno::Sequence<beans::StringPair>& aSeq : aSeqs)
+ {
+ OUString sType;
+ OUString sTarget;
+ for (const beans::StringPair& aPair : aSeq)
{
- OUString sType;
- OUString sTarget;
- for (const beans::StringPair& aPair : aSeq)
- {
- if (aPair.First == "Target")
- sTarget = aPair.Second;
- else if (aPair.First == "Type")
- sType = aPair.Second;
- }
+ if (aPair.First == "Target")
+ sTarget = aPair.Second;
+ else if (aPair.First == "Type")
+ sType = aPair.Second;
+ }
- // Preserve non-standard (i.e. custom) entries.
- if (!sType.match("http://schemas.openxmlformats.org"))
+ // Preserve non-standard (i.e. custom) entries.
+ if (!sType.match("http://schemas.openxmlformats.org"))
+ {
+ StreamDataSequence aDataSeq;
+ if (importBinaryData(aDataSeq, sTarget))
{
- StreamDataSequence aDataSeq;
- if (importBinaryData(aDataSeq, sTarget))
- {
- aCustomFragments.emplace_back(aDataSeq);
- aCustomFragmentTypes.emplace_back(sType);
- aCustomFragmentTargets.emplace_back(sTarget);
- }
+ aCustomFragments.emplace_back(aDataSeq);
+ aCustomFragmentTypes.emplace_back(sType);
+ aCustomFragmentTargets.emplace_back(sTarget);
}
}
+ }
- // Adding the saved custom xml DOM
- comphelper::SequenceAsHashMap aGrabBagProperties;
- aGrabBagProperties["OOXCustomFragments"] <<= comphelper::containerToSequence(aCustomFragments);
- aGrabBagProperties["OOXCustomFragmentTypes"] <<= comphelper::containerToSequence(aCustomFragmentTypes);
- aGrabBagProperties["OOXCustomFragmentTargets"] <<= comphelper::containerToSequence(aCustomFragmentTargets);
-
- std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomList;
- std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomPropsList;
- //FIXME: Ideally, we should get these the relations, but it seems that is not consistently set.
- // In some cases it's stored in the workbook relationships, which is unexpected. So we discover them directly.
- for (int i = 1; ; ++i)
+ // Adding the saved custom xml DOM
+ comphelper::SequenceAsHashMap aGrabBagProperties;
+ aGrabBagProperties["OOXCustomFragments"] <<= comphelper::containerToSequence(aCustomFragments);
+ aGrabBagProperties["OOXCustomFragmentTypes"] <<= comphelper::containerToSequence(aCustomFragmentTypes);
+ aGrabBagProperties["OOXCustomFragmentTargets"] <<= comphelper::containerToSequence(aCustomFragmentTargets);
+
+ std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomList;
+ std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomPropsList;
+ //FIXME: Ideally, we should get these the relations, but it seems that is not consistently set.
+ // In some cases it's stored in the workbook relationships, which is unexpected. So we discover them directly.
+ for (int i = 1; ; ++i)
+ {
+ Reference<XDocument> xCustDoc = importFragment("customXml/item" + OUString::number(i) + ".xml");
+ Reference<XDocument> xCustDocProps = importFragment("customXml/itemProps" + OUString::number(i) + ".xml");
+ if (xCustDoc && xCustDocProps)
{
- Reference<XDocument> xCustDoc = importFragment("customXml/item" + OUString::number(i) + ".xml");
- Reference<XDocument> xCustDocProps = importFragment("customXml/itemProps" + OUString::number(i) + ".xml");
- if (xCustDoc && xCustDocProps)
- {
- aCustomXmlDomList.emplace_back(xCustDoc);
- aCustomXmlDomPropsList.emplace_back(xCustDocProps);
- }
- else
- break;
+ aCustomXmlDomList.emplace_back(xCustDoc);
+ aCustomXmlDomPropsList.emplace_back(xCustDocProps);
}
+ else
+ break;
+ }
- // Adding the saved custom xml DOM
- aGrabBagProperties["OOXCustomXml"] <<= comphelper::containerToSequence(aCustomXmlDomList);
- aGrabBagProperties["OOXCustomXmlProps"] <<= comphelper::containerToSequence(aCustomXmlDomPropsList);
+ // Adding the saved custom xml DOM
+ aGrabBagProperties["OOXCustomXml"] <<= comphelper::containerToSequence(aCustomXmlDomList);
+ aGrabBagProperties["OOXCustomXmlProps"] <<= comphelper::containerToSequence(aCustomXmlDomPropsList);
- // Save the [Content_Types].xml after parsing.
- uno::Sequence<uno::Sequence<beans::StringPair>> aContentTypeInfo;
- uno::Reference<io::XInputStream> xInputStream = openInputStream("[Content_Types].xml");
- if (xInputStream.is())
- aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xInputStream, getComponentContext());
+ // Save the [Content_Types].xml after parsing.
+ uno::Sequence<uno::Sequence<beans::StringPair>> aContentTypeInfo;
+ uno::Reference<io::XInputStream> xInputStream = openInputStream("[Content_Types].xml");
+ if (xInputStream.is())
+ aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xInputStream, getComponentContext());
- aGrabBagProperties["OOXContentTypes"] <<= aContentTypeInfo;
+ aGrabBagProperties["OOXContentTypes"] <<= aContentTypeInfo;
- Reference<XComponent> xModel = getModel();
- oox::core::XmlFilterBase::putPropertiesToDocumentGrabBag(xModel, aGrabBagProperties);
- }
+ Reference<XComponent> xModel = getModel();
+ oox::core::XmlFilterBase::putPropertiesToDocumentGrabBag(xModel, aGrabBagProperties);
}
void XmlFilterBase::exportCustomFragments()
diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx
index 47882a0749de..67de4a8366bd 100644
--- a/oox/source/docprop/docprophandler.cxx
+++ b/oox/source/docprop/docprophandler.cxx
@@ -69,26 +69,26 @@ void OOXMLDocPropHandler::InitNew()
void OOXMLDocPropHandler::AddCustomProperty( const uno::Any& aAny )
{
- if ( !m_aCustomPropertyName.isEmpty() )
- {
- const uno::Reference< beans::XPropertyContainer > xUserProps =
- m_xDocProp->getUserDefinedProperties();
- if ( !xUserProps.is() )
- throw uno::RuntimeException();
+ if ( m_aCustomPropertyName.isEmpty() )
+ return;
- try
- {
- xUserProps->addProperty( m_aCustomPropertyName,
- beans::PropertyAttribute::REMOVABLE, aAny );
- }
- catch( beans::PropertyExistException& )
- {
- // conflicts with core and extended properties are possible
- }
- catch( uno::Exception& )
- {
- OSL_FAIL( "Can not add custom property!" );
- }
+ const uno::Reference< beans::XPropertyContainer > xUserProps =
+ m_xDocProp->getUserDefinedProperties();
+ if ( !xUserProps.is() )
+ throw uno::RuntimeException();
+
+ try
+ {
+ xUserProps->addProperty( m_aCustomPropertyName,
+ beans::PropertyAttribute::REMOVABLE, aAny );
+ }
+ catch( beans::PropertyExistException& )
+ {
+ // conflicts with core and extended properties are possible
+ }
+ catch( uno::Exception& )
+ {
+ OSL_FAIL( "Can not add custom property!" );
}
}
@@ -245,24 +245,24 @@ void OOXMLDocPropHandler::UpdateDocStatistic( const OUString& aChars )
break;
}
- if ( !aName.isEmpty() )
- {
- sal_Int32 nInd = 0;
- for ( auto pProp = aSet.getConstArray(); nInd < aSet.getLength(); ++nInd )
- if ( pProp[nInd].Name == aName )
- break;
+ if ( aName.isEmpty() )
+ return;
- if (nInd == aSet.getLength())
- aSet.realloc( nInd + 1 );
+ sal_Int32 nInd = 0;
+ for ( auto pProp = aSet.getConstArray(); nInd < aSet.getLength(); ++nInd )
+ if ( pProp[nInd].Name == aName )
+ break;
- beans::NamedValue aProp;
- aProp.Name = aName;
- aProp.Value <<= aChars.toInt32();
+ if (nInd == aSet.getLength())
+ aSet.realloc( nInd + 1 );
- aSet[nInd] = aProp;
+ beans::NamedValue aProp;
+ aProp.Name = aName;
+ aProp.Value <<= aChars.toInt32();
- m_xDocProp->setDocumentStatistics( aSet );
- }
+ aSet[nInd] = aProp;
+
+ m_xDocProp->setDocumentStatistics( aSet );
}
// com.sun.star.xml.sax.XFastDocumentHandler
@@ -338,41 +338,41 @@ void SAL_CALL OOXMLDocPropHandler::startUnknownElement( const OUString& aNamespa
void SAL_CALL OOXMLDocPropHandler::endFastElement( ::sal_Int32 )
{
- if ( m_nInBlock )
- {
- m_nInBlock--;
+ if ( !m_nInBlock )
+ return;
- if ( !m_nInBlock )
- m_nState = 0;
- else if ( m_nInBlock == 1 )
- {
- m_nBlock = 0;
- m_aCustomPropertyName.clear();
- }
- else if ( m_nInBlock == 2 )
+ m_nInBlock--;
+
+ if ( !m_nInBlock )
+ m_nState = 0;
+ else if ( m_nInBlock == 1 )
+ {
+ m_nBlock = 0;
+ m_aCustomPropertyName.clear();
+ }
+ else if ( m_nInBlock == 2 )
+ {
+ if ( m_nState == CUSTPR_TOKEN(Properties)
+ && m_nBlock == CUSTPR_TOKEN(property))
{
- if ( m_nState == CUSTPR_TOKEN(Properties)
- && m_nBlock == CUSTPR_TOKEN(property))
+ switch (m_nType)
{
- switch (m_nType)
- {
- case VT_TOKEN(bstr):
- case VT_TOKEN(lpstr):
- case VT_TOKEN(lpwstr):
- if (!m_aCustomPropertyName.isEmpty() &&
- INSERTED != m_CustomStringPropertyState)
- {
- // the property has string type, so it is valid
- // even with an empty value - characters() has
- // not been called in that case
- AddCustomProperty(uno::makeAny(OUString()));
- }
- break;
- }
+ case VT_TOKEN(bstr):
+ case VT_TOKEN(lpstr):
+ case VT_TOKEN(lpwstr):
+ if (!m_aCustomPropertyName.isEmpty() &&
+ INSERTED != m_CustomStringPropertyState)
+ {
+ // the property has string type, so it is valid
+ // even with an empty value - characters() has
+ // not been called in that case
+ AddCustomProperty(uno::makeAny(OUString()));
+ }
+ break;
}
- m_CustomStringPropertyState = NONE;
- m_nType = 0;
}
+ m_CustomStringPropertyState = NONE;
+ m_nType = 0;
}
}
diff --git a/oox/source/docprop/ooxmldocpropimport.cxx b/oox/source/docprop/ooxmldocpropimport.cxx
index 8731ecf56897..621173b6bdea 100644
--- a/oox/source/docprop/ooxmldocpropimport.cxx
+++ b/oox/source/docprop/ooxmldocpropimport.cxx
@@ -136,27 +136,27 @@ void SAL_CALL DocumentPropertiesImport::importProperties(
if( !aCustomStreams.hasElements() )
aCustomStreams = lclGetRelatedStreams( rxSource, CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "custom-properties" ) );
- if( aCoreStreams.hasElements() || aExtStreams.hasElements() || aCustomStreams.hasElements() )
- {
- if( aCoreStreams.getLength() > 1 )
- throw IOException( "Unexpected core properties stream!" );
-
- ::oox::core::FastParser aParser;
- aParser.registerNamespace( NMSP_packageMetaCorePr );
- aParser.registerNamespace( NMSP_dc );
- aParser.registerNamespace( NMSP_dcTerms );
- aParser.registerNamespace( NMSP_officeExtPr );
- aParser.registerNamespace( NMSP_officeCustomPr );
- aParser.registerNamespace( NMSP_officeDocPropsVT );
- aParser.setDocumentHandler( new OOXMLDocPropHandler( mxContext, rxDocumentProperties ) );
-
- if( aCoreStreams.hasElements() )
- aParser.parseStream( aCoreStreams[ 0 ], true );
- for( const auto& rExtStream : std::as_const(aExtStreams) )
- aParser.parseStream( rExtStream, true );
- for( const auto& rCustomStream : std::as_const(aCustomStreams) )
- aParser.parseStream( rCustomStream, true );
- }
+ if( !(aCoreStreams.hasElements() || aExtStreams.hasElements() || aCustomStreams.hasElements()) )
+ return;
+
+ if( aCoreStreams.getLength() > 1 )
+ throw IOException( "Unexpected core properties stream!" );
+
+ ::oox::core::FastParser aParser;
+ aParser.registerNamespace( NMSP_packageMetaCorePr );
+ aParser.registerNamespace( NMSP_dc );
+ aParser.registerNamespace( NMSP_dcTerms );
+ aParser.registerNamespace( NMSP_officeExtPr );
+ aParser.registerNamespace( NMSP_officeCustomPr );
+ aParser.registerNamespace( NMSP_officeDocPropsVT );
+ aParser.setDocumentHandler( new OOXMLDocPropHandler( mxContext, rxDocumentProperties ) );
+
+ if( aCoreStreams.hasElements() )
+ aParser.parseStream( aCoreStreams[ 0 ], true );
+ for( const auto& rExtStream : std::as_const(aExtStreams) )
+ aParser.parseStream( rExtStream, true );
+ for( const auto& rCustomStream : std::as_const(aCustomStreams) )
+ aParser.parseStream( rCustomStream, true );
}
} // namespace oox::docprop
diff --git a/oox/source/drawingml/chart/chartdrawingfragment.cxx b/oox/source/drawingml/chart/chartdrawingfragment.cxx
index af20cd292368..fb775338d90c 100644
--- a/oox/source/drawingml/chart/chartdrawingfragment.cxx
+++ b/oox/source/drawingml/chart/chartdrawingfragment.cxx
@@ -201,31 +201,31 @@ void ChartDrawingFragment::onCharacters( const OUString& rChars )
void ChartDrawingFragment::onEndElement()
{
- if( isCurrentElement( CDR_TOKEN( absSizeAnchor ), CDR_TOKEN( relSizeAnchor ) ) )
+ if( !isCurrentElement( CDR_TOKEN( absSizeAnchor ), CDR_TOKEN( relSizeAnchor ) ) )
+ return;
+
+ if( mxDrawPage.is() && mxShape.get() && mxAnchor.get() )
{
- if( mxDrawPage.is() && mxShape.get() && mxAnchor.get() )
+ EmuRectangle aShapeRectEmu = mxAnchor->calcAnchorRectEmu( maChartRectEmu );
+ if( (aShapeRectEmu.X >= 0) && (aShapeRectEmu.Y >= 0) && (aShapeRectEmu.Width >= 0) && (aShapeRectEmu.Height >= 0) )
{
- EmuRectangle aShapeRectEmu = mxAnchor->calcAnchorRectEmu( maChartRectEmu );
- if( (aShapeRectEmu.X >= 0) && (aShapeRectEmu.Y >= 0) && (aShapeRectEmu.Width >= 0) && (aShapeRectEmu.Height >= 0) )
- {
- // TODO: DrawingML implementation expects 32-bit coordinates for EMU rectangles (change that to EmuRectangle)
- awt::Rectangle aShapeRectEmu32(
- getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.X, 0, SAL_MAX_INT32 ),
- 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 ) );
-
- // Set the position and size before calling addShape().
- mxShape->setPosition(awt::Point(aShapeRectEmu32.X, aShapeRectEmu32.Y));
- mxShape->setSize(awt::Size(aShapeRectEmu32.Width, aShapeRectEmu32.Height));
-
- basegfx::B2DHomMatrix aMatrix;
- mxShape->addShape( getFilter(), getFilter().getCurrentTheme(), mxDrawPage, aMatrix, mxShape->getFillProperties() );
- }
+ // TODO: DrawingML implementation expects 32-bit coordinates for EMU rectangles (change that to EmuRectangle)
+ awt::Rectangle aShapeRectEmu32(
+ getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.X, 0, SAL_MAX_INT32 ),
+ 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 ) );
+
+ // Set the position and size before calling addShape().
+ mxShape->setPosition(awt::Point(aShapeRectEmu32.X, aShapeRectEmu32.Y));
+ mxShape->setSize(awt::Size(aShapeRectEmu32.Width, aShapeRectEmu32.Height));
+
+ basegfx::B2DHomMatrix aMatrix;
+ mxShape->addShape( getFilter(), getFilter().getCurrentTheme(), mxDrawPage, aMatrix, mxShape->getFillProperties() );
}
- mxShape.reset();
- mxAnchor.reset();
}
+ mxShape.reset();
+ mxAnchor.reset();
}
} // namespace oox::drawingml::chart
diff --git a/oox/source/drawingml/chart/converterbase.cxx b/oox/source/drawingml/chart/converterbase.cxx
index 46494ebd8d8f..e24d6c72821e 100644
--- a/oox/source/drawingml/chart/converterbase.cxx
+++ b/oox/source/drawingml/chart/converterbase.cxx
@@ -76,7 +76,10 @@ struct TitleLayoutInfo
void TitleLayoutInfo::convertTitlePos( ConverterRoot const & rRoot, const Reference< cssc::XChartDocument >& rxChart1Doc )
{
- if( mxTitle.is() && mpGetShape ) try
+ if( !(mxTitle.is() && mpGetShape) )
+ return;
+
+ try
{
// try to get the title shape
Reference< XShape > xTitleShape = mpGetShape( rxChart1Doc );
@@ -387,48 +390,48 @@ bool LayoutConverter::convertFromModel( PropertySet& rPropSet )
void LayoutConverter::convertFromModel( const Reference< XShape >& rxShape, double fRotationAngle )
{
- if( !mrModel.mbAutoLayout )
+ if( mrModel.mbAutoLayout )
+ return;
+
+ awt::Size aChartSize = getChartSize();
+ if( aChartSize.Width <= 0 || aChartSize.Height <= 0 )
{
- awt::Size aChartSize = getChartSize();
- if( aChartSize.Width <= 0 || aChartSize.Height <= 0 )
- {
- aChartSize = getDefaultPageSize();
- }
- awt::Point aShapePos(
- lclCalcPosition( aChartSize.Width, mrModel.mfX, mrModel.mnXMode ),
- lclCalcPosition( aChartSize.Height, mrModel.mfY, mrModel.mnYMode ) );
- if( (aShapePos.X >= 0) && (aShapePos.Y >= 0) )
- {
- bool bPropSet = false;
- // the call to XShape.getSize() may recalc the chart view
- awt::Size aShapeSize = rxShape->getSize();
- // rotated shapes need special handling...
- if( aShapeSize.Height > 0 || aShapeSize.Width > 0 )
- {
- double fSin = fabs(sin(basegfx::deg2rad(fRotationAngle)));
- // add part of height to X direction, if title is rotated down
- if( fRotationAngle > 180.0 )
- aShapePos.X += static_cast<sal_Int32>(fSin * aShapeSize.Height + 0.5);
- // add part of width to Y direction, if title is rotated up
- else if( fRotationAngle > 0.0 )
- aShapePos.Y += static_cast<sal_Int32>(fSin * aShapeSize.Width + 0.5);
- }
- else if( fRotationAngle == 90.0 || fRotationAngle == 270.0 )
- {
- PropertySet aShapeProp( rxShape );
- RelativePosition aPos(
- getLimitedValue< double, double >(mrModel.mfX, 0.0, 1.0),
- getLimitedValue< double, double >(mrModel.mfY, 0.0, 1.0),
- fRotationAngle == 90.0 ? Alignment_TOP_RIGHT : Alignment_BOTTOM_LEFT );
- // set the resulting position at the shape
- if( aShapeProp.setProperty(PROP_RelativePosition, aPos) )
- bPropSet = true;
- }
- // set the resulting position at the shape
- if( !bPropSet )
- rxShape->setPosition( aShapePos );
- }
+ aChartSize = getDefaultPageSize();
+ }
+ awt::Point aShapePos(
+ lclCalcPosition( aChartSize.Width, mrModel.mfX, mrModel.mnXMode ),
+ lclCalcPosition( aChartSize.Height, mrModel.mfY, mrModel.mnYMode ) );
+ if( !((aShapePos.X >= 0) && (aShapePos.Y >= 0)) )
+ return;
+
+ bool bPropSet = false;
+ // the call to XShape.getSize() may recalc the chart view
+ awt::Size aShapeSize = rxShape->getSize();
+ // rotated shapes need special handling...
+ if( aShapeSize.Height > 0 || aShapeSize.Width > 0 )
+ {
+ double fSin = fabs(sin(basegfx::deg2rad(fRotationAngle)));
+ // add part of height to X direction, if title is rotated down
+ if( fRotationAngle > 180.0 )
+ aShapePos.X += static_cast<sal_Int32>(fSin * aShapeSize.Height + 0.5);
+ // add part of width to Y direction, if title is rotated up
+ else if( fRotationAngle > 0.0 )
+ aShapePos.Y += static_cast<sal_Int32>(fSin * aShapeSize.Width + 0.5);
+ }
+ else if( fRotationAngle == 90.0 || fRotationAngle == 270.0 )
+ {
+ PropertySet aShapeProp( rxShape );
+ RelativePosition aPos(
+ getLimitedValue< double, double >(mrModel.mfX, 0.0, 1.0),
+ getLimitedValue< double, double >(mrModel.mfY, 0.0, 1.0),
+ fRotationAngle == 90.0 ? Alignment_TOP_RIGHT : Alignment_BOTTOM_LEFT );
+ // set the resulting position at the shape
+ if( aShapeProp.setProperty(PROP_RelativePosition, aPos) )
+ bPropSet = true;
}
+ // set the resulting position at the shape
+ if( !bPropSet )
+ rxShape->setPosition( aShapePos );
}
} // namespace oox
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index 1a43409dbea0..b82fdbe6e026 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -728,21 +728,21 @@ DetailFormatterBase::DetailFormatterBase( ObjectFormatterData& rData, const Auto
mrData( rData ),
mnPhClr( 0xffffffff )
{
- if( pAutoFormatEntry )
+ if( !pAutoFormatEntry )
+ return;
+
+ if( pAutoFormatEntry->mpPattern )
{
- if( pAutoFormatEntry->mpPattern )
- {
- // prepare multi-color pattern
- for( const AutoFormatPatternEntry* pPatternEntry = pAutoFormatEntry->mpPattern; pPatternEntry->mnColorToken != XML_TOKEN_INVALID; ++pPatternEntry )
- maColorPattern.push_back( getSchemeColor( pPatternEntry->mnColorToken, pPatternEntry->mnModToken, pPatternEntry->mnModValue ) );
- }
- else if( pAutoFormatEntry->mnColorToken != XML_TOKEN_INVALID )
- {
- // prepare color or single-color pattern (color fading)
- mnPhClr = getSchemeColor( pAutoFormatEntry->mnColorToken, pAutoFormatEntry->mnModToken, pAutoFormatEntry->mnModValue );
- if( pAutoFormatEntry->mbFadedColor )
- maColorPattern.push_back( mnPhClr );
- }
+ // prepare multi-color pattern
+ for( const AutoFormatPatternEntry* pPatternEntry = pAutoFormatEntry->mpPattern; pPatternEntry->mnColorToken != XML_TOKEN_INVALID; ++pPatternEntry )
+ maColorPattern.push_back( getSchemeColor( pPatternEntry->mnColorToken, pPatternEntry->mnModToken, pPatternEntry->mnModValue ) );
+ }
+ else if( pAutoFormatEntry->mnColorToken != XML_TOKEN_INVALID )
+ {
+ // prepare color or single-color pattern (color fading)
+ mnPhClr = getSchemeColor( pAutoFormatEntry->mnColorToken, pAutoFormatEntry->mnModToken, pAutoFormatEntry->mnModValue );
+ if( pAutoFormatEntry->mbFadedColor )
+ maColorPattern.push_back( mnPhClr );
}
}
@@ -817,25 +817,25 @@ DetailFormatterBase::DetailFormatterBase( ObjectFormatterData& rData, const Auto
LineFormatter::LineFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, const ObjectType eObjType ) :
DetailFormatterBase(rData, pAutoFormatEntry)
{
- if( pAutoFormatEntry )
+ if( !pAutoFormatEntry )
+ return;
+
+ mxAutoLine = std::make_shared<LineProperties>();
+ mxAutoLine->maLineFill.moFillType = XML_noFill;
+ if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
+ if( const LineProperties* pLineProps = pTheme->getLineStyle( pAutoFormatEntry->mnThemedIdx ) )
+ *mxAutoLine = *pLineProps;
+ // set automatic border property for chartarea, because of tdf#81437 and tdf#82217
+ if ( eObjType == OBJECTTYPE_CHARTSPACE )
{
- mxAutoLine = std::make_shared<LineProperties>();
- mxAutoLine->maLineFill.moFillType = XML_noFill;
- if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
- if( const LineProperties* pLineProps = pTheme->getLineStyle( pAutoFormatEntry->mnThemedIdx ) )
- *mxAutoLine = *pLineProps;
- // set automatic border property for chartarea, because of tdf#81437 and tdf#82217
- if ( eObjType == OBJECTTYPE_CHARTSPACE )
- {
- mxAutoLine->maLineFill.moFillType = oox::GraphicHelper::getDefaultChartAreaLineStyle();
- mxAutoLine->moLineWidth = oox::GraphicHelper::getDefaultChartAreaLineWidth();
- // this value is what MSO 2016 use as a default color for chartspace border
- mxAutoLine->maLineFill.maFillColor.setSrgbClr( 0xD9D9D9 );
- }
- // change line width according to chart auto style
- if( mxAutoLine->moLineWidth.has() )
- mxAutoLine->moLineWidth = mxAutoLine->moLineWidth.get() * pAutoFormatEntry->mnRelLineWidth / 100;
+ mxAutoLine->maLineFill.moFillType = oox::GraphicHelper::getDefaultChartAreaLineStyle();
+ mxAutoLine->moLineWidth = oox::GraphicHelper::getDefaultChartAreaLineWidth();
+ // this value is what MSO 2016 use as a default color for chartspace border
+ mxAutoLine->maLineFill.maFillColor.setSrgbClr( 0xD9D9D9 );
}
+ // change line width according to chart auto style
+ if( mxAutoLine->moLineWidth.has() )
+ mxAutoLine->moLineWidth = mxAutoLine->moLineWidth.get() * pAutoFormatEntry->mnRelLineWidth / 100;
}
void LineFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRef< Shape >& rxShapeProp, sal_Int32 nSeriesIdx )
@@ -851,19 +851,19 @@ void LineFormatter::convertFormatting( ShapePropertyMap& rPropMap, const ModelRe
FillFormatter::FillFormatter( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry, const ObjectType eObjType ) :
DetailFormatterBase( rData, pAutoFormatEntry )
{
- if( pAutoFormatEntry )
+ if( !pAutoFormatEntry )
+ return;
+
+ mxAutoFill = std::make_shared<FillProperties>();
+ if( eObjType != OBJECTTYPE_CHARTSPACE )
+ mxAutoFill->moFillType = XML_noFill;
+ if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
+ if( const FillProperties* pFillProps = pTheme->getFillStyle( pAutoFormatEntry->mnThemedIdx ) )
+ *mxAutoFill = *pFillProps;
+
+ if (eObjType == OBJECTTYPE_CHARTSPACE)
{
- mxAutoFill = std::make_shared<FillProperties>();
- if( eObjType != OBJECTTYPE_CHARTSPACE )
- mxAutoFill->moFillType = XML_noFill;
- if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
- if( const FillProperties* pFillProps = pTheme->getFillStyle( pAutoFormatEntry->mnThemedIdx ) )
- *mxAutoFill = *pFillProps;
-
- if (eObjType == OBJECTTYPE_CHARTSPACE)
- {
- mxAutoFill->moFillType = rData.mrFilter.getGraphicHelper().getDefaultChartAreaFillStyle();
- }
+ mxAutoFill->moFillType = rData.mrFilter.getGraphicHelper().getDefaultChartAreaFillStyle();
}
}
@@ -892,26 +892,26 @@ const TextCharacterProperties* lclGetTextProperties( const ModelRef< TextBody >&
TextFormatter::TextFormatter( ObjectFormatterData& rData, const AutoTextEntry* pAutoTextEntry, const ModelRef< TextBody >& rxGlobalTextProp ) :
DetailFormatterBase( rData, pAutoTextEntry )
{
- if( pAutoTextEntry )
- {
- mxAutoText = std::make_shared<TextCharacterProperties>();
- if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
- if( const TextCharacterProperties* pTextProps = pTheme->getFontStyle( pAutoTextEntry->mnThemedFont ) )
- *mxAutoText = *pTextProps;
- ::Color nTextColor = getPhColor( -1 );
- if( sal_Int32(nTextColor) >= 0 ) {
- mxAutoText->maFillProperties.maFillColor.setSrgbClr( nTextColor );
- mxAutoText->maFillProperties.moFillType.set(XML_solidFill);
- }
- mxAutoText->moHeight = pAutoTextEntry->mnDefFontSize;
- mxAutoText->moBold = pAutoTextEntry->mbBold;
+ if( !pAutoTextEntry )
+ return;
+
+ mxAutoText = std::make_shared<TextCharacterProperties>();
+ if( const Theme* pTheme = mrData.mrFilter.getCurrentTheme() )
+ if( const TextCharacterProperties* pTextProps = pTheme->getFontStyle( pAutoTextEntry->mnThemedFont ) )
+ *mxAutoText = *pTextProps;
+ ::Color nTextColor = getPhColor( -1 );
+ if( sal_Int32(nTextColor) >= 0 ) {
+ mxAutoText->maFillProperties.maFillColor.setSrgbClr( nTextColor );
+ mxAutoText->maFillProperties.moFillType.set(XML_solidFill);
+ }
+ mxAutoText->moHeight = pAutoTextEntry->mnDefFontSize;
+ mxAutoText->moBold = pAutoTextEntry->mbBold;
- if( const TextCharacterProperties* pTextProps = lclGetTextProperties( rxGlobalTextProp ) )
- {
- mxAutoText->assignUsed( *pTextProps );
- if( pTextProps->moHeight.has() )
- mxAutoText->moHeight = pTextProps->moHeight.get() * pAutoTextEntry->mnRelFontSize / 100;
- }
+ if( const TextCharacterProperties* pTextProps = lclGetTextProperties( rxGlobalTextProp ) )
+ {
+ mxAutoText->assignUsed( *pTextProps );
+ if( pTextProps->moHeight.has() )
+ mxAutoText->moHeight = pTextProps->moHeight.get() * pAutoTextEntry->mnRelFontSize / 100;
}
}
@@ -1050,77 +1050,77 @@ void ObjectFormatter::convertTextFormatting( PropertySet& rPropSet, const TextCh
void ObjectFormatter::convertTextRotation( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp, bool bSupportsStacked, sal_Int32 nDefaultRotation )
{
- if( rxTextProp.is() )
+ if( !rxTextProp.is() )
+ return;
+
+ bool bStacked = false;
+ if( bSupportsStacked )
{
- bool bStacked = false;
- if( bSupportsStacked )
- {
- sal_Int32 nVert = rxTextProp->getTextProperties().moVert.get( XML_horz );
- bStacked = (nVert == XML_wordArtVert) || (nVert == XML_wordArtVertRtl);
- rPropSet.setProperty( PROP_StackCharacters, bStacked );
- }
+ sal_Int32 nVert = rxTextProp->getTextProperties().moVert.get( XML_horz );
+ bStacked = (nVert == XML_wordArtVert) || (nVert == XML_wordArtVertRtl);
+ rPropSet.setProperty( PROP_StackCharacters, bStacked );
+ }
- /* Chart2 expects rotation angle as double value in range of [0,360).
- OOXML counts clockwise, Chart2 counts counterclockwise. */
- double fAngle = static_cast< double >( bStacked ? 0 : rxTextProp->getTextProperties().moRotation.get( nDefaultRotation ) );
- // MS Office UI allows values only in range of [-90,90].
- if ( fAngle < -5400000.0 || fAngle > 5400000.0 )
- {
- fAngle = 0.0;
- }
- fAngle = getDoubleIntervalValue< double >( -fAngle / 60000.0, 0.0, 360.0 );
- rPropSet.setProperty( PROP_TextRotation, fAngle );
+ /* Chart2 expects rotation angle as double value in range of [0,360).
+ OOXML counts clockwise, Chart2 counts counterclockwise. */
+ double fAngle = static_cast< double >( bStacked ? 0 : rxTextProp->getTextProperties().moRotation.get( nDefaultRotation ) );
+ // MS Office UI allows values only in range of [-90,90].
+ if ( fAngle < -5400000.0 || fAngle > 5400000.0 )
+ {
+ fAngle = 0.0;
}
+ fAngle = getDoubleIntervalValue< double >( -fAngle / 60000.0, 0.0, 360.0 );
+ rPropSet.setProperty( PROP_TextRotation, fAngle );
}
void ObjectFormatter::convertTextWrap( PropertySet& rPropSet, const ModelRef< TextBody >& rxTextProp )
{
- if( rxTextProp.is() )
+ if( !rxTextProp.is() )
+ return;
+
+ PropertyMap& aPropMap = rxTextProp->getTextProperties().maPropertyMap;
+ if( aPropMap.hasProperty(PROP_TextWordWrap) )
{
- PropertyMap& aPropMap = rxTextProp->getTextProperties().maPropertyMap;
- if( aPropMap.hasProperty(PROP_TextWordWrap) )
+ Any aValue = aPropMap.getProperty( PROP_TextWordWrap );
+ if( aValue.hasValue() )
{
- Any aValue = aPropMap.getProperty( PROP_TextWordWrap );
- if( aValue.hasValue() )
- {
- bool bValue = false;
- aValue >>= bValue;
- rPropSet.setProperty( PROP_TextWordWrap, bValue );
- }
+ bool bValue = false;
+ aValue >>= bValue;
+ rPropSet.setProperty( PROP_TextWordWrap, bValue );
}
}
}
void ObjectFormatter::convertNumberFormat( PropertySet& rPropSet, const NumberFormat& rNumberFormat, bool bAxis, bool bShowPercent )
{
- if( mxData->mxNumFmts.is() )
- {
- const bool bGeneral = rNumberFormat.maFormatCode.equalsIgnoreAsciiCase("general");
- const bool bPercent = !bAxis && bShowPercent && !rNumberFormat.mbSourceLinked;
- sal_Int32 nPropId = bPercent ? PROP_PercentageNumberFormat : PROP_NumberFormat;
- OUString sFormatCode(rNumberFormat.maFormatCode);
- if (bPercent && bGeneral)
- sFormatCode = "0%";
- try
- {
- sal_Int32 nIndex = bGeneral && !bPercent ?
- mxData->mxNumTypes->getStandardIndex( mxData->maFromLocale ) :
- mxData->mxNumFmts->addNewConverted( sFormatCode, mxData->maEnUsLocale, mxData->maFromLocale );
- if( nIndex >= 0 )
- rPropSet.setProperty( nPropId, nIndex );
- }
- catch( Exception& )
- {
- OSL_FAIL( OStringBuffer( "ObjectFormatter::convertNumberFormat - cannot create number format '" ).
- append( OUStringToOString( rNumberFormat.maFormatCode, osl_getThreadTextEncoding() ) ).append( '\'' ).getStr() );
- }
+ if( !mxData->mxNumFmts.is() )
+ return;
- // Setting "LinkNumberFormatToSource" does not really work, at least not for axis :-/
- if (!bAxis)
- rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.mbSourceLinked));
- else
- rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.maFormatCode.isEmpty()));
+ const bool bGeneral = rNumberFormat.maFormatCode.equalsIgnoreAsciiCase("general");
+ const bool bPercent = !bAxis && bShowPercent && !rNumberFormat.mbSourceLinked;
+ sal_Int32 nPropId = bPercent ? PROP_PercentageNumberFormat : PROP_NumberFormat;
+ OUString sFormatCode(rNumberFormat.maFormatCode);
+ if (bPercent && bGeneral)
+ sFormatCode = "0%";
+ try
+ {
+ sal_Int32 nIndex = bGeneral && !bPercent ?
+ mxData->mxNumTypes->getStandardIndex( mxData->maFromLocale ) :
+ mxData->mxNumFmts->addNewConverted( sFormatCode, mxData->maEnUsLocale, mxData->maFromLocale );
+ if( nIndex >= 0 )
+ rPropSet.setProperty( nPropId, nIndex );
}
+ catch( Exception& )
+ {
+ OSL_FAIL( OStringBuffer( "ObjectFormatter::convertNumberFormat - cannot create number format '" ).
+ append( OUStringToOString( rNumberFormat.maFormatCode, osl_getThreadTextEncoding() ) ).append( '\'' ).getStr() );
+ }
+
+ // Setting "LinkNumberFormatToSource" does not really work, at least not for axis :-/
+ if (!bAxis)
+ rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.mbSourceLinked));
+ else
+ rPropSet.setProperty(PROP_LinkNumberFormatToSource, makeAny(rNumberFormat.maFormatCode.isEmpty()));
}
void ObjectFormatter::convertAutomaticFill( PropertySet& rPropSet, ObjectType eObjType, sal_Int32 nSeriesIdx )
diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx
index 1862dea1c8cb..e5f337a94193 100644
--- a/oox/source/drawingml/chart/plotareaconverter.cxx
+++ b/oox/source/drawingml/chart/plotareaconverter.cxx
@@ -114,7 +114,10 @@ void AxesSetConverter::convertFromModel( const Reference< XDiagram >& rxDiagram,
aTypeGroups.push_back( std::make_shared<TypeGroupConverter>( *this, *typeGroup ) );
OSL_ENSURE( !aTypeGroups.empty(), "AxesSetConverter::convertFromModel - no type groups in axes set" );
- if( !aTypeGroups.empty() ) try
+ if( aTypeGroups.empty() )
+ return;
+
+ try
{
// first type group needed for coordinate system and axis conversion
TypeGroupConverter& rFirstTypeGroup = *aTypeGroups.front();
@@ -452,7 +455,10 @@ void PlotAreaConverter::convertPositionFromModel()
LayoutModel& rLayout = mrModel.mxLayout.getOrCreate();
LayoutConverter aLayoutConv( *this, rLayout );
awt::Rectangle aDiagramRect;
- if( aLayoutConv.calcAbsRectangle( aDiagramRect ) ) try
+ if( !aLayoutConv.calcAbsRectangle( aDiagramRect ) )
+ return;
+
+ try
{
namespace cssc = ::com::sun::star::chart;
Reference< cssc::XChartDocument > xChart1Doc( getChartDocument(), UNO_QUERY_THROW );
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index f063019b8327..01e004f45c59 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -134,49 +134,50 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt
rPropSet.setProperty( PROP_Label, aPointLabel );
}
- if( !rDataLabel.mbDeleted )
- {
- // data label number format (percentage format wins over value format)
- rFormatter.convertNumberFormat( rPropSet, rDataLabel.maNumberFormat, false, bShowPercent );
-
- // data label text formatting (frame formatting not supported by Chart2)
- if( bDataSeriesLabel || (rDataLabel.mxTextProp.is() && !rDataLabel.mxTextProp->getParagraphs().empty()) )
- convertTextProperty(rPropSet, rFormatter, rDataLabel.mxTextProp);
-
- // data label separator (do not overwrite series separator, if no explicit point separator is present)
- // Set the data label separator to "new line" if the value is shown as percentage with a category name,
- // just like in MS-Office. In any other case the default separator will be a semicolon.
- if( bShowPercent && !bShowValue && ( bDataSeriesLabel || rDataLabel.moaSeparator.has() ) )
- rPropSet.setProperty( PROP_LabelSeparator, rDataLabel.moaSeparator.get( "\n" ) );
- else if( bDataSeriesLabel || rDataLabel.moaSeparator.has() )
- rPropSet.setProperty( PROP_LabelSeparator, rDataLabel.moaSeparator.get( "; " ) );
-
- // data label placement (do not overwrite series placement, if no explicit point placement is present)
- if( bDataSeriesLabel || rDataLabel.monLabelPos.has() )
- {
- namespace csscd = ::com::sun::star::chart::DataLabelPlacement;
- sal_Int32 nPlacement = -1;
- switch( rDataLabel.monLabelPos.get( XML_TOKEN_INVALID ) )
- {
- case XML_outEnd: nPlacement = csscd::OUTSIDE; break;
- case XML_inEnd: nPlacement = csscd::INSIDE; break;
- case XML_ctr: nPlacement = csscd::CENTER; break;
- case XML_inBase: nPlacement = csscd::NEAR_ORIGIN; break;
- case XML_t: nPlacement = csscd::TOP; break;
- case XML_b: nPlacement = csscd::BOTTOM; break;
- case XML_l: nPlacement = csscd::LEFT; break;
- case XML_r: nPlacement = csscd::RIGHT; break;
- case XML_bestFit: nPlacement = csscd::AVOID_OVERLAP; break;
- }
+ if( rDataLabel.mbDeleted )
+ return;
- if( !bDataSeriesLabel && nPlacement == -1 )
- return;
- else if( nPlacement == -1 )
- nPlacement = rTypeInfo.mnDefLabelPos;
+ // data label number format (percentage format wins over value format)
+ rFormatter.convertNumberFormat( rPropSet, rDataLabel.maNumberFormat, false, bShowPercent );
- rPropSet.setProperty( PROP_LabelPlacement, nPlacement );
- }
+ // data label text formatting (frame formatting not supported by Chart2)
+ if( bDataSeriesLabel || (rDataLabel.mxTextProp.is() && !rDataLabel.mxTextProp->getParagraphs().empty()) )
+ convertTextProperty(rPropSet, rFormatter, rDataLabel.mxTextProp);
+
+ // data label separator (do not overwrite series separator, if no explicit point separator is present)
+ // Set the data label separator to "new line" if the value is shown as percentage with a category name,
+ // just like in MS-Office. In any other case the default separator will be a semicolon.
+ if( bShowPercent && !bShowValue && ( bDataSeriesLabel || rDataLabel.moaSeparator.has() ) )
+ rPropSet.setProperty( PROP_LabelSeparator, rDataLabel.moaSeparator.get( "\n" ) );
+ else if( bDataSeriesLabel || rDataLabel.moaSeparator.has() )
+ rPropSet.setProperty( PROP_LabelSeparator, rDataLabel.moaSeparator.get( "; " ) );
+
+ // data label placement (do not overwrite series placement, if no explicit point placement is present)
+ if( !(bDataSeriesLabel || rDataLabel.monLabelPos.has()) )
+ return;
+
+ namespace csscd = ::com::sun::star::chart::DataLabelPlacement;
+ sal_Int32 nPlacement = -1;
+ switch( rDataLabel.monLabelPos.get( XML_TOKEN_INVALID ) )
+ {
+ case XML_outEnd: nPlacement = csscd::OUTSIDE; break;
+ case XML_inEnd: nPlacement = csscd::INSIDE; break;
+ case XML_ctr: nPlacement = csscd::CENTER; break;
+ case XML_inBase: nPlacement = csscd::NEAR_ORIGIN; break;
+ case XML_t: nPlacement = csscd::TOP; break;
+ case XML_b: nPlacement = csscd::BOTTOM; break;
+ case XML_l: nPlacement = csscd::LEFT; break;
+ case XML_r: nPlacement = csscd::RIGHT; break;
+ case XML_bestFit: nPlacement = csscd::AVOID_OVERLAP; break;
}
+
+ if( !bDataSeriesLabel && nPlacement == -1 )
+ return;
+
+ if( nPlacement == -1 )
+ nPlacement = rTypeInfo.mnDefLabelPos;
+
+ rPropSet.setProperty( PROP_LabelPlacement, nPlacement );
}
void importBorderProperties( PropertySet& rPropSet, Shape& rShape, const GraphicHelper& rGraphicHelper )
@@ -356,7 +357,10 @@ void ErrorBarConverter::convertFromModel( const Reference< XDataSeries >& rxData
{
bool bShowPos = (mrModel.mnTypeId == XML_plus) || (mrModel.mnTypeId == XML_both);
bool bShowNeg = (mrModel.mnTypeId == XML_minus) || (mrModel.mnTypeId == XML_both);
- if( bShowPos || bShowNeg ) try
+ if( !(bShowPos || bShowNeg) )
+ return;
+
+ try
{
Reference< XPropertySet > xErrorBar( createInstance( "com.sun.star.chart2.ErrorBar" ), UNO_QUERY_THROW );
PropertySet aBarProp( xErrorBar );
diff --git a/oox/source/drawingml/chart/titleconverter.cxx b/oox/source/drawingml/chart/titleconverter.cxx
index 10ebd308b4fa..a4a2d9c1ec89 100644
--- a/oox/source/drawingml/chart/titleconverter.cxx
+++ b/oox/source/drawingml/chart/titleconverter.cxx
@@ -144,34 +144,37 @@ TitleConverter::~TitleConverter()
void TitleConverter::convertFromModel( const Reference< XTitled >& rxTitled, const OUString& rAutoTitle, ObjectType eObjType, sal_Int32 nMainIdx, sal_Int32 nSubIdx )
{
- if( rxTitled.is() )
+ if( !rxTitled.is() )
+ return;
+
+ // create the formatted strings
+ TextModel& rText = mrModel.mxText.getOrCreate();
+ TextConverter aTextConv( *this, rText );
+ Sequence< Reference< XFormattedString > > aStringSeq = aTextConv.createStringSequence( rAutoTitle, mrModel.mxTextProp, eObjType );
+ if( !aStringSeq.hasElements() )
+ return;
+
+ try
+ {
+ // create the title object and set the string data
+ Reference< XTitle > xTitle( createInstance( "com.sun.star.chart2.Title" ), UNO_QUERY_THROW );
+ xTitle->setText( aStringSeq );
+ rxTitled->setTitleObject( xTitle );
+
+ // frame formatting (text formatting already done in TextConverter::createStringSequence())
+ PropertySet aPropSet( xTitle );
+ getFormatter().convertFrameFormatting( aPropSet, mrModel.mxShapeProp, eObjType );
+
+ // frame rotation
+ OSL_ENSURE( !mrModel.mxTextProp || !rText.mxTextBody, "TitleConverter::convertFromModel - multiple text properties" );
+ ModelRef< TextBody > xTextProp = mrModel.mxTextProp.is() ? mrModel.mxTextProp : rText.mxTextBody;
+ ObjectFormatter::convertTextRotation( aPropSet, xTextProp, true, mrModel.mnDefaultRotation );
+
+ // register the title and layout data for conversion of position
+ registerTitleLayout( xTitle, mrModel.mxLayout, eObjType, nMainIdx, nSubIdx );
+ }
+ catch( Exception& )
{
- // create the formatted strings
- TextModel& rText = mrModel.mxText.getOrCreate();
- TextConverter aTextConv( *this, rText );
- Sequence< Reference< XFormattedString > > aStringSeq = aTextConv.createStringSequence( rAutoTitle, mrModel.mxTextProp, eObjType );
- if( aStringSeq.hasElements() ) try
- {
- // create the title object and set the string data
- Reference< XTitle > xTitle( createInstance( "com.sun.star.chart2.Title" ), UNO_QUERY_THROW );
- xTitle->setText( aStringSeq );
- rxTitled->setTitleObject( xTitle );
-
- // frame formatting (text formatting already done in TextConverter::createStringSequence())
- PropertySet aPropSet( xTitle );
- getFormatter().convertFrameFormatting( aPropSet, mrModel.mxShapeProp, eObjType );
-
- // frame rotation
- OSL_ENSURE( !mrModel.mxTextProp || !rText.mxTextBody, "TitleConverter::convertFromModel - multiple text properties" );
- ModelRef< TextBody > xTextProp = mrModel.mxTextProp.is() ? mrModel.mxTextProp : rText.mxTextBody;
- ObjectFormatter::convertTextRotation( aPropSet, xTextProp, true, mrModel.mnDefaultRotation );
-
- // register the title and layout data for conversion of position
- registerTitleLayout( xTitle, mrModel.mxLayout, eObjType, nMainIdx, nSubIdx );
- }
- catch( Exception& )
- {
- }
}
}
@@ -186,7 +189,10 @@ LegendConverter::~LegendConverter()
void LegendConverter::convertFromModel( const Reference< XDiagram >& rxDiagram )
{
- if( rxDiagram.is() ) try
+ if( !rxDiagram.is() )
+ return;
+
+ try
{
namespace cssc = ::com::sun::star::chart;
namespace cssc2 = ::com::sun::star::chart2;
diff --git a/oox/source/drawingml/chart/typegroupconverter.cxx b/oox/source/drawingml/chart/typegroupconverter.cxx
index 7ce8adc3ffdf..f55ac931fb98 100644
--- a/oox/source/drawingml/chart/typegroupconverter.cxx
+++ b/oox/source/drawingml/chart/typegroupconverter.cxx
@@ -468,50 +468,50 @@ void TypeGroupConverter::convertFromModel( const Reference< XDiagram >& rxDiagra
void TypeGroupConverter::convertMarker( PropertySet& rPropSet, sal_Int32 nOoxSymbol, sal_Int32 nOoxSize,
const ModelRef< Shape >& xShapeProps ) const
{
- if( !isSeriesFrameFormat() )
- {
- namespace cssc = ::com::sun::star::chart2;
+ if( isSeriesFrameFormat() )
+ return;
- // symbol style
- cssc::Symbol aSymbol;
- aSymbol.Style = cssc::SymbolStyle_STANDARD;
- switch( nOoxSymbol ) // compare with XclChPropSetHelper::WriteMarkerProperties in xlchart.cxx
- {
- case XML_auto: aSymbol.Style = cssc::SymbolStyle_AUTO; break;
- case XML_none: aSymbol.Style = cssc::SymbolStyle_NONE; break;
- case XML_square: aSymbol.StandardSymbol = 0; break; // square
- case XML_diamond: aSymbol.StandardSymbol = 1; break; // diamond
- case XML_triangle: aSymbol.StandardSymbol = 3; break; // arrow up
- case XML_x: aSymbol.StandardSymbol = 10; break; // X, legacy bow tie
- case XML_star: aSymbol.StandardSymbol = 12; break; // asterisk, legacy sand glass
- case XML_dot: aSymbol.StandardSymbol = 4; break; // arrow right
- case XML_dash: aSymbol.StandardSymbol = 13; break; // horizontal bar, legacy arrow down
- case XML_circle: aSymbol.StandardSymbol = 8; break; // circle, legacy arrow right
- case XML_plus: aSymbol.StandardSymbol = 11; break; // plus, legacy arrow left
- }
+ namespace cssc = ::com::sun::star::chart2;
- // symbol size (points in OOXML, 1/100 mm in Chart2)
- sal_Int32 nSize = static_cast< sal_Int32 >( nOoxSize * (2540.0 / 72.0) + 0.5 );
- aSymbol.Size.Width = aSymbol.Size.Height = nSize;
+ // symbol style
+ cssc::Symbol aSymbol;
+ aSymbol.Style = cssc::SymbolStyle_STANDARD;
+ switch( nOoxSymbol ) // compare with XclChPropSetHelper::WriteMarkerProperties in xlchart.cxx
+ {
+ case XML_auto: aSymbol.Style = cssc::SymbolStyle_AUTO; break;
+ case XML_none: aSymbol.Style = cssc::SymbolStyle_NONE; break;
+ case XML_square: aSymbol.StandardSymbol = 0; break; // square
+ case XML_diamond: aSymbol.StandardSymbol = 1; break; // diamond
+ case XML_triangle: aSymbol.StandardSymbol = 3; break; // arrow up
+ case XML_x: aSymbol.StandardSymbol = 10; break; // X, legacy bow tie
+ case XML_star: aSymbol.StandardSymbol = 12; break; // asterisk, legacy sand glass
+ case XML_dot: aSymbol.StandardSymbol = 4; break; // arrow right
+ case XML_dash: aSymbol.StandardSymbol = 13; break; // horizontal bar, legacy arrow down
+ case XML_circle: aSymbol.StandardSymbol = 8; break; // circle, legacy arrow right
+ case XML_plus: aSymbol.StandardSymbol = 11; break; // plus, legacy arrow left
+ }
+
+ // symbol size (points in OOXML, 1/100 mm in Chart2)
+ sal_Int32 nSize = static_cast< sal_Int32 >( nOoxSize * (2540.0 / 72.0) + 0.5 );
+ aSymbol.Size.Width = aSymbol.Size.Height = nSize;
- if(xShapeProps.is())
+ if(xShapeProps.is())
+ {
+ Color aFillColor = xShapeProps->getFillProperties().maFillColor;
+ aSymbol.FillColor = sal_Int32(aFillColor.getColor(getFilter().getGraphicHelper()));
+ // tdf#124817: if there is no fill color, use line color of the symbol
+ if( aSymbol.FillColor < 0 )
{
- Color aFillColor = xShapeProps->getFillProperties().maFillColor;
- aSymbol.FillColor = sal_Int32(aFillColor.getColor(getFilter().getGraphicHelper()));
- // tdf#124817: if there is no fill color, use line color of the symbol
- if( aSymbol.FillColor < 0 )
- {
- Color aLineColor = xShapeProps->getLineProperties().maLineFill.maFillColor;
- aSymbol.BorderColor = sal_Int32(aLineColor.getColor(getFilter().getGraphicHelper()));
- rPropSet.setProperty(PROP_Color, aSymbol.BorderColor);
- }
- else
- rPropSet.setProperty(PROP_Color, aSymbol.FillColor);
+ Color aLineColor = xShapeProps->getLineProperties().maLineFill.maFillColor;
+ aSymbol.BorderColor = sal_Int32(aLineColor.getColor(getFilter().getGraphicHelper()));
+ rPropSet.setProperty(PROP_Color, aSymbol.BorderColor);
}
-
- // set the property
- rPropSet.setProperty( PROP_Symbol, aSymbol );
+ else
+ rPropSet.setProperty(PROP_Color, aSymbol.FillColor);
}
+
+ // set the property
+ rPropSet.setProperty( PROP_Symbol, aSymbol );
}
void TypeGroupConverter::convertLineSmooth( PropertySet& rPropSet, bool bOoxSmooth ) const
@@ -526,23 +526,23 @@ void TypeGroupConverter::convertLineSmooth( PropertySet& rPropSet, bool bOoxSmoo
void TypeGroupConverter::convertBarGeometry( PropertySet& rPropSet, sal_Int32 nOoxShape ) const
{
- if( mb3dChart && (maTypeInfo.meTypeCategory == TYPECATEGORY_BAR) )
- {
- namespace cssc = ::com::sun::star::chart2;
+ if( !(mb3dChart && (maTypeInfo.meTypeCategory == TYPECATEGORY_BAR)) )
+ return;
- sal_Int32 nGeom3d = cssc::DataPointGeometry3D::CUBOID;
- switch( nOoxShape )
- {
- case XML_box: nGeom3d = cssc::DataPointGeometry3D::CUBOID; break;
- case XML_cone: nGeom3d = cssc::DataPointGeometry3D::CONE; break;
- case XML_coneToMax: nGeom3d = cssc::DataPointGeometry3D::CONE; break;
- 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_FAIL( "TypeGroupConverter::convertBarGeometry - unknown 3D bar shape type" );
- }
- rPropSet.setProperty( PROP_Geometry3D, nGeom3d );
+ namespace cssc = ::com::sun::star::chart2;
+
+ sal_Int32 nGeom3d = cssc::DataPointGeometry3D::CUBOID;
+ switch( nOoxShape )
+ {
+ case XML_box: nGeom3d = cssc::DataPointGeometry3D::CUBOID; break;
+ case XML_cone: nGeom3d = cssc::DataPointGeometry3D::CONE; break;
+ case XML_coneToMax: nGeom3d = cssc::DataPointGeometry3D::CONE; break;
+ 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_FAIL( "TypeGroupConverter::convertBarGeometry - unknown 3D bar shape type" );
}
+ rPropSet.setProperty( PROP_Geometry3D, nGeom3d );
}
void TypeGroupConverter::convertPieRotation( PropertySet& rPropSet, sal_Int32 nOoxAngle ) const
@@ -569,33 +569,33 @@ void TypeGroupConverter::convertPieExplosion( PropertySet& rPropSet, sal_Int32 n
void TypeGroupConverter::insertDataSeries( const Reference< XChartType >& rxChartType, const Reference< XDataSeries >& rxSeries, sal_Int32 nAxesSetIdx )
{
- if( rxSeries.is() )
- {
- PropertySet aSeriesProp( rxSeries );
+ if( !rxSeries.is() )
+ return;
- // series stacking mode
- namespace cssc = ::com::sun::star::chart2;
- cssc::StackingDirection eStacking = cssc::StackingDirection_NO_STACKING;
- // stacked overrides deep-3d
- if( isStacked() || isPercent() )
- eStacking = cssc::StackingDirection_Y_STACKING;
- else if( isDeep3dChart() )
- eStacking = cssc::StackingDirection_Z_STACKING;
- aSeriesProp.setProperty( PROP_StackingDirection, eStacking );
-
- // additional series properties
- aSeriesProp.setProperty( PROP_AttachedAxisIndex, nAxesSetIdx );
-
- // insert series into container
- try
- {
- Reference< XDataSeriesContainer > xSeriesCont( rxChartType, UNO_QUERY_THROW );
- xSeriesCont->addDataSeries( rxSeries );
- }
- catch( Exception& )
- {
- OSL_FAIL( "TypeGroupConverter::insertDataSeries - cannot add data series" );
- }
+ PropertySet aSeriesProp( rxSeries );
+
+ // series stacking mode
+ namespace cssc = ::com::sun::star::chart2;
+ cssc::StackingDirection eStacking = cssc::StackingDirection_NO_STACKING;
+ // stacked overrides deep-3d
+ if( isStacked() || isPercent() )
+ eStacking = cssc::StackingDirection_Y_STACKING;
+ else if( isDeep3dChart() )
+ eStacking = cssc::StackingDirection_Z_STACKING;
+ aSeriesProp.setProperty( PROP_StackingDirection, eStacking );
+
+ // additional series properties
+ aSeriesProp.setProperty( PROP_AttachedAxisIndex, nAxesSetIdx );
+
+ // insert series into container
+ try
+ {
+ Reference< XDataSeriesContainer > xSeriesCont( rxChartType, UNO_QUERY_THROW );
+ xSeriesCont->addDataSeries( rxSeries );
+ }
+ catch( Exception& )
+ {
+ OSL_FAIL( "TypeGroupConverter::insertDataSeries - cannot add data series" );
}
}
diff --git a/oox/source/drawingml/fillproperties.cxx b/oox/source/drawingml/fillproperties.cxx
index c8cc88f7b470..acc13271ebc1 100644
--- a/oox/source/drawingml/fillproperties.cxx
+++ b/oox/source/drawingml/fillproperties.cxx
@@ -325,157 +325,222 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, ::Color nPhClr,
bool bFlipH, bool bFlipV ) const
{
- if( moFillType.has() )
+ if( !moFillType.has() )
+ return;
+
+ FillStyle eFillStyle = FillStyle_NONE;
+ OSL_ASSERT((moFillType.get() & sal_Int32(0xFFFF0000))==0);
+ switch( moFillType.get() )
{
- FillStyle eFillStyle = FillStyle_NONE;
- OSL_ASSERT((moFillType.get() & sal_Int32(0xFFFF0000))==0);
- switch( moFillType.get() )
- {
- case XML_noFill:
- eFillStyle = FillStyle_NONE;
- break;
+ case XML_noFill:
+ eFillStyle = FillStyle_NONE;
+ break;
- case XML_solidFill:
- if( maFillColor.isUsed() )
+ case XML_solidFill:
+ if( maFillColor.isUsed() )
+ {
+ rPropMap.setProperty( ShapeProperty::FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) );
+ if( maFillColor.hasTransparency() )
+ rPropMap.setProperty( ShapeProperty::FillTransparency, maFillColor.getTransparency() );
+ eFillStyle = FillStyle_SOLID;
+ }
+ break;
+
+ case XML_gradFill:
+ // do not create gradient struct if property is not supported...
+ if( rPropMap.supportsProperty( ShapeProperty::FillGradient ) )
+ {
+ sal_Int32 nEndTrans = 0;
+ sal_Int32 nStartTrans = 0;
+ awt::Gradient aGradient;
+ aGradient.Angle = 900;
+ aGradient.StartIntensity = 100;
+ aGradient.EndIntensity = 100;
+
+ // Old code, values in aGradient overwritten in many cases by newer code below
+ if( maGradientProps.maGradientStops.size() > 1 )
{
- rPropMap.setProperty( ShapeProperty::FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) );
- if( maFillColor.hasTransparency() )
- rPropMap.setProperty( ShapeProperty::FillTransparency, maFillColor.getTransparency() );
- eFillStyle = FillStyle_SOLID;
+ aGradient.StartColor = sal_Int32(maGradientProps.maGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr ));
+ aGradient.EndColor = sal_Int32(maGradientProps.maGradientStops.rbegin()->second.getColor( rGraphicHelper, nPhClr ));
+ if( maGradientProps.maGradientStops.rbegin()->second.hasTransparency() )
+ nEndTrans = maGradientProps.maGradientStops.rbegin()->second.getTransparency()*255/100;
+ if( maGradientProps.maGradientStops.begin()->second.hasTransparency() )
+ nStartTrans = maGradientProps.maGradientStops.begin()->second.getTransparency()*255/100;
}
- break;
- case XML_gradFill:
- // do not create gradient struct if property is not supported...
- if( rPropMap.supportsProperty( ShapeProperty::FillGradient ) )
+ // "rotate with shape" set to false -> do not rotate
+ if ( !maGradientProps.moRotateWithShape.get( true ) )
+ nShapeRotation = 0;
+
+ if( maGradientProps.moGradientPath.has() )
+ {
+ // position of gradient center (limited to [30%;100%], otherwise gradient is too hidden)
+ IntegerRectangle2D aFillToRect = maGradientProps.moFillToRect.get( IntegerRectangle2D( 0, 0, MAX_PERCENT, MAX_PERCENT ) );
+ sal_Int32 nCenterX = (MAX_PERCENT + aFillToRect.X1 - aFillToRect.X2) / 2;
+ aGradient.XOffset = getLimitedValue<sal_Int16, sal_Int32>(
+ nCenterX / PER_PERCENT, 30, 100);
+
+ // Style should be radial at least when the horizontal center is at 50%.
+ awt::GradientStyle eCircle = aGradient.XOffset == 50
+ ? awt::GradientStyle_RADIAL
+ : awt::GradientStyle_ELLIPTICAL;
+ aGradient.Style = (maGradientProps.moGradientPath.get() == XML_circle)
+ ? eCircle
+ : awt::GradientStyle_RECT;
+
+ sal_Int32 nCenterY = (MAX_PERCENT + aFillToRect.Y1 - aFillToRect.Y2) / 2;
+ aGradient.YOffset = getLimitedValue<sal_Int16, sal_Int32>(
+ nCenterY / PER_PERCENT, 30, 100);
+ ::std::swap( aGradient.StartColor, aGradient.EndColor );
+ ::std::swap( nStartTrans, nEndTrans );
+
+ extractGradientBorderFromStops(maGradientProps, rGraphicHelper, nPhClr,
+ aGradient);
+ }
+ else if (!maGradientProps.maGradientStops.empty())
{
- sal_Int32 nEndTrans = 0;
- sal_Int32 nStartTrans = 0;
- awt::Gradient aGradient;
- aGradient.Angle = 900;
- aGradient.StartIntensity = 100;
- aGradient.EndIntensity = 100;
-
- // Old code, values in aGradient overwritten in many cases by newer code below
- if( maGradientProps.maGradientStops.size() > 1 )
+ // A copy of the gradient stops for local modification
+ GradientFillProperties::GradientStopMap aGradientStops(maGradientProps.maGradientStops);
+
+ // Add a fake gradient stop at 0% and 100% if necessary, so that the gradient always starts
+ // at 0% and ends at 100%, to make following logic clearer (?).
+ auto a0 = aGradientStops.find( 0.0 );
+ if( a0 == aGradientStops.end() )
{
- aGradient.StartColor = sal_Int32(maGradientProps.maGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr ));
- aGradient.EndColor = sal_Int32(maGradientProps.maGradientStops.rbegin()->second.getColor( rGraphicHelper, nPhClr ));
- if( maGradientProps.maGradientStops.rbegin()->second.hasTransparency() )
- nEndTrans = maGradientProps.maGradientStops.rbegin()->second.getTransparency()*255/100;
- if( maGradientProps.maGradientStops.begin()->second.hasTransparency() )
- nStartTrans = maGradientProps.maGradientStops.begin()->second.getTransparency()*255/100;
+ // temp variable required
+ Color aFirstColor(aGradientStops.begin()->second);
+ aGradientStops.emplace( 0.0, aFirstColor );
}
- // "rotate with shape" set to false -> do not rotate
- if ( !maGradientProps.moRotateWithShape.get( true ) )
- nShapeRotation = 0;
-
- if( maGradientProps.moGradientPath.has() )
+ auto a1 = aGradientStops.find( 1.0 );
+ if( a1 == aGradientStops.end() )
{
- // position of gradient center (limited to [30%;100%], otherwise gradient is too hidden)
- IntegerRectangle2D aFillToRect = maGradientProps.moFillToRect.get( IntegerRectangle2D( 0, 0, MAX_PERCENT, MAX_PERCENT ) );
- sal_Int32 nCenterX = (MAX_PERCENT + aFillToRect.X1 - aFillToRect.X2) / 2;
- aGradient.XOffset = getLimitedValue<sal_Int16, sal_Int32>(
- nCenterX / PER_PERCENT, 30, 100);
-
- // Style should be radial at least when the horizontal center is at 50%.
- awt::GradientStyle eCircle = aGradient.XOffset == 50
- ? awt::GradientStyle_RADIAL
- : awt::GradientStyle_ELLIPTICAL;
- aGradient.Style = (maGradientProps.moGradientPath.get() == XML_circle)
- ? eCircle
- : awt::GradientStyle_RECT;
-
- sal_Int32 nCenterY = (MAX_PERCENT + aFillToRect.Y1 - aFillToRect.Y2) / 2;
- aGradient.YOffset = getLimitedValue<sal_Int16, sal_Int32>(
- nCenterY / PER_PERCENT, 30, 100);
- ::std::swap( aGradient.StartColor, aGradient.EndColor );
- ::std::swap( nStartTrans, nEndTrans );
-
- extractGradientBorderFromStops(maGradientProps, rGraphicHelper, nPhClr,
- aGradient);
+ // ditto
+ Color aLastColor(aGradientStops.rbegin()->second);
+ aGradientStops.emplace( 1.0, aLastColor );
}
- else if (!maGradientProps.maGradientStops.empty())
- {
- // A copy of the gradient stops for local modification
- GradientFillProperties::GradientStopMap aGradientStops(maGradientProps.maGradientStops);
- // Add a fake gradient stop at 0% and 100% if necessary, so that the gradient always starts
- // at 0% and ends at 100%, to make following logic clearer (?).
- auto a0 = aGradientStops.find( 0.0 );
- if( a0 == aGradientStops.end() )
- {
- // temp variable required
- Color aFirstColor(aGradientStops.begin()->second);
- aGradientStops.emplace( 0.0, aFirstColor );
- }
-
- auto a1 = aGradientStops.find( 1.0 );
- if( a1 == aGradientStops.end() )
+ // Check if the gradient is symmetric, which we will emulate with an "axial" gradient.
+ bool bSymmetric(true);
+ {
+ GradientFillProperties::GradientStopMap::const_iterator aItA( aGradientStops.begin() );
+ GradientFillProperties::GradientStopMap::const_iterator aItZ(std::prev(aGradientStops.end()));
+ while( bSymmetric && aItA->first < aItZ->first )
{
- // ditto
- Color aLastColor(aGradientStops.rbegin()->second);
- aGradientStops.emplace( 1.0, aLastColor );
+ if (!aItA->second.equals(aItZ->second, rGraphicHelper, nPhClr))
+ bSymmetric = false;
+ else
+ {
+ ++aItA;
+ aItZ = std::prev(aItZ);
+ }
}
+ // Don't be fooled if the middlemost stop isn't at 0.5.
+ if( bSymmetric && aItA == aItZ && aItA->first != 0.5 )
+ bSymmetric = false;
- // Check if the gradient is symmetric, which we will emulate with an "axial" gradient.
- bool bSymmetric(true);
+ // If symmetric, do the rest of the logic for just a half.
+ if( bSymmetric )
{
- GradientFillProperties::GradientStopMap::const_iterator aItA( aGradientStops.begin() );
- GradientFillProperties::GradientStopMap::const_iterator aItZ(std::prev(aGradientStops.end()));
- while( bSymmetric && aItA->first < aItZ->first )
+ // aItZ already points to the colour for the middle, but insert a fake stop at the
+ // exact middle if necessary.
+ if( aItA->first != aItZ->first )
{
- if (!aItA->second.equals(aItZ->second, rGraphicHelper, nPhClr))
- bSymmetric = false;
- else
- {
- ++aItA;
- aItZ = std::prev(aItZ);
- }
- }
- // Don't be fooled if the middlemost stop isn't at 0.5.
- if( bSymmetric && aItA == aItZ && aItA->first != 0.5 )
- bSymmetric = false;
+ Color aMiddleColor = aItZ->second;
+ auto a05 = aGradientStops.find( 0.5 );
- // If symmetric, do the rest of the logic for just a half.
- if( bSymmetric )
- {
- // aItZ already points to the colour for the middle, but insert a fake stop at the
- // exact middle if necessary.
- if( aItA->first != aItZ->first )
- {
- Color aMiddleColor = aItZ->second;
- auto a05 = aGradientStops.find( 0.5 );
-
- if( a05 != aGradientStops.end() )
- a05->second = aMiddleColor;
- else
- aGradientStops.emplace( 0.5, aMiddleColor );
- }
- // Drop the rest of the stops
- while( aGradientStops.rbegin()->first > 0.5 )
- aGradientStops.erase( aGradientStops.rbegin()->first );
+ if( a05 != aGradientStops.end() )
+ a05->second = aMiddleColor;
+ else
+ aGradientStops.emplace( 0.5, aMiddleColor );
}
+ // Drop the rest of the stops
+ while( aGradientStops.rbegin()->first > 0.5 )
+ aGradientStops.erase( aGradientStops.rbegin()->first );
}
+ }
- SAL_INFO("oox.drawingml.gradient", "symmetric: " << (bSymmetric ? "YES" : "NO") <<
- ", number of stops: " << aGradientStops.size());
- size_t nIndex = 0;
- for (auto const& gradientStop : aGradientStops)
- SAL_INFO("oox.drawingml.gradient", " " << nIndex++ << ": " <<
- gradientStop.first << ": " <<
- std::hex << sal_Int32(gradientStop.second.getColor( rGraphicHelper, nPhClr )) << std::dec <<
- "@" << (100 - gradientStop.second.getTransparency()) << "%");
-
- // Now estimate the simple LO style gradient (only two stops, at n% and 100%, where n ==
- // the "border") that best emulates the gradient between begin() and prior(end()).
-
- // First look for the largest segment in the gradient.
- GradientFillProperties::GradientStopMap::iterator aIt(aGradientStops.begin());
- double nWidestWidth = -1;
- GradientFillProperties::GradientStopMap::iterator aWidestSegmentStart;
+ SAL_INFO("oox.drawingml.gradient", "symmetric: " << (bSymmetric ? "YES" : "NO") <<
+ ", number of stops: " << aGradientStops.size());
+ size_t nIndex = 0;
+ for (auto const& gradientStop : aGradientStops)
+ SAL_INFO("oox.drawingml.gradient", " " << nIndex++ << ": " <<
+ gradientStop.first << ": " <<
+ std::hex << sal_Int32(gradientStop.second.getColor( rGraphicHelper, nPhClr )) << std::dec <<
+ "@" << (100 - gradientStop.second.getTransparency()) << "%");
+
+ // Now estimate the simple LO style gradient (only two stops, at n% and 100%, where n ==
+ // the "border") that best emulates the gradient between begin() and prior(end()).
+
+ // First look for the largest segment in the gradient.
+ GradientFillProperties::GradientStopMap::iterator aIt(aGradientStops.begin());
+ double nWidestWidth = -1;
+ GradientFillProperties::GradientStopMap::iterator aWidestSegmentStart;
+ ++aIt;
+ while( aIt != aGradientStops.end() )
+ {
+ if (aIt->first - std::prev(aIt)->first > nWidestWidth)
+ {
+ nWidestWidth = aIt->first - std::prev(aIt)->first;
+ aWidestSegmentStart = std::prev(aIt);
+ }
++aIt;
+ }
+ assert( nWidestWidth > 0 );
+
+ double nBorder = 0;
+ bool bSwap(false);
+
+ // Do we have just two segments, and either one is of uniform colour, or three or more
+ // segments, and the widest one is the first or last one, and is it of uniform colour? If
+ // so, deduce the border from it, and drop that segment.
+ if( aGradientStops.size() == 3 &&
+ aGradientStops.begin()->second.getColor(rGraphicHelper, nPhClr) == std::next(aGradientStops.begin())->second.getColor(rGraphicHelper, nPhClr) &&
+ aGradientStops.begin()->second.getTransparency() == std::next(aGradientStops.begin())->second.getTransparency())
+ {
+ // Two segments, first is uniformly coloured
+ SAL_INFO("oox.drawingml.gradient", "two segments, first is uniformly coloured");
+ nBorder = std::next(aGradientStops.begin())->first - aGradientStops.begin()->first;
+ aGradientStops.erase(aGradientStops.begin());
+ aWidestSegmentStart = aGradientStops.begin();
+ }
+ else if( !bSymmetric &&
+ aGradientStops.size() == 3 &&
+ std::next(aGradientStops.begin())->second.getColor(rGraphicHelper, nPhClr) == std::prev(aGradientStops.end())->second.getColor(rGraphicHelper, nPhClr) &&
+ std::next(aGradientStops.begin())->second.getTransparency() == std::prev(aGradientStops.end())->second.getTransparency())
+ {
+ // Two segments, second is uniformly coloured
+ SAL_INFO("oox.drawingml.gradient", "two segments, second is uniformly coloured");
+ nBorder = std::prev(aGradientStops.end())->first - std::next(aGradientStops.begin())->first;
+ aGradientStops.erase(std::next(aGradientStops.begin()));
+ aWidestSegmentStart = aGradientStops.begin();
+ bSwap = true;
+ nShapeRotation = 180*60000 - nShapeRotation;
+ }
+ else if( !bSymmetric &&
+ aGradientStops.size() >= 4 &&
+ aWidestSegmentStart->second.getColor( rGraphicHelper, nPhClr ) == std::next(aWidestSegmentStart)->second.getColor(rGraphicHelper, nPhClr) &&
+ aWidestSegmentStart->second.getTransparency() == std::next(aWidestSegmentStart)->second.getTransparency() &&
+ ( aWidestSegmentStart == aGradientStops.begin() ||
+ std::next(aWidestSegmentStart) == std::prev(aGradientStops.end())))
+ {
+ // Not symmetric, three or more segments, the widest is first or last and is uniformly coloured
+ SAL_INFO("oox.drawingml.gradient", "first or last segment is widest and is uniformly coloured");
+ nBorder = std::next(aWidestSegmentStart)->first - aWidestSegmentStart->first;
+
+ // If it's the last segment that is uniformly coloured, rotate the gradient 180
+ // degrees and swap start and end colours
+ if (std::next(aWidestSegmentStart) == std::prev(aGradientStops.end()))
+ {
+ bSwap = true;
+ nShapeRotation = 180*60000 - nShapeRotation;
+ }
+
+ aGradientStops.erase( aWidestSegmentStart++ );
+
+ // Look for which is widest now
+ aIt = std::next(aGradientStops.begin());
+ nWidestWidth = -1;
while( aIt != aGradientStops.end() )
{
if (aIt->first - std::prev(aIt)->first > nWidestWidth)
@@ -485,253 +550,188 @@ void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
}
++aIt;
}
- assert( nWidestWidth > 0 );
+ }
+ SAL_INFO("oox.drawingml.gradient", "widest segment start: " << aWidestSegmentStart->first << ", border: " << nBorder);
+ assert( (!bSymmetric && !bSwap) || !(bSymmetric && bSwap) );
+
+ // Now we have a potential border and a largest segment. Use those.
+
+ aGradient.Style = bSymmetric ? awt::GradientStyle_AXIAL : awt::GradientStyle_LINEAR;
+ sal_Int32 nShadeAngle = maGradientProps.moShadeAngle.get( 0 );
+ // Adjust for flips
+ if ( bFlipH )
+ nShadeAngle = 180*60000 - nShadeAngle;
+ if ( bFlipV )
+ nShadeAngle = -nShadeAngle;
+ sal_Int32 nDmlAngle = nShadeAngle + nShapeRotation;
+ // convert DrawingML angle (in 1/60000 degrees) to API angle (in 1/10 degrees)
+ aGradient.Angle = static_cast< sal_Int16 >( (8100 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 );
+ Color aStartColor, aEndColor;
+ if( bSymmetric )
+ {
+ aStartColor = std::next(aWidestSegmentStart)->second;
+ aEndColor = aWidestSegmentStart->second;
+ nBorder *= 2;
+ }
+ else if( bSwap )
+ {
+ aStartColor = std::next(aWidestSegmentStart)->second;
+ aEndColor = aWidestSegmentStart->second;
+ }
+ else
+ {
+ aStartColor = aWidestSegmentStart->second;
+ aEndColor = std::next(aWidestSegmentStart)->second;
+ }
- double nBorder = 0;
- bool bSwap(false);
+ SAL_INFO("oox.drawingml.gradient", "start color: " << std::hex << sal_Int32(aStartColor.getColor( rGraphicHelper, nPhClr )) << std::dec <<
+ "@" << (100-aStartColor.getTransparency()) << "%"
+ ", end color: " << std::hex << sal_Int32(aEndColor.getColor( rGraphicHelper, nPhClr )) << std::dec <<
+ "@" << (100-aEndColor.getTransparency()) << "%");
- // Do we have just two segments, and either one is of uniform colour, or three or more
- // segments, and the widest one is the first or last one, and is it of uniform colour? If
- // so, deduce the border from it, and drop that segment.
- if( aGradientStops.size() == 3 &&
- aGradientStops.begin()->second.getColor(rGraphicHelper, nPhClr) == std::next(aGradientStops.begin())->second.getColor(rGraphicHelper, nPhClr) &&
- aGradientStops.begin()->second.getTransparency() == std::next(aGradientStops.begin())->second.getTransparency())
- {
- // Two segments, first is uniformly coloured
- SAL_INFO("oox.drawingml.gradient", "two segments, first is uniformly coloured");
- nBorder = std::next(aGradientStops.begin())->first - aGradientStops.begin()->first;
- aGradientStops.erase(aGradientStops.begin());
- aWidestSegmentStart = aGradientStops.begin();
- }
- else if( !bSymmetric &&
- aGradientStops.size() == 3 &&
- std::next(aGradientStops.begin())->second.getColor(rGraphicHelper, nPhClr) == std::prev(aGradientStops.end())->second.getColor(rGraphicHelper, nPhClr) &&
- std::next(aGradientStops.begin())->second.getTransparency() == std::prev(aGradientStops.end())->second.getTransparency())
- {
- // Two segments, second is uniformly coloured
- SAL_INFO("oox.drawingml.gradient", "two segments, second is uniformly coloured");
- nBorder = std::prev(aGradientStops.end())->first - std::next(aGradientStops.begin())->first;
- aGradientStops.erase(std::next(aGradientStops.begin()));
- aWidestSegmentStart = aGradientStops.begin();
- bSwap = true;
- nShapeRotation = 180*60000 - nShapeRotation;
- }
- else if( !bSymmetric &&
- aGradientStops.size() >= 4 &&
- aWidestSegmentStart->second.getColor( rGraphicHelper, nPhClr ) == std::next(aWidestSegmentStart)->second.getColor(rGraphicHelper, nPhClr) &&
- aWidestSegmentStart->second.getTransparency() == std::next(aWidestSegmentStart)->second.getTransparency() &&
- ( aWidestSegmentStart == aGradientStops.begin() ||
- std::next(aWidestSegmentStart) == std::prev(aGradientStops.end())))
- {
- // Not symmetric, three or more segments, the widest is first or last and is uniformly coloured
- SAL_INFO("oox.drawingml.gradient", "first or last segment is widest and is uniformly coloured");
- nBorder = std::next(aWidestSegmentStart)->first - aWidestSegmentStart->first;
+ aGradient.StartColor = sal_Int32(aStartColor.getColor( rGraphicHelper, nPhClr ));
+ aGradient.EndColor = sal_Int32(aEndColor.getColor( rGraphicHelper, nPhClr ));
- // If it's the last segment that is uniformly coloured, rotate the gradient 180
- // degrees and swap start and end colours
- if (std::next(aWidestSegmentStart) == std::prev(aGradientStops.end()))
- {
- bSwap = true;
- nShapeRotation = 180*60000 - nShapeRotation;
- }
+ if( aStartColor.hasTransparency() )
+ nStartTrans = aStartColor.getTransparency()*255/100;
+ if( aEndColor.hasTransparency() )
+ nEndTrans = aEndColor.getTransparency()*255/100;
- aGradientStops.erase( aWidestSegmentStart++ );
+ aGradient.Border = rtl::math::round(100*nBorder);
+ }
- // Look for which is widest now
- aIt = std::next(aGradientStops.begin());
- nWidestWidth = -1;
- while( aIt != aGradientStops.end() )
- {
- if (aIt->first - std::prev(aIt)->first > nWidestWidth)
- {
- nWidestWidth = aIt->first - std::prev(aIt)->first;
- aWidestSegmentStart = std::prev(aIt);
- }
- ++aIt;
- }
- }
- SAL_INFO("oox.drawingml.gradient", "widest segment start: " << aWidestSegmentStart->first << ", border: " << nBorder);
- assert( (!bSymmetric && !bSwap) || !(bSymmetric && bSwap) );
-
- // Now we have a potential border and a largest segment. Use those.
-
- aGradient.Style = bSymmetric ? awt::GradientStyle_AXIAL : awt::GradientStyle_LINEAR;
- sal_Int32 nShadeAngle = maGradientProps.moShadeAngle.get( 0 );
- // Adjust for flips
- if ( bFlipH )
- nShadeAngle = 180*60000 - nShadeAngle;
- if ( bFlipV )
- nShadeAngle = -nShadeAngle;
- sal_Int32 nDmlAngle = nShadeAngle + nShapeRotation;
- // convert DrawingML angle (in 1/60000 degrees) to API angle (in 1/10 degrees)
- aGradient.Angle = static_cast< sal_Int16 >( (8100 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 );
- Color aStartColor, aEndColor;
- if( bSymmetric )
- {
- aStartColor = std::next(aWidestSegmentStart)->second;
- aEndColor = aWidestSegmentStart->second;
- nBorder *= 2;
- }
- else if( bSwap )
- {
- aStartColor = std::next(aWidestSegmentStart)->second;
- aEndColor = aWidestSegmentStart->second;
- }
- else
- {
- aStartColor = aWidestSegmentStart->second;
- aEndColor = std::next(aWidestSegmentStart)->second;
- }
+ // push gradient or named gradient to property map
+ if( rPropMap.setProperty( ShapeProperty::FillGradient, aGradient ) )
+ eFillStyle = FillStyle_GRADIENT;
- SAL_INFO("oox.drawingml.gradient", "start color: " << std::hex << sal_Int32(aStartColor.getColor( rGraphicHelper, nPhClr )) << std::dec <<
- "@" << (100-aStartColor.getTransparency()) << "%"
- ", end color: " << std::hex << sal_Int32(aEndColor.getColor( rGraphicHelper, nPhClr )) << std::dec <<
- "@" << (100-aEndColor.getTransparency()) << "%");
+ // push gradient transparency to property map
+ if( nStartTrans != 0 || nEndTrans != 0 )
+ {
+ awt::Gradient aGrad(aGradient);
+ uno::Any aVal;
+ aGrad.EndColor = static_cast<sal_Int32>( nEndTrans | nEndTrans << 8 | nEndTrans << 16 );
+ aGrad.StartColor = static_cast<sal_Int32>( nStartTrans | nStartTrans << 8 | nStartTrans << 16 );
+ aVal <<= aGrad;
+ rPropMap.setProperty( ShapeProperty::GradientTransparency, aGrad );
+ }
- aGradient.StartColor = sal_Int32(aStartColor.getColor( rGraphicHelper, nPhClr ));
- aGradient.EndColor = sal_Int32(aEndColor.getColor( rGraphicHelper, nPhClr ));
+ }
+ break;
- if( aStartColor.hasTransparency() )
- nStartTrans = aStartColor.getTransparency()*255/100;
- if( aEndColor.hasTransparency() )
- nEndTrans = aEndColor.getTransparency()*255/100;
+ case XML_blipFill:
+ // do not start complex graphic transformation if property is not supported...
+ if (maBlipProps.mxFillGraphic.is() && rPropMap.supportsProperty(ShapeProperty::FillBitmap))
+ {
+ uno::Reference<graphic::XGraphic> xGraphic = lclCheckAndApplyDuotoneTransform(maBlipProps, maBlipProps.mxFillGraphic, rGraphicHelper, nPhClr);
+ // TODO: "rotate with shape" is not possible with our current core
- aGradient.Border = rtl::math::round(100*nBorder);
+ if (xGraphic.is())
+ {
+ if (rPropMap.supportsProperty(ShapeProperty::FillBitmapName) &&
+ rPropMap.setProperty(ShapeProperty::FillBitmapName, xGraphic))
+ {
+ eFillStyle = FillStyle_BITMAP;
}
-
- // push gradient or named gradient to property map
- if( rPropMap.setProperty( ShapeProperty::FillGradient, aGradient ) )
- eFillStyle = FillStyle_GRADIENT;
-
- // push gradient transparency to property map
- if( nStartTrans != 0 || nEndTrans != 0 )
+ else if (rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic))
{
- awt::Gradient aGrad(aGradient);
- uno::Any aVal;
- aGrad.EndColor = static_cast<sal_Int32>( nEndTrans | nEndTrans << 8 | nEndTrans << 16 );
- aGrad.StartColor = static_cast<sal_Int32>( nStartTrans | nStartTrans << 8 | nStartTrans << 16 );
- aVal <<= aGrad;
- rPropMap.setProperty( ShapeProperty::GradientTransparency, aGrad );
+ eFillStyle = FillStyle_BITMAP;
}
-
}
- break;
- case XML_blipFill:
- // do not start complex graphic transformation if property is not supported...
- if (maBlipProps.mxFillGraphic.is() && rPropMap.supportsProperty(ShapeProperty::FillBitmap))
+ // set other bitmap properties, if bitmap has been inserted into the map
+ if( eFillStyle == FillStyle_BITMAP )
{
- uno::Reference<graphic::XGraphic> xGraphic = lclCheckAndApplyDuotoneTransform(maBlipProps, maBlipProps.mxFillGraphic, rGraphicHelper, nPhClr);
- // TODO: "rotate with shape" is not possible with our current core
+ // bitmap mode (single, repeat, stretch)
+ BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.get( XML_TOKEN_INVALID ) );
+ rPropMap.setProperty( ShapeProperty::FillBitmapMode, eBitmapMode );
- if (xGraphic.is())
+ // additional settings for repeated bitmap
+ if( eBitmapMode == BitmapMode_REPEAT )
{
- if (rPropMap.supportsProperty(ShapeProperty::FillBitmapName) &&
- rPropMap.setProperty(ShapeProperty::FillBitmapName, xGraphic))
- {
- eFillStyle = FillStyle_BITMAP;
- }
- else if (rPropMap.setProperty(ShapeProperty::FillBitmap, xGraphic))
+ // anchor position inside bitmap
+ RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) );
+ rPropMap.setProperty( ShapeProperty::FillBitmapRectanglePoint, eRectPoint );
+
+ awt::Size aOriginalSize = lclGetOriginalSize(rGraphicHelper, maBlipProps.mxFillGraphic);
+ if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) )
{
- eFillStyle = FillStyle_BITMAP;
+ // size of one bitmap tile (given as 1/1000 percent of bitmap size), convert to 1/100 mm
+ double fScaleX = maBlipProps.moTileScaleX.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
+ sal_Int32 nFillBmpSizeX = getLimitedValue< sal_Int32, double >( aOriginalSize.Width * fScaleX, 1, SAL_MAX_INT32 );
+ rPropMap.setProperty( ShapeProperty::FillBitmapSizeX, nFillBmpSizeX );
+ double fScaleY = maBlipProps.moTileScaleY.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
+ sal_Int32 nFillBmpSizeY = getLimitedValue< sal_Int32, double >( aOriginalSize.Height * fScaleY, 1, SAL_MAX_INT32 );
+ rPropMap.setProperty( ShapeProperty::FillBitmapSizeY, nFillBmpSizeY );
+
+ // offset of the first bitmap tile (given as EMUs), convert to percent
+ sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetX.get( 0 ) / 3.6 / aOriginalSize.Width, 0, 100 );
+ rPropMap.setProperty( ShapeProperty::FillBitmapOffsetX, nTileOffsetX );
+ sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetY.get( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 );
+ rPropMap.setProperty( ShapeProperty::FillBitmapOffsetY, nTileOffsetY );
}
}
-
- // set other bitmap properties, if bitmap has been inserted into the map
- if( eFillStyle == FillStyle_BITMAP )
+ else if ( eBitmapMode == BitmapMode_STRETCH && maBlipProps.moFillRect.has() )
{
- // bitmap mode (single, repeat, stretch)
- BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.get( XML_TOKEN_INVALID ) );
- rPropMap.setProperty( ShapeProperty::FillBitmapMode, eBitmapMode );
-
- // additional settings for repeated bitmap
- if( eBitmapMode == BitmapMode_REPEAT )
+ geometry::IntegerRectangle2D aFillRect( maBlipProps.moFillRect.get() );
+ awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) );
+ if ( aOriginalSize.Width && aOriginalSize.Height )
{
- // anchor position inside bitmap
- RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) );
- rPropMap.setProperty( ShapeProperty::FillBitmapRectanglePoint, eRectPoint );
-
- awt::Size aOriginalSize = lclGetOriginalSize(rGraphicHelper, maBlipProps.mxFillGraphic);
- if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) )
- {
- // size of one bitmap tile (given as 1/1000 percent of bitmap size), convert to 1/100 mm
- double fScaleX = maBlipProps.moTileScaleX.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
- sal_Int32 nFillBmpSizeX = getLimitedValue< sal_Int32, double >( aOriginalSize.Width * fScaleX, 1, SAL_MAX_INT32 );
- rPropMap.setProperty( ShapeProperty::FillBitmapSizeX, nFillBmpSizeX );
- double fScaleY = maBlipProps.moTileScaleY.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
- sal_Int32 nFillBmpSizeY = getLimitedValue< sal_Int32, double >( aOriginalSize.Height * fScaleY, 1, SAL_MAX_INT32 );
- rPropMap.setProperty( ShapeProperty::FillBitmapSizeY, nFillBmpSizeY );
-
- // offset of the first bitmap tile (given as EMUs), convert to percent
- sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetX.get( 0 ) / 3.6 / aOriginalSize.Width, 0, 100 );
- rPropMap.setProperty( ShapeProperty::FillBitmapOffsetX, nTileOffsetX );
- sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetY.get( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 );
- rPropMap.setProperty( ShapeProperty::FillBitmapOffsetY, nTileOffsetY );
- }
- }
- else if ( eBitmapMode == BitmapMode_STRETCH && maBlipProps.moFillRect.has() )
- {
- geometry::IntegerRectangle2D aFillRect( maBlipProps.moFillRect.get() );
- awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) );
- if ( aOriginalSize.Width && aOriginalSize.Height )
- {
- text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
- if ( aFillRect.X1 )
- aGraphCrop.Left = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * aFillRect.X1 ) / 100000 );
- if ( aFillRect.Y1 )
- aGraphCrop.Top = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y1 ) / 100000 );
- if ( aFillRect.X2 )
- aGraphCrop.Right = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * aFillRect.X2 ) / 100000 );
- if ( aFillRect.Y2 )
- aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 100000 );
- rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
- }
+ text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
+ if ( aFillRect.X1 )
+ aGraphCrop.Left = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * aFillRect.X1 ) / 100000 );
+ if ( aFillRect.Y1 )
+ aGraphCrop.Top = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y1 ) / 100000 );
+ if ( aFillRect.X2 )
+ aGraphCrop.Right = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * aFillRect.X2 ) / 100000 );
+ if ( aFillRect.Y2 )
+ aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 100000 );
+ rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
}
}
-
- if (maBlipProps.moAlphaModFix.has())
- rPropMap.setProperty(ShapeProperty::FillTransparency, static_cast<sal_Int16>(100 - (maBlipProps.moAlphaModFix.get() / PER_PERCENT)));
}
- break;
- case XML_pattFill:
+ if (maBlipProps.moAlphaModFix.has())
+ rPropMap.setProperty(ShapeProperty::FillTransparency, static_cast<sal_Int16>(100 - (maBlipProps.moAlphaModFix.get() / PER_PERCENT)));
+ }
+ break;
+
+ case XML_pattFill:
+ {
+ if( rPropMap.supportsProperty( ShapeProperty::FillHatch ) )
{
- if( rPropMap.supportsProperty( ShapeProperty::FillHatch ) )
+ Color aColor( maPatternProps.maPattFgColor );
+ if( aColor.isUsed() && maPatternProps.moPattPreset.has() )
{
- Color aColor( maPatternProps.maPattFgColor );
- if( aColor.isUsed() && maPatternProps.moPattPreset.has() )
- {
- eFillStyle = FillStyle_HATCH;
- rPropMap.setProperty( ShapeProperty::FillHatch, createHatch( maPatternProps.moPattPreset.get(), aColor.getColor( rGraphicHelper, nPhClr ) ) );
+ eFillStyle = FillStyle_HATCH;
+ rPropMap.setProperty( ShapeProperty::FillHatch, createHatch( maPatternProps.moPattPreset.get(), aColor.getColor( rGraphicHelper, nPhClr ) ) );
- // Set background color for hatch
- if(maPatternProps.maPattBgColor.isUsed())
- {
- rPropMap.setProperty( ShapeProperty::FillBackground, true );
- rPropMap.setProperty( ShapeProperty::FillColor, maPatternProps.maPattBgColor.getColor( rGraphicHelper, nPhClr ) );
- }
- }
- else if ( maPatternProps.maPattBgColor.isUsed() )
+ // Set background color for hatch
+ if(maPatternProps.maPattBgColor.isUsed())
{
- aColor = maPatternProps.maPattBgColor;
- rPropMap.setProperty( ShapeProperty::FillColor, aColor.getColor( rGraphicHelper, nPhClr ) );
- if( aColor.hasTransparency() )
- rPropMap.setProperty( ShapeProperty::FillTransparency, aColor.getTransparency() );
- eFillStyle = FillStyle_SOLID;
+ rPropMap.setProperty( ShapeProperty::FillBackground, true );
+ rPropMap.setProperty( ShapeProperty::FillColor, maPatternProps.maPattBgColor.getColor( rGraphicHelper, nPhClr ) );
}
}
+ else if ( maPatternProps.maPattBgColor.isUsed() )
+ {
+ aColor = maPatternProps.maPattBgColor;
+ rPropMap.setProperty( ShapeProperty::FillColor, aColor.getColor( rGraphicHelper, nPhClr ) );
+ if( aColor.hasTransparency() )
+ rPropMap.setProperty( ShapeProperty::FillTransparency, aColor.getTransparency() );
+ eFillStyle = FillStyle_SOLID;
+ }
}
- break;
-
- case XML_grpFill:
- // todo
- eFillStyle = FillStyle_NONE;
- break;
}
+ break;
- // set final fill style property
- rPropMap.setProperty( ShapeProperty::FillStyle, eFillStyle );
+ case XML_grpFill:
+ // todo
+ eFillStyle = FillStyle_NONE;
+ break;
}
+
+ // set final fill style property
+ rPropMap.setProperty( ShapeProperty::FillStyle, eFillStyle );
}
void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper) const
diff --git a/oox/source/drawingml/lineproperties.cxx b/oox/source/drawingml/lineproperties.cxx
index 8b6418f995e4..3183d5ce4c24 100644
--- a/oox/source/drawingml/lineproperties.cxx
+++ b/oox/source/drawingml/lineproperties.cxx
@@ -389,20 +389,20 @@ void lclPushMarkerProperties( ShapePropertyMap& rPropMap,
}
// push the properties (filled aNamedMarker.Name indicates valid marker)
- if( !aNamedMarker.Name.isEmpty() )
+ if( aNamedMarker.Name.isEmpty() )
+ return;
+
+ if( bLineEnd )
{
- if( bLineEnd )
- {
- rPropMap.setProperty( ShapeProperty::LineEnd, aNamedMarker );
- rPropMap.setProperty( ShapeProperty::LineEndWidth, nMarkerWidth );
- rPropMap.setProperty( ShapeProperty::LineEndCenter, bMarkerCenter );
- }
- else
- {
- rPropMap.setProperty( ShapeProperty::LineStart, aNamedMarker );
- rPropMap.setProperty( ShapeProperty::LineStartWidth, nMarkerWidth );
- rPropMap.setProperty( ShapeProperty::LineStartCenter, bMarkerCenter );
- }
+ rPropMap.setProperty( ShapeProperty::LineEnd, aNamedMarker );
+ rPropMap.setProperty( ShapeProperty::LineEndWidth, nMarkerWidth );
+ rPropMap.setProperty( ShapeProperty::LineEndCenter, bMarkerCenter );
+ }
+ else
+ {
+ rPropMap.setProperty( ShapeProperty::LineStart, aNamedMarker );
+ rPropMap.setProperty( ShapeProperty::LineStartWidth, nMarkerWidth );
+ rPropMap.setProperty( ShapeProperty::LineStartCenter, bMarkerCenter );
}
}
@@ -433,55 +433,55 @@ void LineProperties::pushToPropMap( ShapePropertyMap& rPropMap,
const GraphicHelper& rGraphicHelper, ::Color nPhClr ) const
{
// line fill type must exist, otherwise ignore other properties
- if( maLineFill.moFillType.has() )
- {
- // line style (our core only supports none and solid)
- drawing::LineStyle eLineStyle = (maLineFill.moFillType.get() == XML_noFill) ? drawing::LineStyle_NONE : drawing::LineStyle_SOLID;
-
- // line width in 1/100mm
- sal_Int32 nLineWidth = getLineWidth(); // includes conversion from EMUs to 1/100mm
- rPropMap.setProperty( ShapeProperty::LineWidth, nLineWidth );
-
- // create line dash from preset dash token or dash stop vector (not for invisible line)
- if( (eLineStyle != drawing::LineStyle_NONE) && (moPresetDash.differsFrom( XML_solid ) || !maCustomDash.empty()) )
- {
- LineDash aLineDash;
- aLineDash.Style = lclGetDashStyle( moLineCap.get( XML_flat ) );
+ if( !maLineFill.moFillType.has() )
+ return;
- if(moPresetDash.differsFrom(XML_solid))
- lclConvertPresetDash(aLineDash, moPresetDash.get(XML_dash));
- else // !maCustomDash.empty()
- {
- lclConvertCustomDash(aLineDash, maCustomDash);
- lclRecoverStandardDashStyles(aLineDash, nLineWidth);
- }
- if( rPropMap.setProperty( ShapeProperty::LineDash, aLineDash ) )
- eLineStyle = drawing::LineStyle_DASH;
- }
- // line cap type
- if( moLineCap.has() )
- rPropMap.setProperty( ShapeProperty::LineCap, lclGetLineCap( moLineCap.get() ) );
+ // line style (our core only supports none and solid)
+ drawing::LineStyle eLineStyle = (maLineFill.moFillType.get() == XML_noFill) ? drawing::LineStyle_NONE : drawing::LineStyle_SOLID;
- // set final line style property
- rPropMap.setProperty( ShapeProperty::LineStyle, eLineStyle );
+ // line width in 1/100mm
+ sal_Int32 nLineWidth = getLineWidth(); // includes conversion from EMUs to 1/100mm
+ rPropMap.setProperty( ShapeProperty::LineWidth, nLineWidth );
- // line joint type
- if( moLineJoint.has() )
- rPropMap.setProperty( ShapeProperty::LineJoint, lclGetLineJoint( moLineJoint.get() ) );
+ // create line dash from preset dash token or dash stop vector (not for invisible line)
+ if( (eLineStyle != drawing::LineStyle_NONE) && (moPresetDash.differsFrom( XML_solid ) || !maCustomDash.empty()) )
+ {
+ LineDash aLineDash;
+ aLineDash.Style = lclGetDashStyle( moLineCap.get( XML_flat ) );
- // line color and transparence
- Color aLineColor = maLineFill.getBestSolidColor();
- if( aLineColor.isUsed() )
+ if(moPresetDash.differsFrom(XML_solid))
+ lclConvertPresetDash(aLineDash, moPresetDash.get(XML_dash));
+ else // !maCustomDash.empty()
{
- rPropMap.setProperty( ShapeProperty::LineColor, aLineColor.getColor( rGraphicHelper, nPhClr ) );
- if( aLineColor.hasTransparency() )
- rPropMap.setProperty( ShapeProperty::LineTransparency, aLineColor.getTransparency() );
+ lclConvertCustomDash(aLineDash, maCustomDash);
+ lclRecoverStandardDashStyles(aLineDash, nLineWidth);
}
+ if( rPropMap.setProperty( ShapeProperty::LineDash, aLineDash ) )
+ eLineStyle = drawing::LineStyle_DASH;
+ }
+ // line cap type
+ if( moLineCap.has() )
+ rPropMap.setProperty( ShapeProperty::LineCap, lclGetLineCap( moLineCap.get() ) );
+
+ // set final line style property
+ rPropMap.setProperty( ShapeProperty::LineStyle, eLineStyle );
+
+ // line joint type
+ if( moLineJoint.has() )
+ rPropMap.setProperty( ShapeProperty::LineJoint, lclGetLineJoint( moLineJoint.get() ) );
- // line markers
- lclPushMarkerProperties( rPropMap, maStartArrow, nLineWidth, false );
- lclPushMarkerProperties( rPropMap, maEndArrow, nLineWidth, true );
+ // line color and transparence
+ Color aLineColor = maLineFill.getBestSolidColor();
+ if( aLineColor.isUsed() )
+ {
+ rPropMap.setProperty( ShapeProperty::LineColor, aLineColor.getColor( rGraphicHelper, nPhClr ) );
+ if( aLineColor.hasTransparency() )
+ rPropMap.setProperty( ShapeProperty::LineTransparency, aLineColor.getTransparency() );
}
+
+ // line markers
+ lclPushMarkerProperties( rPropMap, maStartArrow, nLineWidth, false );
+ lclPushMarkerProperties( rPropMap, maEndArrow, nLineWidth, true );
}
drawing::LineStyle LineProperties::getLineStyle() const
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 76b1737e125a..7ffd1058fda9 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -1780,27 +1780,27 @@ void Shape::putPropertiesToGrabBag( const Sequence< PropertyValue >& aProperties
Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
Reference< XPropertySetInfo > xSetInfo( xSet->getPropertySetInfo() );
const OUString aGrabBagPropName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
- if( mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName ) )
- {
- // get existing grab bag
- Sequence< PropertyValue > aGrabBag;
- xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
+ if( !(mxShape.is() && xSet.is() && xSetInfo.is() && xSetInfo->hasPropertyByName( aGrabBagPropName )) )
+ return;
- std::vector<PropertyValue> aVec;
- aVec.reserve(aProperties.getLength());
+ // get existing grab bag
+ Sequence< PropertyValue > aGrabBag;
+ xSet->getPropertyValue( aGrabBagPropName ) >>= aGrabBag;
- // put the new items
- std::transform(aProperties.begin(), aProperties.end(), std::back_inserter(aVec),
- [](const PropertyValue& rProp) {
- PropertyValue aProp;
- aProp.Name = rProp.Name;
- aProp.Value = rProp.Value;
- return aProp;
- });
+ std::vector<PropertyValue> aVec;
+ aVec.reserve(aProperties.getLength());
- // put it back to the shape
- xSet->setPropertyValue( aGrabBagPropName, Any( comphelper::concatSequences(aGrabBag, aVec) ) );
- }
+ // put the new items
+ std::transform(aProperties.begin(), aProperties.end(), std::back_inserter(aVec),
+ [](const PropertyValue& rProp) {
+ PropertyValue aProp;
+ aProp.Name = rProp.Name;
+ aProp.Value = rProp.Value;
+ return aProp;
+ });
+
+ // put it back to the shape
+ xSet->setPropertyValue( aGrabBagPropName, Any( comphelper::concatSequences(aGrabBag, aVec) ) );
}
FillProperties Shape::getActualFillProperties(const Theme* pTheme, const FillProperties* pParentShapeFillProps) const
diff --git a/oox/source/drawingml/textbodyproperties.cxx b/oox/source/drawingml/textbodyproperties.cxx
index 94163ce10c8b..7143f059a006 100644
--- a/oox/source/drawingml/textbodyproperties.cxx
+++ b/oox/source/drawingml/textbodyproperties.cxx
@@ -39,22 +39,23 @@ TextBodyProperties::TextBodyProperties()
void TextBodyProperties::pushVertSimulation()
{
sal_Int32 tVert = moVert.get( XML_horz );
- if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert ) {
- // #160799# fake different vertical text modes by top-bottom writing mode
- maPropertyMap.setProperty( PROP_TextWritingMode, WritingMode_TB_RL);
+ if( !(tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert) )
+ return;
- // workaround for TB_LR as using WritingMode2 doesn't work
- if( meVA != TextVerticalAdjust_CENTER )
- maPropertyMap.setProperty( PROP_TextHorizontalAdjust,
- (tVert == XML_vert270) ? TextHorizontalAdjust_RIGHT : TextHorizontalAdjust_LEFT);
- if( tVert == XML_vert270 )
- maPropertyMap.setProperty( PROP_TextVerticalAdjust, TextVerticalAdjust_BOTTOM);
- if( ( tVert == XML_vert && meVA == TextVerticalAdjust_TOP ) ||
- ( tVert == XML_vert270 && meVA == TextVerticalAdjust_BOTTOM ) )
- maPropertyMap.setProperty( PROP_TextHorizontalAdjust, TextHorizontalAdjust_RIGHT);
- else if( meVA == TextVerticalAdjust_CENTER )
- maPropertyMap.setProperty( PROP_TextHorizontalAdjust, TextHorizontalAdjust_CENTER);
- }
+ // #160799# fake different vertical text modes by top-bottom writing mode
+ maPropertyMap.setProperty( PROP_TextWritingMode, WritingMode_TB_RL);
+
+ // workaround for TB_LR as using WritingMode2 doesn't work
+ if( meVA != TextVerticalAdjust_CENTER )
+ maPropertyMap.setProperty( PROP_TextHorizontalAdjust,
+ (tVert == XML_vert270) ? TextHorizontalAdjust_RIGHT : TextHorizontalAdjust_LEFT);
+ if( tVert == XML_vert270 )
+ maPropertyMap.setProperty( PROP_TextVerticalAdjust, TextVerticalAdjust_BOTTOM);
+ if( ( tVert == XML_vert && meVA == TextVerticalAdjust_TOP ) ||
+ ( tVert == XML_vert270 && meVA == TextVerticalAdjust_BOTTOM ) )
+ maPropertyMap.setProperty( PROP_TextHorizontalAdjust, TextHorizontalAdjust_RIGHT);
+ else if( meVA == TextVerticalAdjust_CENTER )
+ maPropertyMap.setProperty( PROP_TextHorizontalAdjust, TextHorizontalAdjust_CENTER);
}
/* Push adjusted values, taking into consideration Shape Rotation */
diff --git a/oox/source/dump/dumperbase.cxx b/oox/source/dump/dumperbase.cxx
index 067d4a3b35f4..3329cc5e12aa 100644
--- a/oox/source/dump/dumperbase.cxx
+++ b/oox/source/dump/dumperbase.cxx
@@ -1346,17 +1346,17 @@ void SharedConfigData::createShortList( const OUString& rData )
{
OUStringVector aDataVec;
StringHelper::convertStringToStringList( aDataVec, rData, false );
- if( aDataVec.size() >= 3 )
+ if( aDataVec.size() < 3 )
+ return;
+
+ sal_Int64 nStartKey;
+ if( StringHelper::convertStringToInt( nStartKey, aDataVec[ 1 ] ) )
{
- sal_Int64 nStartKey;
- if( StringHelper::convertStringToInt( nStartKey, aDataVec[ 1 ] ) )
+ std::shared_ptr< MultiList > xList = createNameList< MultiList >( aDataVec[ 0 ] );
+ if( xList.get() )
{
- std::shared_ptr< MultiList > xList = createNameList< MultiList >( aDataVec[ 0 ] );
- if( xList.get() )
- {
- aDataVec.erase( aDataVec.begin(), aDataVec.begin() + 2 );
- xList->setNamesFromVec( nStartKey, aDataVec );
- }
+ aDataVec.erase( aDataVec.begin(), aDataVec.begin() + 2 );
+ xList->setNamesFromVec( nStartKey, aDataVec );
}
}
}
@@ -1365,22 +1365,22 @@ void SharedConfigData::createUnitConverter( const OUString& rData )
{
OUStringVector aDataVec;
StringHelper::convertStringToStringList( aDataVec, rData, false );
- if( aDataVec.size() >= 2 )
- {
- OUString aFactor = aDataVec[ 1 ];
- bool bRecip = aFactor.startsWith("/");
- if( bRecip )
- aFactor = aFactor.copy( 1 );
- double fFactor;
- if( StringHelper::convertStringToDouble( fFactor, aFactor ) && (fFactor != 0.0) )
+ if( aDataVec.size() < 2 )
+ return;
+
+ OUString aFactor = aDataVec[ 1 ];
+ bool bRecip = aFactor.startsWith("/");
+ if( bRecip )
+ aFactor = aFactor.copy( 1 );
+ double fFactor;
+ if( StringHelper::convertStringToDouble( fFactor, aFactor ) && (fFactor != 0.0) )
+ {
+ std::shared_ptr< UnitConverter > xList = createNameList< UnitConverter >( aDataVec[ 0 ] );
+ if( xList.get() )
{
- std::shared_ptr< UnitConverter > xList = createNameList< UnitConverter >( aDataVec[ 0 ] );
- if( xList.get() )
- {
- xList->setFactor( bRecip ? (1.0 / fFactor) : fFactor );
- if( aDataVec.size() >= 3 )
- xList->setUnitName( aDataVec[ 2 ] );
- }
+ xList->setFactor( bRecip ? (1.0 / fFactor) : fFactor );
+ if( aDataVec.size() >= 3 )
+ xList->setUnitName( aDataVec[ 2 ] );
}
}
}
diff --git a/oox/source/dump/oledumper.cxx b/oox/source/dump/oledumper.cxx
index 61115283b5d3..4a9102bb7ccc 100644
--- a/oox/source/dump/oledumper.cxx
+++ b/oox/source/dump/oledumper.cxx
@@ -1115,28 +1115,28 @@ void AxPropertyObjectBase::dumpLargeProperties()
}
dumpToPosition( mnPropertiesEnd );
- if( ensureValid() && !maStreamProps.empty() )
+ if( !(ensureValid() && !maStreamProps.empty()) )
+ return;
+
+ writeEmptyItem( "stream-properties" );
+ IndentGuard aIndGuard( mxOut );
+ for (auto const& streamProp : maStreamProps)
{
- writeEmptyItem( "stream-properties" );
- IndentGuard aIndGuard( mxOut );
- for (auto const& streamProp : maStreamProps)
+ if (!ensureValid())
+ break;
+ writeEmptyItem( streamProp.maItemName );
+ if( ensureValid( streamProp.mnData == 0xFFFF ) )
{
- if (!ensureValid())
- break;
- writeEmptyItem( streamProp.maItemName );
- if( ensureValid( streamProp.mnData == 0xFFFF ) )
- {
- IndentGuard aIndGuard2( mxOut );
- OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
- if ( aClassName == "StdFont" )
- StdFontObject( *this ).dump();
- else if ( aClassName == "StdPic" )
- StdPicObject( *this ).dump();
- else if ( aClassName == "CFontNew" )
- AxCFontNewObject( *this ).dump();
- else
- ensureValid( false );
- }
+ IndentGuard aIndGuard2( mxOut );
+ OUString aClassName = cfg().getStringOption( dumpGuid(), OUString() );
+ if ( aClassName == "StdFont" )
+ StdFontObject( *this ).dump();
+ else if ( aClassName == "StdPic" )
+ StdPicObject( *this ).dump();
+ else if ( aClassName == "CFontNew" )
+ AxCFontNewObject( *this ).dump();
+ else
+ ensureValid( false );
}
}
}
@@ -1661,39 +1661,39 @@ void VbaFStreamObject::dumpFormSites( sal_uInt32 nCount )
void VbaFStreamObject::dumpSiteData()
{
- if( ensureValid() )
+ if( !ensureValid() )
+ return;
+
+ mxOut->emptyLine();
+ setAlignAnchor();
+ sal_uInt32 nSiteCount = dumpDec< sal_uInt32 >( "site-count" );
+ sal_uInt32 nSiteLength = dumpDec< sal_uInt32 >( "site-data-size" );
+ sal_Int64 nEndPos = mxStrm->tell() + nSiteLength;
+ if( !ensureValid( nEndPos <= mxStrm->size() ) )
+ return;
+
+ mxOut->resetItemIndex();
+ sal_uInt32 nSiteIdx = 0;
+ while( ensureValid() && (nSiteIdx < nSiteCount) )
{
mxOut->emptyLine();
- setAlignAnchor();
- sal_uInt32 nSiteCount = dumpDec< sal_uInt32 >( "site-count" );
- sal_uInt32 nSiteLength = dumpDec< sal_uInt32 >( "site-data-size" );
- sal_Int64 nEndPos = mxStrm->tell() + nSiteLength;
- if( ensureValid( nEndPos <= mxStrm->size() ) )
+ writeEmptyItem( "#site-info" );
+ IndentGuard aIndGuard( mxOut );
+ dumpDec< sal_uInt8 >( "depth" );
+ sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "VBA-FORM-SITE-TYPECOUNT" );
+ if( getFlag( nTypeCount, AX_FORM_SITECOUNTTYPE_COUNT ) )
{
- mxOut->resetItemIndex();
- sal_uInt32 nSiteIdx = 0;
- while( ensureValid() && (nSiteIdx < nSiteCount) )
- {
- mxOut->emptyLine();
- writeEmptyItem( "#site-info" );
- IndentGuard aIndGuard( mxOut );
- dumpDec< sal_uInt8 >( "depth" );
- sal_uInt8 nTypeCount = dumpHex< sal_uInt8 >( "type-count", "VBA-FORM-SITE-TYPECOUNT" );
- if( getFlag( nTypeCount, AX_FORM_SITECOUNTTYPE_COUNT ) )
- {
- dumpDec< sal_uInt8 >( "repeated-type" );
- nSiteIdx += (nTypeCount & AX_FORM_SITECOUNTTYPE_MASK);
- }
- else
- {
- ++nSiteIdx;
- }
- }
- alignInput< sal_uInt32 >();
- dumpFormSites( nSiteCount );
- dumpToPosition( nEndPos );
+ dumpDec< sal_uInt8 >( "repeated-type" );
+ nSiteIdx += (nTypeCount & AX_FORM_SITECOUNTTYPE_MASK);
+ }
+ else
+ {
+ ++nSiteIdx;
}
}
+ alignInput< sal_uInt32 >();
+ dumpFormSites( nSiteCount );
+ dumpToPosition( nEndPos );
}
void VbaFStreamObject::dumpDesignExtender()
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 2d7758fb7ed0..d6eaac8eedb2 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -761,21 +761,23 @@ void ChartExport::WriteChartObj( const Reference< XShape >& xShape, sal_Int32 nI
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())
- {
- mbHasCategoryLabels = lcl_hasCategoryLabels( xChartDoc );
- mbIsCategoryPositionShifted = lcl_isCategoryAxisShifted( xChartDoc );
- }
- }
- catch( const uno::Exception & )
+ if( !xChartDoc.is())
+ return;
+
+ try
+ {
+ Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider() );
+ OSL_ENSURE( xDataProvider.is(), "No DataProvider" );
+ if( xDataProvider.is())
{
- DBG_UNHANDLED_EXCEPTION("oox");
+ mbHasCategoryLabels = lcl_hasCategoryLabels( xChartDoc );
+ mbIsCategoryPositionShifted = lcl_isCategoryAxisShifted( xChartDoc );
}
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_UNHANDLED_EXCEPTION("oox");
+ }
}
void ChartExport::ExportContent()
@@ -873,30 +875,30 @@ void ChartExport::exportExternalData( const Reference< css::chart::XChartDocumen
SAL_WARN("oox", "Required property not found in ChartDocument");
}
}
- if(!externalDataPath.isEmpty())
+ if(externalDataPath.isEmpty())
+ return;
+
+ // Here adding external data entry to relationship.
+ OUString relationPath = externalDataPath;
+ // Converting absolute path to relative path.
+ if( externalDataPath[ 0 ] != '.' && externalDataPath[ 1 ] != '.')
{
- // Here adding external data entry to relationship.
- OUString relationPath = externalDataPath;
- // Converting absolute path to relative path.
- if( externalDataPath[ 0 ] != '.' && externalDataPath[ 1 ] != '.')
+ sal_Int32 nSepPos = externalDataPath.indexOf( '/', 0 );
+ if( nSepPos > 0)
{
- sal_Int32 nSepPos = externalDataPath.indexOf( '/', 0 );
- if( nSepPos > 0)
- {
- relationPath = relationPath.copy( nSepPos, ::std::max< sal_Int32 >( externalDataPath.getLength(), 0 ) - nSepPos );
- relationPath = ".." + relationPath;
- }
+ relationPath = relationPath.copy( nSepPos, ::std::max< sal_Int32 >( externalDataPath.getLength(), 0 ) - nSepPos );
+ relationPath = ".." + relationPath;
}
- FSHelperPtr pFS = GetFS();
- OUString type = oox::getRelationship(Relationship::PACKAGE);
- if (relationPath.endsWith(".bin"))
- type = oox::getRelationship(Relationship::OLEOBJECT);
-
- OUString sRelId = GetFB()->addRelation(pFS->getOutputStream(),
- type,
- relationPath);
- pFS->singleElementNS(XML_c, XML_externalData, FSNS(XML_r, XML_id), sRelId.toUtf8());
}
+ FSHelperPtr pFS = GetFS();
+ OUString type = oox::getRelationship(Relationship::PACKAGE);
+ if (relationPath.endsWith(".bin"))
+ type = oox::getRelationship(Relationship::OLEOBJECT);
+
+ OUString sRelId = GetFB()->addRelation(pFS->getOutputStream(),
+ type,
+ relationPath);
+ pFS->singleElementNS(XML_c, XML_externalData, FSNS(XML_r, XML_id), sRelId.toUtf8());
}
void ChartExport::exportChart( const Reference< css::chart::XChartDocument >& xChartDoc )
@@ -1581,70 +1583,69 @@ void ChartExport::exportHatch( const Reference< XPropertySet >& xPropSet )
void ChartExport::exportBitmapFill( const Reference< XPropertySet >& xPropSet )
{
- if( xPropSet.is() )
- {
- OUString sFillBitmapName;
- xPropSet->getPropertyValue("FillBitmapName") >>= sFillBitmapName;
+ if( !xPropSet.is() )
+ return;
- uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY );
- try
+ OUString sFillBitmapName;
+ xPropSet->getPropertyValue("FillBitmapName") >>= sFillBitmapName;
+
+ uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY );
+ try
+ {
+ uno::Reference< container::XNameAccess > xBitmapTable( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY );
+ uno::Any rValue = xBitmapTable->getByName( sFillBitmapName );
+ if (rValue.has<uno::Reference<awt::XBitmap>>())
{
- uno::Reference< container::XNameAccess > xBitmapTable( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY );
- uno::Any rValue = xBitmapTable->getByName( sFillBitmapName );
- if (rValue.has<uno::Reference<awt::XBitmap>>())
+ uno::Reference<awt::XBitmap> xBitmap = rValue.get<uno::Reference<awt::XBitmap>>();
+ uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
+ if (xGraphic.is())
{
- uno::Reference<awt::XBitmap> xBitmap = rValue.get<uno::Reference<awt::XBitmap>>();
- uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
- if (xGraphic.is())
- {
- WriteXGraphicBlipFill(xPropSet, xGraphic, XML_a, true, true);
- }
+ WriteXGraphicBlipFill(xPropSet, xGraphic, XML_a, true, true);
}
}
- catch (const uno::Exception &)
- {
- TOOLS_WARN_EXCEPTION("oox", "ChartExport::exportBitmapFill");
- }
+ }
+ catch (const uno::Exception &)
+ {
+ TOOLS_WARN_EXCEPTION("oox", "ChartExport::exportBitmapFill");
}
}
void ChartExport::exportGradientFill( const Reference< XPropertySet >& xPropSet )
{
- if( xPropSet.is() )
- {
- OUString sFillGradientName;
- xPropSet->getPropertyValue("FillGradientName") >>= sFillGradientName;
+ if( !xPropSet.is() )
+ return;
- awt::Gradient aGradient;
- awt::Gradient aTransparenceGradient;
- uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY );
- try
+ OUString sFillGradientName;
+ xPropSet->getPropertyValue("FillGradientName") >>= sFillGradientName;
+
+ awt::Gradient aGradient;
+ awt::Gradient aTransparenceGradient;
+ uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY );
+ try
+ {
+ uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY );
+ uno::Any rGradientValue = xGradient->getByName( sFillGradientName );
+ if( rGradientValue >>= aGradient )
{
- uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY );
- uno::Any rGradientValue = xGradient->getByName( sFillGradientName );
- if( rGradientValue >>= aGradient )
+ mpFS->startElementNS(XML_a, XML_gradFill);
+ OUString sFillTransparenceGradientName;
+ if( (xPropSet->getPropertyValue("FillTransparenceGradientName") >>= sFillTransparenceGradientName) && !sFillTransparenceGradientName.isEmpty())
{
- mpFS->startElementNS(XML_a, XML_gradFill);
- OUString sFillTransparenceGradientName;
- if( (xPropSet->getPropertyValue("FillTransparenceGradientName") >>= sFillTransparenceGradientName) && !sFillTransparenceGradientName.isEmpty())
- {
- uno::Reference< container::XNameAccess > xTransparenceGradient(xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY);
- uno::Any rTransparenceValue = xTransparenceGradient->getByName(sFillTransparenceGradientName);
- rTransparenceValue >>= aTransparenceGradient;
- WriteGradientFill(aGradient, aTransparenceGradient);
- }
- else
- {
- WriteGradientFill(aGradient, aTransparenceGradient, xPropSet);
- }
- mpFS->endElementNS(XML_a, XML_gradFill);
+ uno::Reference< container::XNameAccess > xTransparenceGradient(xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY);
+ uno::Any rTransparenceValue = xTransparenceGradient->getByName(sFillTransparenceGradientName);
+ rTransparenceValue >>= aTransparenceGradient;
+ WriteGradientFill(aGradient, aTransparenceGradient);
}
+ else
+ {
+ WriteGradientFill(aGradient, aTransparenceGradient, xPropSet);
+ }
+ mpFS->endElementNS(XML_a, XML_gradFill);
}
- catch (const uno::Exception &)
- {
- TOOLS_INFO_EXCEPTION("oox", "ChartExport::exportGradientFill");
- }
-
+ }
+ catch (const uno::Exception &)
+ {
+ TOOLS_INFO_EXCEPTION("oox", "ChartExport::exportGradientFill");
}
}
@@ -1664,19 +1665,19 @@ void ChartExport::exportDataTable( )
if (GetProperty( aPropSet, "DataTableOutline"))
mAny >>= bShowOutline;
- if (bShowVBorder || bShowHBorder || bShowOutline)
- {
- pFS->startElement(FSNS(XML_c, XML_dTable));
- if (bShowHBorder)
- pFS->singleElement( FSNS( XML_c, XML_showHorzBorder ),
- XML_val, "1" );
- if (bShowVBorder)
- pFS->singleElement(FSNS(XML_c, XML_showVertBorder), XML_val, "1");
- if (bShowOutline)
- pFS->singleElement(FSNS(XML_c, XML_showOutline), XML_val, "1");
-
- pFS->endElement( FSNS( XML_c, XML_dTable));
- }
+ if (!(bShowVBorder || bShowHBorder || bShowOutline))
+ return;
+
+ pFS->startElement(FSNS(XML_c, XML_dTable));
+ if (bShowHBorder)
+ pFS->singleElement( FSNS( XML_c, XML_showHorzBorder ),
+ XML_val, "1" );
+ if (bShowVBorder)
+ pFS->singleElement(FSNS(XML_c, XML_showVertBorder), XML_val, "1");
+ if (bShowOutline)
+ pFS->singleElement(FSNS(XML_c, XML_showOutline), XML_val, "1");
+
+ pFS->endElement( FSNS( XML_c, XML_dTable));
}
void ChartExport::exportAreaChart( const Reference< chart2::XChartType >& xChartType )
@@ -2063,37 +2064,37 @@ void ChartExport::exportUpDownBars( const Reference< chart2::XChartType >& xChar
FSHelperPtr pFS = GetFS();
// export the chart property
Reference< css::chart::XStatisticDisplay > xChartPropProvider( mxDiagram, uno::UNO_QUERY );
- if(xChartPropProvider.is())
- {
- // updownbar
- pFS->startElement(FSNS(XML_c, XML_upDownBars));
- // TODO: gapWidth
- pFS->singleElement(FSNS(XML_c, XML_gapWidth), XML_val, OString::number(150));
+ if(!xChartPropProvider.is())
+ return;
+
+ // updownbar
+ pFS->startElement(FSNS(XML_c, XML_upDownBars));
+ // TODO: gapWidth
+ pFS->singleElement(FSNS(XML_c, XML_gapWidth), XML_val, OString::number(150));
- Reference< beans::XPropertySet > xChartPropSet = xChartPropProvider->getUpBar();
- if( xChartPropSet.is() )
+ Reference< beans::XPropertySet > xChartPropSet = xChartPropProvider->getUpBar();
+ if( xChartPropSet.is() )
+ {
+ pFS->startElement(FSNS(XML_c, XML_upBars));
+ // For Linechart with UpDownBars, spPr is not getting imported
+ // so no need to call the exportShapeProps() for LineChart
+ if(xChartType->getChartType() == "com.sun.star.chart2.CandleStickChartType")
{
- pFS->startElement(FSNS(XML_c, XML_upBars));
- // For Linechart with UpDownBars, spPr is not getting imported
- // so no need to call the exportShapeProps() for LineChart
- if(xChartType->getChartType() == "com.sun.star.chart2.CandleStickChartType")
- {
- exportShapeProps(xChartPropSet);
- }
- pFS->endElement( FSNS( XML_c, XML_upBars ) );
+ exportShapeProps(xChartPropSet);
}
- xChartPropSet = xChartPropProvider->getDownBar();
- if( xChartPropSet.is() )
+ pFS->endElement( FSNS( XML_c, XML_upBars ) );
+ }
+ xChartPropSet = xChartPropProvider->getDownBar();
+ if( xChartPropSet.is() )
+ {
+ pFS->startElement(FSNS(XML_c, XML_downBars));
+ if(xChartType->getChartType() == "com.sun.star.chart2.CandleStickChartType")
{
- pFS->startElement(FSNS(XML_c, XML_downBars));
- if(xChartType->getChartType() == "com.sun.star.chart2.CandleStickChartType")
- {
- exportShapeProps(xChartPropSet);
- }
- pFS->endElement( FSNS( XML_c, XML_downBars ) );
+ exportShapeProps(xChartPropSet);
}
- pFS->endElement( FSNS( XML_c, XML_upDownBars ) );
+ pFS->endElement( FSNS( XML_c, XML_downBars ) );
}
+ pFS->endElement( FSNS( XML_c, XML_upDownBars ) );
}
void ChartExport::exportSurfaceChart( const Reference< chart2::XChartType >& xChartType )
@@ -3554,56 +3555,56 @@ void ChartExport::exportDataPoints(
}
// Export Data Point Property in Charts even if the VaryColors is false
- if( !bVaryColorsByPoint )
+ if( bVaryColorsByPoint )
+ return;
+
+ ::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 )
{
- ::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 )
{
- uno::Reference< beans::XPropertySet > xPropSet;
- if( aAttrPointSet.find( nElement ) != aEndIt )
+ try
{
- try
- {
- xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet(
- xSeries, nElement, getModel() );
- }
- catch( const uno::Exception & )
- {
- DBG_UNHANDLED_EXCEPTION( "oox", "Exception caught during Export of data point" );
- }
+ xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet(
+ xSeries, nElement, getModel() );
}
-
- if( xPropSet.is() )
+ catch( const uno::Exception & )
{
- FSHelperPtr pFS = GetFS();
- pFS->startElement(FSNS(XML_c, XML_dPt));
- pFS->singleElement(FSNS(XML_c, XML_idx), XML_val, OString::number(nElement));
+ DBG_UNHANDLED_EXCEPTION( "oox", "Exception caught during Export of data point" );
+ }
+ }
- switch( eChartType )
- {
- case chart::TYPEID_BUBBLE:
- case chart::TYPEID_HORBAR:
- case chart::TYPEID_BAR:
- pFS->singleElement(FSNS(XML_c, XML_invertIfNegative), XML_val, "0");
- exportShapeProps(xPropSet);
- break;
+ if( xPropSet.is() )
+ {
+ FSHelperPtr pFS = GetFS();
+ pFS->startElement(FSNS(XML_c, XML_dPt));
+ pFS->singleElement(FSNS(XML_c, XML_idx), XML_val, OString::number(nElement));
- case chart::TYPEID_LINE:
- case chart::TYPEID_SCATTER:
- case chart::TYPEID_RADARLINE:
- exportMarker(xPropSet);
- break;
+ switch( eChartType )
+ {
+ case chart::TYPEID_BUBBLE:
+ case chart::TYPEID_HORBAR:
+ case chart::TYPEID_BAR:
+ pFS->singleElement(FSNS(XML_c, XML_invertIfNegative), XML_val, "0");
+ exportShapeProps(xPropSet);
+ break;
- default:
- exportShapeProps(xPropSet);
- break;
- }
+ case chart::TYPEID_LINE:
+ case chart::TYPEID_SCATTER:
+ case chart::TYPEID_RADARLINE:
+ exportMarker(xPropSet);
+ break;
- pFS->endElement( FSNS( XML_c, XML_dPt ) );
+ default:
+ exportShapeProps(xPropSet);
+ break;
}
+
+ pFS->endElement( FSNS( XML_c, XML_dPt ) );
}
}
}
@@ -3680,126 +3681,126 @@ void ChartExport::exportTrendlines( const Reference< chart2::XDataSeries >& xSer
{
FSHelperPtr pFS = GetFS();
Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeries, UNO_QUERY );
- if( xRegressionCurveContainer.is() )
+ if( !xRegressionCurveContainer.is() )
+ return;
+
+ const Sequence< Reference< chart2::XRegressionCurve > > aRegCurveSeq = xRegressionCurveContainer->getRegressionCurves();
+ for( const Reference< chart2::XRegressionCurve >& xRegCurve : aRegCurveSeq )
{
- const Sequence< Reference< chart2::XRegressionCurve > > aRegCurveSeq = xRegressionCurveContainer->getRegressionCurves();
- for( const Reference< chart2::XRegressionCurve >& xRegCurve : aRegCurveSeq )
- {
- if (!xRegCurve.is())
- continue;
+ if (!xRegCurve.is())
+ continue;
- Reference< XPropertySet > xProperties( xRegCurve , uno::UNO_QUERY );
+ Reference< XPropertySet > xProperties( xRegCurve , uno::UNO_QUERY );
- OUString aService;
- Reference< lang::XServiceName > xServiceName( xProperties, UNO_QUERY );
- if( !xServiceName.is() )
- continue;
+ OUString aService;
+ Reference< lang::XServiceName > xServiceName( xProperties, UNO_QUERY );
+ if( !xServiceName.is() )
+ continue;
- aService = xServiceName->getServiceName();
+ aService = xServiceName->getServiceName();
- if(aService != "com.sun.star.chart2.LinearRegressionCurve" &&
- aService != "com.sun.star.chart2.ExponentialRegressionCurve" &&
- aService != "com.sun.star.chart2.LogarithmicRegressionCurve" &&
- aService != "com.sun.star.chart2.PotentialRegressionCurve" &&
- aService != "com.sun.star.chart2.PolynomialRegressionCurve" &&
- aService != "com.sun.star.chart2.MovingAverageRegressionCurve")
- continue;
+ if(aService != "com.sun.star.chart2.LinearRegressionCurve" &&
+ aService != "com.sun.star.chart2.ExponentialRegressionCurve" &&
+ aService != "com.sun.star.chart2.LogarithmicRegressionCurve" &&
+ aService != "com.sun.star.chart2.PotentialRegressionCurve" &&
+ aService != "com.sun.star.chart2.PolynomialRegressionCurve" &&
+ aService != "com.sun.star.chart2.MovingAverageRegressionCurve")
+ continue;
- pFS->startElement(FSNS(XML_c, XML_trendline));
+ pFS->startElement(FSNS(XML_c, XML_trendline));
- OUString aName;
- xProperties->getPropertyValue("CurveName") >>= aName;
- if(!aName.isEmpty())
- {
- pFS->startElement(FSNS(XML_c, XML_name));
- pFS->writeEscaped(aName);
- pFS->endElement( FSNS( XML_c, XML_name) );
- }
+ OUString aName;
+ xProperties->getPropertyValue("CurveName") >>= aName;
+ if(!aName.isEmpty())
+ {
+ pFS->startElement(FSNS(XML_c, XML_name));
+ pFS->writeEscaped(aName);
+ pFS->endElement( FSNS( XML_c, XML_name) );
+ }
- exportShapeProps( xProperties );
+ exportShapeProps( xProperties );
- if( aService == "com.sun.star.chart2.LinearRegressionCurve" )
- {
- pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "linear");
- }
- else if( aService == "com.sun.star.chart2.ExponentialRegressionCurve" )
- {
- pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "exp");
- }
- else if( aService == "com.sun.star.chart2.LogarithmicRegressionCurve" )
- {
- pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "log");
- }
- else if( aService == "com.sun.star.chart2.PotentialRegressionCurve" )
- {
- pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "power");
- }
- else if( aService == "com.sun.star.chart2.PolynomialRegressionCurve" )
- {
- pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "poly");
+ if( aService == "com.sun.star.chart2.LinearRegressionCurve" )
+ {
+ pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "linear");
+ }
+ else if( aService == "com.sun.star.chart2.ExponentialRegressionCurve" )
+ {
+ pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "exp");
+ }
+ else if( aService == "com.sun.star.chart2.LogarithmicRegressionCurve" )
+ {
+ pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "log");
+ }
+ else if( aService == "com.sun.star.chart2.PotentialRegressionCurve" )
+ {
+ pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "power");
+ }
+ else if( aService == "com.sun.star.chart2.PolynomialRegressionCurve" )
+ {
+ pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "poly");
- sal_Int32 aDegree = 2;
- xProperties->getPropertyValue( "PolynomialDegree") >>= aDegree;
- pFS->singleElement(FSNS(XML_c, XML_order), XML_val, OString::number(aDegree));
- }
- else if( aService == "com.sun.star.chart2.MovingAverageRegressionCurve" )
- {
- pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "movingAvg");
+ sal_Int32 aDegree = 2;
+ xProperties->getPropertyValue( "PolynomialDegree") >>= aDegree;
+ pFS->singleElement(FSNS(XML_c, XML_order), XML_val, OString::number(aDegree));
+ }
+ else if( aService == "com.sun.star.chart2.MovingAverageRegressionCurve" )
+ {
+ pFS->singleElement(FSNS(XML_c, XML_trendlineType), XML_val, "movingAvg");
- sal_Int32 aPeriod = 2;
- xProperties->getPropertyValue( "MovingAveragePeriod") >>= aPeriod;
+ sal_Int32 aPeriod = 2;
+ xProperties->getPropertyValue( "MovingAveragePeriod") >>= aPeriod;
- pFS->singleElement(FSNS(XML_c, XML_period), XML_val, OString::number(aPeriod));
- }
- else
- {
- // should never happen
- // This would produce invalid OOXML files so we check earlier for the type
- assert(false);
- }
+ pFS->singleElement(FSNS(XML_c, XML_period), XML_val, OString::number(aPeriod));
+ }
+ else
+ {
+ // should never happen
+ // This would produce invalid OOXML files so we check earlier for the type
+ assert(false);
+ }
- double fExtrapolateForward = 0.0;
- double fExtrapolateBackward = 0.0;
+ double fExtrapolateForward = 0.0;
+ double fExtrapolateBackward = 0.0;
- xProperties->getPropertyValue("ExtrapolateForward") >>= fExtrapolateForward;
- xProperties->getPropertyValue("ExtrapolateBackward") >>= fExtrapolateBackward;
+ xProperties->getPropertyValue("ExtrapolateForward") >>= fExtrapolateForward;
+ xProperties->getPropertyValue("ExtrapolateBackward") >>= fExtrapolateBackward;
- pFS->singleElement( FSNS( XML_c, XML_forward ),
- XML_val, OString::number(fExtrapolateForward) );
+ pFS->singleElement( FSNS( XML_c, XML_forward ),
+ XML_val, OString::number(fExtrapolateForward) );
- pFS->singleElement( FSNS( XML_c, XML_backward ),
- XML_val, OString::number(fExtrapolateBackward) );
+ pFS->singleElement( FSNS( XML_c, XML_backward ),
+ XML_val, OString::number(fExtrapolateBackward) );
- bool bForceIntercept = false;
- xProperties->getPropertyValue("ForceIntercept") >>= bForceIntercept;
+ bool bForceIntercept = false;
+ xProperties->getPropertyValue("ForceIntercept") >>= bForceIntercept;
- if (bForceIntercept)
- {
- double fInterceptValue = 0.0;
- xProperties->getPropertyValue("InterceptValue") >>= fInterceptValue;
+ if (bForceIntercept)
+ {
+ double fInterceptValue = 0.0;
+ xProperties->getPropertyValue("InterceptValue") >>= fInterceptValue;
- pFS->singleElement( FSNS( XML_c, XML_intercept ),
- XML_val, OString::number(fInterceptValue) );
- }
+ pFS->singleElement( FSNS( XML_c, XML_intercept ),
+ XML_val, OString::number(fInterceptValue) );
+ }
- // Equation properties
- Reference< XPropertySet > xEquationProperties( xRegCurve->getEquationProperties() );
+ // Equation properties
+ Reference< XPropertySet > xEquationProperties( xRegCurve->getEquationProperties() );
- // Show Equation
- bool bShowEquation = false;
- xEquationProperties->getPropertyValue("ShowEquation") >>= bShowEquation;
+ // Show Equation
+ bool bShowEquation = false;
+ xEquationProperties->getPropertyValue("ShowEquation") >>= bShowEquation;
- // Show R^2
- bool bShowCorrelationCoefficient = false;
- xEquationProperties->getPropertyValue("ShowCorrelationCoefficient") >>= bShowCorrelationCoefficient;
+ // Show R^2
+ bool bShowCorrelationCoefficient = false;
+ xEquationProperties->getPropertyValue("ShowCorrelationCoefficient") >>= bShowCorrelationCoefficient;
- pFS->singleElement( FSNS( XML_c, XML_dispRSqr ),
- XML_val, ToPsz10(bShowCorrelationCoefficient) );
+ pFS->singleElement( FSNS( XML_c, XML_dispRSqr ),
+ XML_val, ToPsz10(bShowCorrelationCoefficient) );
- pFS->singleElement(FSNS(XML_c, XML_dispEq), XML_val, ToPsz10(bShowEquation));
+ pFS->singleElement(FSNS(XML_c, XML_dispEq), XML_val, ToPsz10(bShowEquation));
- pFS->endElement( FSNS( XML_c, XML_trendline ) );
- }
+ pFS->endElement( FSNS( XML_c, XML_trendline ) );
}
}
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 63f1088970d8..254bf0d96a6f 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -473,46 +473,46 @@ void DrawingML::WriteGradientFill( const Reference< XPropertySet >& rXPropSet )
{
awt::Gradient aGradient;
awt::Gradient aTransparenceGradient;
- if (GetProperty(rXPropSet, "FillGradient"))
- {
- aGradient = *o3tl::doAccess<awt::Gradient>(mAny);
+ if (!GetProperty(rXPropSet, "FillGradient"))
+ return;
- // get InteropGrabBag and search the relevant attributes
- awt::Gradient aOriginalGradient;
- Sequence< PropertyValue > aGradientStops;
- if ( GetProperty( rXPropSet, "InteropGrabBag" ) )
- {
- Sequence< PropertyValue > aGrabBag;
- mAny >>= aGrabBag;
- for( const auto& rProp : std::as_const(aGrabBag) )
- if( rProp.Name == "GradFillDefinition" )
- rProp.Value >>= aGradientStops;
- else if( rProp.Name == "OriginalGradFill" )
- rProp.Value >>= aOriginalGradient;
- }
+ aGradient = *o3tl::doAccess<awt::Gradient>(mAny);
- // check if an ooxml gradient had been imported and if the user has modified it
- // Gradient grab-bag depends on theme grab-bag, which is implemented
- // only for DOCX.
- if( EqualGradients( aOriginalGradient, aGradient ) && GetDocumentType() == DOCUMENT_DOCX)
- {
- // If we have no gradient stops that means original gradient were defined by a theme.
- if( aGradientStops.hasElements() )
- {
- mpFS->startElementNS(XML_a, XML_gradFill, XML_rotWithShape, "0");
- WriteGrabBagGradientFill(aGradientStops, aGradient);
- mpFS->endElementNS( XML_a, XML_gradFill );
- }
- }
- else
+ // get InteropGrabBag and search the relevant attributes
+ awt::Gradient aOriginalGradient;
+ Sequence< PropertyValue > aGradientStops;
+ if ( GetProperty( rXPropSet, "InteropGrabBag" ) )
+ {
+ Sequence< PropertyValue > aGrabBag;
+ mAny >>= aGrabBag;
+ for( const auto& rProp : std::as_const(aGrabBag) )
+ if( rProp.Name == "GradFillDefinition" )
+ rProp.Value >>= aGradientStops;
+ else if( rProp.Name == "OriginalGradFill" )
+ rProp.Value >>= aOriginalGradient;
+ }
+
+ // check if an ooxml gradient had been imported and if the user has modified it
+ // Gradient grab-bag depends on theme grab-bag, which is implemented
+ // only for DOCX.
+ if( EqualGradients( aOriginalGradient, aGradient ) && GetDocumentType() == DOCUMENT_DOCX)
+ {
+ // If we have no gradient stops that means original gradient were defined by a theme.
+ if( aGradientStops.hasElements() )
{
mpFS->startElementNS(XML_a, XML_gradFill, XML_rotWithShape, "0");
- if( GetProperty(rXPropSet, "FillTransparenceGradient") )
- aTransparenceGradient = *o3tl::doAccess<awt::Gradient>(mAny);
- WriteGradientFill(aGradient, aTransparenceGradient);
+ WriteGrabBagGradientFill(aGradientStops, aGradient);
mpFS->endElementNS( XML_a, XML_gradFill );
}
}
+ else
+ {
+ mpFS->startElementNS(XML_a, XML_gradFill, XML_rotWithShape, "0");
+ if( GetProperty(rXPropSet, "FillTransparenceGradient") )
+ aTransparenceGradient = *o3tl::doAccess<awt::Gradient>(mAny);
+ WriteGradientFill(aGradient, aTransparenceGradient);
+ mpFS->endElementNS( XML_a, XML_gradFill );
+ }
}
void DrawingML::WriteGrabBagGradientFill( const Sequence< PropertyValue >& aGradientStops, awt::Gradient rGradient )
@@ -675,68 +675,68 @@ void DrawingML::WriteLineArrow( const Reference< XPropertySet >& rXPropSet, bool
sal_Int32 nArrowLength;
sal_Int32 nArrowWidth;
- if ( EscherPropertyContainer::GetLineArrow( bLineStart, rXPropSet, eLineEnd, nArrowLength, nArrowWidth ) )
- {
- const char* len;
- const char* type;
- const char* width;
+ if ( !EscherPropertyContainer::GetLineArrow( bLineStart, rXPropSet, eLineEnd, nArrowLength, nArrowWidth ) )
+ return;
- switch( nArrowLength )
- {
- case ESCHER_LineShortArrow:
- len = "sm";
- break;
- default:
- case ESCHER_LineMediumLenArrow:
- len = "med";
- break;
- case ESCHER_LineLongArrow:
- len = "lg";
- break;
- }
+ const char* len;
+ const char* type;
+ const char* width;
- switch( eLineEnd )
- {
- default:
- case ESCHER_LineNoEnd:
- type = "none";
- break;
- case ESCHER_LineArrowEnd:
- type = "triangle";
- break;
- case ESCHER_LineArrowStealthEnd:
- type = "stealth";
- break;
- case ESCHER_LineArrowDiamondEnd:
- type = "diamond";
- break;
- case ESCHER_LineArrowOvalEnd:
- type = "oval";
- break;
- case ESCHER_LineArrowOpenEnd:
- type = "arrow";
- break;
- }
+ switch( nArrowLength )
+ {
+ case ESCHER_LineShortArrow:
+ len = "sm";
+ break;
+ default:
+ case ESCHER_LineMediumLenArrow:
+ len = "med";
+ break;
+ case ESCHER_LineLongArrow:
+ len = "lg";
+ break;
+ }
- switch( nArrowWidth )
- {
- case ESCHER_LineNarrowArrow:
- width = "sm";
- break;
- default:
- case ESCHER_LineMediumWidthArrow:
- width = "med";
- break;
- case ESCHER_LineWideArrow:
- width = "lg";
- break;
- }
+ switch( eLineEnd )
+ {
+ default:
+ case ESCHER_LineNoEnd:
+ type = "none";
+ break;
+ case ESCHER_LineArrowEnd:
+ type = "triangle";
+ break;
+ case ESCHER_LineArrowStealthEnd:
+ type = "stealth";
+ break;
+ case ESCHER_LineArrowDiamondEnd:
+ type = "diamond";
+ break;
+ case ESCHER_LineArrowOvalEnd:
+ type = "oval";
+ break;
+ case ESCHER_LineArrowOpenEnd:
+ type = "arrow";
+ break;
+ }
- mpFS->singleElementNS( XML_a, bLineStart ? XML_headEnd : XML_tailEnd,
- XML_len, len,
- XML_type, type,
- XML_w, width );
+ switch( nArrowWidth )
+ {
+ case ESCHER_LineNarrowArrow:
+ width = "sm";
+ break;
+ default:
+ case ESCHER_LineMediumWidthArrow:
+ width = "med";
+ break;
+ case ESCHER_LineWideArrow:
+ width = "lg";
+ break;
}
+
+ mpFS->singleElementNS( XML_a, bLineStart ? XML_headEnd : XML_tailEnd,
+ XML_len, len,
+ XML_type, type,
+ XML_w, width );
}
void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Reference< frame::XModel > const & xModel )
@@ -1411,27 +1411,27 @@ void DrawingML::WriteBlipFill( const Reference< XPropertySet >& rXPropSet, const
void DrawingML::WriteBlipFill( const Reference< XPropertySet >& rXPropSet, const OUString& sURLPropName, sal_Int32 nXmlNamespace )
{
- if ( GetProperty( rXPropSet, sURLPropName ) )
+ if ( !GetProperty( rXPropSet, sURLPropName ) )
+ return;
+
+ uno::Reference<graphic::XGraphic> xGraphic;
+ if (mAny.has<uno::Reference<awt::XBitmap>>())
{
- uno::Reference<graphic::XGraphic> xGraphic;
- if (mAny.has<uno::Reference<awt::XBitmap>>())
- {
- uno::Reference<awt::XBitmap> xBitmap = mAny.get<uno::Reference<awt::XBitmap>>();
- if (xBitmap.is())
- xGraphic.set(xBitmap, uno::UNO_QUERY);
- }
- else if (mAny.has<uno::Reference<graphic::XGraphic>>())
- {
- xGraphic = mAny.get<uno::Reference<graphic::XGraphic>>();
- }
+ uno::Reference<awt::XBitmap> xBitmap = mAny.get<uno::Reference<awt::XBitmap>>();
+ if (xBitmap.is())
+ xGraphic.set(xBitmap, uno::UNO_QUERY);
+ }
+ else if (mAny.has<uno::Reference<graphic::XGraphic>>())
+ {
+ xGraphic = mAny.get<uno::Reference<graphic::XGraphic>>();
+ }
- if (xGraphic.is())
- {
- bool bWriteMode = false;
- if (sURLPropName == "FillBitmap" || sURLPropName == "BackGraphic")
- bWriteMode = true;
- WriteXGraphicBlipFill(rXPropSet, xGraphic, nXmlNamespace, bWriteMode);
- }
+ if (xGraphic.is())
+ {
+ bool bWriteMode = false;
+ if (sURLPropName == "FillBitmap" || sURLPropName == "BackGraphic")
+ bWriteMode = true;
+ WriteXGraphicBlipFill(rXPropSet, xGraphic, nXmlNamespace, bWriteMode);
}
}
@@ -1507,25 +1507,25 @@ void DrawingML::WritePattFill(const Reference<XPropertySet>& rXPropSet, const cs
void DrawingML::WriteGraphicCropProperties(uno::Reference<beans::XPropertySet> const & rXPropSet, Size const & rOriginalSize, MapMode const & rMapMode)
{
- if (GetProperty(rXPropSet, "GraphicCrop"))
- {
- Size aOriginalSize(rOriginalSize);
+ if (!GetProperty(rXPropSet, "GraphicCrop"))
+ return;
- // GraphicCrop is in mm100, so in case the original size is in pixels, convert it over.
- if (rMapMode.GetMapUnit() == MapUnit::MapPixel)
- aOriginalSize = Application::GetDefaultDevice()->PixelToLogic(aOriginalSize, MapMode(MapUnit::Map100thMM));
+ Size aOriginalSize(rOriginalSize);
- css::text::GraphicCrop aGraphicCropStruct;
- mAny >>= aGraphicCropStruct;
+ // GraphicCrop is in mm100, so in case the original size is in pixels, convert it over.
+ if (rMapMode.GetMapUnit() == MapUnit::MapPixel)
+ aOriginalSize = Application::GetDefaultDevice()->PixelToLogic(aOriginalSize, MapMode(MapUnit::Map100thMM));
- if ( (0 != aGraphicCropStruct.Left) || (0 != aGraphicCropStruct.Top) || (0 != aGraphicCropStruct.Right) || (0 != aGraphicCropStruct.Bottom) )
- {
- mpFS->singleElementNS( XML_a, XML_srcRect,
- XML_l, OString::number(rtl::math::round(aGraphicCropStruct.Left * 100000.0 / aOriginalSize.Width())),
- XML_t, OString::number(rtl::math::round(aGraphicCropStruct.Top * 100000.0 / aOriginalSize.Height())),
- XML_r, OString::number(rtl::math::round(aGraphicCropStruct.Right * 100000.0 / aOriginalSize.Width())),
- XML_b, OString::number(rtl::math::round(aGraphicCropStruct.Bottom * 100000.0 / aOriginalSize.Height())) );
- }
+ css::text::GraphicCrop aGraphicCropStruct;
+ mAny >>= aGraphicCropStruct;
+
+ if ( (0 != aGraphicCropStruct.Left) || (0 != aGraphicCropStruct.Top) || (0 != aGraphicCropStruct.Right) || (0 != aGraphicCropStruct.Bottom) )
+ {
+ mpFS->singleElementNS( XML_a, XML_srcRect,
+ XML_l, OString::number(rtl::math::round(aGraphicCropStruct.Left * 100000.0 / aOriginalSize.Width())),
+ XML_t, OString::number(rtl::math::round(aGraphicCropStruct.Top * 100000.0 / aOriginalSize.Height())),
+ XML_r, OString::number(rtl::math::round(aGraphicCropStruct.Right * 100000.0 / aOriginalSize.Width())),
+ XML_b, OString::number(rtl::math::round(aGraphicCropStruct.Bottom * 100000.0 / aOriginalSize.Height())) );
}
}
@@ -2546,57 +2546,57 @@ void DrawingML::WriteParagraphProperties( const Reference< XTextContent >& rPara
sal_Int32 nLeftMargin = getBulletMarginIndentation ( rXPropSet, nLevel,"LeftMargin");
sal_Int32 nLineIndentation = getBulletMarginIndentation ( rXPropSet, nLevel,"FirstLineOffset");
- if( nLevel != -1
+ if( !(nLevel != -1
|| nAlignment != style::ParagraphAdjust_LEFT
- || bHasLinespacing )
- {
- if (nParaLeftMargin) // For Paragraph
- mpFS->startElementNS( XML_a, XML_pPr,
- XML_lvl, nLevel > 0 ? OString::number(nLevel).getStr() : nullptr,
- XML_marL, nParaLeftMargin > 0 ? OString::number(oox::drawingml::convertHmmToEmu(nParaLeftMargin)).getStr() : nullptr,
- XML_indent, nParaFirstLineIndent ? OString::number(oox::drawingml::convertHmmToEmu(nParaFirstLineIndent)).getStr() : nullptr,
- XML_algn, GetAlignment( nAlignment ),
- XML_rtl, bRtl ? ToPsz10(bRtl) : nullptr );
- else
- mpFS->startElementNS( XML_a, XML_pPr,
- XML_lvl, nLevel > 0 ? OString::number(nLevel).getStr() : nullptr,
- XML_marL, nLeftMargin > 0 ? OString::number(oox::drawingml::convertHmmToEmu(nLeftMargin)).getStr() : nullptr,
- XML_indent, nLineIndentation ? OString::number(oox::drawingml::convertHmmToEmu(nLineIndentation)).getStr() : nullptr,
- XML_algn, GetAlignment( nAlignment ),
- XML_rtl, bRtl ? ToPsz10(bRtl) : nullptr );
+ || bHasLinespacing) )
+ return;
+ if (nParaLeftMargin) // For Paragraph
+ mpFS->startElementNS( XML_a, XML_pPr,
+ XML_lvl, nLevel > 0 ? OString::number(nLevel).getStr() : nullptr,
+ XML_marL, nParaLeftMargin > 0 ? OString::number(oox::drawingml::convertHmmToEmu(nParaLeftMargin)).getStr() : nullptr,
+ XML_indent, nParaFirstLineIndent ? OString::number(oox::drawingml::convertHmmToEmu(nParaFirstLineIndent)).getStr() : nullptr,
+ XML_algn, GetAlignment( nAlignment ),
+ XML_rtl, bRtl ? ToPsz10(bRtl) : nullptr );
+ else
+ mpFS->startElementNS( XML_a, XML_pPr,
+ XML_lvl, nLevel > 0 ? OString::number(nLevel).getStr() : nullptr,
+ XML_marL, nLeftMargin > 0 ? OString::number(oox::drawingml::convertHmmToEmu(nLeftMargin)).getStr() : nullptr,
+ XML_indent, nLineIndentation ? OString::number(oox::drawingml::convertHmmToEmu(nLineIndentation)).getStr() : nullptr,
+ XML_algn, GetAlignment( nAlignment ),
+ XML_rtl, bRtl ? ToPsz10(bRtl) : nullptr );
- if( bHasLinespacing )
- {
- mpFS->startElementNS(XML_a, XML_lnSpc);
- WriteLinespacing( aLineSpacing );
- mpFS->endElementNS( XML_a, XML_lnSpc );
- }
- if( nParaTopMargin != 0 )
+ if( bHasLinespacing )
+ {
+ mpFS->startElementNS(XML_a, XML_lnSpc);
+ WriteLinespacing( aLineSpacing );
+ mpFS->endElementNS( XML_a, XML_lnSpc );
+ }
+
+ if( nParaTopMargin != 0 )
+ {
+ mpFS->startElementNS(XML_a, XML_spcBef);
{
- mpFS->startElementNS(XML_a, XML_spcBef);
- {
- mpFS->singleElementNS( XML_a, XML_spcPts,
- XML_val, OString::number(std::lround(nParaTopMargin / 25.4 * 72)));
- }
- mpFS->endElementNS( XML_a, XML_spcBef );
+ mpFS->singleElementNS( XML_a, XML_spcPts,
+ XML_val, OString::number(std::lround(nParaTopMargin / 25.4 * 72)));
}
+ mpFS->endElementNS( XML_a, XML_spcBef );
+ }
- if( nParaBottomMargin != 0 )
+ if( nParaBottomMargin != 0 )
+ {
+ mpFS->startElementNS(XML_a, XML_spcAft);
{
- mpFS->startElementNS(XML_a, XML_spcAft);
- {
- mpFS->singleElementNS( XML_a, XML_spcPts,
- XML_val, OString::number(std::lround(nParaBottomMargin / 25.4 * 72)));
- }
- mpFS->endElementNS( XML_a, XML_spcAft );
+ mpFS->singleElementNS( XML_a, XML_spcPts,
+ XML_val, OString::number(std::lround(nParaBottomMargin / 25.4 * 72)));
}
+ mpFS->endElementNS( XML_a, XML_spcAft );
+ }
- WriteParagraphNumbering( rXPropSet, fFirstCharHeight, nLevel );
+ WriteParagraphNumbering( rXPropSet, fFirstCharHeight, nLevel );
- mpFS->endElementNS( XML_a, XML_pPr );
- }
+ mpFS->endElementNS( XML_a, XML_pPr );
}
void DrawingML::WriteParagraph( const Reference< XTextContent >& rParagraph,
@@ -3661,20 +3661,20 @@ void DrawingML::WriteShapeEffect( const OUString& sName, const Sequence< Propert
}
}
- if( nEffectToken > 0 )
- {
- mpFS->startElement( nEffectToken, xOuterShdwAttrList );
+ if( nEffectToken <= 0 )
+ return;
- if( bContainsColor )
- {
- if( sSchemeClr.isEmpty() )
- WriteColor( nRgbClr, nAlpha );
- else
- WriteColor( sSchemeClr, aTransformations );
- }
+ mpFS->startElement( nEffectToken, xOuterShdwAttrList );
- mpFS->endElement( nEffectToken );
+ if( bContainsColor )
+ {
+ if( sSchemeClr.isEmpty() )
+ WriteColor( nRgbClr, nAlpha );
+ else
+ WriteColor( sSchemeClr, aTransformations );
}
+
+ mpFS->endElement( nEffectToken );
}
static sal_Int32 lcl_CalculateDist(const double dX, const double dY)
@@ -4407,21 +4407,21 @@ void DrawingML::WriteDiagram(const css::uno::Reference<css::drawing::XShape>& rX
uno::Sequence<beans::StringPair>());
// write drawing file
- if (drawingDom.is())
- {
- serializer.set(drawingDom, uno::UNO_QUERY);
- uno::Reference<io::XOutputStream> xDrawingOutputStream = mpFB->openFragmentStream(
- sDir + "/" + drawingFileName, "application/vnd.ms-office.drawingml.diagramDrawing+xml");
- writer->setOutputStream(xDrawingOutputStream);
- serializer->serialize(
- uno::Reference<xml::sax::XDocumentHandler>(writer, uno::UNO_QUERY_THROW),
- uno::Sequence<beans::StringPair>());
+ if (!drawingDom.is())
+ return;
- // write the associated Images and rels for drawing file
- uno::Sequence<uno::Sequence<uno::Any>> xDrawingRelSeq;
- diagramDrawing[1] >>= xDrawingRelSeq;
- writeDiagramRels(xDrawingRelSeq, xDrawingOutputStream, "OOXDiagramDrawingRels", nDiagramId);
- }
+ serializer.set(drawingDom, uno::UNO_QUERY);
+ uno::Reference<io::XOutputStream> xDrawingOutputStream = mpFB->openFragmentStream(
+ sDir + "/" + drawingFileName, "application/vnd.ms-office.drawingml.diagramDrawing+xml");
+ writer->setOutputStream(xDrawingOutputStream);
+ serializer->serialize(
+ uno::Reference<xml::sax::XDocumentHandler>(writer, uno::UNO_QUERY_THROW),
+ uno::Sequence<beans::StringPair>());
+
+ // write the associated Images and rels for drawing file
+ uno::Sequence<uno::Sequence<uno::Any>> xDrawingRelSeq;
+ diagramDrawing[1] >>= xDrawingRelSeq;
+ writeDiagramRels(xDrawingRelSeq, xDrawingOutputStream, "OOXDiagramDrawingRels", nDiagramId);
}
void DrawingML::writeDiagramRels(const uno::Sequence<uno::Sequence<uno::Any>>& xRelSeq,
diff --git a/oox/source/export/vmlexport.cxx b/oox/source/export/vmlexport.cxx
index 98f3243e5461..dc0fe18cd437 100644
--- a/oox/source/export/vmlexport.cxx
+++ b/oox/source/export/vmlexport.cxx
@@ -94,20 +94,20 @@ void VMLExport::OpenContainer( sal_uInt16 nEscherContainer, int nRecInstance )
{
EscherEx::OpenContainer( nEscherContainer, nRecInstance );
- if ( nEscherContainer == ESCHER_SpContainer )
- {
- // opening a shape container
- SAL_WARN_IF(m_nShapeType != ESCHER_ShpInst_Nil, "oox.vml", "opening shape inside of a shape!");
- m_nShapeType = ESCHER_ShpInst_Nil;
- m_pShapeAttrList = FastSerializerHelper::createAttrList();
+ if ( nEscherContainer != ESCHER_SpContainer )
+ return;
- m_ShapeStyle.setLength(0);
- m_ShapeStyle.ensureCapacity(200);
+ // opening a shape container
+ SAL_WARN_IF(m_nShapeType != ESCHER_ShpInst_Nil, "oox.vml", "opening shape inside of a shape!");
+ m_nShapeType = ESCHER_ShpInst_Nil;
+ m_pShapeAttrList = FastSerializerHelper::createAttrList();
- // postpone the output so that we are able to write even the elements
- // that we learn inside Commit()
- m_pSerializer->mark(Tag_Container);
- }
+ m_ShapeStyle.setLength(0);
+ m_ShapeStyle.ensureCapacity(200);
+
+ // postpone the output so that we are able to write even the elements
+ // that we learn inside Commit()
+ m_pSerializer->mark(Tag_Container);
}
void VMLExport::CloseContainer()
@@ -1383,31 +1383,31 @@ sal_Int32 VMLExport::StartShape()
void VMLExport::EndShape( sal_Int32 nShapeElement )
{
- if ( nShapeElement >= 0 )
+ if ( nShapeElement < 0 )
+ return;
+
+ if (m_pTextExport && lcl_isTextBox(m_pSdrObject))
{
- if (m_pTextExport && lcl_isTextBox(m_pSdrObject))
+ uno::Reference<beans::XPropertySet> xPropertySet(const_cast<SdrObject*>(m_pSdrObject)->getUnoShape(), uno::UNO_QUERY);
+ comphelper::SequenceAsHashMap aCustomShapeProperties(xPropertySet->getPropertyValue("CustomShapeGeometry"));
+ sax_fastparser::FastAttributeList* pTextboxAttrList = FastSerializerHelper::createAttrList();
+ if (aCustomShapeProperties.find("TextPreRotateAngle") != aCustomShapeProperties.end())
{
- uno::Reference<beans::XPropertySet> xPropertySet(const_cast<SdrObject*>(m_pSdrObject)->getUnoShape(), uno::UNO_QUERY);
- comphelper::SequenceAsHashMap aCustomShapeProperties(xPropertySet->getPropertyValue("CustomShapeGeometry"));
- sax_fastparser::FastAttributeList* pTextboxAttrList = FastSerializerHelper::createAttrList();
- if (aCustomShapeProperties.find("TextPreRotateAngle") != aCustomShapeProperties.end())
- {
- sal_Int32 nTextRotateAngle = aCustomShapeProperties["TextPreRotateAngle"].get<sal_Int32>();
- if (nTextRotateAngle == -270)
- pTextboxAttrList->add(XML_style, "mso-layout-flow-alt:bottom-to-top");
- }
- sax_fastparser::XFastAttributeListRef xTextboxAttrList(pTextboxAttrList);
- pTextboxAttrList = nullptr;
- m_pSerializer->startElementNS(XML_v, XML_textbox, xTextboxAttrList);
-
- m_pTextExport->WriteVMLTextBox(uno::Reference<drawing::XShape>(xPropertySet, uno::UNO_QUERY_THROW));
-
- m_pSerializer->endElementNS(XML_v, XML_textbox);
+ sal_Int32 nTextRotateAngle = aCustomShapeProperties["TextPreRotateAngle"].get<sal_Int32>();
+ if (nTextRotateAngle == -270)
+ pTextboxAttrList->add(XML_style, "mso-layout-flow-alt:bottom-to-top");
}
+ sax_fastparser::XFastAttributeListRef xTextboxAttrList(pTextboxAttrList);
+ pTextboxAttrList = nullptr;
+ m_pSerializer->startElementNS(XML_v, XML_textbox, xTextboxAttrList);
+
+ m_pTextExport->WriteVMLTextBox(uno::Reference<drawing::XShape>(xPropertySet, uno::UNO_QUERY_THROW));
- // end of the shape
- m_pSerializer->endElementNS( XML_v, nShapeElement );
+ m_pSerializer->endElementNS(XML_v, XML_textbox);
}
+
+ // end of the shape
+ m_pSerializer->endElementNS( XML_v, nShapeElement );
}
OString const & VMLExport::AddSdrObject( const SdrObject& rObj, sal_Int16 eHOri, sal_Int16 eVOri, sal_Int16 eHRel, sal_Int16 eVRel, const bool bOOxmlExport )
diff --git a/oox/source/helper/binaryoutputstream.cxx b/oox/source/helper/binaryoutputstream.cxx
index ccfd6e4ed9f2..bac274af1857 100644
--- a/oox/source/helper/binaryoutputstream.cxx
+++ b/oox/source/helper/binaryoutputstream.cxx
@@ -82,19 +82,19 @@ void BinaryXOutputStream::writeData( const StreamDataSequence& rData, size_t /*n
void BinaryXOutputStream::writeMemory( const void* pMem, sal_Int32 nBytes, size_t nAtomSize )
{
- if( mxOutStrm.is() && (nBytes > 0) )
+ if( !(mxOutStrm.is() && (nBytes > 0)) )
+ return;
+
+ sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, (OUTPUTSTREAM_BUFFERSIZE / nAtomSize) * nAtomSize );
+ const sal_uInt8* pnMem = static_cast< const sal_uInt8* >( pMem );
+ while( nBytes > 0 )
{
- sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, (OUTPUTSTREAM_BUFFERSIZE / nAtomSize) * nAtomSize );
- const sal_uInt8* pnMem = static_cast< const sal_uInt8* >( pMem );
- while( nBytes > 0 )
- {
- sal_Int32 nWriteSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, nBufferSize );
- maBuffer.realloc( nWriteSize );
- memcpy( maBuffer.getArray(), pnMem, static_cast< size_t >( nWriteSize ) );
- writeData( maBuffer, nAtomSize );
- pnMem += nWriteSize;
- nBytes -= nWriteSize;
- }
+ sal_Int32 nWriteSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, nBufferSize );
+ maBuffer.realloc( nWriteSize );
+ memcpy( maBuffer.getArray(), pnMem, static_cast< size_t >( nWriteSize ) );
+ writeData( maBuffer, nAtomSize );
+ pnMem += nWriteSize;
+ nBytes -= nWriteSize;
}
}
diff --git a/oox/source/helper/propertymap.cxx b/oox/source/helper/propertymap.cxx
index 00fd23d01505..f7016022b478 100644
--- a/oox/source/helper/propertymap.cxx
+++ b/oox/source/helper/propertymap.cxx
@@ -249,18 +249,18 @@ void PropertyMap::fillSequences( Sequence< OUString >& rNames, Sequence< Any >&
{
rNames.realloc( static_cast< sal_Int32 >( maProperties.size() ) );
rValues.realloc( static_cast< sal_Int32 >( maProperties.size() ) );
- if( !maProperties.empty() )
+ if( maProperties.empty() )
+ return;
+
+ OUString* pNames = rNames.getArray();
+ Any* pValues = rValues.getArray();
+ for (auto const& prop : maProperties)
{
- OUString* pNames = rNames.getArray();
- Any* pValues = rValues.getArray();
- for (auto const& prop : maProperties)
- {
- OSL_ENSURE( (0 <= prop.first) && (prop.first < PROP_COUNT), "PropertyMap::fillSequences - invalid property identifier" );
- *pNames = (*mpPropNames)[ prop.first ];
- *pValues = prop.second;
- ++pNames;
- ++pValues;
- }
+ OSL_ENSURE( (0 <= prop.first) && (prop.first < PROP_COUNT), "PropertyMap::fillSequences - invalid property identifier" );
+ *pNames = (*mpPropNames)[ prop.first ];
+ *pValues = prop.second;
+ ++pNames;
+ ++pValues;
}
}
diff --git a/oox/source/helper/storagebase.cxx b/oox/source/helper/storagebase.cxx
index 4738eda6fead..d0928373350f 100644
--- a/oox/source/helper/storagebase.cxx
+++ b/oox/source/helper/storagebase.cxx
@@ -190,27 +190,27 @@ void StorageBase::copyToStorage( StorageBase& rDestStrg, const OUString& rElemen
{
OSL_ENSURE( rDestStrg.isStorage() && !rDestStrg.isReadOnly(), "StorageBase::copyToStorage - invalid destination" );
OSL_ENSURE( !rElementName.isEmpty(), "StorageBase::copyToStorage - invalid element name" );
- if( rDestStrg.isStorage() && !rDestStrg.isReadOnly() && !rElementName.isEmpty() )
+ if( !(rDestStrg.isStorage() && !rDestStrg.isReadOnly() && !rElementName.isEmpty()) )
+ return;
+
+ StorageRef xSubStrg = openSubStorage( rElementName, false );
+ if( xSubStrg.get() )
{
- StorageRef xSubStrg = openSubStorage( rElementName, false );
- if( xSubStrg.get() )
- {
- StorageRef xDestSubStrg = rDestStrg.openSubStorage( rElementName, true );
- if( xDestSubStrg.get() )
- xSubStrg->copyStorageToStorage( *xDestSubStrg );
- }
- else
+ StorageRef xDestSubStrg = rDestStrg.openSubStorage( rElementName, true );
+ if( xDestSubStrg.get() )
+ xSubStrg->copyStorageToStorage( *xDestSubStrg );
+ }
+ else
+ {
+ Reference< XInputStream > xInStrm = openInputStream( rElementName );
+ if( xInStrm.is() )
{
- Reference< XInputStream > xInStrm = openInputStream( rElementName );
- if( xInStrm.is() )
+ Reference< XOutputStream > xOutStrm = rDestStrg.openOutputStream( rElementName );
+ if( xOutStrm.is() )
{
- Reference< XOutputStream > xOutStrm = rDestStrg.openOutputStream( rElementName );
- if( xOutStrm.is() )
- {
- BinaryXInputStream aInStrm( xInStrm, true );
- BinaryXOutputStream aOutStrm( xOutStrm, true );
- aInStrm.copyToStream( aOutStrm );
- }
+ BinaryXInputStream aInStrm( xInStrm, true );
+ BinaryXOutputStream aOutStrm( xOutStrm, true );
+ aInStrm.copyToStream( aOutStrm );
}
}
}
diff --git a/oox/source/helper/zipstorage.cxx b/oox/source/helper/zipstorage.cxx
index b9e7c80e1390..987ab3b809d1 100644
--- a/oox/source/helper/zipstorage.cxx
+++ b/oox/source/helper/zipstorage.cxx
@@ -43,7 +43,10 @@ ZipStorage::ZipStorage( const Reference< XComponentContext >& rxContext, const R
{
OSL_ENSURE( rxContext.is(), "ZipStorage::ZipStorage - missing component context" );
// create base storage object
- if( rxContext.is() ) try
+ if( !rxContext.is() )
+ return;
+
+ try
{
/* #i105325# ::comphelper::OStorageHelper::GetStorageFromInputStream()
cannot be used here as it will open a storage with format type
diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx
index 5d5c8a41ff9d..0f7ef9647f85 100644
--- a/oox/source/ole/axcontrol.cxx
+++ b/oox/source/ole/axcontrol.cxx
@@ -358,7 +358,10 @@ void ControlConverter::bindToSources( const Reference< XControlModel >& rxCtrlMo
}
// list entry source
- if( !rRowSource.isEmpty() ) try
+ if( rRowSource.isEmpty() )
+ return;
+
+ try
{
// first check if the XListEntrySink interface is supported
Reference< XListEntrySink > xEntrySink( rxCtrlModel, UNO_QUERY_THROW );
diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx
index 4b7bc6e11975..1ffbbec89a30 100644
--- a/oox/source/ole/olehelper.cxx
+++ b/oox/source/ole/olehelper.cxx
@@ -329,54 +329,54 @@ OleFormCtrlExportHelper::OleFormCtrlExportHelper( const Reference< XComponentCo
{
// try to get the guid
Reference< css::beans::XPropertySet > xProps( xCntrlModel, UNO_QUERY );
- if ( xProps.is() )
+ if ( !xProps.is() )
+ return;
+
+ sal_Int16 nClassId = 0;
+ PropertySet aPropSet( mxControlModel );
+ if ( !aPropSet.getProperty( nClassId, PROP_ClassId ) )
+ return;
+
+ /* pseudo ripped from legacy msocximex:
+ "There is a truly horrible thing with EditControls and FormattedField
+ Controls, they both pretend to have an EDITBOX ClassId for compatibility
+ reasons, at some stage in the future hopefully there will be a proper
+ FormulaField ClassId rather than this piggybacking two controls onto the
+ same ClassId, cmc." - when fixed the fake FORMULAFIELD id entry
+ and definition above can be removed/replaced
+ */
+ if ( nClassId == FormComponentType::TEXTFIELD)
{
- sal_Int16 nClassId = 0;
- PropertySet aPropSet( mxControlModel );
- if ( aPropSet.getProperty( nClassId, PROP_ClassId ) )
- {
- /* pseudo ripped from legacy msocximex:
- "There is a truly horrible thing with EditControls and FormattedField
- Controls, they both pretend to have an EDITBOX ClassId for compatibility
- reasons, at some stage in the future hopefully there will be a proper
- FormulaField ClassId rather than this piggybacking two controls onto the
- same ClassId, cmc." - when fixed the fake FORMULAFIELD id entry
- and definition above can be removed/replaced
- */
- if ( nClassId == FormComponentType::TEXTFIELD)
- {
- Reference< XServiceInfo > xInfo( xCntrlModel,
- UNO_QUERY);
- if (xInfo->
- supportsService( "com.sun.star.form.component.FormattedField" ) )
- nClassId = FORMULAFIELD;
- }
- else if ( nClassId == FormComponentType::COMMANDBUTTON )
- {
- bool bToggle = false;
- if ( aPropSet.getProperty( bToggle, PROP_Toggle ) && bToggle )
- nClassId = TOGGLEBUTTON;
- }
- else if ( nClassId == FormComponentType::CONTROL )
- {
- Reference< XServiceInfo > xInfo( xCntrlModel,
- UNO_QUERY);
- if (xInfo->supportsService("com.sun.star.form.component.ImageControl" ) )
- nClassId = FormComponentType::IMAGECONTROL;
- }
+ Reference< XServiceInfo > xInfo( xCntrlModel,
+ UNO_QUERY);
+ if (xInfo->
+ supportsService( "com.sun.star.form.component.FormattedField" ) )
+ nClassId = FORMULAFIELD;
+ }
+ else if ( nClassId == FormComponentType::COMMANDBUTTON )
+ {
+ bool bToggle = false;
+ if ( aPropSet.getProperty( bToggle, PROP_Toggle ) && bToggle )
+ nClassId = TOGGLEBUTTON;
+ }
+ else if ( nClassId == FormComponentType::CONTROL )
+ {
+ Reference< XServiceInfo > xInfo( xCntrlModel,
+ UNO_QUERY);
+ if (xInfo->supportsService("com.sun.star.form.component.ImageControl" ) )
+ nClassId = FormComponentType::IMAGECONTROL;
+ }
- GUIDCNamePairMap& cntrlMap = classIdToGUIDCNamePairMap::get();
- GUIDCNamePairMap::iterator it = cntrlMap.find( nClassId );
- if ( it != cntrlMap.end() )
- {
- aPropSet.getProperty(maName, PROP_Name );
- maTypeName = OUString::createFromAscii( it->second.sName );
- maFullName = "Microsoft Forms 2.0 " + maTypeName;
- mpControl.reset(new EmbeddedControl( maName ));
- maGUID = OUString::createFromAscii( it->second.sGUID );
- mpModel = mpControl->createModelFromGuid( maGUID );
- }
- }
+ GUIDCNamePairMap& cntrlMap = classIdToGUIDCNamePairMap::get();
+ GUIDCNamePairMap::iterator it = cntrlMap.find( nClassId );
+ if ( it != cntrlMap.end() )
+ {
+ aPropSet.getProperty(maName, PROP_Name );
+ maTypeName = OUString::createFromAscii( it->second.sName );
+ maFullName = "Microsoft Forms 2.0 " + maTypeName;
+ mpControl.reset(new EmbeddedControl( maName ));
+ maGUID = OUString::createFromAscii( it->second.sGUID );
+ mpModel = mpControl->createModelFromGuid( maGUID );
}
}
diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx
index 32c7ffc43a09..c48e701e1dae 100644
--- a/oox/source/ole/vbacontrol.cxx
+++ b/oox/source/ole/vbacontrol.cxx
@@ -324,21 +324,21 @@ VbaFormControl::~VbaFormControl()
void VbaFormControl::importModelOrStorage( BinaryInputStream& rInStrm, StorageBase& rStrg, const AxClassTable& rClassTable )
{
- if( mxSiteModel.get() )
+ if( !mxSiteModel.get() )
+ return;
+
+ if( mxSiteModel->isContainer() )
{
- if( mxSiteModel->isContainer() )
- {
- StorageRef xSubStrg = rStrg.openSubStorage( mxSiteModel->getSubStorageName(), false );
- OSL_ENSURE( xSubStrg.get(), "VbaFormControl::importModelOrStorage - cannot find storage for embedded control" );
- if( xSubStrg.get() )
- importStorage( *xSubStrg, rClassTable );
- }
- else if( !rInStrm.isEof() )
- {
- sal_Int64 nNextStrmPos = rInStrm.tell() + mxSiteModel->getStreamLength();
- importControlModel( rInStrm, rClassTable );
- rInStrm.seek( nNextStrmPos );
- }
+ StorageRef xSubStrg = rStrg.openSubStorage( mxSiteModel->getSubStorageName(), false );
+ OSL_ENSURE( xSubStrg.get(), "VbaFormControl::importModelOrStorage - cannot find storage for embedded control" );
+ if( xSubStrg.get() )
+ importStorage( *xSubStrg, rClassTable );
+ }
+ else if( !rInStrm.isEof() )
+ {
+ sal_Int64 nNextStrmPos = rInStrm.tell() + mxSiteModel->getStreamLength();
+ importControlModel( rInStrm, rClassTable );
+ rInStrm.seek( nNextStrmPos );
}
}
@@ -350,7 +350,10 @@ OUString VbaFormControl::getControlName() const
void VbaFormControl::createAndConvert( sal_Int32 nCtrlIndex,
const Reference< XNameContainer >& rxParentNC, const ControlConverter& rConv ) const
{
- if( rxParentNC.is() && mxSiteModel.get() && mxCtrlModel.get() ) try
+ if( !(rxParentNC.is() && mxSiteModel.get() && mxCtrlModel.get()) )
+ return;
+
+ try
{
// create the control model
OUString aServiceName = mxCtrlModel->getServiceName();
@@ -385,97 +388,97 @@ void VbaFormControl::importStorage( StorageBase& rStrg, const AxClassTable& rCla
createControlModel( rClassTable );
AxContainerModelBase* pContainerModel = dynamic_cast< AxContainerModelBase* >( mxCtrlModel.get() );
OSL_ENSURE( pContainerModel, "VbaFormControl::importStorage - missing container control model" );
- if( pContainerModel )
+ if( !pContainerModel )
+ return;
+
+ /* Open the 'f' stream containing the model of this control and a list
+ of site models for all child controls. */
+ BinaryXInputStream aFStrm( rStrg.openInputStream( "f" ), true );
+ OSL_ENSURE( !aFStrm.isEof(), "VbaFormControl::importStorage - missing 'f' stream" );
+
+ /* Read the properties of this container control and the class table
+ (into the maClassTable vector) containing a list of GUIDs for
+ exotic embedded controls. */
+ if( !(!aFStrm.isEof() && pContainerModel->importBinaryModel( aFStrm ) && pContainerModel->importClassTable( aFStrm, maClassTable )) )
+ return;
+
+ /* Read the site models of all embedded controls (this fills the
+ maControls vector). Ignore failure of importSiteModels() but
+ try to import as much controls as possible. */
+ importEmbeddedSiteModels( aFStrm );
+ /* Open the 'o' stream containing models of embedded simple
+ controls. Stream may be empty or missing, if this control
+ contains no controls or only container controls. */
+ BinaryXInputStream aOStrm( rStrg.openInputStream( "o" ), true );
+
+ /* Iterate over all embedded controls, import model from 'o'
+ stream (for embedded simple controls) or from the substorage
+ (for embedded container controls). */
+ maControls.forEachMem( &VbaFormControl::importModelOrStorage,
+ ::std::ref( aOStrm ), ::std::ref( rStrg ), ::std::cref( maClassTable ) );
+
+ // Special handling for multi-page which has non-standard
+ // containment and additionally needs to re-order Page children
+ if ( pContainerModel->getControlType() == API_CONTROL_MULTIPAGE )
{
- /* Open the 'f' stream containing the model of this control and a list
- of site models for all child controls. */
- BinaryXInputStream aFStrm( rStrg.openInputStream( "f" ), true );
- OSL_ENSURE( !aFStrm.isEof(), "VbaFormControl::importStorage - missing 'f' stream" );
-
- /* Read the properties of this container control and the class table
- (into the maClassTable vector) containing a list of GUIDs for
- exotic embedded controls. */
- if( !aFStrm.isEof() && pContainerModel->importBinaryModel( aFStrm ) && pContainerModel->importClassTable( aFStrm, maClassTable ) )
+ AxMultiPageModel* pMultiPage = dynamic_cast< AxMultiPageModel* >( pContainerModel );
+ assert(pMultiPage);
+ {
+ BinaryXInputStream aXStrm( rStrg.openInputStream( "x" ), true );
+ pMultiPage->importPageAndMultiPageProperties( aXStrm, maControls.size() );
+ }
+ typedef std::unordered_map< sal_uInt32, std::shared_ptr< VbaFormControl > > IdToPageMap;
+ IdToPageMap idToPage;
+ AxArrayString sCaptions;
+
+ for (auto const& control : maControls)
{
- /* Read the site models of all embedded controls (this fills the
- maControls vector). Ignore failure of importSiteModels() but
- try to import as much controls as possible. */
- importEmbeddedSiteModels( aFStrm );
- /* Open the 'o' stream containing models of embedded simple
- controls. Stream may be empty or missing, if this control
- contains no controls or only container controls. */
- BinaryXInputStream aOStrm( rStrg.openInputStream( "o" ), true );
-
- /* Iterate over all embedded controls, import model from 'o'
- stream (for embedded simple controls) or from the substorage
- (for embedded container controls). */
- maControls.forEachMem( &VbaFormControl::importModelOrStorage,
- ::std::ref( aOStrm ), ::std::ref( rStrg ), ::std::cref( maClassTable ) );
-
- // Special handling for multi-page which has non-standard
- // containment and additionally needs to re-order Page children
- if ( pContainerModel->getControlType() == API_CONTROL_MULTIPAGE )
+ auto& elem = control->mxCtrlModel;
+ if (!elem)
{
- AxMultiPageModel* pMultiPage = dynamic_cast< AxMultiPageModel* >( pContainerModel );
- assert(pMultiPage);
- {
- BinaryXInputStream aXStrm( rStrg.openInputStream( "x" ), true );
- pMultiPage->importPageAndMultiPageProperties( aXStrm, maControls.size() );
- }
- typedef std::unordered_map< sal_uInt32, std::shared_ptr< VbaFormControl > > IdToPageMap;
- IdToPageMap idToPage;
- AxArrayString sCaptions;
+ SAL_WARN("oox", "empty control model");
+ continue;
+ }
+ if (elem->getControlType() == API_CONTROL_PAGE)
+ {
+ VbaSiteModelRef xPageSiteRef = control->mxSiteModel;
+ if ( xPageSiteRef.get() )
+ idToPage[ xPageSiteRef->getId() ] = control;
+ }
+ else
+ {
+ AxTabStripModel* pTabStrip = static_cast<AxTabStripModel*>(elem.get());
+ sCaptions = pTabStrip->maItems;
+ pMultiPage->mnActiveTab = pTabStrip->mnListIndex;
+ pMultiPage->mnTabStyle = pTabStrip->mnTabStyle;
+ }
+ }
+ // apply caption/titles to pages
- for (auto const& control : maControls)
+ maControls.clear();
+ // need to sort the controls according to the order of the ids
+ if ( sCaptions.size() == idToPage.size() )
+ {
+ AxArrayString::iterator itCaption = sCaptions.begin();
+ for ( const auto& rCtrlId : pMultiPage->mnIDs )
+ {
+ IdToPageMap::iterator iter = idToPage.find( rCtrlId );
+ if ( iter != idToPage.end() )
{
- auto& elem = control->mxCtrlModel;
- if (!elem)
- {
- SAL_WARN("oox", "empty control model");
- continue;
- }
- if (elem->getControlType() == API_CONTROL_PAGE)
- {
- VbaSiteModelRef xPageSiteRef = control->mxSiteModel;
- if ( xPageSiteRef.get() )
- idToPage[ xPageSiteRef->getId() ] = control;
- }
- else
- {
- AxTabStripModel* pTabStrip = static_cast<AxTabStripModel*>(elem.get());
- sCaptions = pTabStrip->maItems;
- pMultiPage->mnActiveTab = pTabStrip->mnListIndex;
- pMultiPage->mnTabStyle = pTabStrip->mnTabStyle;
- }
- }
- // apply caption/titles to pages
+ AxPageModel* pPage = static_cast<AxPageModel*> ( iter->second->mxCtrlModel.get() );
- maControls.clear();
- // need to sort the controls according to the order of the ids
- if ( sCaptions.size() == idToPage.size() )
- {
- AxArrayString::iterator itCaption = sCaptions.begin();
- for ( const auto& rCtrlId : pMultiPage->mnIDs )
- {
- IdToPageMap::iterator iter = idToPage.find( rCtrlId );
- if ( iter != idToPage.end() )
- {
- AxPageModel* pPage = static_cast<AxPageModel*> ( iter->second->mxCtrlModel.get() );
-
- pPage->importProperty( XML_Caption, *itCaption );
- maControls.push_back( iter->second );
- }
- ++itCaption;
- }
+ pPage->importProperty( XML_Caption, *itCaption );
+ maControls.push_back( iter->second );
}
+ ++itCaption;
}
- /* 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();
}
}
+ /* 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();
}
bool VbaFormControl::convertProperties( const Reference< XControlModel >& rxCtrlModel,
@@ -692,24 +695,24 @@ void VbaFormControl::moveRelative( const AxPairData& rDistance )
void VbaFormControl::moveEmbeddedToAbsoluteParent()
{
- if( mxSiteModel.get() && !maControls.empty() )
- {
- // distance to move is equal to position of this control in its parent
- AxPairData aDistance = mxSiteModel->getPosition();
+ if( !(mxSiteModel.get() && !maControls.empty()) )
+ return;
- /* 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) )
- {
- // 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;
- }
+ // distance to move is equal to position of this control in its parent
+ AxPairData aDistance = mxSiteModel->getPosition();
- // move the embedded controls
- maControls.forEachMem( &VbaFormControl::moveRelative, ::std::cref( aDistance ) );
+ /* 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) )
+ {
+ // 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;
}
+
+ // move the embedded controls
+ maControls.forEachMem( &VbaFormControl::moveRelative, ::std::cref( aDistance ) );
}
bool VbaFormControl::compareByTabIndex( const VbaFormControlRef& rxLeft, const VbaFormControlRef& rxRight )
diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx
index 91738efddbfa..02b290ed8d1c 100644
--- a/oox/source/ole/vbaproject.cxx
+++ b/oox/source/ole/vbaproject.cxx
@@ -397,7 +397,11 @@ void VbaProject::readVbaModules( StorageBase& rVbaPrjStrg )
}
}
}
- if( !maModules.empty() ) try
+
+ if( maModules.empty() )
+ return;
+
+ try
{
/* Set library container to VBA compatibility mode. This will create
the VBA Globals object and store it in the Basic manager of the
@@ -511,7 +515,10 @@ void VbaProject::importModulesAndForms( StorageBase& rVbaPrjStrg, const GraphicH
void VbaProject::attachMacros()
{
- if( !maMacroAttachers.empty() && mxContext.is() ) try
+ if( !(!maMacroAttachers.empty() && mxContext.is()) )
+ return;
+
+ try
{
comphelper::DocumentInfo::notifyMacroEventRead(mxDocModel);
@@ -531,7 +538,10 @@ void VbaProject::attachMacros()
void VbaProject::copyStorage( StorageBase& rVbaPrjStrg )
{
- if( mxContext.is() ) try
+ if( !mxContext.is() )
+ return;
+
+ try
{
Reference< XStorageBasedDocument > xStorageBasedDoc( mxDocModel, UNO_QUERY_THROW );
Reference< XStorage > xDocStorage( xStorageBasedDoc->getDocumentStorage(), UNO_SET_THROW );
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 9ce8dc2b4824..dea04a98e9a3 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -75,29 +75,30 @@ PowerPointImport::~PowerPointImport()
/// Visits the relations from pRelations which are of type rType.
static void visitRelations(PowerPointImport& rImport, const core::RelationsRef& pRelations, const OUString& rType, std::vector<OUString>& rImageFragments)
{
- if (core::RelationsRef pRelationsOfType = pRelations->getRelationsFromTypeFromOfficeDoc(rType))
+ core::RelationsRef pRelationsOfType = pRelations->getRelationsFromTypeFromOfficeDoc(rType);
+ if (!pRelationsOfType)
+ return;
+
+ for (const auto& rRelation : *pRelationsOfType)
{
- for (const auto& rRelation : *pRelationsOfType)
+ OUString aFragment = pRelationsOfType->getFragmentPathFromRelation(rRelation.second);
+ if (core::RelationsRef pFragmentRelations = rImport.importRelations(aFragment))
{
- OUString aFragment = pRelationsOfType->getFragmentPathFromRelation(rRelation.second);
- if (core::RelationsRef pFragmentRelations = rImport.importRelations(aFragment))
+ // See if the fragment has images.
+ if (core::RelationsRef pImages = pFragmentRelations->getRelationsFromTypeFromOfficeDoc("image"))
{
- // See if the fragment has images.
- if (core::RelationsRef pImages = pFragmentRelations->getRelationsFromTypeFromOfficeDoc("image"))
+ for (const auto& rImage : *pImages)
{
- for (const auto& rImage : *pImages)
- {
- OUString aPath = pImages->getFragmentPathFromRelation(rImage.second);
- // Safe subset: e.g. WMF may have an external header from the
- // referencing fragment.
- if (aPath.endsWith(".jpg") || aPath.endsWith(".jpeg"))
- rImageFragments.push_back(aPath);
- }
+ OUString aPath = pImages->getFragmentPathFromRelation(rImage.second);
+ // Safe subset: e.g. WMF may have an external header from the
+ // referencing fragment.
+ if (aPath.endsWith(".jpg") || aPath.endsWith(".jpeg"))
+ rImageFragments.push_back(aPath);
}
-
- // See if the fragment has a slide layout, and recurse.
- visitRelations(rImport, pFragmentRelations, "slideLayout", rImageFragments);
}
+
+ // See if the fragment has a slide layout, and recurse.
+ visitRelations(rImport, pFragmentRelations, "slideLayout", rImageFragments);
}
}
}
diff --git a/oox/source/ppt/pptshapegroupcontext.cxx b/oox/source/ppt/pptshapegroupcontext.cxx
index 98ba3a4d259f..4355f951bc8b 100644
--- a/oox/source/ppt/pptshapegroupcontext.cxx
+++ b/oox/source/ppt/pptshapegroupcontext.cxx
@@ -142,24 +142,24 @@ ContextHandlerRef PPTShapeGroupContext::onCreateContext( sal_Int32 aElementToken
void PPTShapeGroupContext::importExtDrawings( )
{
- if( pGraphicShape )
+ if( !pGraphicShape )
+ return;
+
+ for (auto const& extDrawing : pGraphicShape->getExtDrawings())
{
- for (auto const& extDrawing : pGraphicShape->getExtDrawings())
- {
- OUString aFragmentPath = getFragmentPathFromRelId(extDrawing);
- getFilter().importFragment( new ExtDrawingFragmentHandler( getFilter(), aFragmentPath,
- mpSlidePersistPtr,
- meShapeLocation,
- mpGroupShapePtr,
- pGraphicShape ) );
- pGraphicShape->keepDiagramDrawing(getFilter(), aFragmentPath);
+ OUString aFragmentPath = getFragmentPathFromRelId(extDrawing);
+ getFilter().importFragment( new ExtDrawingFragmentHandler( getFilter(), aFragmentPath,
+ mpSlidePersistPtr,
+ meShapeLocation,
+ mpGroupShapePtr,
+ pGraphicShape ) );
+ pGraphicShape->keepDiagramDrawing(getFilter(), aFragmentPath);
- // Apply font color imported from color fragment
- if( pGraphicShape->getFontRefColorForNodes().isUsed() )
- applyFontRefColor(mpGroupShapePtr, pGraphicShape->getFontRefColorForNodes());
- }
- pGraphicShape = oox::drawingml::ShapePtr( nullptr );
+ // Apply font color imported from color fragment
+ if( pGraphicShape->getFontRefColorForNodes().isUsed() )
+ applyFontRefColor(mpGroupShapePtr, pGraphicShape->getFontRefColorForNodes());
}
+ pGraphicShape = oox::drawingml::ShapePtr( nullptr );
}
void PPTShapeGroupContext::applyFontRefColor(const oox::drawingml::ShapePtr& pShape, const oox::drawingml::Color& rFontRefColor)
diff --git a/oox/source/ppt/presentationfragmenthandler.cxx b/oox/source/ppt/presentationfragmenthandler.cxx
index 5c4bfe987249..908b13fdc4ab 100644
--- a/oox/source/ppt/presentationfragmenthandler.cxx
+++ b/oox/source/ppt/presentationfragmenthandler.cxx
@@ -100,55 +100,55 @@ PresentationFragmentHandler::~PresentationFragmentHandler() throw()
static void ResolveTextFields( XmlFilterBase const & rFilter )
{
const oox::core::TextFieldStack& rTextFields = rFilter.getTextFieldStack();
- if ( !rTextFields.empty() )
+ if ( rTextFields.empty() )
+ return;
+
+ const Reference< frame::XModel >& xModel( rFilter.getModel() );
+ for (auto const& textField : rTextFields)
{
- const Reference< frame::XModel >& xModel( rFilter.getModel() );
- for (auto const& textField : rTextFields)
+ const OUString sURL = "URL";
+ Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW );
+ Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_SET_THROW );
+
+ const oox::core::TextField& rTextField( textField );
+ Reference< XPropertySet > xPropSet( rTextField.xTextField, UNO_QUERY );
+ Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
+ if ( xPropSetInfo->hasPropertyByName( sURL ) )
{
- const OUString sURL = "URL";
- Reference< drawing::XDrawPagesSupplier > xDPS( xModel, uno::UNO_QUERY_THROW );
- Reference< drawing::XDrawPages > xDrawPages( xDPS->getDrawPages(), uno::UNO_SET_THROW );
-
- const oox::core::TextField& rTextField( textField );
- Reference< XPropertySet > xPropSet( rTextField.xTextField, UNO_QUERY );
- Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
- if ( xPropSetInfo->hasPropertyByName( sURL ) )
+ OUString aURL;
+ if ( xPropSet->getPropertyValue( sURL ) >>= aURL )
{
- OUString aURL;
- if ( xPropSet->getPropertyValue( sURL ) >>= aURL )
+ const OUString sSlide = "#Slide ";
+ const OUString sNotes = "#Notes ";
+ bool bNotes = false;
+ sal_Int32 nPageNumber = 0;
+ if ( aURL.match( sSlide ) )
+ nPageNumber = aURL.copy( sSlide.getLength() ).toInt32();
+ else if ( aURL.match( sNotes ) )
{
- const OUString sSlide = "#Slide ";
- const OUString sNotes = "#Notes ";
- bool bNotes = false;
- sal_Int32 nPageNumber = 0;
- if ( aURL.match( sSlide ) )
- nPageNumber = aURL.copy( sSlide.getLength() ).toInt32();
- else if ( aURL.match( sNotes ) )
- {
- nPageNumber = aURL.copy( sNotes.getLength() ).toInt32();
- bNotes = true;
- }
- if ( nPageNumber )
+ nPageNumber = aURL.copy( sNotes.getLength() ).toInt32();
+ bNotes = true;
+ }
+ if ( nPageNumber )
+ {
+ try
{
- try
- {
- Reference< XDrawPage > xDrawPage;
- xDrawPages->getByIndex( nPageNumber - 1 ) >>= xDrawPage;
- if ( bNotes )
- {
- Reference< css::presentation::XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
- xDrawPage = xPresentationPage->getNotesPage();
- }
- Reference< container::XNamed > xNamed( xDrawPage, UNO_QUERY_THROW );
- aURL = "#" + xNamed->getName();
- xPropSet->setPropertyValue( sURL, Any( aURL ) );
- Reference< text::XTextContent > xContent( rTextField.xTextField, UNO_QUERY);
- Reference< text::XTextRange > xTextRange = rTextField.xTextCursor;
- rTextField.xText->insertTextContent( xTextRange, xContent, true );
- }
- catch( uno::Exception& )
+ Reference< XDrawPage > xDrawPage;
+ xDrawPages->getByIndex( nPageNumber - 1 ) >>= xDrawPage;
+ if ( bNotes )
{
+ Reference< css::presentation::XPresentationPage > xPresentationPage( xDrawPage, UNO_QUERY_THROW );
+ xDrawPage = xPresentationPage->getNotesPage();
}
+ Reference< container::XNamed > xNamed( xDrawPage, UNO_QUERY_THROW );
+ aURL = "#" + xNamed->getName();
+ xPropSet->setPropertyValue( sURL, Any( aURL ) );
+ Reference< text::XTextContent > xContent( rTextField.xTextField, UNO_QUERY);
+ Reference< text::XTextRange > xTextRange = rTextField.xTextCursor;
+ rTextField.xText->insertTextContent( xTextRange, xContent, true );
+ }
+ catch( uno::Exception& )
+ {
}
}
}
diff --git a/oox/source/ppt/slidepersist.cxx b/oox/source/ppt/slidepersist.cxx
index ba8fb4ace641..65dc198759ea 100644
--- a/oox/source/ppt/slidepersist.cxx
+++ b/oox/source/ppt/slidepersist.cxx
@@ -147,18 +147,18 @@ void SlidePersist::createXShapes( XmlFilterBase& rFilterBase )
}
Reference< XAnimationNodeSupplier > xNodeSupplier( getPage(), UNO_QUERY);
- if( xNodeSupplier.is() )
+ if( !xNodeSupplier.is() )
+ return;
+
+ Reference< XAnimationNode > xNode( xNodeSupplier->getAnimationNode() );
+ if( xNode.is() && !maTimeNodeList.empty() )
{
- Reference< XAnimationNode > xNode( xNodeSupplier->getAnimationNode() );
- if( xNode.is() && !maTimeNodeList.empty() )
- {
- SlidePersistPtr pSlidePtr( shared_from_this() );
- TimeNodePtr pNode(maTimeNodeList.front());
- OSL_ENSURE( pNode, "pNode" );
+ SlidePersistPtr pSlidePtr( shared_from_this() );
+ TimeNodePtr pNode(maTimeNodeList.front());
+ OSL_ENSURE( pNode, "pNode" );
- Reference<XAnimationNode> xDummy;
- pNode->setNode(rFilterBase, xNode, pSlidePtr, xDummy);
- }
+ Reference<XAnimationNode> xDummy;
+ pNode->setNode(rFilterBase, xNode, pSlidePtr, xDummy);
}
}
@@ -197,96 +197,96 @@ static void setTextStyle( Reference< beans::XPropertySet > const & rxPropSet, co
void SlidePersist::applyTextStyles( const XmlFilterBase& rFilterBase )
{
- if ( mbMaster )
+ if ( !mbMaster )
+ return;
+
+ try
{
- try
- {
- Reference< style::XStyleFamiliesSupplier > aXStyleFamiliesSupplier( rFilterBase.getModel(), UNO_QUERY_THROW );
- Reference< container::XNameAccess > aXNameAccess( aXStyleFamiliesSupplier->getStyleFamilies() );
- Reference< container::XNamed > aXNamed( mxPage, UNO_QUERY_THROW );
+ Reference< style::XStyleFamiliesSupplier > aXStyleFamiliesSupplier( rFilterBase.getModel(), UNO_QUERY_THROW );
+ Reference< container::XNameAccess > aXNameAccess( aXStyleFamiliesSupplier->getStyleFamilies() );
+ Reference< container::XNamed > aXNamed( mxPage, UNO_QUERY_THROW );
- if ( aXNameAccess.is() )
- {
- oox::drawingml::TextListStylePtr pTextListStylePtr;
- OUString aStyle;
- OUString aFamily;
+ if ( aXNameAccess.is() )
+ {
+ oox::drawingml::TextListStylePtr pTextListStylePtr;
+ OUString aStyle;
+ OUString aFamily;
- const OUString sOutline( "outline1" );
- const OUString sTitle( "title" );
- const OUString sStandard( "standard" );
- const OUString sSubtitle( "subtitle" );
+ const OUString sOutline( "outline1" );
+ const OUString sTitle( "title" );
+ const OUString sStandard( "standard" );
+ const OUString sSubtitle( "subtitle" );
- for( int i = 0; i < 4; i++ ) // todo: aggregation of bodystyle (subtitle)
+ for( int i = 0; i < 4; i++ ) // todo: aggregation of bodystyle (subtitle)
+ {
+ switch( i )
{
- switch( i )
+ case 0 : // title style
{
- case 0 : // title style
- {
- pTextListStylePtr = maTitleTextStylePtr;
- aStyle = sTitle;
- aFamily= aXNamed->getName();
- break;
- }
- case 1 : // body style
- {
- pTextListStylePtr = maBodyTextStylePtr;
- aStyle = sOutline;
- aFamily= aXNamed->getName();
- break;
- }
- case 3 : // notes style
- {
- pTextListStylePtr = maNotesTextStylePtr;
- aStyle = sTitle;
- aFamily= aXNamed->getName();
- break;
- }
- case 4 : // standard style
- {
- pTextListStylePtr = maOtherTextStylePtr;
- aStyle = sStandard;
- aFamily = "graphics";
- break;
- }
- case 5 : // subtitle
- {
- pTextListStylePtr = maBodyTextStylePtr;
- aStyle = sSubtitle;
- aFamily = aXNamed->getName();
- break;
- }
+ pTextListStylePtr = maTitleTextStylePtr;
+ aStyle = sTitle;
+ aFamily= aXNamed->getName();
+ break;
+ }
+ case 1 : // body style
+ {
+ pTextListStylePtr = maBodyTextStylePtr;
+ aStyle = sOutline;
+ aFamily= aXNamed->getName();
+ break;
+ }
+ case 3 : // notes style
+ {
+ pTextListStylePtr = maNotesTextStylePtr;
+ aStyle = sTitle;
+ aFamily= aXNamed->getName();
+ break;
+ }
+ case 4 : // standard style
+ {
+ pTextListStylePtr = maOtherTextStylePtr;
+ aStyle = sStandard;
+ aFamily = "graphics";
+ break;
}
- Reference< container::XNameAccess > xFamilies;
- if ( aXNameAccess->hasByName( aFamily ) )
+ case 5 : // subtitle
{
- if( aXNameAccess->getByName( aFamily ) >>= xFamilies )
+ pTextListStylePtr = maBodyTextStylePtr;
+ aStyle = sSubtitle;
+ aFamily = aXNamed->getName();
+ break;
+ }
+ }
+ Reference< container::XNameAccess > xFamilies;
+ if ( aXNameAccess->hasByName( aFamily ) )
+ {
+ if( aXNameAccess->getByName( aFamily ) >>= xFamilies )
+ {
+ if ( xFamilies->hasByName( aStyle ) )
{
- if ( xFamilies->hasByName( aStyle ) )
+ Reference< style::XStyle > aXStyle;
+ if ( xFamilies->getByName( aStyle ) >>= aXStyle )
{
- Reference< style::XStyle > aXStyle;
- if ( xFamilies->getByName( aStyle ) >>= aXStyle )
+ Reference< beans::XPropertySet > xPropSet( aXStyle, UNO_QUERY_THROW );
+ setTextStyle( xPropSet, rFilterBase, maDefaultTextStylePtr, 0 );
+ setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, 0 );
+ if ( i == 1 /* BodyStyle */ )
{
- Reference< beans::XPropertySet > xPropSet( aXStyle, UNO_QUERY_THROW );
- setTextStyle( xPropSet, rFilterBase, maDefaultTextStylePtr, 0 );
- setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, 0 );
- if ( i == 1 /* BodyStyle */ )
+ for ( int nLevel = 1; nLevel < 5; nLevel++ )
{
- for ( int nLevel = 1; nLevel < 5; nLevel++ )
{
+ char pOutline[ 9 ] = "outline1";
+ pOutline[ 7 ] = static_cast< char >( '0' + nLevel );
+ OUString sOutlineStyle( OUString::createFromAscii( pOutline ) );
+ if ( xFamilies->hasByName( sOutlineStyle ) )
{
- char pOutline[ 9 ] = "outline1";
- pOutline[ 7 ] = static_cast< char >( '0' + nLevel );
- OUString sOutlineStyle( OUString::createFromAscii( pOutline ) );
- if ( xFamilies->hasByName( sOutlineStyle ) )
- {
- xFamilies->getByName( sOutlineStyle ) >>= aXStyle;
- if( aXStyle.is() )
- xPropSet.set( aXStyle, UNO_QUERY_THROW );
- }
+ xFamilies->getByName( sOutlineStyle ) >>= aXStyle;
+ if( aXStyle.is() )
+ xPropSet.set( aXStyle, UNO_QUERY_THROW );
}
- setTextStyle( xPropSet, rFilterBase, maDefaultTextStylePtr, nLevel );
- setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, nLevel );
}
+ setTextStyle( xPropSet, rFilterBase, maDefaultTextStylePtr, nLevel );
+ setTextStyle( xPropSet, rFilterBase, pTextListStylePtr, nLevel );
}
}
}
@@ -295,9 +295,9 @@ void SlidePersist::applyTextStyles( const XmlFilterBase& rFilterBase )
}
}
}
- catch( const Exception& )
- {
- }
+ }
+ catch( const Exception& )
+ {
}
}
diff --git a/oox/source/ppt/soundactioncontext.cxx b/oox/source/ppt/soundactioncontext.cxx
index 51e709b9f577..4c9d242af092 100644
--- a/oox/source/ppt/soundactioncontext.cxx
+++ b/oox/source/ppt/soundactioncontext.cxx
@@ -53,30 +53,30 @@ namespace oox::ppt {
void SoundActionContext::onEndElement()
{
- if ( isCurrentElement( PPT_TOKEN( sndAc ) ) )
+ if ( !isCurrentElement( PPT_TOKEN( sndAc ) ) )
+ return;
+
+ if( !mbHasStartSound )
+ return;
+
+ OUString url;
+#if HAVE_FEATURE_AVMEDIA
+ if ( !msSndName.isEmpty() )
{
- if( mbHasStartSound )
+ Reference<css::io::XInputStream>
+ xInputStream = getFilter().openInputStream(msSndName);
+ if (xInputStream.is())
{
- OUString url;
-#if HAVE_FEATURE_AVMEDIA
- if ( !msSndName.isEmpty() )
- {
- Reference<css::io::XInputStream>
- xInputStream = getFilter().openInputStream(msSndName);
- if (xInputStream.is())
- {
- ::avmedia::EmbedMedia(getFilter().getModel(), msSndName, url, xInputStream);
- xInputStream->closeInput();
- }
- }
-#endif
- if ( !url.isEmpty() )
- {
- maSlideProperties.setProperty( PROP_Sound, url);
- maSlideProperties.setProperty( PROP_SoundOn, true);
- }
+ ::avmedia::EmbedMedia(getFilter().getModel(), msSndName, url, xInputStream);
+ xInputStream->closeInput();
}
}
+#endif
+ if ( !url.isEmpty() )
+ {
+ maSlideProperties.setProperty( PROP_Sound, url);
+ maSlideProperties.setProperty( PROP_SoundOn, true);
+ }
}
::oox::core::ContextHandlerRef SoundActionContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
diff --git a/oox/source/ppt/timenodelistcontext.cxx b/oox/source/ppt/timenodelistcontext.cxx
index 278fcde198f6..b13fbb9c9bf3 100644
--- a/oox/source/ppt/timenodelistcontext.cxx
+++ b/oox/source/ppt/timenodelistcontext.cxx
@@ -267,74 +267,74 @@ namespace oox::ppt {
virtual void onEndElement() override
{
- if( isCurrentElement( PPT_TOKEN( cmd ) ) )
- {
- try {
- // see sd/source/filter/ppt/pptinanimations.cxx
- // in AnimationImporter::importCommandContainer()
- // REFACTOR?
- // a good chunk of this code has been copied verbatim *sigh*
- sal_Int16 nCommand = EffectCommands::CUSTOM;
- NamedValue aParamValue;
-
- switch( maType )
+ if( !isCurrentElement( PPT_TOKEN( cmd ) ) )
+ return;
+
+ try {
+ // see sd/source/filter/ppt/pptinanimations.cxx
+ // in AnimationImporter::importCommandContainer()
+ // REFACTOR?
+ // a good chunk of this code has been copied verbatim *sigh*
+ sal_Int16 nCommand = EffectCommands::CUSTOM;
+ NamedValue aParamValue;
+
+ switch( maType )
+ {
+ case XML_verb:
+ aParamValue.Name = "Verb";
+ // TODO make sure msCommand has what we want
+ aParamValue.Value <<= msCommand.toInt32();
+ nCommand = EffectCommands::VERB;
+ break;
+ case XML_evt:
+ case XML_call:
+ if ( msCommand == "onstopaudio" )
{
- case XML_verb:
- aParamValue.Name = "Verb";
- // TODO make sure msCommand has what we want
- aParamValue.Value <<= msCommand.toInt32();
- nCommand = EffectCommands::VERB;
- break;
- case XML_evt:
- case XML_call:
- if ( msCommand == "onstopaudio" )
- {
- nCommand = EffectCommands::STOPAUDIO;
- }
- else if ( msCommand == "play" )
- {
- nCommand = EffectCommands::PLAY;
- }
- else if( msCommand == "playFrom" )
- {
- const OUString aMediaTime( msCommand.copy( 9, msCommand.getLength() - 10 ) );
- rtl_math_ConversionStatus eStatus;
- double fMediaTime = ::rtl::math::stringToDouble( aMediaTime, u'.', u',', &eStatus );
- if( eStatus == rtl_math_ConversionStatus_Ok )
- {
- aParamValue.Name = "MediaTime";
- aParamValue.Value <<= fMediaTime;
- }
- nCommand = EffectCommands::PLAY;
- }
- else if ( msCommand == "togglePause" )
- {
- nCommand = EffectCommands::TOGGLEPAUSE;
- }
- else if ( msCommand == "stop" )
+ nCommand = EffectCommands::STOPAUDIO;
+ }
+ else if ( msCommand == "play" )
+ {
+ nCommand = EffectCommands::PLAY;
+ }
+ else if( msCommand == "playFrom" )
+ {
+ const OUString aMediaTime( msCommand.copy( 9, msCommand.getLength() - 10 ) );
+ rtl_math_ConversionStatus eStatus;
+ double fMediaTime = ::rtl::math::stringToDouble( aMediaTime, u'.', u',', &eStatus );
+ if( eStatus == rtl_math_ConversionStatus_Ok )
{
- nCommand = EffectCommands::STOP;
+ aParamValue.Name = "MediaTime";
+ aParamValue.Value <<= fMediaTime;
}
- break;
+ nCommand = EffectCommands::PLAY;
}
- mpNode->getNodeProperties()[ NP_COMMAND ] <<= nCommand;
- if( nCommand == EffectCommands::CUSTOM )
+ else if ( msCommand == "togglePause" )
{
- SAL_WARN("oox.ppt", "OOX: CmdTimeNodeContext::endFastElement(), unknown command!");
- aParamValue.Name = "UserDefined";
- aParamValue.Value <<= msCommand;
+ nCommand = EffectCommands::TOGGLEPAUSE;
}
- if( aParamValue.Value.hasValue() )
+ else if ( msCommand == "stop" )
{
- Sequence< NamedValue > aParamSeq( &aParamValue, 1 );
- mpNode->getNodeProperties()[ NP_PARAMETER ] <<= aParamSeq;
+ nCommand = EffectCommands::STOP;
}
+ break;
}
- catch( RuntimeException& )
+ mpNode->getNodeProperties()[ NP_COMMAND ] <<= nCommand;
+ if( nCommand == EffectCommands::CUSTOM )
{
- SAL_WARN("oox.ppt", "OOX: Exception in CmdTimeNodeContext::endFastElement()" );
+ SAL_WARN("oox.ppt", "OOX: CmdTimeNodeContext::endFastElement(), unknown command!");
+ aParamValue.Name = "UserDefined";
+ aParamValue.Value <<= msCommand;
+ }
+ if( aParamValue.Value.hasValue() )
+ {
+ Sequence< NamedValue > aParamSeq( &aParamValue, 1 );
+ mpNode->getNodeProperties()[ NP_PARAMETER ] <<= aParamSeq;
}
}
+ catch( RuntimeException& )
+ {
+ SAL_WARN("oox.ppt", "OOX: Exception in CmdTimeNodeContext::endFastElement()" );
+ }
}
virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& /*rAttribs*/ ) override
@@ -444,19 +444,19 @@ namespace oox::ppt {
virtual void onEndElement() override
{
//xParentNode
- if( isCurrentElement( mnElement ) )
- {
- NodePropertyMap & rProps(mpNode->getNodeProperties());
- rProps[ NP_DIRECTION ] <<= mnDir == XML_cw;
- rProps[ NP_COLORINTERPOLATION ] <<= mnColorSpace == XML_hsl ? AnimationColorSpace::HSL : AnimationColorSpace::RGB;
- const GraphicHelper& rGraphicHelper = getFilter().getGraphicHelper();
- if( maToClr.isUsed() )
- mpNode->setTo( makeAny( maToClr.getColor( rGraphicHelper ) ) );
- if( maFromClr.isUsed() )
- mpNode->setFrom( makeAny( maFromClr.getColor( rGraphicHelper ) ) );
- if( mbHasByColor )
- mpNode->setBy( m_byColor.get() );
- }
+ if( !isCurrentElement( mnElement ) )
+ return;
+
+ NodePropertyMap & rProps(mpNode->getNodeProperties());
+ rProps[ NP_DIRECTION ] <<= mnDir == XML_cw;
+ rProps[ NP_COLORINTERPOLATION ] <<= mnColorSpace == XML_hsl ? AnimationColorSpace::HSL : AnimationColorSpace::RGB;
+ const GraphicHelper& rGraphicHelper = getFilter().getGraphicHelper();
+ if( maToClr.isUsed() )
+ mpNode->setTo( makeAny( maToClr.getColor( rGraphicHelper ) ) );
+ if( maFromClr.isUsed() )
+ mpNode->setFrom( makeAny( maFromClr.getColor( rGraphicHelper ) ) );
+ if( mbHasByColor )
+ mpNode->setBy( m_byColor.get() );
}
virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) override
@@ -582,35 +582,35 @@ namespace oox::ppt {
}
int nKeyTimes = maTavList.size();
- if( nKeyTimes > 0)
- {
- int i=0;
- Sequence< double > aKeyTimes( nKeyTimes );
- Sequence< Any > aValues( nKeyTimes );
+ if( nKeyTimes <= 0)
+ return;
- NodePropertyMap & aProps( mpNode->getNodeProperties() );
- for (auto const& tav : maTavList)
- {
- // TODO what to do if it is Timing_INFINITE ?
- Any aTime = GetTimeAnimateValueTime( tav.msTime );
- aTime >>= aKeyTimes[i];
- aValues[i] = tav.maValue;
- convertAnimationValueWithTimeNode(mpNode, aValues[i]);
-
- // Examine pptx documents and find that only the first tav
- // has the formula set. The formula can be used for the whole.
- if (!tav.msFormula.isEmpty())
- {
- OUString sFormula = tav.msFormula;
- (void)convertMeasure(sFormula);
- aProps[NP_FORMULA] <<= sFormula;
- }
+ int i=0;
+ Sequence< double > aKeyTimes( nKeyTimes );
+ Sequence< Any > aValues( nKeyTimes );
- ++i;
+ NodePropertyMap & aProps( mpNode->getNodeProperties() );
+ for (auto const& tav : maTavList)
+ {
+ // TODO what to do if it is Timing_INFINITE ?
+ Any aTime = GetTimeAnimateValueTime( tav.msTime );
+ aTime >>= aKeyTimes[i];
+ aValues[i] = tav.maValue;
+ convertAnimationValueWithTimeNode(mpNode, aValues[i]);
+
+ // Examine pptx documents and find that only the first tav
+ // has the formula set. The formula can be used for the whole.
+ if (!tav.msFormula.isEmpty())
+ {
+ OUString sFormula = tav.msFormula;
+ (void)convertMeasure(sFormula);
+ aProps[NP_FORMULA] <<= sFormula;
}
- aProps[ NP_VALUES ] <<= aValues;
- aProps[ NP_KEYTIMES ] <<= aKeyTimes;
+
+ ++i;
}
+ aProps[ NP_VALUES ] <<= aValues;
+ aProps[ NP_KEYTIMES ] <<= aKeyTimes;
}
virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& /*rAttribs*/ ) override
@@ -655,20 +655,20 @@ namespace oox::ppt {
virtual void onEndElement() override
{
- if( isCurrentElement( mnElement ) )
+ if( !isCurrentElement( mnElement ) )
+ return;
+
+ if( maTo.hasValue() )
{
- if( maTo.hasValue() )
- {
- mpNode->setTo( maTo );
- }
- if( maBy.hasValue() )
- {
- mpNode->setBy( maBy );
- }
- if( maFrom.hasValue() )
- {
- mpNode->setFrom( maFrom );
- }
+ mpNode->setTo( maTo );
+ }
+ if( maBy.hasValue() )
+ {
+ mpNode->setBy( maBy );
+ }
+ if( maFrom.hasValue() )
+ {
+ mpNode->setFrom( maFrom );
}
}
diff --git a/oox/source/shape/ShapeContextHandler.cxx b/oox/source/shape/ShapeContextHandler.cxx
index 2108f9e3ff94..ab5dfdb8524c 100644
--- a/oox/source/shape/ShapeContextHandler.cxx
+++ b/oox/source/shape/ShapeContextHandler.cxx
@@ -326,21 +326,21 @@ void SAL_CALL ShapeContextHandler::endFastElement(::sal_Int32 Element)
xContextHandler->endFastElement(Element);
// In case a textbox is sent, and later we get additional properties for
// the textbox, then the wps context is not cleared, so do that here.
- if (Element == (NMSP_wps | XML_wsp))
+ if (Element != (NMSP_wps | XML_wsp))
+ return;
+
+ uno::Reference<lang::XServiceInfo> xServiceInfo(mxSavedShape, uno::UNO_QUERY);
+ bool bTextFrame = xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame");
+ bool bTextBox = false;
+ if (!bTextFrame)
{
- uno::Reference<lang::XServiceInfo> xServiceInfo(mxSavedShape, uno::UNO_QUERY);
- bool bTextFrame = xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame");
- bool bTextBox = false;
- if (!bTextFrame)
- {
- uno::Reference<beans::XPropertySet> xPropertySet(mxSavedShape, uno::UNO_QUERY);
- if (xPropertySet.is())
- xPropertySet->getPropertyValue("TextBox") >>= bTextBox;
- }
- if (bTextFrame || bTextBox)
- mxWpsContext.clear();
- mxSavedShape.clear();
+ uno::Reference<beans::XPropertySet> xPropertySet(mxSavedShape, uno::UNO_QUERY);
+ if (xPropertySet.is())
+ xPropertySet->getPropertyValue("TextBox") >>= bTextBox;
}
+ if (bTextFrame || bTextBox)
+ mxWpsContext.clear();
+ mxSavedShape.clear();
}
void SAL_CALL ShapeContextHandler::endUnknownElement
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index de01cbab22b3..d89914e8c3be 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -546,34 +546,34 @@ sal_Int64 lclGetEmu( const GraphicHelper& rGraphicHelper, const OptValue< OUStri
void lclGetDmlLineDash( OptValue< sal_Int32 >& oroPresetDash, LineProperties::DashStopVector& orCustomDash, const OptValue< OUString >& roDashStyle )
{
- if( roDashStyle.has() )
+ if( !roDashStyle.has() )
+ return;
+
+ const OUString& rDashStyle = roDashStyle.get();
+ switch( AttributeConversion::decodeToken( rDashStyle ) )
{
- const OUString& rDashStyle = roDashStyle.get();
- switch( AttributeConversion::decodeToken( rDashStyle ) )
+ case XML_solid: oroPresetDash = XML_solid; return;
+ case XML_shortdot: oroPresetDash = XML_sysDot; return;
+ case XML_shortdash: oroPresetDash = XML_sysDash; return;
+ case XML_shortdashdot: oroPresetDash = XML_sysDashDot; return;
+ case XML_shortdashdotdot: oroPresetDash = XML_sysDashDotDot; return;
+ case XML_dot: oroPresetDash = XML_dot; return;
+ case XML_dash: oroPresetDash = XML_dash; return;
+ case XML_dashdot: oroPresetDash = XML_dashDot; return;
+ case XML_longdash: oroPresetDash = XML_lgDash; return;
+ case XML_longdashdot: oroPresetDash = XML_lgDashDot; return;
+ case XML_longdashdotdot: oroPresetDash = XML_lgDashDotDot; return;
+
+ // try to convert user-defined dash style
+ default:
{
- case XML_solid: oroPresetDash = XML_solid; return;
- case XML_shortdot: oroPresetDash = XML_sysDot; return;
- case XML_shortdash: oroPresetDash = XML_sysDash; return;
- case XML_shortdashdot: oroPresetDash = XML_sysDashDot; return;
- case XML_shortdashdotdot: oroPresetDash = XML_sysDashDotDot; return;
- case XML_dot: oroPresetDash = XML_dot; return;
- case XML_dash: oroPresetDash = XML_dash; return;
- case XML_dashdot: oroPresetDash = XML_dashDot; return;
- case XML_longdash: oroPresetDash = XML_lgDash; return;
- case XML_longdashdot: oroPresetDash = XML_lgDashDot; return;
- case XML_longdashdotdot: oroPresetDash = XML_lgDashDotDot; return;
-
- // try to convert user-defined dash style
- default:
- {
- ::std::vector< sal_Int32 > aValues;
- sal_Int32 nIndex = 0;
- while( nIndex >= 0 )
- aValues.push_back( rDashStyle.getToken( 0, ' ', nIndex ).toInt32() );
- size_t nPairs = aValues.size() / 2; // ignore last value if size is odd
- for( size_t nPairIdx = 0; nPairIdx < nPairs; ++nPairIdx )
- orCustomDash.emplace_back( aValues[ 2 * nPairIdx ], aValues[ 2 * nPairIdx + 1 ] );
- }
+ ::std::vector< sal_Int32 > aValues;
+ sal_Int32 nIndex = 0;
+ while( nIndex >= 0 )
+ aValues.push_back( rDashStyle.getToken( 0, ' ', nIndex ).toInt32() );
+ size_t nPairs = aValues.size() / 2; // ignore last value if size is odd
+ for( size_t nPairIdx = 0; nPairIdx < nPairs; ++nPairIdx )
+ orCustomDash.emplace_back( aValues[ 2 * nPairIdx ], aValues[ 2 * nPairIdx + 1 ] );
}
}
}
@@ -963,21 +963,21 @@ void TextpathModel::pushToPropMap(ShapePropertyMap& rPropMap, const uno::Referen
}
}
}
- if (!moTrim.has() || !moTrim.get())
+ if (moTrim.has() && moTrim.get())
+ return;
+
+ OUString sText = moString.get();
+ ScopedVclPtrInstance<VirtualDevice> pDevice;
+ vcl::Font aFont = pDevice->GetFont();
+ aFont.SetFamilyName(sFont);
+ aFont.SetFontSize(Size(0, 96));
+ pDevice->SetFont(aFont);
+
+ auto nTextWidth = pDevice->GetTextWidth(sText);
+ if (nTextWidth)
{
- OUString sText = moString.get();
- ScopedVclPtrInstance<VirtualDevice> pDevice;
- vcl::Font aFont = pDevice->GetFont();
- aFont.SetFamilyName(sFont);
- aFont.SetFontSize(Size(0, 96));
- pDevice->SetFont(aFont);
-
- auto nTextWidth = pDevice->GetTextWidth(sText);
- if (nTextWidth)
- {
- sal_Int32 nNewHeight = (static_cast<double>(pDevice->GetTextHeight()) / nTextWidth) * xShape->getSize().Width;
- xShape->setSize(awt::Size(xShape->getSize().Width, nNewHeight));
- }
+ sal_Int32 nNewHeight = (static_cast<double>(pDevice->GetTextHeight()) / nTextWidth) * xShape->getSize().Width;
+ xShape->setSize(awt::Size(xShape->getSize().Width, nNewHeight));
}
}
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index bdd9ac593dd6..7da04739c8e1 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -286,20 +286,20 @@ ShapeBase::ShapeBase( Drawing& rDrawing ) :
void ShapeBase::finalizeFragmentImport()
{
- if( maShapeModel.maType.getLength() > 1 )
- {
- OUString aType = maShapeModel.maType;
- if (aType[ 0 ] == '#')
- aType = aType.copy(1);
- if( const ShapeType* pShapeType = mrDrawing.getShapes().getShapeTypeById( aType ) )
- maTypeModel.assignUsed( pShapeType->getTypeModel() );
- else {
- // Temporary fix, shapetype not found if referenced from different substream
- // FIXME: extend scope of ShapeContainer to store all shapetypes from the document
- const OUString sShapeTypePrefix = "shapetype_";
- if (aType.startsWith(sShapeTypePrefix)) {
- maTypeModel.moShapeType = aType.copy(sShapeTypePrefix.getLength()).toInt32();
- }
+ if( maShapeModel.maType.getLength() <= 1 )
+ return;
+
+ OUString aType = maShapeModel.maType;
+ if (aType[ 0 ] == '#')
+ aType = aType.copy(1);
+ if( const ShapeType* pShapeType = mrDrawing.getShapes().getShapeTypeById( aType ) )
+ maTypeModel.assignUsed( pShapeType->getTypeModel() );
+ else {
+ // Temporary fix, shapetype not found if referenced from different substream
+ // FIXME: extend scope of ShapeContainer to store all shapetypes from the document
+ const OUString sShapeTypePrefix = "shapetype_";
+ if (aType.startsWith(sShapeTypePrefix)) {
+ maTypeModel.moShapeType = aType.copy(sShapeTypePrefix.getLength()).toInt32();
}
}
}
@@ -462,19 +462,19 @@ Reference< XShape > ShapeBase::convertAndInsert( const Reference< XShapes >& rxS
void ShapeBase::convertFormatting( const Reference< XShape >& rxShape ) const
{
- if( rxShape.is() )
- {
- /* Calculate shape rectangle. Applications may do something special
- according to some imported shape client data (e.g. Excel cell anchor). */
- awt::Rectangle aShapeRect = calcShapeRectangle( nullptr );
+ if( !rxShape.is() )
+ return;
- // convert the shape, if the calculated rectangle is not empty
- if( (aShapeRect.Width > 0) || (aShapeRect.Height > 0) )
- {
- rxShape->setPosition( awt::Point( aShapeRect.X, aShapeRect.Y ) );
- rxShape->setSize( awt::Size( aShapeRect.Width, aShapeRect.Height ) );
- convertShapeProperties( rxShape );
- }
+ /* Calculate shape rectangle. Applications may do something special
+ according to some imported shape client data (e.g. Excel cell anchor). */
+ awt::Rectangle aShapeRect = calcShapeRectangle( nullptr );
+
+ // convert the shape, if the calculated rectangle is not empty
+ if( (aShapeRect.Width > 0) || (aShapeRect.Height > 0) )
+ {
+ rxShape->setPosition( awt::Point( aShapeRect.X, aShapeRect.Y ) );
+ rxShape->setSize( awt::Size( aShapeRect.Width, aShapeRect.Height ) );
+ convertShapeProperties( rxShape );
}
}
diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx
index 215966ded6f5..5b79e8410bf9 100644
--- a/oox/source/vml/vmltextbox.cxx
+++ b/oox/source/vml/vmltextbox.cxx
@@ -181,21 +181,21 @@ void TextBox::convert(const uno::Reference<drawing::XShape>& xShape) const
if (xCursor->getString() == "\n")
xCursor->setString("");
- if ( maLayoutFlow == "vertical" )
- {
- uno::Reference<beans::XPropertySet> xProperties(xShape, uno::UNO_QUERY);
-
- // VML has the text horizontally aligned to left (all the time),
- // v-text-anchor for vertical alignment, and vertical mode to swap the
- // two. drawinglayer supports both horizontal and vertical alignment,
- // but no vertical mode: we use T->B, R->L instead.
- // As a result, we need to set horizontal adjustment here to 'right',
- // that will result in vertical 'top' after writing mode is applied,
- // which matches the VML behavior.
- xProperties->setPropertyValue("TextHorizontalAdjust", uno::makeAny(drawing::TextHorizontalAdjust_RIGHT));
-
- xProperties->setPropertyValue( "TextWritingMode", uno::makeAny( text::WritingMode_TB_RL ) );
- }
+ if ( maLayoutFlow != "vertical" )
+ return;
+
+ uno::Reference<beans::XPropertySet> xProperties(xShape, uno::UNO_QUERY);
+
+ // VML has the text horizontally aligned to left (all the time),
+ // v-text-anchor for vertical alignment, and vertical mode to swap the
+ // two. drawinglayer supports both horizontal and vertical alignment,
+ // but no vertical mode: we use T->B, R->L instead.
+ // As a result, we need to set horizontal adjustment here to 'right',
+ // that will result in vertical 'top' after writing mode is applied,
+ // which matches the VML behavior.
+ xProperties->setPropertyValue("TextHorizontalAdjust", uno::makeAny(drawing::TextHorizontalAdjust_RIGHT));
+
+ xProperties->setPropertyValue( "TextWritingMode", uno::makeAny( text::WritingMode_TB_RL ) );
}
} // namespace oox::vml