summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/chgtrack.hxx1
-rw-r--r--sc/inc/strings.hrc1
-rw-r--r--sc/qa/uitest/calc_tests4/trackedChanges.py28
-rw-r--r--sc/source/core/tool/chgtrack.cxx24
4 files changed, 35 insertions, 19 deletions
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index 24e4f653b165..9e3aed17aa55 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -966,6 +966,7 @@ public:
bool IsInDeleteTop() const { return bInDeleteTop; }
bool IsInDeleteUndo() const { return bInDeleteUndo; }
bool IsInPasteCut() const { return bInPasteCut; }
+ void CreateAuthorName();
SC_DLLPUBLIC void SetUser( const OUString& rUser );
const OUString& GetUser() const { return maUser;}
const std::set<OUString>& GetUserCollection() const { return maUserCollection;}
diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc
index 24a40a41ef57..f7d33399faa2 100644
--- a/sc/inc/strings.hrc
+++ b/sc/inc/strings.hrc
@@ -202,6 +202,7 @@
#define STR_CHG_REJECTED NC_("STR_CHG_REJECTED", "Rejected")
#define STR_CHG_NO_ENTRY NC_("STR_CHG_NO_ENTRY", "No Entry")
#define STR_CHG_EMPTY NC_("STR_CHG_EMPTY", "<empty>")
+#define STR_CHG_UNKNOWN_AUTHOR NC_("STR_CHG_UNKNOWN_AUTHOR", "Unknown Author")
#define STR_NOT_PROTECTED NC_("STR_NOT_PROTECTED", "Not protected")
#define STR_NOT_PASS_PROTECTED NC_("STR_NOT_PASS_PROTECTED", "Not password-protected")
diff --git a/sc/qa/uitest/calc_tests4/trackedChanges.py b/sc/qa/uitest/calc_tests4/trackedChanges.py
index 53306de0c88b..0f38f9f3042c 100644
--- a/sc/qa/uitest/calc_tests4/trackedChanges.py
+++ b/sc/qa/uitest/calc_tests4/trackedChanges.py
@@ -70,7 +70,7 @@ class CalcTrackedChanges(UITestCase):
xChangesList = xTrackDlg.getChild("calcchanges")
self.assertEqual(1, len(xChangesList.getChildren()))
- textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStart = "Changed contents\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
xChild = xChangesList.getChild('0')
self.assertTrue(get_state_as_dict(xChild)["Text"].startswith(textStart))
@@ -78,11 +78,11 @@ class CalcTrackedChanges(UITestCase):
xChild.executeAction("EXPAND", tuple())
self.assertEqual(3, len(xChild.getChildren()))
- textStartChild1 = "<empty>\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStartChild1 = "<empty>\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEndChild1 = "(Original: <empty>)"
- textStartChild2 = "'Hello'\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStartChild2 = "'Hello'\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEndChild2 = "(Changed to 'Hello')"
- textStartChild3 = "'There'\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStartChild3 = "'There'\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEndChild3 = "(Changed to 'There')"
self.assertTrue(get_state_as_dict(xChild.getChild('0'))["Text"].startswith(textStartChild1))
@@ -113,7 +113,7 @@ class CalcTrackedChanges(UITestCase):
xChangesList = xTrackDlg.getChild("calcchanges")
self.assertEqual(1, len(xChangesList.getChildren()))
- textStart = "Row deleted\t(Sheet1.1:1)\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStart = "Row deleted\t(Sheet1.1:1)\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEnd = "(Row 1:1 deleted)"
xChild = xChangesList.getChild('0')
@@ -125,7 +125,7 @@ class CalcTrackedChanges(UITestCase):
xChild.executeAction("EXPAND", tuple())
self.assertEqual(1, len(xChild.getChildren()))
- textStartChild1 = "Changed contents\t(Sheet1.A1)\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStartChild1 = "Changed contents\t(Sheet1.A1)\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEndChild1 = "(Cell (A1) changed from '<empty>' to 'Hello')"
self.assertTrue(get_state_as_dict(xChild.getChild('0'))["Text"].startswith(textStartChild1))
@@ -147,9 +147,9 @@ class CalcTrackedChanges(UITestCase):
xChangesList = xTrackDlg.getChild("calcchanges")
self.assertEqual(2, len(xChangesList.getChildren()))
- textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStart = "Changed contents\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')"
- textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStart2 = "Changed contents\tSheet1.A2\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')"
self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart))
self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd))
@@ -197,9 +197,9 @@ class CalcTrackedChanges(UITestCase):
xChangesList = xTrackDlg.getChild("calcchanges")
self.assertEqual(2, len(xChangesList.getChildren()))
- textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStart = "Changed contents\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')"
- textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStart2 = "Changed contents\tSheet1.A2\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')"
self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart))
self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd))
@@ -239,9 +239,9 @@ class CalcTrackedChanges(UITestCase):
xChangesList = xTrackDlg.getChild("calcchanges")
self.assertEqual(2, len(xChangesList.getChildren()))
- textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStart = "Changed contents\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')"
- textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStart2 = "Changed contents\tSheet1.A2\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')"
self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart))
self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd))
@@ -301,9 +301,9 @@ class CalcTrackedChanges(UITestCase):
xChangesList = xTrackDlg.getChild("calcchanges")
self.assertEqual(2, len(xChangesList.getChildren()))
- textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStart = "Changed contents\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')"
- textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y")
+ textStart2 = "Changed contents\tSheet1.A2\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y")
textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')"
self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart))
self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd))
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 925b30378c1a..996ff1c912e3 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -43,6 +43,7 @@
#include <tools/json_writer.hxx>
#include <algorithm>
#include <memory>
+#include <strings.hrc>
#include <utility>
ScChangeAction::ScChangeAction( ScChangeActionType eTypeP, const ScRange& rRange )
@@ -2061,9 +2062,7 @@ void ScChangeTrack::Init()
bUseFixDateTime = false;
bTimeNanoSeconds = true;
- const SvtUserOptions& rUserOpt = SC_MOD()->GetUserOptions();
- maUser = rUserOpt.GetFirstName() + " " + rUserOpt.GetLastName();
- maUserCollection.insert(maUser);
+ CreateAuthorName();
}
void ScChangeTrack::DtorClear()
@@ -2160,10 +2159,9 @@ void ScChangeTrack::ConfigurationChanged( utl::ConfigurationBroadcaster*, Config
if ( rDoc.IsInDtorClear() )
return;
- const SvtUserOptions& rUserOptions = SC_MOD()->GetUserOptions();
size_t nOldCount = maUserCollection.size();
- SetUser(rUserOptions.GetFirstName() + " " + rUserOptions.GetLastName());
+ CreateAuthorName();
if ( maUserCollection.size() != nOldCount )
{
@@ -2178,6 +2176,22 @@ void ScChangeTrack::ConfigurationChanged( utl::ConfigurationBroadcaster*, Config
}
}
+void ScChangeTrack::CreateAuthorName()
+{
+ const SvtUserOptions& rUserOptions = SC_MOD()->GetUserOptions();
+ OUString aFirstName(rUserOptions.GetFirstName());
+ OUString aLastName(rUserOptions.GetLastName());
+ if (aFirstName.isEmpty() && aLastName.isEmpty())
+ SetUser(ScResId(STR_CHG_UNKNOWN_AUTHOR));
+ else if(!aFirstName.isEmpty() && aLastName.isEmpty())
+ SetUser(aFirstName);
+ else if(aFirstName.isEmpty() && !aLastName.isEmpty())
+ SetUser(aLastName);
+ else
+ SetUser(aFirstName + " " + aLastName);
+}
+
+
void ScChangeTrack::SetUser( const OUString& rUser )
{
maUser = rUser;