summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-07-07 13:26:50 +0200
committerMichael Stahl <mstahl@redhat.com>2017-07-07 15:49:01 +0200
commit31c54fa7bb03768b425ae019096e0a0e26e9c736 (patch)
treefba4e0c0b0eaf35769a9461a277cf1521b91ba1a /sw
parent7b4f14e481846b90b124f2ff2b4ac0a6fc79f77b (diff)
sw: convert SwTextAnnotationField OSL_ENSUREs to assert() and simplify
Change-Id: Ica69cd4527f36edd7480d897a28ff814ecbe97a9
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/crsr/annotationmark.cxx37
-rw-r--r--sw/source/core/doc/docbm.cxx12
-rw-r--r--sw/source/core/txtnode/atrfld.cxx12
-rw-r--r--sw/source/core/unocore/unoportenum.cxx15
4 files changed, 24 insertions, 52 deletions
diff --git a/sw/source/core/crsr/annotationmark.cxx b/sw/source/core/crsr/annotationmark.cxx
index bca5e903c72a..a73c1715bb36 100644
--- a/sw/source/core/crsr/annotationmark.cxx
+++ b/sw/source/core/crsr/annotationmark.cxx
@@ -52,26 +52,19 @@ namespace sw { namespace mark
void AnnotationMark::InitDoc(SwDoc* const io_pDoc)
{
SwTextNode *pTextNode = GetMarkEnd().nNode.GetNode().GetTextNode();
-
- SwTextField* pTextField = pTextNode ?
- pTextNode->GetFieldTextAttrAt(
- GetMarkEnd().nContent.GetIndex()-1, true ) : nullptr;
- OSL_ENSURE( pTextField != nullptr, "<AnnotationMark::InitDoc(..)> - missing text attribute for annotation field!" );
- if ( pTextField != nullptr )
+ assert(pTextNode);
+ SwTextField *const pTextField = pTextNode->GetFieldTextAttrAt(
+ GetMarkEnd().nContent.GetIndex()-1, true);
+ assert(pTextField != nullptr);
+ const SwPostItField* pPostItField = dynamic_cast< const SwPostItField* >(pTextField->GetFormatField().GetField());
+ assert(pPostItField != nullptr);
+ // use the annotation mark's name as the annotation name, if
+ // - the annotation field has an empty annotation name or
+ // - the annotation mark's name differs (on mark creation a name clash had been detected)
+ if ( pPostItField->GetName().isEmpty()
+ || pPostItField->GetName() != GetName() )
{
- const SwPostItField* pPostItField = dynamic_cast< const SwPostItField* >(pTextField->GetFormatField().GetField());
- OSL_ENSURE( pPostItField != nullptr, "<AnnotationMark::InitDoc(..)> - annotation field missing!" );
- if ( pPostItField != nullptr )
- {
- // use the annotation mark's name as the annotation name, if
- // - the annotation field has an empty annotation name or
- // - the annotation mark's name differs (on mark creation a name clash had been detected)
- if ( pPostItField->GetName().isEmpty()
- || pPostItField->GetName() != GetName() )
- {
- const_cast<SwPostItField*>(pPostItField)->SetName( GetName() );
- }
- }
+ const_cast<SwPostItField*>(pPostItField)->SetName( GetName() );
}
if (io_pDoc->GetIDocumentUndoRedo().DoesUndo())
@@ -84,11 +77,7 @@ namespace sw { namespace mark
const SwFormatField* AnnotationMark::GetAnnotationFormatField() const
{
SwDoc* pDoc = GetMarkPos().GetDoc();
- if ( pDoc == nullptr )
- {
- OSL_ENSURE( false, "<AnnotationMark::GetAnnotationFormatField()> - missing document at annotation mark" );
- return nullptr;
- }
+ assert(pDoc != nullptr);
SwFormatField* pAnnotationFormatField = nullptr;
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 7ea1692dd559..68030bbb2955 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -918,15 +918,9 @@ namespace sw { namespace mark
case IDocumentMarkAccess::MarkType::ANNOTATIONMARK:
{
IDocumentMarkAccess::iterator_t ppAnnotationMark = lcl_FindMark(m_vAnnotationMarks, *ppMark);
- if ( ppAnnotationMark != m_vAnnotationMarks.end() )
- {
- m_vAnnotationMarks.erase(ppAnnotationMark);
- }
- else
- {
- assert(false &&
- "<MarkManager::deleteMark(..)> - Annotation Mark not found in Annotation Mark container.");
- }
+ assert(ppAnnotationMark != m_vAnnotationMarks.end() &&
+ "<MarkManager::deleteMark(..)> - Annotation Mark not found in Annotation Mark container.");
+ m_vAnnotationMarks.erase(ppAnnotationMark);
}
break;
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index de3817eeece9..4beca6d098c6 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -618,18 +618,10 @@ SwTextAnnotationField::~SwTextAnnotationField()
::sw::mark::IMark* SwTextAnnotationField::GetAnnotationMark() const
{
const SwPostItField* pPostItField = dynamic_cast<const SwPostItField*>(GetFormatField().GetField());
- OSL_ENSURE( pPostItField != nullptr, "<SwTextAnnotationField::GetAnnotationMark()> - field missing" );
- if ( pPostItField == nullptr )
- {
- return nullptr;
- }
+ assert(pPostItField != nullptr);
SwDoc* pDoc = static_cast<const SwPostItFieldType*>(pPostItField->GetTyp())->GetDoc();
- OSL_ENSURE( pDoc != nullptr, "<SwTextAnnotationField::GetAnnotationMark()> - missing document" );
- if ( pDoc == nullptr )
- {
- return nullptr;
- }
+ assert(pDoc != nullptr);
IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
IDocumentMarkAccess::const_iterator_t pMark = pMarksAccess->findAnnotationMark( pPostItField->GetName() );
diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx
index 3e8828c51319..fa2d6d0173a7 100644
--- a/sw/source/core/unocore/unoportenum.cxx
+++ b/sw/source/core/unocore/unoportenum.cxx
@@ -297,15 +297,12 @@ namespace
if ( rStartPos.nNode == nOwnNode )
{
const SwFormatField* pAnnotationFormatField = pAnnotationMark->GetAnnotationFormatField();
- OSL_ENSURE( pAnnotationFormatField != nullptr, "<lcl_FillAnnotationStartArray(..)> - annotation fmt fld instance missing!" );
- if ( pAnnotationFormatField != nullptr )
- {
- rAnnotationStartArr.insert(
- std::make_shared<SwAnnotationStartPortion_Impl>(
- SwXTextField::CreateXTextField(&rDoc,
- pAnnotationFormatField),
- rStartPos));
- }
+ assert(pAnnotationFormatField != nullptr);
+ rAnnotationStartArr.insert(
+ std::make_shared<SwAnnotationStartPortion_Impl>(
+ SwXTextField::CreateXTextField(&rDoc,
+ pAnnotationFormatField),
+ rStartPos));
}
}
}