summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8/docxattributeoutput.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/filter/ww8/docxattributeoutput.cxx')
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx158
1 files changed, 108 insertions, 50 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 959e391e3e37..f31342d3074d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -1913,16 +1913,32 @@ void DocxAttributeOutput::DoWriteBookmarkTagEnd(sal_Int32 const nId)
void DocxAttributeOutput::DoWriteMoveRangeTagStart(const OString & bookmarkName,
bool bFrom, const SwRedlineData* pRedlineData)
{
- const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) );
- OString aDate( DateTimeToOString( pRedlineData->GetTimeStamp() ) );
+ bool bRemovePersonalInfo = SvtSecurityOptions::IsOptionSet(
+ SvtSecurityOptions::EOption::DocWarnRemovePersonalInfo );
- m_pSerializer->singleElementNS(XML_w, bFrom
+ const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) );
+ const DateTime aDateTime = pRedlineData->GetTimeStamp();
+ bool bNoDate = bRemovePersonalInfo ||
+ ( aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1 && aDateTime.GetDay() == 1 );
+ if ( bNoDate )
+ m_pSerializer->singleElementNS(XML_w, bFrom
? XML_moveFromRangeStart
: XML_moveToRangeStart,
- FSNS(XML_w, XML_id), OString::number(m_nNextBookmarkId),
- FSNS(XML_w, XML_author ), OUStringToOString(rAuthor, RTL_TEXTENCODING_UTF8),
- FSNS(XML_w, XML_date ), aDate,
- FSNS(XML_w, XML_name), bookmarkName);
+ FSNS(XML_w, XML_id), OString::number(m_nNextBookmarkId),
+ FSNS(XML_w, XML_author ), bRemovePersonalInfo
+ ? "Author" + OString::number( GetExport().GetInfoID(rAuthor) )
+ : OUStringToOString(rAuthor, RTL_TEXTENCODING_UTF8),
+ FSNS(XML_w, XML_name), bookmarkName);
+ else
+ m_pSerializer->singleElementNS(XML_w, bFrom
+ ? XML_moveFromRangeStart
+ : XML_moveToRangeStart,
+ FSNS(XML_w, XML_id), OString::number(m_nNextBookmarkId),
+ FSNS(XML_w, XML_author ), bRemovePersonalInfo
+ ? "Author" + OString::number( GetExport().GetInfoID(rAuthor) )
+ : OUStringToOString(rAuthor, RTL_TEXTENCODING_UTF8),
+ FSNS(XML_w, XML_date ), DateTimeToOString( aDateTime ),
+ FSNS(XML_w, XML_name), bookmarkName);
}
void DocxAttributeOutput::DoWriteMoveRangeTagEnd(sal_Int32 const nId, bool bFrom)
@@ -3048,7 +3064,7 @@ void DocxAttributeOutput::WriteCollectedRunProperties()
{
const char* pVal = nullptr;
m_pColorAttrList->getAsChar(FSNS(XML_w, XML_val), pVal);
- if (std::string_view("auto") != pVal)
+ if (pVal != nullptr && std::string_view("auto") != pVal)
{
m_pSerializer->startElementNS(XML_w14, XML_textFill);
m_pSerializer->startElementNS(XML_w14, XML_solidFill);
@@ -3483,9 +3499,9 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
OString aId( OString::number( pRedlineData->GetSeqNo() ) );
const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) );
- OString aDate( DateTimeToOString( bRemovePersonalInfo
- ? DateTime(Date( 1, 1, 1970 )) // Epoch time
- : pRedlineData->GetTimeStamp() ) );
+ const DateTime aDateTime = pRedlineData->GetTimeStamp();
+ bool bNoDate = bRemovePersonalInfo ||
+ ( aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1 && aDateTime.GetDay() == 1 );
switch( pRedlineData->GetType() )
{
@@ -3496,12 +3512,19 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
break;
case RedlineType::Format:
- m_pSerializer->startElementNS( XML_w, XML_rPrChange,
+ if ( bNoDate )
+ m_pSerializer->startElementNS( XML_w, XML_rPrChange,
+ FSNS( XML_w, XML_id ), aId,
+ FSNS( XML_w, XML_author ), bRemovePersonalInfo
+ ? "Author" + OUString::number( GetExport().GetInfoID(rAuthor) )
+ : rAuthor );
+ else
+ m_pSerializer->startElementNS( XML_w, XML_rPrChange,
FSNS( XML_w, XML_id ), aId,
FSNS( XML_w, XML_author ), bRemovePersonalInfo
? "Author" + OUString::number( GetExport().GetInfoID(rAuthor) )
: rAuthor,
- FSNS( XML_w, XML_date ), aDate );
+ FSNS( XML_w, XML_date ), DateTimeToOString( aDateTime ) );
// Check if there is any extra data stored in the redline object
if (pRedlineData->GetExtraData())
@@ -3535,12 +3558,19 @@ void DocxAttributeOutput::Redline( const SwRedlineData* pRedlineData)
break;
case RedlineType::ParagraphFormat:
- m_pSerializer->startElementNS( XML_w, XML_pPrChange,
+ if ( bNoDate )
+ m_pSerializer->startElementNS( XML_w, XML_pPrChange,
+ FSNS( XML_w, XML_id ), aId,
+ FSNS( XML_w, XML_author ), bRemovePersonalInfo
+ ? "Author" + OUString::number( GetExport().GetInfoID(rAuthor) )
+ : rAuthor );
+ else
+ m_pSerializer->startElementNS( XML_w, XML_pPrChange,
FSNS( XML_w, XML_id ), aId,
FSNS( XML_w, XML_author ), bRemovePersonalInfo
? "Author" + OUString::number( GetExport().GetInfoID(rAuthor) )
: rAuthor,
- FSNS( XML_w, XML_date ), aDate );
+ FSNS( XML_w, XML_date ), DateTimeToOString( aDateTime ) );
// Check if there is any extra data stored in the redline object
if (pRedlineData->GetExtraData())
@@ -3621,27 +3651,29 @@ void DocxAttributeOutput::StartRedline( const SwRedlineData * pRedlineData )
? "Author" + OUString::number( GetExport().GetInfoID(rAuthor) )
: rAuthor, RTL_TEXTENCODING_UTF8 ) );
- OString aDate( DateTimeToOString( bRemovePersonalInfo
- ? DateTime(Date( 1, 1, 1970 )) // Epoch time
- : pRedlineData->GetTimeStamp() ) );
-
+ const DateTime aDateTime = pRedlineData->GetTimeStamp();
+ bool bNoDate = bRemovePersonalInfo ||
+ ( aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1 && aDateTime.GetDay() == 1 );
bool bMoved = pRedlineData->IsMoved();
switch ( pRedlineData->GetType() )
{
case RedlineType::Insert:
- m_pSerializer->startElementNS( XML_w, bMoved ? XML_moveTo : XML_ins,
- FSNS( XML_w, XML_id ), aId,
- FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
- break;
-
case RedlineType::Delete:
- m_pSerializer->startElementNS( XML_w, bMoved ? XML_moveFrom : XML_del,
+ {
+ sal_Int32 eElement = RedlineType::Insert == pRedlineData->GetType()
+ ? ( bMoved ? XML_moveTo : XML_ins )
+ : ( bMoved ? XML_moveFrom : XML_del );
+ if ( bNoDate )
+ m_pSerializer->startElementNS( XML_w, eElement,
+ FSNS( XML_w, XML_id ), aId,
+ FSNS( XML_w, XML_author ), aAuthor );
+ else
+ m_pSerializer->startElementNS( XML_w, eElement,
FSNS( XML_w, XML_id ), aId,
FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
+ FSNS( XML_w, XML_date ), DateTimeToOString( aDateTime ) );
break;
-
+ }
case RedlineType::Format:
SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::StartRedline()" );
break;
@@ -4742,15 +4774,21 @@ void DocxAttributeOutput::TableRowRedline( ww8::WW8TableNodeInfoInner::Pointer_t
? "Author" + OUString::number( GetExport().GetInfoID(rAuthor) )
: rAuthor, RTL_TEXTENCODING_UTF8 ) );
- OString aDate( DateTimeToOString( bRemovePersonalInfo
- ? DateTime(Date( 1, 1, 1970 )) // Epoch time
- : aRedlineData.GetTimeStamp() ) );
+ const DateTime aDateTime = aRedlineData.GetTimeStamp();
+ bool bNoDate = bRemovePersonalInfo ||
+ ( aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1 && aDateTime.GetDay() == 1 );
- m_pSerializer->singleElementNS( XML_w,
+ if ( bNoDate )
+ m_pSerializer->singleElementNS( XML_w,
+ RedlineType::Delete == pRedline->GetType() ? XML_del : XML_ins,
+ FSNS( XML_w, XML_id ), aId,
+ FSNS( XML_w, XML_author ), aAuthor );
+ else
+ m_pSerializer->singleElementNS( XML_w,
RedlineType::Delete == pRedline->GetType() ? XML_del : XML_ins,
FSNS( XML_w, XML_id ), aId,
FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
+ FSNS( XML_w, XML_date ), DateTimeToOString( aDateTime ) );
return;
}
}
@@ -4784,20 +4822,21 @@ void DocxAttributeOutput::TableCellRedline( ww8::WW8TableNodeInfoInner::Pointer_
? "Author" + OUString::number( GetExport().GetInfoID(rAuthor) )
: rAuthor, RTL_TEXTENCODING_UTF8 ) );
- OString aDate( DateTimeToOString( bRemovePersonalInfo
- ? DateTime(Date( 1, 1, 1970 )) // Epoch time
- : aRedlineData.GetTimeStamp() ) );
-
- if (nRedlineType == RedlineType::TableCellInsert)
- m_pSerializer->singleElementNS( XML_w, XML_cellIns,
+ sal_Int32 nElement = nRedlineType == RedlineType::TableCellInsert
+ ? XML_cellIns
+ : XML_cellDel;
+ const DateTime aDateTime = aRedlineData.GetTimeStamp();
+ bool bNoDate = bRemovePersonalInfo || ( aDateTime.GetYear() == 1970 &&
+ aDateTime.GetMonth() == 1 && aDateTime.GetDay() == 1 );
+ if ( bNoDate )
+ m_pSerializer->singleElementNS( XML_w, nElement,
FSNS( XML_w, XML_id ), aId,
- FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
- else if (nRedlineType == RedlineType::TableCellDelete)
- m_pSerializer->singleElementNS( XML_w, XML_cellDel,
+ FSNS( XML_w, XML_author ), aAuthor );
+ else
+ m_pSerializer->singleElementNS( XML_w, nElement,
FSNS( XML_w, XML_id ), aId,
FSNS( XML_w, XML_author ), aAuthor,
- FSNS( XML_w, XML_date ), aDate );
+ FSNS( XML_w, XML_date ), DateTimeToOString( aDateTime ) );
}
break;
default: break;
@@ -7676,6 +7715,7 @@ void DocxAttributeOutput::OverrideNumberingDefinition(
SwNumRule const& rAbstractRule = *(*m_rExport.m_pUsedNumTable)[nAbstractNum - 1];
sal_uInt8 const nLevels = static_cast<sal_uInt8>(rRule.IsContinusNum()
? WW8ListManager::nMinLevel : WW8ListManager::nMaxLevel);
+ sal_uInt8 nPreviousOverrideLevel = 0;
for (sal_uInt8 nLevel = 0; nLevel < nLevels; ++nLevel)
{
const auto levelOverride = rLevelOverrides.find(nLevel);
@@ -7685,6 +7725,14 @@ void DocxAttributeOutput::OverrideNumberingDefinition(
// or we have a level numbering override
if (bListsAreDifferent || levelOverride != rLevelOverrides.end())
{
+ // If there are "gaps" in w:lvlOverride numbers, MS Word can have issues with numbering.
+ // So we need to emit empty override tokens up to current one.
+ while (nPreviousOverrideLevel < nLevel)
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_lvlOverride, FSNS(XML_w, XML_ilvl), OString::number(nPreviousOverrideLevel));
+ nPreviousOverrideLevel++;
+ }
+
m_pSerializer->startElementNS(XML_w, XML_lvlOverride, FSNS(XML_w, XML_ilvl), OString::number(nLevel));
if (bListsAreDifferent)
@@ -8466,14 +8514,24 @@ DocxAttributeOutput::hasResolved DocxAttributeOutput::WritePostitFields()
for (auto& [f, data] : m_postitFields)
{
OString idstr = OString::number(data.id);
- m_pSerializer->startElementNS( XML_w, XML_comment, FSNS( XML_w, XML_id ), idstr,
- FSNS( XML_w, XML_author ), bRemovePersonalInfo
+ const DateTime aDateTime = f->GetDateTime();
+ bool bNoDate = bRemovePersonalInfo ||
+ ( aDateTime.GetYear() == 1970 && aDateTime.GetMonth() == 1 && aDateTime.GetDay() == 1 );
+ if ( bNoDate )
+ m_pSerializer->startElementNS( XML_w, XML_comment, FSNS( XML_w, XML_id ), idstr,
+ FSNS( XML_w, XML_author ), bRemovePersonalInfo
+ ? "Author" + OUString::number( GetExport().GetInfoID(f->GetPar1()) )
+ : f->GetPar1(),
+ FSNS( XML_w, XML_initials ), bRemovePersonalInfo
+ ? OUString::number( GetExport().GetInfoID(f->GetInitials()) )
+ : f->GetInitials() );
+ else
+ m_pSerializer->startElementNS( XML_w, XML_comment, FSNS( XML_w, XML_id ), idstr,
+ FSNS( XML_w, XML_author ), bRemovePersonalInfo
? "Author" + OUString::number( GetExport().GetInfoID(f->GetPar1()) )
: f->GetPar1(),
- FSNS( XML_w, XML_date ), DateTimeToOString( bRemovePersonalInfo
- ? util::DateTime() // "no date" time
- : f->GetDateTime() ),
- FSNS( XML_w, XML_initials ), bRemovePersonalInfo
+ FSNS( XML_w, XML_date ), DateTimeToOString( aDateTime ),
+ FSNS( XML_w, XML_initials ), bRemovePersonalInfo
? OUString::number( GetExport().GetInfoID(f->GetInitials()) )
: f->GetInitials() );