summaryrefslogtreecommitdiff
path: root/sc/source/ui/unoobj
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2021-08-31 12:08:39 +0200
committerLászló Németh <nemeth@numbertext.org>2021-09-01 11:29:08 +0200
commitc082158018148be01476d5bc82c1cd71ea6541df (patch)
treef4cb11058151559e6da2b0211109f0d3454fe134 /sc/source/ui/unoobj
parent521d91bce3a88dfaf529216f19e133dea7bb5af4 (diff)
tdf#118938 XLSX import/export: fix permission for editing
The password for editing wasn't asked, also wasn't exported in XLSX documents. Now it's exported in Calc using the following steps, also verified before editing: - In File->Save As, choose Excel 2007–365 (.xlsx) format; - enable checkbox "Save with password" and click Save; - in the dialog "Set password", click on "Options" and enable checkbox "Open file read-only", and enter a password for editing (i.e. skip the password for opening). Note: Excel 2016 doesn't ask password for editing, but Office 365 does. Passwords created in Excel haven't been supported, yet. Also passwords with diacritics aren't interoperable. Note: saving the file under a different path is still allowed both in Calc and Excel without asking the password for editing. Change-Id: Ic00d7c5a785e04d270a182a4087ea922d7d92979 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121371 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc/source/ui/unoobj')
-rw-r--r--sc/source/ui/unoobj/confuno.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
index d7ead11acdd4..f148b9abed8f 100644
--- a/sc/source/ui/unoobj/confuno.cxx
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -83,6 +83,7 @@ static const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap()
{u"" SC_UNO_LOADREADONLY, 0, cppu::UnoType<bool>::get(), 0, 0},
{u"" SC_UNO_SHAREDOC, 0, cppu::UnoType<bool>::get(), 0, 0},
{u"" SC_UNO_MODIFYPASSWORDINFO, 0, cppu::UnoType<uno::Sequence< beans::PropertyValue >>::get(), 0, 0},
+ {u"" SC_UNO_MODIFYPASSWORDHASH, 0, cppu::UnoType<sal_Int32>::get(), 0, 0},
{u"" SC_UNO_EMBED_FONTS, 0, cppu::UnoType<bool>::get(), 0, 0},
{u"" SC_UNO_EMBED_ONLY_USED_FONTS, 0, cppu::UnoType<bool>::get(), 0, 0},
{u"" SC_UNO_EMBED_FONT_SCRIPT_LATIN, 0, cppu::UnoType<bool>::get(), 0, 0},
@@ -337,6 +338,16 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
throw beans::PropertyVetoException(
"The hash is not allowed to be changed now!" );
}
+ else if (aPropertyName == SC_UNO_MODIFYPASSWORDHASH)
+ {
+ sal_Int32 nHash;
+ if (!(aValue >>= nHash))
+ throw lang::IllegalArgumentException("Value of type sal_Int32 expected!",
+ uno::Reference<uno::XInterface>(), 2);
+
+ if (!pDocShell->SetModifyPasswordHash(nHash))
+ throw beans::PropertyVetoException("The hash is not allowed to be changed now!");
+ }
else if (aPropertyName == SC_UNO_EMBED_FONTS)
{
bool bVal = aValue.has<bool>() && aValue.get<bool>();
@@ -537,6 +548,8 @@ uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const OUString& aPr
}
else if ( aPropertyName == SC_UNO_MODIFYPASSWORDINFO )
aRet <<= pDocShell->GetModifyPasswordInfo();
+ else if (aPropertyName == SC_UNO_MODIFYPASSWORDHASH)
+ aRet <<= pDocShell->GetModifyPasswordHash();
else if (aPropertyName == SC_UNO_EMBED_FONTS)
aRet <<= rDoc.IsEmbedFonts();
else if (aPropertyName == SC_UNO_EMBED_ONLY_USED_FONTS)