summaryrefslogtreecommitdiff
path: root/writerfilter/source/ooxml
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-02 20:08:17 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-02 22:44:54 +0200
commite2644b014005e1c79b0a7eaf1c3c4002464a1cf0 (patch)
tree52c24bcb37f2ebd73ad70efc2f45f0bdd5ed6875 /writerfilter/source/ooxml
parentf0da01e59ffe1f7f1b5446f111994be6cf6f7d4a (diff)
loplugin:flatten in writerfilter
Change-Id: Ifaa63738c4e38dddd385821f568911927d834f1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99966 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'writerfilter/source/ooxml')
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.cxx372
-rw-r--r--writerfilter/source/ooxml/OOXMLFastContextHandler.cxx298
-rw-r--r--writerfilter/source/ooxml/OOXMLPropertySet.cxx28
-rw-r--r--writerfilter/source/ooxml/OOXMLStreamImpl.cxx34
4 files changed, 365 insertions, 367 deletions
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index 285028cc9053..db4990cc6497 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -184,38 +184,38 @@ void OOXMLDocumentImpl::importSubStreamRelations(const OOXMLStream::Pointer_t& p
uno::Reference<io::XInputStream> xcpInputStream = cStream->getDocumentStream();
- if (xcpInputStream.is())
+ if (!xcpInputStream.is())
+ return;
+
+ // importing itemprops files for item.xml from customXml.
+ if (OOXMLStream::CUSTOMXMLPROPS == nType)
{
- // importing itemprops files for item.xml from customXml.
- if (OOXMLStream::CUSTOMXMLPROPS == nType)
+ try
{
- try
- {
- uno::Reference<uno::XComponentContext> xcpContext(pStream->getContext());
- uno::Reference<xml::dom::XDocumentBuilder> xDomBuilder(xml::dom::DocumentBuilder::create(xcpContext));
- xRelation = xDomBuilder->parse(xcpInputStream);
- }
- catch (uno::Exception const&)
- {
- TOOLS_WARN_EXCEPTION("writerfilter.ooxml", "importSubStream: exception while "
- "parsing stream " << nType);
- mxCustomXmlProsDom = xRelation;
- }
-
- if(xRelation.is())
- {
- mxCustomXmlProsDom = xRelation;
- }
+ uno::Reference<uno::XComponentContext> xcpContext(pStream->getContext());
+ uno::Reference<xml::dom::XDocumentBuilder> xDomBuilder(xml::dom::DocumentBuilder::create(xcpContext));
+ xRelation = xDomBuilder->parse(xcpInputStream);
}
- else if(OOXMLStream::EMBEDDINGS == nType)
+ catch (uno::Exception const&)
{
- mxEmbeddings = xcpInputStream;
+ TOOLS_WARN_EXCEPTION("writerfilter.ooxml", "importSubStream: exception while "
+ "parsing stream " << nType);
+ mxCustomXmlProsDom = xRelation;
}
- else if(OOXMLStream::CHARTS == nType)
+
+ if(xRelation.is())
{
- importSubStreamRelations(cStream, OOXMLStream::EMBEDDINGS);
+ mxCustomXmlProsDom = xRelation;
}
}
+ else if(OOXMLStream::EMBEDDINGS == nType)
+ {
+ mxEmbeddings = xcpInputStream;
+ }
+ else if(OOXMLStream::CHARTS == nType)
+ {
+ importSubStreamRelations(cStream, OOXMLStream::EMBEDDINGS);
+ }
}
@@ -454,67 +454,67 @@ void OOXMLDocumentImpl::resolve(Stream & rStream)
}
}
- if (xParser.is())
- {
- uno::Reference<uno::XComponentContext> xContext(mpStream->getContext());
+ if (!xParser.is())
+ return;
- OOXMLFastDocumentHandler * pDocHandler =
- new OOXMLFastDocumentHandler(xContext, &rStream, this, mnXNoteId);
- pDocHandler->setIsSubstream( mbIsSubstream );
- uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler(pDocHandler);
- uno::Reference < xml::sax::XFastTokenHandler > xTokenHandler(mpStream->getFastTokenHandler());
+ uno::Reference<uno::XComponentContext> xContext(mpStream->getContext());
- resolveFastSubStream(rStream, OOXMLStream::SETTINGS);
- mxThemeDom = importSubStream(OOXMLStream::THEME);
- resolveFastSubStream(rStream, OOXMLStream::THEME);
- mxGlossaryDocDom = importSubStream(OOXMLStream::GLOSSARY);
- if (mxGlossaryDocDom.is())
- resolveGlossaryStream(rStream);
+ OOXMLFastDocumentHandler * pDocHandler =
+ new OOXMLFastDocumentHandler(xContext, &rStream, this, mnXNoteId);
+ pDocHandler->setIsSubstream( mbIsSubstream );
+ uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler(pDocHandler);
+ uno::Reference < xml::sax::XFastTokenHandler > xTokenHandler(mpStream->getFastTokenHandler());
- resolveEmbeddingsStream(mpStream);
+ resolveFastSubStream(rStream, OOXMLStream::SETTINGS);
+ mxThemeDom = importSubStream(OOXMLStream::THEME);
+ resolveFastSubStream(rStream, OOXMLStream::THEME);
+ mxGlossaryDocDom = importSubStream(OOXMLStream::GLOSSARY);
+ if (mxGlossaryDocDom.is())
+ resolveGlossaryStream(rStream);
- // Custom xml's are handled as part of grab bag.
- resolveCustomXmlStream(rStream);
+ resolveEmbeddingsStream(mpStream);
- resolveFastSubStream(rStream, OOXMLStream::FONTTABLE);
- resolveFastSubStream(rStream, OOXMLStream::STYLES);
- resolveFastSubStream(rStream, OOXMLStream::NUMBERING);
+ // Custom xml's are handled as part of grab bag.
+ resolveCustomXmlStream(rStream);
- xParser->setFastDocumentHandler( xDocumentHandler );
- xParser->setTokenHandler( xTokenHandler );
+ resolveFastSubStream(rStream, OOXMLStream::FONTTABLE);
+ resolveFastSubStream(rStream, OOXMLStream::STYLES);
+ resolveFastSubStream(rStream, OOXMLStream::NUMBERING);
- xml::sax::InputSource aParserInput;
- aParserInput.sSystemId = mpStream->getTarget();
- aParserInput.aInputStream = mpStream->getDocumentStream();
- try
- {
- xParser->parseStream(aParserInput);
- }
- catch (xml::sax::SAXException const& rErr)
- {
- // don't silently swallow these - handlers may not have been executed,
- // and the domain mapper is likely in an inconsistent state
- // In case user chooses to try to continue loading, don't ask again for this file
- SfxObjectShell* rShell = SfxObjectShell::GetShellFromComponent(mxModel);
- if (!rShell || !rShell->IsContinueImportOnFilterExceptions("SAXException: " + rErr.Message))
- throw;
- }
- catch (uno::RuntimeException const&)
- {
+ xParser->setFastDocumentHandler( xDocumentHandler );
+ xParser->setTokenHandler( xTokenHandler );
+
+ xml::sax::InputSource aParserInput;
+ aParserInput.sSystemId = mpStream->getTarget();
+ aParserInput.aInputStream = mpStream->getDocumentStream();
+ try
+ {
+ xParser->parseStream(aParserInput);
+ }
+ catch (xml::sax::SAXException const& rErr)
+ {
+ // don't silently swallow these - handlers may not have been executed,
+ // and the domain mapper is likely in an inconsistent state
+ // In case user chooses to try to continue loading, don't ask again for this file
+ SfxObjectShell* rShell = SfxObjectShell::GetShellFromComponent(mxModel);
+ if (!rShell || !rShell->IsContinueImportOnFilterExceptions("SAXException: " + rErr.Message))
throw;
- }
- // note: cannot throw anything other than SAXException out of here?
- catch (uno::Exception const&)
- {
- css::uno::Any anyEx = cppu::getCaughtException();
- SAL_WARN("writerfilter.ooxml", "OOXMLDocumentImpl::resolve(): " << exceptionToString(anyEx));
- throw lang::WrappedTargetRuntimeException("", nullptr, anyEx);
- }
- catch (...)
- {
- SAL_WARN("writerfilter.ooxml",
- "OOXMLDocumentImpl::resolve(): non-UNO exception");
- }
+ }
+ catch (uno::RuntimeException const&)
+ {
+ throw;
+ }
+ // note: cannot throw anything other than SAXException out of here?
+ catch (uno::Exception const&)
+ {
+ css::uno::Any anyEx = cppu::getCaughtException();
+ SAL_WARN("writerfilter.ooxml", "OOXMLDocumentImpl::resolve(): " << exceptionToString(anyEx));
+ throw lang::WrappedTargetRuntimeException("", nullptr, anyEx);
+ }
+ catch (...)
+ {
+ SAL_WARN("writerfilter.ooxml",
+ "OOXMLDocumentImpl::resolve(): non-UNO exception");
}
}
@@ -537,50 +537,50 @@ void OOXMLDocumentImpl::resolveCustomXmlStream(Stream & rStream)
// Resolving all item[n].xml files from CustomXml folder.
uno::Reference<embed::XRelationshipAccess> xRelationshipAccess;
xRelationshipAccess.set(dynamic_cast<OOXMLStreamImpl&>(*mpStream).accessDocumentStream(), uno::UNO_QUERY);
- if (xRelationshipAccess.is())
+ if (!xRelationshipAccess.is())
+ return;
+
+ static const char sCustomType[] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml";
+ static const char sCustomTypeStrict[] = "http://purl.oclc.org/ooxml/officeDocument/relationships/customXml";
+ bool bFound = false;
+ const uno::Sequence<uno::Sequence< beans::StringPair>> aSeqs = xRelationshipAccess->getAllRelationships();
+ std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomList;
+ std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomPropsList;
+ for (const uno::Sequence<beans::StringPair>& aSeq : aSeqs)
{
- static const char sCustomType[] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml";
- static const char sCustomTypeStrict[] = "http://purl.oclc.org/ooxml/officeDocument/relationships/customXml";
- bool bFound = false;
- const uno::Sequence<uno::Sequence< beans::StringPair>> aSeqs = xRelationshipAccess->getAllRelationships();
- std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomList;
- std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomPropsList;
- for (const uno::Sequence<beans::StringPair>& aSeq : aSeqs)
+ for (const beans::StringPair& aPair : aSeq)
{
- for (const beans::StringPair& aPair : aSeq)
+ // Need to resolve only customxml files from document relationships.
+ // Skipping other files.
+ if (aPair.Second == sCustomType ||
+ aPair.Second == sCustomTypeStrict)
+ bFound = true;
+ else if (aPair.First == "Target" && bFound)
{
- // Need to resolve only customxml files from document relationships.
- // Skipping other files.
- if (aPair.Second == sCustomType ||
- aPair.Second == sCustomTypeStrict)
- bFound = true;
- else if (aPair.First == "Target" && bFound)
- {
- // Adding value to extern variable customTarget. It will be used in ooxmlstreamimpl
- // to ensure customxml target is visited in lcl_getTarget.
- customTarget = aPair.Second;
- }
+ // Adding value to extern variable customTarget. It will be used in ooxmlstreamimpl
+ // to ensure customxml target is visited in lcl_getTarget.
+ customTarget = aPair.Second;
}
+ }
- if (bFound)
+ if (bFound)
+ {
+ uno::Reference<xml::dom::XDocument> customXmlTemp = importSubStream(OOXMLStream::CUSTOMXML);
+ // This will add all item[n].xml with its relationship file i.e itemprops.xml to
+ // grabbag list.
+ if (mxCustomXmlProsDom.is() && customXmlTemp.is())
{
- uno::Reference<xml::dom::XDocument> customXmlTemp = importSubStream(OOXMLStream::CUSTOMXML);
- // This will add all item[n].xml with its relationship file i.e itemprops.xml to
- // grabbag list.
- if (mxCustomXmlProsDom.is() && customXmlTemp.is())
- {
- aCustomXmlDomList.push_back(customXmlTemp);
- aCustomXmlDomPropsList.push_back(mxCustomXmlProsDom);
- resolveFastSubStream(rStream, OOXMLStream::CUSTOMXML);
- }
-
- bFound = false;
+ aCustomXmlDomList.push_back(customXmlTemp);
+ aCustomXmlDomPropsList.push_back(mxCustomXmlProsDom);
+ resolveFastSubStream(rStream, OOXMLStream::CUSTOMXML);
}
- }
- mxCustomXmlDomList = comphelper::containerToSequence(aCustomXmlDomList);
- mxCustomXmlDomPropsList = comphelper::containerToSequence(aCustomXmlDomPropsList);
+ bFound = false;
+ }
}
+
+ mxCustomXmlDomList = comphelper::containerToSequence(aCustomXmlDomList);
+ mxCustomXmlDomPropsList = comphelper::containerToSequence(aCustomXmlDomPropsList);
}
void OOXMLDocumentImpl::resolveGlossaryStream(Stream & /*rStream*/)
@@ -607,90 +607,90 @@ void OOXMLDocumentImpl::resolveGlossaryStream(Stream & /*rStream*/)
}
uno::Reference<embed::XRelationshipAccess> xRelationshipAccess;
xRelationshipAccess.set(dynamic_cast<OOXMLStreamImpl&>(*pStream).accessDocumentStream(), uno::UNO_QUERY);
- if (xRelationshipAccess.is())
- {
-
- const uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs = xRelationshipAccess->getAllRelationships();
- std::vector< uno::Sequence<uno::Any> > aGlossaryDomList;
- for (const uno::Sequence< beans::StringPair >& aSeq : aSeqs)
- {
- OOXMLStream::Pointer_t gStream;
- //Follows following aSeq[0] is Id, aSeq[1] is Type, aSeq[2] is Target
- if (aSeq.getLength() < 3)
- {
- SAL_WARN("writerfilter.ooxml", "too short sequence");
- continue;
- }
+ if (!xRelationshipAccess.is())
+ return;
- OUString gId(aSeq[0].Second);
- OUString gType(aSeq[1].Second);
- OUString gTarget(aSeq[2].Second);
- OUString contentType;
- OOXMLStream::StreamType_t nType(OOXMLStream::UNKNOWN);
- bool bFound = true;
- if(gType == sSettingsType ||
- gType == sSettingsTypeStrict)
- {
- nType = OOXMLStream::SETTINGS;
- contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml";
- }
- else if(gType == sStylesType ||
- gType == sStylesTypeStrict)
- {
- nType = OOXMLStream::STYLES;
- contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";
- }
- else if(gType == sWebSettings ||
- gType == sWebSettingsStrict)
- {
- nType = OOXMLStream::WEBSETTINGS;
- contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml";
- }
- else if(gType == sFonttableType ||
- gType == sFonttableTypeStrict)
+ const uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs = xRelationshipAccess->getAllRelationships();
+ std::vector< uno::Sequence<uno::Any> > aGlossaryDomList;
+ for (const uno::Sequence< beans::StringPair >& aSeq : aSeqs)
+ {
+ OOXMLStream::Pointer_t gStream;
+ //Follows following aSeq[0] is Id, aSeq[1] is Type, aSeq[2] is Target
+ if (aSeq.getLength() < 3)
+ {
+ SAL_WARN("writerfilter.ooxml", "too short sequence");
+ continue;
+ }
+
+ OUString gId(aSeq[0].Second);
+ OUString gType(aSeq[1].Second);
+ OUString gTarget(aSeq[2].Second);
+ OUString contentType;
+
+ OOXMLStream::StreamType_t nType(OOXMLStream::UNKNOWN);
+ bool bFound = true;
+ if(gType == sSettingsType ||
+ gType == sSettingsTypeStrict)
+ {
+ nType = OOXMLStream::SETTINGS;
+ contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml";
+ }
+ else if(gType == sStylesType ||
+ gType == sStylesTypeStrict)
+ {
+ nType = OOXMLStream::STYLES;
+ contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";
+ }
+ else if(gType == sWebSettings ||
+ gType == sWebSettingsStrict)
+ {
+ nType = OOXMLStream::WEBSETTINGS;
+ contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml";
+ }
+ else if(gType == sFonttableType ||
+ gType == sFonttableTypeStrict)
+ {
+ nType = OOXMLStream::FONTTABLE;
+ contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml";
+ }
+ else
+ {
+ bFound = false;
+ //"Unhandled content-type while grab bagging Glossary Folder");
+ }
+
+ if (bFound)
+ {
+ uno::Reference<xml::dom::XDocument> xDom;
+ try
{
- nType = OOXMLStream::FONTTABLE;
- contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml";
+ gStream = OOXMLDocumentFactory::createStream(pStream, nType);
+ uno::Reference<io::XInputStream> xInputStream = gStream->getDocumentStream();
+ uno::Reference<uno::XComponentContext> xContext(pStream->getContext());
+ uno::Reference<xml::dom::XDocumentBuilder> xDomBuilder(xml::dom::DocumentBuilder::create(xContext));
+ xDom = xDomBuilder->parse(xInputStream);
}
- else
+ catch (uno::Exception const&)
{
- bFound = false;
- //"Unhandled content-type while grab bagging Glossary Folder");
+ TOOLS_INFO_EXCEPTION("writerfilter.ooxml", "importSubStream: exception while "
+ "parsing stream of Type" << nType);
+ return;
}
- if (bFound)
+ if (xDom.is())
{
- uno::Reference<xml::dom::XDocument> xDom;
- try
- {
- gStream = OOXMLDocumentFactory::createStream(pStream, nType);
- uno::Reference<io::XInputStream> xInputStream = gStream->getDocumentStream();
- uno::Reference<uno::XComponentContext> xContext(pStream->getContext());
- uno::Reference<xml::dom::XDocumentBuilder> xDomBuilder(xml::dom::DocumentBuilder::create(xContext));
- xDom = xDomBuilder->parse(xInputStream);
- }
- catch (uno::Exception const&)
- {
- TOOLS_INFO_EXCEPTION("writerfilter.ooxml", "importSubStream: exception while "
- "parsing stream of Type" << nType);
- return;
- }
-
- if (xDom.is())
- {
- uno::Sequence< uno::Any > glossaryTuple (5);
- glossaryTuple[0] <<= xDom;
- glossaryTuple[1] <<= gId;
- glossaryTuple[2] <<= gType;
- glossaryTuple[3] <<= gTarget;
- glossaryTuple[4] <<= contentType;
- aGlossaryDomList.push_back(glossaryTuple);
- }
+ uno::Sequence< uno::Any > glossaryTuple (5);
+ glossaryTuple[0] <<= xDom;
+ glossaryTuple[1] <<= gId;
+ glossaryTuple[2] <<= gType;
+ glossaryTuple[3] <<= gTarget;
+ glossaryTuple[4] <<= contentType;
+ aGlossaryDomList.push_back(glossaryTuple);
}
- }
- mxGlossaryDomList = comphelper::containerToSequence(aGlossaryDomList);
+ }
}
+ mxGlossaryDomList = comphelper::containerToSequence(aGlossaryDomList);
}
void OOXMLDocumentImpl::resolveEmbeddingsStream(const OOXMLStream::Pointer_t& pStream)
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 4cdcecb49b12..d4ba7779b0b0 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -333,20 +333,20 @@ Token_t OOXMLFastContextHandler::getToken() const
void OOXMLFastContextHandler::sendTableDepth() const
{
- if (mnTableDepth > 0)
- {
- OOXMLPropertySet::Pointer_t pProps(new OOXMLPropertySet);
- {
- OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(mnTableDepth);
- pProps->add(NS_ooxml::LN_tblDepth, pVal, OOXMLProperty::SPRM);
- }
- {
- OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(1);
- pProps->add(NS_ooxml::LN_inTbl, pVal, OOXMLProperty::SPRM);
- }
+ if (mnTableDepth <= 0)
+ return;
- mpStream->props(pProps.get());
+ OOXMLPropertySet::Pointer_t pProps(new OOXMLPropertySet);
+ {
+ OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(mnTableDepth);
+ pProps->add(NS_ooxml::LN_tblDepth, pVal, OOXMLProperty::SPRM);
}
+ {
+ OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(1);
+ pProps->add(NS_ooxml::LN_inTbl, pVal, OOXMLProperty::SPRM);
+ }
+
+ mpStream->props(pProps.get());
}
void OOXMLFastContextHandler::setHandle()
@@ -357,25 +357,25 @@ void OOXMLFastContextHandler::setHandle()
void OOXMLFastContextHandler::startCharacterGroup()
{
- if (isForwardEvents())
- {
- if (mpParserState->isInCharacterGroup())
- endCharacterGroup();
+ if (!isForwardEvents())
+ return;
- if (! mpParserState->isInParagraphGroup())
- startParagraphGroup();
+ if (mpParserState->isInCharacterGroup())
+ endCharacterGroup();
- if (! mpParserState->isInCharacterGroup())
- {
- mpStream->startCharacterGroup();
- mpParserState->setInCharacterGroup(true);
- mpParserState->resolveCharacterProperties(*mpStream);
- }
+ if (! mpParserState->isInParagraphGroup())
+ startParagraphGroup();
- // tdf#108714 : if we have a postponed break information,
- // then apply it now, before any other paragraph content.
- mpParserState->resolvePostponedBreak(*mpStream);
+ if (! mpParserState->isInCharacterGroup())
+ {
+ mpStream->startCharacterGroup();
+ mpParserState->setInCharacterGroup(true);
+ mpParserState->resolveCharacterProperties(*mpStream);
}
+
+ // tdf#108714 : if we have a postponed break information,
+ // then apply it now, before any other paragraph content.
+ mpParserState->resolvePostponedBreak(*mpStream);
}
void OOXMLFastContextHandler::endCharacterGroup()
@@ -393,19 +393,19 @@ void OOXMLFastContextHandler::popBiDiEmbedLevel() {}
void OOXMLFastContextHandler::startParagraphGroup()
{
- if (isForwardEvents())
- {
- if (mpParserState->isInParagraphGroup())
- endParagraphGroup();
+ if (!isForwardEvents())
+ return;
- if (! mpParserState->isInSectionGroup())
- startSectionGroup();
+ if (mpParserState->isInParagraphGroup())
+ endParagraphGroup();
- if (! mpParserState->isInParagraphGroup())
- {
- mpStream->startParagraphGroup();
- mpParserState->setInParagraphGroup(true);
- }
+ if (! mpParserState->isInSectionGroup())
+ startSectionGroup();
+
+ if (! mpParserState->isInParagraphGroup())
+ {
+ mpStream->startParagraphGroup();
+ mpParserState->setInParagraphGroup(true);
}
}
@@ -650,21 +650,21 @@ OUString TrimXMLWhitespace(const OUString & sText)
void OOXMLFastContextHandler::text(const OUString & sText)
{
- if (isForwardEvents())
+ if (!isForwardEvents())
+ return;
+
+ // tdf#108806: CRLFs in XML were converted to \n before this point.
+ // These must be converted to spaces before further processing.
+ OUString sNormalizedText = sText.replaceAll("\n", " ");
+ // tdf#108995: by default, leading and trailing white space is ignored;
+ // tabs are converted to spaces
+ if (!IsPreserveSpace())
{
- // tdf#108806: CRLFs in XML were converted to \n before this point.
- // These must be converted to spaces before further processing.
- OUString sNormalizedText = sText.replaceAll("\n", " ");
- // tdf#108995: by default, leading and trailing white space is ignored;
- // tabs are converted to spaces
- if (!IsPreserveSpace())
- {
- sNormalizedText = TrimXMLWhitespace(sNormalizedText).replaceAll("\t", " ");
- }
- mpStream->utext(reinterpret_cast < const sal_uInt8 * >
- (sNormalizedText.getStr()),
- sNormalizedText.getLength());
+ sNormalizedText = TrimXMLWhitespace(sNormalizedText).replaceAll("\t", " ");
}
+ mpStream->utext(reinterpret_cast < const sal_uInt8 * >
+ (sNormalizedText.getStr()),
+ sNormalizedText.getLength());
}
void OOXMLFastContextHandler::positionOffset(const OUString& rText)
@@ -886,23 +886,23 @@ void OOXMLFastContextHandler::sendPropertyToParent()
void OOXMLFastContextHandler::sendPropertiesToParent()
{
- if (mpParent != nullptr)
- {
- OOXMLPropertySet::Pointer_t pParentProps(mpParent->getPropertySet());
+ if (mpParent == nullptr)
+ return;
- if (pParentProps)
- {
- OOXMLPropertySet::Pointer_t pProps(getPropertySet());
+ OOXMLPropertySet::Pointer_t pParentProps(mpParent->getPropertySet());
- if (pProps)
- {
- OOXMLValue::Pointer_t pValue
- (new OOXMLPropertySetValue(getPropertySet()));
+ if (!pParentProps)
+ return;
- pParentProps->add(getId(), pValue, OOXMLProperty::SPRM);
+ OOXMLPropertySet::Pointer_t pProps(getPropertySet());
+
+ if (pProps)
+ {
+ OOXMLValue::Pointer_t pValue
+ (new OOXMLPropertySetValue(getPropertySet()));
+
+ pParentProps->add(getId(), pValue, OOXMLProperty::SPRM);
- }
- }
}
}
@@ -1393,28 +1393,28 @@ void OOXMLFastContextHandlerTextTableCell::startCell()
void OOXMLFastContextHandlerTextTableCell::endCell()
{
- if (isForwardEvents())
- {
- OOXMLPropertySet::Pointer_t pProps(new OOXMLPropertySet);
- {
- OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(mnTableDepth);
- pProps->add(NS_ooxml::LN_tblDepth, pVal, OOXMLProperty::SPRM);
- }
- {
- OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(1);
- pProps->add(NS_ooxml::LN_inTbl, pVal, OOXMLProperty::SPRM);
- }
- {
- OOXMLValue::Pointer_t pVal = OOXMLBooleanValue::Create(mnTableDepth > 0);
- pProps->add(NS_ooxml::LN_tblCell, pVal, OOXMLProperty::SPRM);
- }
- {
- OOXMLValue::Pointer_t pVal = OOXMLBooleanValue::Create(mnTableDepth > 0);
- pProps->add(NS_ooxml::LN_tcEnd, pVal, OOXMLProperty::SPRM);
- }
+ if (!isForwardEvents())
+ return;
- mpStream->props(pProps.get());
+ OOXMLPropertySet::Pointer_t pProps(new OOXMLPropertySet);
+ {
+ OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(mnTableDepth);
+ pProps->add(NS_ooxml::LN_tblDepth, pVal, OOXMLProperty::SPRM);
+ }
+ {
+ OOXMLValue::Pointer_t pVal = OOXMLIntegerValue::Create(1);
+ pProps->add(NS_ooxml::LN_inTbl, pVal, OOXMLProperty::SPRM);
+ }
+ {
+ OOXMLValue::Pointer_t pVal = OOXMLBooleanValue::Create(mnTableDepth > 0);
+ pProps->add(NS_ooxml::LN_tblCell, pVal, OOXMLProperty::SPRM);
}
+ {
+ OOXMLValue::Pointer_t pVal = OOXMLBooleanValue::Create(mnTableDepth > 0);
+ pProps->add(NS_ooxml::LN_tcEnd, pVal, OOXMLProperty::SPRM);
+ }
+
+ mpStream->props(pProps.get());
}
/*
@@ -1678,59 +1678,57 @@ void OOXMLFastContextHandlerShape::setToken(Token_t nToken)
void OOXMLFastContextHandlerShape::sendShape( Token_t Element )
{
- if ( mrShapeContext.is() && !m_bShapeSent )
- {
- awt::Point aPosition = mpStream->getPositionOffset();
- mrShapeContext->setPosition(aPosition);
- uno::Reference<drawing::XShape> xShape(mrShapeContext->getShape());
- m_bShapeSent = true;
- if (xShape.is())
- {
- OOXMLValue::Pointer_t
- pValue(new OOXMLShapeValue(xShape));
- newProperty(NS_ooxml::LN_shape, pValue);
+ if ( !(mrShapeContext.is() && !m_bShapeSent) )
+ return;
- bool bIsPicture = Element == ( NMSP_dmlPicture | XML_pic );
+ awt::Point aPosition = mpStream->getPositionOffset();
+ mrShapeContext->setPosition(aPosition);
+ uno::Reference<drawing::XShape> xShape(mrShapeContext->getShape());
+ m_bShapeSent = true;
+ if (!xShape.is())
+ return;
- //tdf#87569: Fix table layout with correcting anchoring
- //If anchored object is in table, Word calculates its position from cell border
- //instead of page (what is set in the sample document)
- uno::Reference<beans::XPropertySet> xShapePropSet(xShape, uno::UNO_QUERY);
- if (mnTableDepth > 0 && xShapePropSet.is() && mbIsVMLfound) //if we had a table
- {
- xShapePropSet->setPropertyValue(dmapper::getPropertyName(dmapper::PROP_FOLLOW_TEXT_FLOW),
- uno::makeAny(mbAllowInCell));
- }
- // Notify the dmapper that the shape is ready to use
- if ( !bIsPicture )
- {
- mpStream->startShape( xShape );
- m_bShapeStarted = true;
- }
- }
+ OOXMLValue::Pointer_t
+ pValue(new OOXMLShapeValue(xShape));
+ newProperty(NS_ooxml::LN_shape, pValue);
+
+ bool bIsPicture = Element == ( NMSP_dmlPicture | XML_pic );
+
+ //tdf#87569: Fix table layout with correcting anchoring
+ //If anchored object is in table, Word calculates its position from cell border
+ //instead of page (what is set in the sample document)
+ uno::Reference<beans::XPropertySet> xShapePropSet(xShape, uno::UNO_QUERY);
+ if (mnTableDepth > 0 && xShapePropSet.is() && mbIsVMLfound) //if we had a table
+ {
+ xShapePropSet->setPropertyValue(dmapper::getPropertyName(dmapper::PROP_FOLLOW_TEXT_FLOW),
+ uno::makeAny(mbAllowInCell));
+ }
+ // Notify the dmapper that the shape is ready to use
+ if ( !bIsPicture )
+ {
+ mpStream->startShape( xShape );
+ m_bShapeStarted = true;
}
}
void OOXMLFastContextHandlerShape::lcl_endFastElement
(Token_t Element)
{
- if (isForwardEvents())
- {
-
- if (mrShapeContext.is())
- {
- mrShapeContext->endFastElement(Element);
- sendShape( Element );
- }
+ if (!isForwardEvents())
+ return;
- OOXMLFastContextHandlerProperties::lcl_endFastElement(Element);
+ if (mrShapeContext.is())
+ {
+ mrShapeContext->endFastElement(Element);
+ sendShape( Element );
+ }
- // Ending the shape should be the last thing to do
- bool bIsPicture = Element == ( NMSP_dmlPicture | XML_pic );
- if ( !bIsPicture && m_bShapeStarted)
- mpStream->endShape( );
+ OOXMLFastContextHandlerProperties::lcl_endFastElement(Element);
- }
+ // Ending the shape should be the last thing to do
+ bool bIsPicture = Element == ( NMSP_dmlPicture | XML_pic );
+ if ( !bIsPicture && m_bShapeStarted)
+ mpStream->endShape( );
}
void SAL_CALL OOXMLFastContextHandlerShape::endUnknownElement
@@ -2159,34 +2157,34 @@ void OOXMLFastContextHandlerMath::process()
// to RTLD_GLOBAL, so most probably a gcc bug.
oox::FormulaImportBase& import = dynamic_cast<oox::FormulaImportBase&>(dynamic_cast<SfxBaseModel&>(*component));
import.readFormulaOoxml(buffer);
- if (isForwardEvents())
+ if (!isForwardEvents())
+ return;
+
+ OOXMLPropertySet::Pointer_t pProps(new OOXMLPropertySet);
+ OOXMLValue::Pointer_t pVal( new OOXMLStarMathValue( ref ));
+ if (mbIsMathPara)
{
- OOXMLPropertySet::Pointer_t pProps(new OOXMLPropertySet);
- OOXMLValue::Pointer_t pVal( new OOXMLStarMathValue( ref ));
- if (mbIsMathPara)
+ switch (mnMathJcVal)
{
- switch (mnMathJcVal)
- {
- case eMathParaJc::CENTER:
- pProps->add(NS_ooxml::LN_Value_math_ST_Jc_centerGroup, pVal,
- OOXMLProperty::ATTRIBUTE);
- break;
- case eMathParaJc::LEFT:
- pProps->add(NS_ooxml::LN_Value_math_ST_Jc_left, pVal,
- OOXMLProperty::ATTRIBUTE);
- break;
- case eMathParaJc::RIGHT:
- pProps->add(NS_ooxml::LN_Value_math_ST_Jc_right, pVal,
- OOXMLProperty::ATTRIBUTE);
- break;
- default:
- break;
- }
+ case eMathParaJc::CENTER:
+ pProps->add(NS_ooxml::LN_Value_math_ST_Jc_centerGroup, pVal,
+ OOXMLProperty::ATTRIBUTE);
+ break;
+ case eMathParaJc::LEFT:
+ pProps->add(NS_ooxml::LN_Value_math_ST_Jc_left, pVal,
+ OOXMLProperty::ATTRIBUTE);
+ break;
+ case eMathParaJc::RIGHT:
+ pProps->add(NS_ooxml::LN_Value_math_ST_Jc_right, pVal,
+ OOXMLProperty::ATTRIBUTE);
+ break;
+ default:
+ break;
}
- else
- pProps->add(NS_ooxml::LN_starmath, pVal, OOXMLProperty::ATTRIBUTE);
- mpStream->props( pProps.get() );
}
+ else
+ pProps->add(NS_ooxml::LN_starmath, pVal, OOXMLProperty::ATTRIBUTE);
+ mpStream->props( pProps.get() );
}
}
diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.cxx b/writerfilter/source/ooxml/OOXMLPropertySet.cxx
index f413ced61d41..1d1724c9c451 100644
--- a/writerfilter/source/ooxml/OOXMLPropertySet.cxx
+++ b/writerfilter/source/ooxml/OOXMLPropertySet.cxx
@@ -575,23 +575,23 @@ string OOXMLHexValue::toString() const
OOXMLHexColorValue::OOXMLHexColorValue(const char * pValue)
: OOXMLHexValue(sal_uInt32(COL_AUTO))
{
- if (strcmp(pValue, "auto"))
- {
- mnValue = rtl_str_toUInt32(pValue, 16);
+ if (!strcmp(pValue, "auto"))
+ return;
+
+ mnValue = rtl_str_toUInt32(pValue, 16);
- // Convert hash-encoded values (like #FF0080)
- const sal_Int32 nLen = strlen(pValue);
- if ( !mnValue && nLen > 1 && pValue[0] == '#' )
+ // Convert hash-encoded values (like #FF0080)
+ const sal_Int32 nLen = strlen(pValue);
+ if ( !mnValue && nLen > 1 && pValue[0] == '#' )
+ {
+ sal_Int32 nColor(COL_AUTO);
+ // Word appears to require strict 6 digit length, else it ignores it
+ if ( nLen == 7 )
{
- sal_Int32 nColor(COL_AUTO);
- // Word appears to require strict 6 digit length, else it ignores it
- if ( nLen == 7 )
- {
- const OUString sHashColor(pValue, nLen, RTL_TEXTENCODING_ASCII_US);
- sax::Converter::convertColor( nColor, sHashColor );
- }
- mnValue = nColor;
+ const OUString sHashColor(pValue, nLen, RTL_TEXTENCODING_ASCII_US);
+ sax::Converter::convertColor( nColor, sHashColor );
}
+ mnValue = nColor;
}
}
diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
index 73e527a5543e..7d48f1c08fce 100644
--- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx
@@ -348,25 +348,25 @@ void OOXMLStreamImpl::init()
bool bFound = lcl_getTarget(mxRelationshipAccess,
mnStreamType, msId, msTarget);
- if (bFound)
- {
- sal_Int32 nLastIndex = msTarget.lastIndexOf('/');
- if (nLastIndex >= 0)
- msPath = msTarget.copy(0, nLastIndex + 1);
+ if (!bFound)
+ return;
- uno::Reference<embed::XHierarchicalStorageAccess>
- xHierarchicalStorageAccess(mxStorage, uno::UNO_QUERY);
+ sal_Int32 nLastIndex = msTarget.lastIndexOf('/');
+ if (nLastIndex >= 0)
+ msPath = msTarget.copy(0, nLastIndex + 1);
- if (xHierarchicalStorageAccess.is())
- {
- uno::Any aAny(xHierarchicalStorageAccess->
- openStreamElementByHierarchicalName
- (msTarget, embed::ElementModes::SEEKABLEREAD));
- aAny >>= mxDocumentStream;
- // Non-cached ID lookup works by accessing mxDocumentStream as an embed::XRelationshipAccess.
- // So when it changes, we should empty the cache.
- maIdCache.clear();
- }
+ uno::Reference<embed::XHierarchicalStorageAccess>
+ xHierarchicalStorageAccess(mxStorage, uno::UNO_QUERY);
+
+ if (xHierarchicalStorageAccess.is())
+ {
+ uno::Any aAny(xHierarchicalStorageAccess->
+ openStreamElementByHierarchicalName
+ (msTarget, embed::ElementModes::SEEKABLEREAD));
+ aAny >>= mxDocumentStream;
+ // Non-cached ID lookup works by accessing mxDocumentStream as an embed::XRelationshipAccess.
+ // So when it changes, we should empty the cache.
+ maIdCache.clear();
}
}