[Libreoffice-commits] core.git: sw/source
Stephan Bergmann
sbergman at redhat.com
Thu Aug 21 06:07:10 PDT 2014
sw/source/core/docnode/node.cxx | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
New commits:
commit de6fd1b90f6ab41b93bc15f2feb72ef0e3eb70c2
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Aug 21 15:06:16 2014 +0200
Avoid invalid downcasts to SwFmtHeader instead of SwFmtFooter
...which only happened to work because the two classes have very similar layout
Change-Id: Ie4bde807a2442a95ff515b065d4f45f257a32f34
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index ed224d4..bfb6d2c 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -609,12 +609,14 @@ const SwPageDesc* SwNode::FindPageDesc( bool bCalcLay,
for( ; nStt < nLast; ++nStt, pFmt = &rPgDsc.GetLeft() )
{
- const SwFmtHeader& rHdFt = (SwFmtHeader&)
- pFmt->GetFmtAttr( nId );
- if( rHdFt.GetHeaderFmt() )
+ const SwFrmFmt * pHdFtFmt = nId == RES_HEADER
+ ? static_cast<SwFmtHeader const &>(
+ pFmt->GetFmtAttr(nId)).GetHeaderFmt()
+ : static_cast<SwFmtFooter const &>(
+ pFmt->GetFmtAttr(nId)).GetFooterFmt();
+ if( pHdFtFmt )
{
- const SwFmtCntnt& rCntnt =
- rHdFt.GetHeaderFmt()->GetCntnt();
+ const SwFmtCntnt& rCntnt = pHdFtFmt->GetCntnt();
if( rCntnt.GetCntntIdx() &&
&rCntnt.GetCntntIdx()->GetNode() ==
(SwNode*)pSttNd )
More information about the Libreoffice-commits
mailing list