summaryrefslogtreecommitdiff
path: root/sw/source/filter/ww8
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-07-03 10:35:48 +0200
committerMiklos Vajna <vmiklos@collabora.com>2019-07-03 12:58:16 +0200
commit132803f99818bffbdc260918ad7a304f228f2843 (patch)
tree2ad2132ea85ce9bd554ec0e7d650fbd33de9e53b /sw/source/filter/ww8
parent58ef52cf3258030860d34f05bc19e2b42d9503c6 (diff)
sw comments on frames: fix DOC handling
The export part didn't use HasFlysAt() to decide what to do with empty annotation marks. Regarding the import side, the only problem was that the start of the annotation range wasn't adjusted to cover the comment anchor, similar to what the UI and the UNO API already does. Change-Id: Ibcbaafa9f3f70de95a70b424aca31ebdc9df099d Reviewed-on: https://gerrit.libreoffice.org/75025 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/filter/ww8')
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx23
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx3
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx7
3 files changed, 25 insertions, 8 deletions
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index c65de3898ff6..35ecc773eb05 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1962,9 +1962,20 @@ WW8_Annotation::WW8_Annotation(const SwRedlineData* pRedline)
maDateTime = pRedline->GetTimeStamp();
}
-void WW8_WrPlcAnnotations::AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp)
+bool WW8_Annotation::HasRange() const
{
- m_aRangeStartPositions[rName] = nStartCp;
+ if (m_nRangeStart != m_nRangeEnd)
+ {
+ return true;
+ }
+
+ return !m_bIgnoreEmpty;
+}
+
+void WW8_WrPlcAnnotations::AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp,
+ bool bIgnoreEmpty)
+{
+ m_aRangeStartPositions[rName] = std::make_pair(nStartCp, bIgnoreEmpty);
}
void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt )
@@ -1973,7 +1984,9 @@ void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt )
WW8_Annotation* p;
if( m_aRangeStartPositions.find(pPostIt->GetName()) != m_aRangeStartPositions.end() )
{
- p = new WW8_Annotation(pPostIt, m_aRangeStartPositions[pPostIt->GetName()], nCp);
+ auto [nStartCp, bIgnoreEmpty] = m_aRangeStartPositions[pPostIt->GetName()];
+ p = new WW8_Annotation(pPostIt, nStartCp, nCp);
+ p->m_bIgnoreEmpty = bIgnoreEmpty;
m_aRangeStartPositions.erase(pPostIt->GetName());
}
else
@@ -2178,7 +2191,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
const WW8_Annotation& rAtn = *static_cast<const WW8_Annotation*>(aContent[i]);
aStrArr.emplace_back(rAtn.msOwner,rAtn.m_sInitials);
// record start and end positions for ranges
- if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd )
+ if (rAtn.HasRange())
{
aRangeStartPos.emplace_back(rAtn.m_nRangeStart, nIdx);
aRangeEndPos.emplace_back(rAtn.m_nRangeEnd, nIdx);
@@ -2403,7 +2416,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFndPos );
SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
- if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd )
+ if (rAtn.HasRange())
{
SwWW8Writer::WriteLong( *rWrt.pTableStrm, nlTag );
++nlTag;
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 1cabdca7b9f0..8f78c2382b1d 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -1490,7 +1490,8 @@ void WW8Export::AppendAnnotationMarks(const SwWW8AttrIter& rAttrs, sal_Int32 nCu
const sal_Int32 nStart = pMark->GetMarkStart().nContent.GetIndex();
if (nStart == nCurrentPos)
{
- m_pAtn->AddRangeStartPosition(pMark->GetName(), Fc2Cp(Strm().Tell()));
+ m_pAtn->AddRangeStartPosition(pMark->GetName(), Fc2Cp(Strm().Tell()),
+ !rAttrs.HasFlysAt(nCurrentPos));
}
}
}
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 6a01f61ed3c0..1ee0c86581bf 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -1230,8 +1230,11 @@ struct WW8_Annotation
OUString m_sInitials;
DateTime maDateTime;
WW8_CP m_nRangeStart, m_nRangeEnd;
+ bool m_bIgnoreEmpty = true;
WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd);
explicit WW8_Annotation(const SwRedlineData* pRedline);
+ /// An annotation has a range if start != end or the m_bIgnoreEmpty flag is cleared.
+ bool HasRange() const;
};
class WW8_WrPlcAnnotations : public WW8_WrPlcSubDoc // double Plc for Postits
@@ -1241,12 +1244,12 @@ private:
WW8_WrPlcAnnotations& operator=(WW8_WrPlcAnnotations const &) = delete;
std::set<const SwRedlineData*> maProcessedRedlines;
- std::map<const OUString, WW8_CP> m_aRangeStartPositions;
+ std::map<const OUString, std::pair<WW8_CP, bool>> m_aRangeStartPositions;
public:
WW8_WrPlcAnnotations() {}
virtual ~WW8_WrPlcAnnotations() override;
- void AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp);
+ void AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp, bool bIgnoreEmpty);
void Append( WW8_CP nCp, const SwPostItField* pPostIt );
void Append( WW8_CP nCp, const SwRedlineData* pRedLine );
bool IsNewRedlineComment( const SwRedlineData* pRedLine );