[Libreoffice-commits] core.git: 4 commits - filter/source include/comphelper include/sfx2 sfx2/source xmlsecurity/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Jan 12 03:36:59 PST 2016
filter/source/config/cache/constant.hxx | 1
filter/source/config/cache/filtercache.cxx | 6 +
filter/source/config/fragments/filters/MS_Word_2007_XML.xcu | 2
include/comphelper/documentconstants.hxx | 3
include/sfx2/docfilt.hxx | 2
sfx2/source/doc/objserv.cxx | 5 -
xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 21 +++--
xmlsecurity/source/helper/documentsignaturehelper.cxx | 44 +++++++-----
8 files changed, 55 insertions(+), 29 deletions(-)
New commits:
commit 6861a8eefdbbfbc89a87011a7028ddbc7a393925
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 12 12:09:35 2016 +0100
xmlsecurity: handle no META-INF in DocumentSignatureHelper
Change-Id: I7e0ac2d43e97fe9cb67a58c8dd8d83c1068f501d
diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx
index 08a4f0b..fd916c6 100644
--- a/xmlsecurity/source/helper/documentsignaturehelper.cxx
+++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx
@@ -32,6 +32,7 @@
#include <osl/diagnose.h>
#include <rtl/uri.hxx>
+using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
namespace
@@ -300,27 +301,34 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream(
SignatureStreamHelper aHelper;
- try
+ uno::Reference<container::XNameAccess> xNameAccess(rxStore, uno::UNO_QUERY);
+ if (!xNameAccess.is())
+ return aHelper;
+
+ if (xNameAccess->hasByName("META-INF"))
{
- OUString aSIGStoreName( "META-INF" );
- aHelper.xSignatureStorage = rxStore->openStorageElement( aSIGStoreName, nSubStorageOpenMode );
- if ( aHelper.xSignatureStorage.is() )
+ try
{
- OUString aSIGStreamName;
- if ( eDocSigMode == SignatureModeDocumentContent )
- aSIGStreamName = DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName();
- else if ( eDocSigMode == SignatureModeMacros )
- aSIGStreamName = DocumentSignatureHelper::GetScriptingContentSignatureDefaultStreamName();
- else
- aSIGStreamName = DocumentSignatureHelper::GetPackageSignatureDefaultStreamName();
-
- aHelper.xSignatureStream = aHelper.xSignatureStorage->openStreamElement( aSIGStreamName, nOpenMode );
+ OUString aSIGStoreName( "META-INF" );
+ aHelper.xSignatureStorage = rxStore->openStorageElement( aSIGStoreName, nSubStorageOpenMode );
+ if ( aHelper.xSignatureStorage.is() )
+ {
+ OUString aSIGStreamName;
+ if ( eDocSigMode == SignatureModeDocumentContent )
+ aSIGStreamName = DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName();
+ else if ( eDocSigMode == SignatureModeMacros )
+ aSIGStreamName = DocumentSignatureHelper::GetScriptingContentSignatureDefaultStreamName();
+ else
+ aSIGStreamName = DocumentSignatureHelper::GetPackageSignatureDefaultStreamName();
+
+ aHelper.xSignatureStream = aHelper.xSignatureStorage->openStreamElement( aSIGStreamName, nOpenMode );
+ }
+ }
+ catch(css::io::IOException& )
+ {
+ // Doesn't have to exist...
+ DBG_ASSERT( nOpenMode == css::embed::ElementModes::READ, "Error creating signature stream..." );
}
- }
- catch(css::io::IOException& )
- {
- // Doesn't have to exist...
- DBG_ASSERT( nOpenMode == css::embed::ElementModes::READ, "Error creating signature stream..." );
}
return aHelper;
commit 1d436cdb3e8670fd8867774be1ed99ce370965b4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 12 11:47:46 2016 +0100
SfxObjectShell::ImplAnalyzeSignature: handle SfxFilterFlags::SUPPORTSSIGNING
Change-Id: I9d45d3a39c8332c01fcc23dcc5da8db7ed4c5cdc
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 86621d1..ce293f4 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1316,7 +1316,8 @@ uno::Sequence< security::DocumentSignatureInformation > SfxObjectShell::ImplAnal
uno::Sequence< security::DocumentSignatureInformation > aResult;
uno::Reference< security::XDocumentDigitalSignatures > xLocSigner = xSigner;
- if ( GetMedium() && !GetMedium()->GetName().isEmpty() && IsOwnStorageFormat_Impl( *GetMedium()) && GetMedium()->GetStorage().is() )
+ bool bSupportsSigning = GetMedium() && GetMedium()->GetFilter() && GetMedium()->GetFilter()->GetSupportsSigning();
+ if (GetMedium() && !GetMedium()->GetName().isEmpty() && (IsOwnStorageFormat_Impl(*GetMedium()) || bSupportsSigning) && GetMedium()->GetStorage().is())
{
try
{
commit fd3bd604496b925c80fb9bfb50de459325f545e0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 12 10:51:28 2016 +0100
xmlsecurity: gracefully handle lack of META-INF storage stream
Change-Id: Ic0b33f7b014ea7cfb16cc1babb69f2d2b6ba8dee
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 0d4319c..bb93298 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -283,15 +283,22 @@ void DigitalSignaturesDialog::SetStorage( const com::sun::star::uno::Reference <
Reference < css::packages::manifest::XManifestReader > xReader =
css::packages::manifest::ManifestReader::create(mxCtx);
- //Get the manifest.xml
- Reference < css::embed::XStorage > xSubStore(rxStore->openStorageElement(
- "META-INF", css::embed::ElementModes::READ), UNO_QUERY_THROW);
+ uno::Reference<container::XNameAccess> xNameAccess(rxStore, uno::UNO_QUERY);
+ if (!xNameAccess.is())
+ return;
+
+ if (xNameAccess->hasByName("META-INF"))
+ {
+ //Get the manifest.xml
+ Reference < css::embed::XStorage > xSubStore(rxStore->openStorageElement(
+ "META-INF", css::embed::ElementModes::READ), UNO_QUERY_THROW);
- Reference< css::io::XInputStream > xStream(
- xSubStore->openStreamElement("manifest.xml", css::embed::ElementModes::READ),
- UNO_QUERY_THROW);
+ Reference< css::io::XInputStream > xStream(
+ xSubStore->openStreamElement("manifest.xml", css::embed::ElementModes::READ),
+ UNO_QUERY_THROW);
- m_manifest = xReader->readManifestSequence(xStream);
+ m_manifest = xReader->readManifestSequence(xStream);
+ }
}
void DigitalSignaturesDialog::SetSignatureStream( const css::uno::Reference < css::io::XStream >& rxStream )
commit dd615af367a11749e6490a40b4d9bcfaeebe7046
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 12 10:34:46 2016 +0100
comphelper: initial SfxFilterFlags::SUPPORTSSIGNING
Currently digital signatures can be made only on OWN formats. Add a new
flag that can be used to mark filters (only DOCX as a start) which could
also support signing and fix the first place that assumes that only OWN
formats support signing.
Change-Id: If9fbf956b765d75838986762e4d4063a9e8c0b5e
diff --git a/filter/source/config/cache/constant.hxx b/filter/source/config/cache/constant.hxx
index c1c37f6..7e8cc02 100644
--- a/filter/source/config/cache/constant.hxx
+++ b/filter/source/config/cache/constant.hxx
@@ -120,6 +120,7 @@
#define FLAGNAME_TEMPLATE "TEMPLATE"
#define FLAGNAME_TEMPLATEPATH "TEMPLATEPATH"
#define FLAGNAME_COMBINED "COMBINED"
+#define FLAGNAME_SUPPORTSSIGNING "SUPPORTSSIGNING"
/** @short some uno service names.
*/
diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx
index dacad09..68a26b6 100644
--- a/filter/source/config/cache/filtercache.cxx
+++ b/filter/source/config/cache/filtercache.cxx
@@ -1935,6 +1935,7 @@ css::uno::Sequence< OUString > FilterCache::impl_convertFlagField2FlagNames(SfxF
if (nFlags & SfxFilterFlags::TEMPLATE ) lFlagNames.push_back(FLAGNAME_TEMPLATE );
if (nFlags & SfxFilterFlags::TEMPLATEPATH ) lFlagNames.push_back(FLAGNAME_TEMPLATEPATH );
if (nFlags & SfxFilterFlags::COMBINED ) lFlagNames.push_back(FLAGNAME_COMBINED );
+ if (nFlags & SfxFilterFlags::SUPPORTSSIGNING) lFlagNames.push_back(FLAGNAME_SUPPORTSSIGNING);
return comphelper::containerToSequence(lFlagNames);
}
@@ -2025,6 +2026,11 @@ SfxFilterFlags FilterCache::impl_convertFlagNames2FlagField(const css::uno::Sequ
nField |= SfxFilterFlags::STARTPRESENTATION;
continue;
}
+ if (pNames[i] == FLAGNAME_SUPPORTSSIGNING)
+ {
+ nField |= SfxFilterFlags::SUPPORTSSIGNING;
+ continue;
+ }
if (pNames[i] == FLAGNAME_READONLY)
{
nField |= SfxFilterFlags::OPENREADONLY;
diff --git a/filter/source/config/fragments/filters/MS_Word_2007_XML.xcu b/filter/source/config/fragments/filters/MS_Word_2007_XML.xcu
index a295ae3..30bd1be 100644
--- a/filter/source/config/fragments/filters/MS_Word_2007_XML.xcu
+++ b/filter/source/config/fragments/filters/MS_Word_2007_XML.xcu
@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="MS Word 2007 XML" oor:op="replace">
- <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER ENCRYPTION PASSWORDTOMODIFY</value></prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER ENCRYPTION PASSWORDTOMODIFY SUPPORTSSIGNING</value></prop>
<prop oor:name="UIComponent"/>
<prop oor:name="FilterService"><value>com.sun.star.comp.Writer.WriterFilter</value></prop>
<prop oor:name="UserData"><value>OXML</value></prop>
diff --git a/include/comphelper/documentconstants.hxx b/include/comphelper/documentconstants.hxx
index 6e5fb1e..7541853 100644
--- a/include/comphelper/documentconstants.hxx
+++ b/include/comphelper/documentconstants.hxx
@@ -112,10 +112,11 @@ enum class SfxFilterFlags
PASSWORDTOMODIFY = 0x02000000L,
PREFERED = 0x10000000L,
STARTPRESENTATION = 0x20000000L,
+ SUPPORTSSIGNING = 0x40000000L,
};
namespace o3tl
{
- template<> struct typed_flags<SfxFilterFlags> : is_typed_flags<SfxFilterFlags, 0x339f157fL> {};
+ template<> struct typed_flags<SfxFilterFlags> : is_typed_flags<SfxFilterFlags, 0x739f157fL> {};
}
#define SFX_FILTER_NOTINSTALLED (SfxFilterFlags::MUSTINSTALL | SfxFilterFlags::CONSULTSERVICE)
diff --git a/include/sfx2/docfilt.hxx b/include/sfx2/docfilt.hxx
index 4a6babb..6f45c97 100644
--- a/include/sfx2/docfilt.hxx
+++ b/include/sfx2/docfilt.hxx
@@ -76,6 +76,8 @@ public:
bool IsAllowedAsTemplate() const { return bool(nFormatType & SfxFilterFlags::TEMPLATE); }
bool IsOwnFormat() const { return bool(nFormatType & SfxFilterFlags::OWN); }
+ /// If the filter supports digital signatures.
+ bool GetSupportsSigning() const { return bool(nFormatType & SfxFilterFlags::SUPPORTSSIGNING); }
bool IsOwnTemplateFormat() const { return bool(nFormatType & SfxFilterFlags::TEMPLATEPATH); }
bool IsAlienFormat() const { return bool(nFormatType & SfxFilterFlags::ALIEN); }
bool CanImport() const { return bool(nFormatType & SfxFilterFlags::IMPORT); }
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 4482ca8..86621d1 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1379,7 +1379,7 @@ void SfxObjectShell::ImplSign( bool bScriptingContent )
if ( GetMedium()
&& GetMedium()->GetFilter()
&& !GetMedium()->GetName().isEmpty()
- && ( !GetMedium()->GetFilter()->IsOwnFormat()
+ && ( (!GetMedium()->GetFilter()->IsOwnFormat() && !GetMedium()->GetFilter()->GetSupportsSigning())
|| !GetMedium()->HasStorage_Impl()
)
)
More information about the Libreoffice-commits
mailing list