summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-06-14 20:46:17 +0200
committerLászló Németh <nemeth@numbertext.org>2021-06-17 10:43:08 +0200
commit12da70f88517bf3c053afe1c504bb70bd27573f2 (patch)
tree27097e4bb9cc343ece830f77991b5d5220ea2ff3 /xmloff
parent68eb62b9bf8a64d892b3cfa58447e7c890ed3ec4 (diff)
tdf#90401 xmloff: remove personal info of comments and changes
If Options → LibreOffice → Security → Security Options and Warnings → Options... → Security Options → Remove personal information on saving" is enabled. Use the same time (1970-01-01T00:00:00) for mandatory time stamps, and replace authors and creator-initials with "1", "2", "3" etc., also to avoid of joining adjacent redline ranges. Note: to see the work of the unit test in Linux command line: (cd sw && make UITest_writer_tests7 UITEST_TEST_NAME="tdf90401.tdf90401.test_tdf90401_remove_personal_info" SAL_USE_VCLPLUGIN=gen) Change-Id: I3b4d710dbeeee12177aff378597cd2b683ca6c25 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117319 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/core/xmlexp.cxx3
-rw-r--r--xmloff/source/draw/sdxmlexp.cxx16
-rw-r--r--xmloff/source/text/XMLRedlineExport.cxx24
-rw-r--r--xmloff/source/text/txtflde.cxx13
4 files changed, 46 insertions, 10 deletions
diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx
index 05d44229e321..d73783994271 100644
--- a/xmloff/source/core/xmlexp.cxx
+++ b/xmloff/source/core/xmlexp.cxx
@@ -459,6 +459,7 @@ SvXMLExport::SvXMLExport(
m_xContext(xContext), m_implementationName(implementationName),
mxAttrList( new SvXMLAttributeList ),
mpNamespaceMap( new SvXMLNamespaceMap ),
+ mpAuthorIDs( new SvtSecurityMapPersonalInfo ),
maUnitConv(xContext, util::MeasureUnit::MM_100TH, eDefaultMeasureUnit, getSaneDefaultVersion()),
meClass( eClass ),
mnExportFlags( nExportFlags ),
@@ -484,6 +485,7 @@ SvXMLExport::SvXMLExport(
mxAttrList( new SvXMLAttributeList ),
msOrigFileName( rFileName ),
mpNamespaceMap( new SvXMLNamespaceMap ),
+ mpAuthorIDs( new SvtSecurityMapPersonalInfo ),
maUnitConv(xContext, util::MeasureUnit::MM_100TH, eDefaultMeasureUnit, getSaneDefaultVersion()),
meClass( XML_TOKEN_INVALID ),
mnExportFlags( SvXMLExportFlags::NONE ),
@@ -517,6 +519,7 @@ SvXMLExport::SvXMLExport(
mxAttrList( new SvXMLAttributeList ),
msOrigFileName( rFileName ),
mpNamespaceMap( new SvXMLNamespaceMap ),
+ mpAuthorIDs( new SvtSecurityMapPersonalInfo ),
maUnitConv( xContext,
util::MeasureUnit::MM_100TH,
SvXMLUnitConverter::GetMeasureUnit(eDefaultFieldUnit),
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 652bce79610d..db1542fc511f 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -2516,6 +2516,10 @@ void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
if( xAnnotationEnumeration.is() && xAnnotationEnumeration->hasMoreElements() )
{
+ SvtSecurityOptions aSecOpt;
+ bool bRemovePersonalInfo = aSecOpt.IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo );
+
OUStringBuffer sStringBuffer;
do
{
@@ -2551,7 +2555,9 @@ void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
if( !aAuthor.isEmpty() )
{
SvXMLElementExport aCreatorElem( *this, XML_NAMESPACE_DC, XML_CREATOR, true, false );
- Characters(aAuthor);
+ Characters( bRemovePersonalInfo
+ ? "Author" + OUString::number( SvXMLExport::GetInfoID(aAuthor) )
+ : aAuthor );
}
// initials
@@ -2567,7 +2573,9 @@ void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
? XML_CREATOR_INITIALS
: XML_SENDER_INITIALS,
true, false );
- Characters(aInitials);
+ Characters( bRemovePersonalInfo
+ ? OUString::number( SvXMLExport::GetInfoID(aInitials) )
+ : aInitials );
}
{
@@ -2575,7 +2583,9 @@ void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
css::util::DateTime aDate( xAnnotation->getDateTime() );
::sax::Converter::convertDateTime(sStringBuffer, aDate, nullptr, true);
SvXMLElementExport aDateElem( *this, XML_NAMESPACE_DC, XML_DATE, true, false );
- Characters(sStringBuffer.makeStringAndClear());
+ Characters( bRemovePersonalInfo
+ ? "1970-01-01T00:00::00"
+ : sStringBuffer.makeStringAndClear() );
}
css::uno::Reference < css::text::XText > xText( xAnnotation->getTextRange() );
diff --git a/xmloff/source/text/XMLRedlineExport.cxx b/xmloff/source/text/XMLRedlineExport.cxx
index e309b1d86731..fad527a77b59 100644
--- a/xmloff/source/text/XMLRedlineExport.cxx
+++ b/xmloff/source/text/XMLRedlineExport.cxx
@@ -42,6 +42,7 @@
#include <xmloff/xmlnamespace.hxx>
#include <xmloff/xmlexp.hxx>
#include <xmloff/xmluconv.hxx>
+#include <unotools/securityoptions.hxx>
using namespace ::com::sun::star;
@@ -433,6 +434,9 @@ OUString XMLRedlineExport::GetRedlineID(
void XMLRedlineExport::ExportChangeInfo(
const Reference<XPropertySet> & rPropSet)
{
+ SvtSecurityOptions aSecOpt;
+ bool bRemovePersonalInfo = aSecOpt.IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo );
SvXMLElementExport aChangeInfo(rExport, XML_NAMESPACE_OFFICE,
XML_CHANGE_INFO, true, true);
@@ -445,7 +449,9 @@ void XMLRedlineExport::ExportChangeInfo(
SvXMLElementExport aCreatorElem( rExport, XML_NAMESPACE_DC,
XML_CREATOR, true,
false );
- rExport.Characters(sTmp);
+ rExport.Characters(bRemovePersonalInfo
+ ? "Author" + OUString::number(rExport.GetInfoID(sTmp))
+ : sTmp );
}
aAny = rPropSet->getPropertyValue("RedlineDateTime");
@@ -457,7 +463,9 @@ void XMLRedlineExport::ExportChangeInfo(
SvXMLElementExport aDateElem( rExport, XML_NAMESPACE_DC,
XML_DATE, true,
false );
- rExport.Characters(sBuf.makeStringAndClear());
+ rExport.Characters(bRemovePersonalInfo
+ ? "1970-01-01T00:00:00"
+ : sBuf.makeStringAndClear());
}
// comment as <text:p> sequence
@@ -470,6 +478,9 @@ void XMLRedlineExport::ExportChangeInfo(
const Sequence<PropertyValue> & rPropertyValues)
{
OUString sComment;
+ SvtSecurityOptions aSecOpt;
+ bool bRemovePersonalInfo = aSecOpt.IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo );
for(const PropertyValue& rVal : rPropertyValues)
{
@@ -479,7 +490,9 @@ void XMLRedlineExport::ExportChangeInfo(
rVal.Value >>= sTmp;
if (!sTmp.isEmpty())
{
- rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_AUTHOR, sTmp);
+ rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_AUTHOR, bRemovePersonalInfo
+ ? "Author" + OUString::number(rExport.GetInfoID(sTmp))
+ : sTmp);
}
}
else if( rVal.Name == "RedlineComment" )
@@ -492,8 +505,9 @@ void XMLRedlineExport::ExportChangeInfo(
rVal.Value >>= aDateTime;
OUStringBuffer sBuf;
::sax::Converter::convertDateTime(sBuf, aDateTime, nullptr);
- rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_DATE_TIME,
- sBuf.makeStringAndClear());
+ rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_CHG_DATE_TIME, bRemovePersonalInfo
+ ? "1970-01-01T00:00:00"
+ : sBuf.makeStringAndClear());
}
else if( rVal.Name == "RedlineType" )
{
diff --git a/xmloff/source/text/txtflde.cxx b/xmloff/source/text/txtflde.cxx
index 962e30e995d4..93f43ee6c082 100644
--- a/xmloff/source/text/txtflde.cxx
+++ b/xmloff/source/text/txtflde.cxx
@@ -1746,6 +1746,10 @@ void XMLTextFieldExport::ExportFieldHelper(
DBG_ASSERT(sPresentation.isEmpty(),
"Unexpected presentation for annotation field");
+ SvtSecurityOptions aSecOpt;
+ bool bRemovePersonalInfo = aSecOpt.IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo );
+
// annotation element + content
OUString aName;
rPropSet->getPropertyValue(gsPropertyName) >>= aName;
@@ -1774,11 +1778,14 @@ void XMLTextFieldExport::ExportFieldHelper(
SvXMLElementExport aCreatorElem( GetExport(), XML_NAMESPACE_DC,
XML_CREATOR, true,
false );
- GetExport().Characters(aAuthor);
+ GetExport().Characters( bRemovePersonalInfo
+ ? "Author" + OUString::number( rExport.GetInfoID(aAuthor) )
+ : aAuthor );
}
// date time
util::DateTime aDate( GetDateTimeProperty(gsPropertyDateTimeValue, rPropSet) );
+ if ( !bRemovePersonalInfo )
{
OUStringBuffer aBuffer;
::sax::Converter::convertDateTime(aBuffer, aDate, nullptr, true);
@@ -1804,7 +1811,9 @@ void XMLTextFieldExport::ExportFieldHelper(
? XML_CREATOR_INITIALS
: XML_SENDER_INITIALS,
true, false );
- GetExport().Characters(aInitials);
+ GetExport().Characters( bRemovePersonalInfo
+ ? OUString::number( rExport.GetInfoID(aInitials) )
+ : aInitials);
}
}