summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-07-06 23:21:51 +0200
committerMichael Stahl <mstahl@redhat.com>2017-07-07 13:48:29 +0200
commit0a710a098e65a5e83c1ea47d5bdc1b56ef48f314 (patch)
tree8552401dc826127c567f1bf178bd21b12380df0d /sw
parentc113d386888152632ae26fae9f59faf4f1d2f2dc (diff)
sw: convert SwTextInputField OSL_ENSUREs to assert() and simplify
Change-Id: I86df59e4b77d2ddc479144f32342113a6e29a725
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/txtfld.hxx3
-rw-r--r--sw/source/core/crsr/crstrvl.cxx14
-rw-r--r--sw/source/core/txtnode/atrfld.cxx23
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx2
-rw-r--r--sw/source/core/txtnode/thints.cxx25
5 files changed, 24 insertions, 43 deletions
diff --git a/sw/inc/txtfld.hxx b/sw/inc/txtfld.hxx
index e389b4725ad8..edd23e06c736 100644
--- a/sw/inc/txtfld.hxx
+++ b/sw/inc/txtfld.hxx
@@ -24,6 +24,7 @@
#include <osl/diagnose.h>
#include <memory>
+#include <cassert>
class SwPaM;
class SwTextNode;
@@ -52,7 +53,7 @@ public:
}
SwTextNode& GetTextNode() const
{
- OSL_ENSURE( m_pTextNode, "SwTextField:: where is my TextNode?" );
+ assert(m_pTextNode);
return *m_pTextNode;
}
void ChgTextNode( SwTextNode* pNew )
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index d96f2729dd14..7df6263076c2 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -892,22 +892,16 @@ bool SwCursorShell::DocPtInsideInputField( const Point& rDocPt ) const
sal_Int32 SwCursorShell::StartOfInputFieldAtPos( const SwPosition& rPos )
{
const SwTextInputField* pTextInputField = dynamic_cast<const SwTextInputField*>(GetTextFieldAtPos( &rPos, true ));
- if ( pTextInputField == nullptr )
- {
- OSL_ENSURE( false, "<SwEditShell::StartOfInputFieldAtPos(..)> - no Input Field at given position" );
- return 0;
- }
+ assert(pTextInputField != nullptr
+ && "<SwEditShell::StartOfInputFieldAtPos(..)> - no Input Field at given position");
return pTextInputField->GetStart();
}
sal_Int32 SwCursorShell::EndOfInputFieldAtPos( const SwPosition& rPos )
{
const SwTextInputField* pTextInputField = dynamic_cast<const SwTextInputField*>(GetTextFieldAtPos( &rPos, true ));
- if ( pTextInputField == nullptr )
- {
- OSL_ENSURE( false, "<SwEditShell::EndOfInputFieldAtPos(..)> - no Input Field at given position" );
- return 0;
- }
+ assert(pTextInputField != nullptr
+ && "<SwEditShell::EndOfInputFieldAtPos(..)> - no Input Field at given position");
return *(pTextInputField->End());
}
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index 136955fdcad5..de3817eeece9 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -568,7 +568,7 @@ void SwTextInputField::UpdateFieldContent()
if ( IsFieldInDoc()
&& GetStart() != (*End()) )
{
- OSL_ENSURE( (*End()) - GetStart() >= 2,
+ assert( (*End()) - GetStart() >= 2 &&
"<SwTextInputField::UpdateFieldContent()> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
// skip CH_TXT_ATR_INPUTFIELDSTART character
const sal_Int32 nIdx = GetStart() + 1;
@@ -577,26 +577,19 @@ void SwTextInputField::UpdateFieldContent()
const OUString aNewFieldContent = GetTextNode().GetExpandText( nIdx, nLen );
const SwInputField* pInputField = dynamic_cast<const SwInputField*>(GetFormatField().GetField());
- OSL_ENSURE( pInputField != nullptr,
- "<SwTextInputField::GetContent()> - Missing <SwInputField> instance!" );
- if ( pInputField != nullptr )
- {
- const_cast<SwInputField*>(pInputField)->applyFieldContent( aNewFieldContent );
- // trigger update of fields for scenarios in which the Input Field's content is part of e.g. a table formula
- GetTextNode().GetDoc()->getIDocumentFieldsAccess().GetUpdateFields().SetFieldsDirty(true);
- }
+ assert(pInputField != nullptr);
+ const_cast<SwInputField*>(pInputField)->applyFieldContent( aNewFieldContent );
+ // trigger update of fields for scenarios in which the Input Field's content is part of e.g. a table formula
+ GetTextNode().GetDoc()->getIDocumentFieldsAccess().GetUpdateFields().SetFieldsDirty(true);
}
}
void SwTextInputField::UpdateTextNodeContent( const OUString& rNewContent )
{
- if ( !IsFieldInDoc() )
- {
- OSL_ENSURE( false, "<SwTextInputField::UpdateTextNodeContent(..)> - misusage as Input Field is not in document content." );
- return;
- }
+ assert(IsFieldInDoc() &&
+ "<SwTextInputField::UpdateTextNodeContent(..)> - misusage as Input Field is not in document content.");
- OSL_ENSURE( (*End()) - GetStart() >= 2,
+ assert( (*End()) - GetStart() >= 2 &&
"<SwTextInputField::UpdateTextNodeContent(..)> - Are CH_TXT_ATR_INPUTFIELDSTART and/or CH_TXT_ATR_INPUTFIELDEND missing?" );
// skip CH_TXT_ATR_INPUTFIELDSTART character
const sal_Int32 nIdx = GetStart() + 1;
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 7cb4099f1b53..ce5c84fddf61 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1818,7 +1818,7 @@ void SwTextNode::CopyText( SwTextNode *const pDest,
// Input Fields are only copied, if completely covered by copied text
if ( nWhich == RES_TXTATR_INPUTFIELD )
{
- OSL_ENSURE( pEndIdx != nullptr,
+ assert(pEndIdx != nullptr &&
"<SwTextNode::CopyText(..)> - RES_TXTATR_INPUTFIELD without EndIndex!" );
if ( nAttrStartIdx < nTextStartIdx
|| ( pEndIdx != nullptr
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 8aefa0d6077e..fe3e05037dec 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1497,12 +1497,9 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode )
InsertText( aContent, aIdx, nInsertFlags );
sal_Int32* const pEnd(pAttr->GetEnd());
- OSL_ENSURE( pEnd != nullptr, "<SwTextNode::InsertHint(..)> - missing end of RES_TXTATR_INPUTFIELD!" );
- if ( pEnd != nullptr )
- {
- *pEnd = *pEnd + aContent.getLength();
- nEnd = *pEnd;
- }
+ assert(pEnd != nullptr);
+ *pEnd = *pEnd + aContent.getLength();
+ nEnd = *pEnd;
}
else
{
@@ -1513,18 +1510,14 @@ bool SwTextNode::InsertHint( SwTextAttr * const pAttr, const SetAttrMode nMode )
InsertText( OUString(CH_TXT_ATR_INPUTFIELDSTART), aIdx, nInsertFlags );
bInputFieldStartCharInserted = true;
sal_Int32* const pEnd(pAttr->GetEnd());
- OSL_ENSURE( pEnd != nullptr, "<SwTextNode::InsertHint(..)> - missing end of RES_TXTATR_INPUTFIELD!" );
- if ( pEnd != nullptr )
- {
- *pEnd = *pEnd + 1;
- nEnd = *pEnd;
- }
+ assert(pEnd != nullptr);
+ *pEnd = *pEnd + 1;
+ nEnd = *pEnd;
}
sal_Int32* const pEnd(pAttr->GetEnd());
- OSL_ENSURE( pEnd != nullptr, "<SwTextNode::InsertHint(..)> - missing end of RES_TXTATR_INPUTFIELD!" );
- if ( pEnd != nullptr
- && m_Text[ *(pEnd) - 1 ] != CH_TXT_ATR_INPUTFIELDEND )
+ assert(pEnd != nullptr);
+ if (m_Text[ *(pEnd) - 1 ] != CH_TXT_ATR_INPUTFIELDEND)
{
SwIndex aIdx( this, *(pEnd) );
InsertText( OUString(CH_TXT_ATR_INPUTFIELDEND), aIdx, nInsertFlags );
@@ -1637,7 +1630,7 @@ void SwTextNode::DeleteAttribute( SwTextAttr * const pAttr )
else if ( pAttr->HasContent() )
{
const SwIndex aIdx( this, pAttr->GetStart() );
- OSL_ENSURE( pAttr->End() != nullptr, "<SwTextNode::DeleteAttribute(..)> - missing End() at <SwTextAttr> instance which has content" );
+ assert(pAttr->End() != nullptr);
EraseText( aIdx, *pAttr->End() - pAttr->GetStart() );
}
else