summaryrefslogtreecommitdiff
path: root/xmlsecurity/source/helper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-07-20 18:27:48 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-07-21 08:51:13 +0200
commit3c6b2b734a00f4844e0bfd5707d14fd4a3d279b0 (patch)
tree40f521e74e3091e2c1115d0961a0308e509bab8c /xmlsecurity/source/helper
parent3284309f19bc76f1778988c5314a795a95620e71 (diff)
loplugin:referencecasting in xmlsecurity
Change-Id: Ic3daba9e6e94516ea4d80f25f73e9e46a50edb5c Reviewed-on: https://gerrit.libreoffice.org/76035 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlsecurity/source/helper')
-rw-r--r--xmlsecurity/source/helper/documentsignaturehelper.cxx23
-rw-r--r--xmlsecurity/source/helper/documentsignaturemanager.cxx14
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper.cxx15
-rw-r--r--xmlsecurity/source/helper/xmlsignaturehelper2.cxx3
4 files changed, 19 insertions, 36 deletions
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx
index 37faa606c32f..6e173afdebff 100644
--- a/xmlsecurity/source/helper/documentsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx
@@ -86,8 +86,7 @@ static void ImplFillElementList(
const OUString& rRootStorageName, const bool bRecursive,
const DocumentSignatureAlgorithm mode)
{
- Reference < css::container::XNameAccess > xElements( rxStore, UNO_QUERY );
- Sequence< OUString > aElements = xElements->getElementNames();
+ Sequence< OUString > aElements = rxStore->getElementNames();
for ( const auto& rName : aElements )
{
@@ -214,8 +213,7 @@ DocumentSignatureHelper::CreateElementList(
xSubStore.clear();
// Object folders...
- Reference < css::container::XNameAccess > xElements( rxStore, UNO_QUERY );
- Sequence< OUString > aElementNames = xElements->getElementNames();
+ Sequence< OUString > aElementNames = rxStore->getElementNames();
for ( const auto& rName : aElementNames )
{
if ( ( rName.match( "Object " ) ) && rxStore->isStorageElement( rName ) )
@@ -288,8 +286,7 @@ DocumentSignatureHelper::CreateElementList(
void DocumentSignatureHelper::AppendContentTypes(const uno::Reference<embed::XStorage>& xStorage, std::vector<OUString>& rElements)
{
- uno::Reference<container::XNameAccess> xNameAccess(xStorage, uno::UNO_QUERY);
- if (!xNameAccess.is() || !xNameAccess->hasByName("[Content_Types].xml"))
+ if (!xStorage.is() || !xStorage->hasByName("[Content_Types].xml"))
// ODF
return;
@@ -341,11 +338,10 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream(
SignatureStreamHelper aHelper;
- uno::Reference<container::XNameAccess> xNameAccess(rxStore, uno::UNO_QUERY);
- if (!xNameAccess.is())
+ if (!rxStore.is())
return aHelper;
- if (xNameAccess->hasByName("META-INF"))
+ if (rxStore->hasByName("META-INF"))
{
try
{
@@ -369,11 +365,11 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream(
SAL_WARN_IF( nOpenMode != css::embed::ElementModes::READ, "xmlsecurity.helper", "Error creating signature stream..." );
}
}
- else if(xNameAccess->hasByName("[Content_Types].xml"))
+ else if(rxStore->hasByName("[Content_Types].xml"))
{
try
{
- if (xNameAccess->hasByName("_xmlsignatures") && (nOpenMode & embed::ElementModes::TRUNCATE))
+ if (rxStore->hasByName("_xmlsignatures") && (nOpenMode & embed::ElementModes::TRUNCATE))
// Truncate, then all signatures will be written -> remove previous ones.
rxStore->removeElement("_xmlsignatures");
@@ -394,11 +390,10 @@ bool DocumentSignatureHelper::CanSignWithGPG(
const Reference < css::embed::XStorage >& rxStore,
const OUString& sOdfVersion)
{
- uno::Reference<container::XNameAccess> xNameAccess(rxStore, uno::UNO_QUERY);
- if (!xNameAccess.is())
+ if (!rxStore.is())
return false;
- if (xNameAccess->hasByName("META-INF")) // ODF
+ if (rxStore->hasByName("META-INF")) // ODF
{
return !isODFPre_1_2(sOdfVersion);
}
diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx
index 37f1baf10921..557557f6bae8 100644
--- a/xmlsecurity/source/helper/documentsignaturemanager.cxx
+++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx
@@ -145,11 +145,7 @@ bool DocumentSignatureManager::readManifest()
uno::Reference<packages::manifest::XManifestReader> xReader
= packages::manifest::ManifestReader::create(mxContext);
- uno::Reference<container::XNameAccess> xNameAccess(mxStore, uno::UNO_QUERY);
- if (!xNameAccess.is())
- return false;
-
- if (xNameAccess->hasByName("META-INF"))
+ if (mxStore->hasByName("META-INF"))
{
//Get the manifest.xml
uno::Reference<embed::XStorage> xSubStore(
@@ -231,12 +227,8 @@ SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int3
bool bTempStream)
{
SignatureStreamHelper aHelper;
- if (mxStore.is())
- {
- uno::Reference<container::XNameAccess> xNameAccess(mxStore, uno::UNO_QUERY);
- if (xNameAccess.is() && xNameAccess->hasByName("[Content_Types].xml"))
- aHelper.nStorageFormat = embed::StorageFormats::OFOPXML;
- }
+ if (mxStore.is() && mxStore->hasByName("[Content_Types].xml"))
+ aHelper.nStorageFormat = embed::StorageFormats::OFOPXML;
if (bTempStream)
{
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
index 0bc850b9af4f..6ec834053a17 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx
@@ -230,8 +230,7 @@ void XMLSignatureHelper::ExportOOXMLSignature(const uno::Reference<embed::XStora
xSaxWriter->setOutputStream(xOutputStream);
xSaxWriter->startDocument();
- uno::Reference<xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter, uno::UNO_QUERY);
- mpXSecController->exportOOXMLSignature(xRootStorage, xDocumentHandler, rInformation);
+ mpXSecController->exportOOXMLSignature(xRootStorage, xSaxWriter, rInformation);
xSaxWriter->endDocument();
}
@@ -318,8 +317,7 @@ bool lcl_isSignatureOriginType(const beans::StringPair& rPair)
bool XMLSignatureHelper::ReadAndVerifySignatureStorage(const uno::Reference<embed::XStorage>& xStorage, bool bCacheLastSignature)
{
sal_Int32 nOpenMode = embed::ElementModes::READ;
- uno::Reference<container::XNameAccess> xNameAccess(xStorage, uno::UNO_QUERY);
- if (xNameAccess.is() && !xNameAccess->hasByName("_rels"))
+ if (xStorage.is() && !xStorage->hasByName("_rels"))
{
SAL_WARN("xmlsecurity.helper", "expected stream, in signature storage but not found: _rels");
return false;
@@ -338,7 +336,7 @@ bool XMLSignatureHelper::ReadAndVerifySignatureStorage(const uno::Reference<embe
std::vector<beans::StringPair>::iterator it = std::find_if(aRelation.begin(), aRelation.end(), [](const beans::StringPair& rPair) { return rPair.First == "Target"; });
if (it != aRelation.end())
{
- if (xNameAccess.is() && !xNameAccess->hasByName(it->Second))
+ if (xStorage.is() && !xStorage->hasByName(it->Second))
{
SAL_WARN("xmlsecurity.helper", "expected stream, but not found: " << it->Second);
continue;
@@ -477,7 +475,7 @@ void XMLSignatureHelper::ExportSignatureRelations(const css::uno::Reference<css:
xOriginStream->closeOutput();
// Write the relations.
- uno::Reference<embed::XStorage> xSubStorage(xStorage->openStorageElement("_rels", nOpenMode), uno::UNO_QUERY);
+ uno::Reference<embed::XStorage> xSubStorage = xStorage->openStorageElement("_rels", nOpenMode);
uno::Reference<io::XOutputStream> xRelStream(xSubStorage->openStreamElement("origin.sigs.rels", nOpenMode), uno::UNO_QUERY);
std::vector< uno::Sequence<beans::StringPair> > aRelations;
for (int i = 0; i < nSignatureCount; ++i)
@@ -495,7 +493,7 @@ void XMLSignatureHelper::ExportSignatureRelations(const css::uno::Reference<css:
void XMLSignatureHelper::ExportSignatureContentTypes(const css::uno::Reference<css::embed::XStorage>& xStorage, int nSignatureCount)
{
- uno::Reference<io::XStream> xStream(xStorage->openStreamElement("[Content_Types].xml", embed::ElementModes::READWRITE), uno::UNO_QUERY);
+ uno::Reference<io::XStream> xStream = xStorage->openStreamElement("[Content_Types].xml", embed::ElementModes::READWRITE);
uno::Reference<io::XInputStream> xInputStream = xStream->getInputStream();
uno::Sequence< uno::Sequence<beans::StringPair> > aContentTypeInfo = comphelper::OFOPXMLHelper::ReadContentTypeSequence(xInputStream, mxCtx);
if (aContentTypeInfo.getLength() < 2)
@@ -542,8 +540,7 @@ void XMLSignatureHelper::CreateAndWriteOOXMLSignature(const uno::Reference<embed
xSaxWriter->startDocument();
mbError = false;
- uno::Reference<xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter, uno::UNO_QUERY);
- if (!mpXSecController->WriteOOXMLSignature(xRootStorage, xDocumentHandler))
+ if (!mpXSecController->WriteOOXMLSignature(xRootStorage, xSaxWriter))
mbError = true;
xSaxWriter->endDocument();
diff --git a/xmlsecurity/source/helper/xmlsignaturehelper2.cxx b/xmlsecurity/source/helper/xmlsignaturehelper2.cxx
index 3e5d01b44861..f733f3a6a4c1 100644
--- a/xmlsecurity/source/helper/xmlsignaturehelper2.cxx
+++ b/xmlsecurity/source/helper/xmlsignaturehelper2.cxx
@@ -88,8 +88,7 @@ uno::Reference < io::XInputStream > UriBindingHelper::OpenInputStream( const uno
throw uno::Exception("Could not decode URI for stream element.", nullptr);
uno::Reference< io::XStream > xStream;
- uno::Reference<container::XNameAccess> xNameAccess(rxStore, uno::UNO_QUERY);
- if (!xNameAccess->hasByName(sName))
+ if (!rxStore->hasByName(sName))
SAL_WARN("xmlsecurity.helper", "expected stream, but not found: " << sName);
else
xStream = rxStore->cloneStreamElement( sName );