summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2016-08-08 10:32:31 +0200
committerJan Holesovsky <kendy@collabora.com>2016-08-24 22:27:10 +0200
commite139edfa1df7e7353b420be20d298fd2882d9289 (patch)
tree3f995b9a815e788940aa0118ad87e13cd121a0d9 /sw
parent28f9dec5be1420a6523a7a4f8396c43933b9c5c1 (diff)
Simplify dynamic_cast followed by a static_cast.
Change-Id: I258906a66f83f5b9b63bd034a22bad3648117819
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/docvw/edtwin3.cxx59
-rw-r--r--sw/source/uibase/docvw/srcedtw.cxx8
-rw-r--r--sw/source/uibase/ribbar/conrect.cxx21
3 files changed, 49 insertions, 39 deletions
diff --git a/sw/source/uibase/docvw/edtwin3.cxx b/sw/source/uibase/docvw/edtwin3.cxx
index 52c56de46ecb..b059ca314ea2 100644
--- a/sw/source/uibase/docvw/edtwin3.cxx
+++ b/sw/source/uibase/docvw/edtwin3.cxx
@@ -40,47 +40,51 @@
void ScrollMDI( SwViewShell* pVwSh, const SwRect &rRect,
sal_uInt16 nRangeX, sal_uInt16 nRangeY)
{
- SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
- if (pSfxVwSh && dynamic_cast< const SwView *>( pSfxVwSh ) != nullptr)
- static_cast<SwView *>(pSfxVwSh)->Scroll( rRect.SVRect(), nRangeX, nRangeY );
+ SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+ if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
+ pSwView->Scroll(rRect.SVRect(), nRangeX, nRangeY);
}
// Docmdi - movable
bool IsScrollMDI( SwViewShell* pVwSh, const SwRect &rRect )
{
- SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
- if (pSfxVwSh && dynamic_cast< const SwView *>( pSfxVwSh ) != nullptr)
- return static_cast<SwView *>(pSfxVwSh)->IsScroll(rRect.SVRect());
+ SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+ if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
+ return pSwView->IsScroll(rRect.SVRect());
+
return false;
}
// Notify for size change
void SizeNotify(SwViewShell* pVwSh, const Size &rSize)
{
- SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
- if (pSfxVwSh)
- {
- if (dynamic_cast< const SwView *>( pSfxVwSh ) != nullptr)
- static_cast<SwView *>(pSfxVwSh)->DocSzChgd(rSize);
- else if (dynamic_cast< const SwPagePreview *>( pSfxVwSh ) != nullptr)
- static_cast<SwPagePreview *>(pSfxVwSh)->DocSzChgd( rSize );
- }
+ SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+ if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
+ pSwView->DocSzChgd(rSize);
+ else if (SwPagePreview* pSwPageView = dynamic_cast<SwPagePreview *>(pSfxViewShell))
+ pSwPageView->DocSzChgd(rSize);
}
// Notify for page number update
void PageNumNotify( SwViewShell* pVwSh, sal_uInt16 nPhyNum, sal_uInt16 nVirtNum,
const OUString& rPgStr)
{
- SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
- if ( pSfxVwSh && dynamic_cast< const SwView *>( pSfxVwSh ) != nullptr &&
- static_cast<SwView*>(pSfxVwSh)->GetCurShell() )
- static_cast<SwView *>(pSfxVwSh)->UpdatePageNums(nPhyNum, nVirtNum, rPgStr);
+ SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+ if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
+ {
+ if (pSwView->GetCurShell())
+ pSwView->UpdatePageNums(nPhyNum, nVirtNum, rPgStr);
+ }
}
void FrameNotify( SwViewShell* pVwSh, FlyMode eMode )
{
- if ( dynamic_cast< const SwCursorShell *>( pVwSh ) != nullptr )
- SwBaseShell::SetFrameMode( eMode, static_cast<SwWrtShell*>(pVwSh) );
+ if (SwWrtShell* pWrtShell = dynamic_cast<SwWrtShell *>(pVwSh))
+ SwBaseShell::SetFrameMode(eMode, pWrtShell);
}
// Notify for page number update
@@ -110,16 +114,19 @@ TableChgMode GetTableChgDefaultMode()
void RepaintPagePreview( SwViewShell* pVwSh, const SwRect& rRect )
{
- SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
- if (pSfxVwSh && dynamic_cast< const SwPagePreview *>( pSfxVwSh ) != nullptr)
- static_cast<SwPagePreview *>(pSfxVwSh)->RepaintCoreRect( rRect );
+ SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+ if (SwPagePreview* pSwPagePreview = dynamic_cast<SwPagePreview *>(pSfxViewShell))
+ pSwPagePreview->RepaintCoreRect(rRect);
}
bool JumpToSwMark( SwViewShell* pVwSh, const OUString& rMark )
{
- SfxViewShell *pSfxVwSh = pVwSh->GetSfxViewShell();
- if( pSfxVwSh && dynamic_cast< const SwView *>( pSfxVwSh ) != nullptr )
- return static_cast<SwView *>(pSfxVwSh)->JumpToSwMark( rMark );
+ SfxViewShell *pSfxViewShell = pVwSh->GetSfxViewShell();
+
+ if (SwView* pSwView = dynamic_cast<SwView *>(pSfxViewShell))
+ return pSwView->JumpToSwMark(rMark);
+
return false;
}
diff --git a/sw/source/uibase/docvw/srcedtw.cxx b/sw/source/uibase/docvw/srcedtw.cxx
index 749d53ceab9f..09741aa7e17d 100644
--- a/sw/source/uibase/docvw/srcedtw.cxx
+++ b/sw/source/uibase/docvw/srcedtw.cxx
@@ -742,11 +742,11 @@ void SwSrcEditWindow::ImpDoHighlight( const OUString& rSource, sal_uInt16 nLineO
void SwSrcEditWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
{
- if ( !dynamic_cast<const TextHint*>(&rHint) )
+ const TextHint* pTextHint = dynamic_cast<const TextHint*>(&rHint);
+ if (!pTextHint)
return;
- const TextHint& rTextHint = static_cast<const TextHint&>(rHint);
- switch (rTextHint.GetId())
+ switch (pTextHint->GetId())
{
case TEXT_HINT_VIEWSCROLLED:
m_pHScrollbar->SetThumbPos( m_pTextView->GetStartDocPos().X() );
@@ -762,7 +762,7 @@ void SwSrcEditWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
case TEXT_HINT_PARAINSERTED:
case TEXT_HINT_PARACONTENTCHANGED:
- DoDelayedSyntaxHighlight( (sal_uInt16)rTextHint.GetValue() );
+ DoDelayedSyntaxHighlight(static_cast<sal_uInt16>(pTextHint->GetValue()));
break;
}
}
diff --git a/sw/source/uibase/ribbar/conrect.cxx b/sw/source/uibase/ribbar/conrect.cxx
index 9966394a04d8..14465603fcca 100644
--- a/sw/source/uibase/ribbar/conrect.cxx
+++ b/sw/source/uibase/ribbar/conrect.cxx
@@ -95,20 +95,23 @@ bool ConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
pObj->SetMergedItemSetAndBroadcast(aItemSet);
}
}
- else if(mbVertical && pObj && dynamic_cast< const SdrTextObj *>( pObj ) != nullptr)
+ else if(mbVertical)
{
- SdrTextObj* pText = static_cast<SdrTextObj*>(pObj);
- SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
+ if (SdrTextObj* pText = dynamic_cast<SdrTextObj*>(pObj))
+ {
+ SfxItemSet aSet(pSdrView->GetModel()->GetItemPool());
- pText->SetVerticalWriting(true);
+ pText->SetVerticalWriting(true);
- aSet.Put(makeSdrTextAutoGrowWidthItem(true));
- aSet.Put(makeSdrTextAutoGrowHeightItem(false));
- aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
- aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
+ aSet.Put(makeSdrTextAutoGrowWidthItem(true));
+ aSet.Put(makeSdrTextAutoGrowHeightItem(false));
+ aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
+ aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
- pText->SetMergedItemSet(aSet);
+ pText->SetMergedItemSet(aSet);
+ }
}
+
if( pObj )
{
SdrPageView* pPV = pSdrView->GetSdrPageView();