diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-11-14 09:56:50 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-11-14 12:02:45 +0000 |
commit | 0332e3a8e968f9f85b40405391120d2f5949fbd2 (patch) | |
tree | 5bb1c10ed24f64d1d3d2a183dd6903c7dafe8f62 /lotuswordpro/source | |
parent | 792b127d5ceb397c5fb280cadd80972e1693e9ec (diff) |
coverity#738972 Use after free
Change-Id: Iba60fc4ff3b10179ebc700467a3d73e7bc7b64c9
Diffstat (limited to 'lotuswordpro/source')
24 files changed, 121 insertions, 100 deletions
diff --git a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx index 992a16dd1f8b..c71cf1594a86 100644 --- a/lotuswordpro/source/filter/lwpbulletstylemgr.cxx +++ b/lotuswordpro/source/filter/lwpbulletstylemgr.cxx @@ -186,7 +186,7 @@ OUString LwpBulletStyleMgr::RegisterBulletStyle(LwpPara* pPara, LwpBulletOverrid } } - aStyleName = pXFStyleMgr->AddStyle(pListStyle)->GetStyleName(); + aStyleName = (pXFStyleMgr->AddStyle(pListStyle)).m_pStyle->GetStyleName(); } else { @@ -242,7 +242,7 @@ OUString LwpBulletStyleMgr::RegisterBulletStyle(LwpPara* pPara, LwpBulletOverrid pListStyle->SetListPosition(nPos, 0.0, 0.635, 0.0); } - aStyleName = pXFStyleMgr->AddStyle(pListStyle)->GetStyleName(); + aStyleName = (pXFStyleMgr->AddStyle(pListStyle)).m_pStyle->GetStyleName(); } else delete pListStyle; diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx index 6510ccb5660b..39717cd1d45c 100644 --- a/lotuswordpro/source/filter/lwpcelllayout.cxx +++ b/lotuswordpro/source/filter/lwpcelllayout.cxx @@ -283,7 +283,7 @@ void LwpCellLayout::ApplyFmtStyle(XFCellStyle *pCellStyle) if (pStyle) { XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_NumfmtName = pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + m_NumfmtName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); pCellStyle->SetDataStyle(m_NumfmtName); } } @@ -559,7 +559,7 @@ void LwpCellLayout::RegisterDefaultCell() } pCellStyle->SetBorders(pBorders); } - m_CellStyleNames[eLoop] = pXFStyleManager->AddStyle(pCellStyle)->GetStyleName(); + m_CellStyleNames[eLoop] = (pXFStyleManager->AddStyle(pCellStyle)).m_pStyle->GetStyleName(); } } /** @@ -583,7 +583,6 @@ void LwpCellLayout::RegisterStyle() XFCellStyle *pCellStyle = new XFCellStyle(); ApplyPadding(pCellStyle); -// ApplyBackColor(pCellStyle); ApplyBackGround(pCellStyle); ApplyWatermark(pCellStyle); ApplyFmtStyle(pCellStyle); @@ -592,7 +591,7 @@ void LwpCellLayout::RegisterStyle() pCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType()); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pCellStyle)->GetStyleName(); + m_StyleName = (pXFStyleManager->AddStyle(pCellStyle)).m_pStyle->GetStyleName(); // content object register styles rtl::Reference<LwpObject> pObj = m_Content.obj(); diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx b/lotuswordpro/source/filter/lwpdrawobj.cxx index 2ca16adec056..1563f3dd4c8c 100644 --- a/lotuswordpro/source/filter/lwpdrawobj.cxx +++ b/lotuswordpro/source/filter/lwpdrawobj.cxx @@ -446,7 +446,7 @@ OUString LwpDrawLine::RegisterStyle() this->SetArrowHead(pStyle, m_aLineRec.nLineEnd, m_aLineRec.nLineWidth); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - return pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + return (pXFStyleManager->AddStyle(pStyle)).m_pStyle->GetStyleName(); } @@ -529,7 +529,7 @@ OUString LwpDrawPolyLine::RegisterStyle() this->SetArrowHead(pStyle, m_aPolyLineRec.nLineEnd, m_aPolyLineRec.nLineWidth); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - return pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } XFFrame* LwpDrawPolyLine::CreateDrawObj(const OUString& rStyleName ) @@ -615,7 +615,7 @@ OUString LwpDrawPolygon::RegisterStyle() this->SetFillStyle(pStyle); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - return pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } XFFrame* LwpDrawPolygon::CreateDrawObj(const OUString& rStyleName) @@ -695,7 +695,7 @@ OUString LwpDrawRectangle::RegisterStyle() this->SetFillStyle(pStyle); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - return pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } XFFrame* LwpDrawRectangle::CreateDrawObj(const OUString& rStyleName) @@ -854,7 +854,7 @@ OUString LwpDrawEllipse::RegisterStyle() this->SetFillStyle(pStyle); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - return pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } XFFrame* LwpDrawEllipse::CreateDrawObj(const OUString& rStyleName ) @@ -933,7 +933,7 @@ OUString LwpDrawArc::RegisterStyle() this->SetArrowHead(pStyle, m_aArcRec.nLineEnd, m_aArcRec.nLineWidth); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - return pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } XFFrame* LwpDrawArc::CreateDrawObj(const OUString& rStyleName ) @@ -1083,7 +1083,7 @@ OUString LwpDrawTextBox::RegisterStyle() pStyle->SetFont(pFont); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - return pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } XFFrame* LwpDrawTextBox::CreateDrawObj(const OUString& rStyleName ) @@ -1112,7 +1112,7 @@ XFFrame* LwpDrawTextBox::CreateDrawObj(const OUString& rStyleName ) XFTextBoxStyle* pBoxStyle = new XFTextBoxStyle(); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - OUString sName = pXFStyleManager->AddStyle(pBoxStyle)->GetStyleName(); + OUString sName = pXFStyleManager->AddStyle(pBoxStyle).m_pStyle->GetStyleName(); pTextBox->SetStyleName(sName); //todo: add the interface for rotating textbox @@ -1288,7 +1288,7 @@ OUString LwpDrawTextArt::RegisterStyle() pStyle->SetFont(pFont); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - return pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + return pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } XFFrame* LwpDrawTextArt::CreateDrawObj(const OUString& rStyleName) @@ -1320,7 +1320,7 @@ XFFrame* LwpDrawTextArt::CreateDrawObj(const OUString& rStyleName) pRetObj->Add(pXFPara); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - pRetObj->SetStyleName(pXFStyleManager->AddStyle(pStyle)->GetStyleName()); + pRetObj->SetStyleName(pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName()); return pRetObj; } @@ -1486,7 +1486,7 @@ OUString LwpDrawBitmap::RegisterStyle() pBmpStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - return pXFStyleManager->AddStyle(pBmpStyle)->GetStyleName(); + return pXFStyleManager->AddStyle(pBmpStyle).m_pStyle->GetStyleName(); } XFFrame* LwpDrawBitmap::CreateDrawObj(const OUString& rStyleName) diff --git a/lotuswordpro/source/filter/lwpfoundry.cxx b/lotuswordpro/source/filter/lwpfoundry.cxx index 8e19cf05b975..04fa6f387ba6 100644 --- a/lotuswordpro/source/filter/lwpfoundry.cxx +++ b/lotuswordpro/source/filter/lwpfoundry.cxx @@ -530,7 +530,7 @@ IXFStyle* LwpStyleManager::AddStyle(LwpObjectID styleObjID, IXFStyle* pStyle) assert(pStyle); //pStyle may change if same style is found in XFStyleManager XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - pStyle = pXFStyleManager->AddStyle(pStyle); + pStyle = pXFStyleManager->AddStyle(pStyle).m_pStyle; m_StyleList.insert(LwpStyleMap::value_type(styleObjID, pStyle)); return pStyle; } diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx index 5edc34d94b2e..61325da000b0 100644 --- a/lotuswordpro/source/filter/lwpframelayout.cxx +++ b/lotuswordpro/source/filter/lwpframelayout.cxx @@ -103,7 +103,7 @@ void LwpFrame::RegisterStyle(XFFrameStyle* pFrameStyle) pFrameStyle->SetStyleName(m_pLayout->GetName().str()); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pFrameStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pFrameStyle).m_pStyle->GetStyleName(); m_pLayout->SetStyleName(m_StyleName); } /** @@ -1270,7 +1270,7 @@ void LwpRubyLayout::RegisterStyle() pRubyStyle->SetPosition(eType); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - OUString rubyStyle = pXFStyleManager->AddStyle(pRubyStyle)->GetStyleName(); + OUString rubyStyle = pXFStyleManager->AddStyle(pRubyStyle).m_pStyle->GetStyleName(); pMarker->SetRubyStyleName(rubyStyle); LwpStory* pStory = GetContentStory(); diff --git a/lotuswordpro/source/filter/lwpfrib.cxx b/lotuswordpro/source/filter/lwpfrib.cxx index 61d5324a224c..ea90d087c097 100644 --- a/lotuswordpro/source/filter/lwpfrib.cxx +++ b/lotuswordpro/source/filter/lwpfrib.cxx @@ -259,9 +259,10 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry) pStyle->SetStyleName(""); pFont = pFoundry->GetFontManger().CreateOverrideFont(pCharStyle->GetFinalFontID(),m_pModifiers->FontID); pStyle->SetFont(pFont); - IXFStyle *pNewStyle = pXFStyleManager->AddStyle(pStyle); + IXFStyleRet aNewStyle = pXFStyleManager->AddStyle(pStyle); + IXFStyle *pNewStyle = aNewStyle.m_pStyle; m_StyleName = pNewStyle->GetStyleName(); - if (pNewStyle != pStyle) + if (aNewStyle.m_bOrigDeleted) pStyle = NULL; } else @@ -274,9 +275,10 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry) pStyle = new XFTextStyle(); pFont = pFoundry->GetFontManger().CreateFont(m_pModifiers->FontID); pStyle->SetFont(pFont); - IXFStyle *pNewStyle = pXFStyleManager->AddStyle(pStyle); + IXFStyleRet aNewStyle = pXFStyleManager->AddStyle(pStyle); + IXFStyle *pNewStyle = aNewStyle.m_pStyle; m_StyleName = pNewStyle->GetStyleName(); - if (pNewStyle != pStyle) + if (aNewStyle.m_bOrigDeleted) pStyle = NULL; } } @@ -302,7 +304,7 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry) pFont->SetBackColor(aColor); pStyle->SetFont(pFont); } - m_StyleName = pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } } } diff --git a/lotuswordpro/source/filter/lwpfribbreaks.cxx b/lotuswordpro/source/filter/lwpfribbreaks.cxx index 43fc58575e6f..eaaf91953e09 100644 --- a/lotuswordpro/source/filter/lwpfribbreaks.cxx +++ b/lotuswordpro/source/filter/lwpfribbreaks.cxx @@ -102,7 +102,7 @@ void LwpFribColumnBreak::RegisterBreakStyle(LwpPara * pPara) pOverStyle->SetBreaks(enumXFBreakBefColumn); } XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName(); } LwpFribPageBreak::LwpFribPageBreak( LwpPara* pPara ) @@ -153,7 +153,7 @@ void LwpFribPageBreak::RegisterBreakStyle(LwpPara* pPara) pOverStyle->SetBreaks(enumXFBreakBefPage); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName(); } void LwpFribPageBreak::ParseLayout() diff --git a/lotuswordpro/source/filter/lwpfribframe.cxx b/lotuswordpro/source/filter/lwpfribframe.cxx index 8eed873f2431..fc16cfd106a7 100644 --- a/lotuswordpro/source/filter/lwpfribframe.cxx +++ b/lotuswordpro/source/filter/lwpfribframe.cxx @@ -123,7 +123,7 @@ void LwpFribFrame::RegisterStyle(LwpFoundry* pFoundry) XFParaStyle* pParaStyle = new XFParaStyle; *pParaStyle = *(pOldStyle); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pParaStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pParaStyle).m_pStyle->GetStyleName(); } } //remember the current paragraph font size which will be used in parsing frame diff --git a/lotuswordpro/source/filter/lwpfribmark.cxx b/lotuswordpro/source/filter/lwpfribmark.cxx index b9d4658babc4..430d7e56b3b9 100644 --- a/lotuswordpro/source/filter/lwpfribmark.cxx +++ b/lotuswordpro/source/filter/lwpfribmark.cxx @@ -408,7 +408,7 @@ void LwpFribField::RegisterTotalTimeStyle() pTimeStyle->SetTruncate(false); pTimeStyle->AddMinute(); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle)->GetStyleName(); + m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle).m_pStyle->GetStyleName(); } void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula) @@ -1179,9 +1179,9 @@ void LwpFribField::RegisterDateTimeStyle(const OUString& sFormula) } XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); if (pDateStyle) - m_TimeStyle = pXFStyleManager->AddStyle(pDateStyle)->GetStyleName(); + m_TimeStyle = pXFStyleManager->AddStyle(pDateStyle).m_pStyle->GetStyleName(); if (pTimeStyle) - m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle)->GetStyleName(); + m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle).m_pStyle->GetStyleName(); } void LwpFribField::CheckFieldType(LwpFieldMark* pFieldMark) diff --git a/lotuswordpro/source/filter/lwpfribsection.cxx b/lotuswordpro/source/filter/lwpfribsection.cxx index 388f9307343c..f66b00f9b509 100644 --- a/lotuswordpro/source/filter/lwpfribsection.cxx +++ b/lotuswordpro/source/filter/lwpfribsection.cxx @@ -310,7 +310,7 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib) m_pPara->RegisterTabStyle(pOverStyle); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName(); //register section style here if(m_bNewSection) { @@ -335,7 +335,7 @@ bool LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib) pSectStyle->SetColumns(pColumns); } //} - m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle)->GetStyleName(); + m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle).m_pStyle->GetStyleName(); } return false; } @@ -447,7 +447,7 @@ void LwpMasterPage::RegisterFillerPageStyle() pPagebreakStyle->SetStyleName(""); pPagebreakStyle->SetBreaks(enumXFBreakAftPage); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_FillerPageStyleName= pXFStyleManager->AddStyle(pPagebreakStyle)->GetStyleName(); + m_FillerPageStyleName= pXFStyleManager->AddStyle(pPagebreakStyle).m_pStyle->GetStyleName(); } } } diff --git a/lotuswordpro/source/filter/lwpfribtable.cxx b/lotuswordpro/source/filter/lwpfribtable.cxx index 500e44e3569c..edd73dae7e7d 100644 --- a/lotuswordpro/source/filter/lwpfribtable.cxx +++ b/lotuswordpro/source/filter/lwpfribtable.cxx @@ -89,7 +89,7 @@ void LwpFribTable::RegisterNewStyle() XFParaStyle* pParaStyle = new XFParaStyle; *pParaStyle = *(pOldStyle); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pParaStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pParaStyle).m_pStyle->GetStyleName(); } } } diff --git a/lotuswordpro/source/filter/lwpfribtext.cxx b/lotuswordpro/source/filter/lwpfribtext.cxx index 31579ac916b4..42da9cddd01a 100644 --- a/lotuswordpro/source/filter/lwpfribtext.cxx +++ b/lotuswordpro/source/filter/lwpfribtext.cxx @@ -205,7 +205,7 @@ void LwpFribDocVar::RegisterDefaultTimeStyle() pDateStyle->AddSecond(true,0); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_TimeStyle = pXFStyleManager->AddStyle(pDateStyle)->GetStyleName(); + m_TimeStyle = pXFStyleManager->AddStyle(pDateStyle).m_pStyle->GetStyleName(); } void LwpFribDocVar::RegisterTotalTimeStyle() { @@ -213,7 +213,7 @@ void LwpFribDocVar::RegisterTotalTimeStyle() pTimeStyle->SetTruncate(false); pTimeStyle->AddMinute(); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle)->GetStyleName(); + m_TimeStyle = pXFStyleManager->AddStyle(pTimeStyle).m_pStyle->GetStyleName(); } /** diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx index a4db19a9539e..4c9f3ced3b48 100644 --- a/lotuswordpro/source/filter/lwpgrfobj.cxx +++ b/lotuswordpro/source/filter/lwpgrfobj.cxx @@ -284,7 +284,7 @@ void LwpGraphicObject::RegisterStyle() pXFFrameStyle->SetXPosType(enumXFFrameXPosFromLeft, enumXFFrameXRelFrame); pXFFrameStyle->SetYPosType(enumXFFrameYPosFromTop, enumXFFrameYRelPara); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_strStyleName = pXFStyleManager->AddStyle(pXFFrameStyle)->GetStyleName(); + m_strStyleName = pXFStyleManager->AddStyle(pXFFrameStyle).m_pStyle->GetStyleName(); } } @@ -647,7 +647,7 @@ void LwpGraphicObject::CreateGrafObject() // set style for the image XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - pImage->SetStyleName(pXFStyleManager->AddStyle(pImageStyle)->GetStyleName()); + pImage->SetStyleName(pXFStyleManager->AddStyle(pImageStyle).m_pStyle->GetStyleName()); // set archor to frame pImage->SetAnchorType(enumXFAnchorFrame); diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx index 865e4d43eefb..ad75b8847814 100644 --- a/lotuswordpro/source/filter/lwppagelayout.cxx +++ b/lotuswordpro/source/filter/lwppagelayout.cxx @@ -338,14 +338,14 @@ void LwpPageLayout::RegisterStyle() //Add the page master to stylemanager XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_pXFPageMaster = pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1)); + m_pXFPageMaster = pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1).m_pStyle); OUString pmname = pm1->GetStyleName(); //Add master page XFMasterPage* mp1 = new XFMasterPage(); mp1->SetStyleName(GetName().str()); mp1->SetPageMaster(pmname); - mp1 = static_cast<XFMasterPage*>(pXFStyleManager->AddStyle(mp1)); + mp1 = static_cast<XFMasterPage*>(pXFStyleManager->AddStyle(mp1).m_pStyle); m_StyleName = mp1->GetStyleName(); //Set footer style @@ -397,7 +397,7 @@ OUString LwpPageLayout::RegisterEndnoteStyle() //Add the page master to stylemanager XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_pXFPageMaster = pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1)); + m_pXFPageMaster = pm1 = static_cast<XFPageMaster*>(pXFStyleManager->AddStyle(pm1).m_pStyle); OUString pmname = pm1->GetStyleName(); //Add master page @@ -423,7 +423,7 @@ OUString LwpPageLayout::RegisterEndnoteStyle() pLayoutHeader->RegisterStyle(mp1); } - return pXFStyleManager->AddStyle(mp1)->GetStyleName(); + return pXFStyleManager->AddStyle(mp1).m_pStyle->GetStyleName(); } /** * @descr: Whether current page layout has columns diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx index 8ac7c8cb73f7..0f6f8bcec396 100644 --- a/lotuswordpro/source/filter/lwppara.cxx +++ b/lotuswordpro/source/filter/lwppara.cxx @@ -338,7 +338,7 @@ bool LwpPara::RegisterMasterPage(XFParaStyle* pBaseStyle) if (!m_ParentStyleName.isEmpty()) pOverStyle->SetParentStyleName(m_ParentStyleName); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName(); } return bSuccess; } @@ -514,7 +514,7 @@ void LwpPara::RegisterStyle() } if (!m_ParentStyleName.isEmpty()) pOverStyle->SetParentStyleName(m_ParentStyleName); - m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName(); } else //use named style @@ -528,7 +528,7 @@ void LwpPara::RegisterStyle() OverrideIndent(NULL,m_pIndentOverride,pOverStyle); if (!m_ParentStyleName.isEmpty()) pOverStyle->SetParentStyleName(m_ParentStyleName); - m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName(); } } } @@ -543,7 +543,7 @@ void LwpPara::RegisterStyle() pOverStyle->SetAlignType(enumXFAlignStart); if (!m_ParentStyleName.isEmpty()) pOverStyle->SetParentStyleName(m_ParentStyleName); - m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName(); } } @@ -720,7 +720,7 @@ void LwpPara::RegisterStyle() if (pOldStyle) { XFListStyle* pNewStyle = new XFListStyle(*pOldStyle); - m_aBulletStyleName = pXFStyleManager->AddStyle(pNewStyle)->GetStyleName(); + m_aBulletStyleName = pXFStyleManager->AddStyle(pNewStyle).m_pStyle->GetStyleName(); } } } @@ -756,7 +756,7 @@ void LwpPara::RegisterStyle() pMargin->SetTop(pMargin->GetTop()+pPrePara->GetBelowSpacing()); if (!m_ParentStyleName.isEmpty()) pOverStyle->SetParentStyleName(m_ParentStyleName); - m_StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName(); } } @@ -769,7 +769,7 @@ void LwpPara::RegisterStyle() this->RegisterTabStyle(pParaStyle); if (!m_ParentStyleName.isEmpty()) pParaStyle->SetParentStyleName(m_ParentStyleName); - m_StyleName = pXFStyleManager->AddStyle(pParaStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pParaStyle).m_pStyle->GetStyleName(); } //register master page; @@ -787,7 +787,7 @@ void LwpPara::RegisterStyle() pStyle->SetDropCap(m_nChars-1,m_nLines); if (!m_ParentStyleName.isEmpty()) pStyle->SetParentStyleName(m_ParentStyleName); - m_StyleName = pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } // maybe useful for futer version // deleted because Leader of Table is not supported in this version @@ -806,7 +806,7 @@ void LwpPara::RegisterNewSectionStyle(LwpPageLayout *pLayout) pSectStyle->SetColumns(pColumns); } XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle)->GetStyleName(); + m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle).m_pStyle->GetStyleName(); } XFSection* LwpPara::CreateXFSection() diff --git a/lotuswordpro/source/filter/lwppara1.cxx b/lotuswordpro/source/filter/lwppara1.cxx index c9a83d9659af..bba150691ae6 100644 --- a/lotuswordpro/source/filter/lwppara1.cxx +++ b/lotuswordpro/source/filter/lwppara1.cxx @@ -414,25 +414,25 @@ void LwpPara::OverrideParaBreaks(LwpParaProperty* pProps, XFParaStyle* pOverStyl { XFParaStyle* pStyle = new XFParaStyle(); pStyle->SetBreaks(enumXFBreakAftPage); - m_BefPageBreakName = pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + m_BefPageBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } if (m_pBreaks->IsPageBreakAfter()) { XFParaStyle* pStyle = new XFParaStyle(); pStyle->SetBreaks(enumXFBreakAftPage); - m_AftPageBreakName = pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + m_AftPageBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } if (m_pBreaks->IsColumnBreakBefore()) { XFParaStyle* pStyle = new XFParaStyle(); pStyle->SetBreaks(enumXFBreakAftColumn);//tmp after, should change when layout read - m_BefColumnBreakName = pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + m_BefColumnBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } if (m_pBreaks->IsColumnBreakAfter()) { XFParaStyle* pStyle = new XFParaStyle(); pStyle->SetBreaks(enumXFBreakAftColumn); - m_AftColumnBreakName = pXFStyleManager->AddStyle(pStyle)->GetStyleName(); + m_AftColumnBreakName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); } // pParaStyle->ApplyBreaks(pOverStyle, &aFinalBreaks); diff --git a/lotuswordpro/source/filter/lwprowlayout.cxx b/lotuswordpro/source/filter/lwprowlayout.cxx index b09f1ad7547e..32f052e72da8 100644 --- a/lotuswordpro/source/filter/lwprowlayout.cxx +++ b/lotuswordpro/source/filter/lwprowlayout.cxx @@ -127,7 +127,7 @@ void LwpRowLayout::RegisterStyle() pRowStyle->SetRowHeight((float)LwpTools::ConvertFromUnitsToMetric(cheight)); } XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pRowStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pRowStyle).m_pStyle->GetStyleName(); LwpTableLayout* pTableLayout = GetParentTableLayout(); if (pTableLayout) @@ -293,7 +293,7 @@ void LwpRowLayout::RegisterCurRowStyle(XFRow* pXFRow,sal_uInt16 nRowMark) pNewStyle->SetRowHeight((float)fHeight); } - pXFRow->SetStyleName(pXFStyleManager->AddStyle(pNewStyle)->GetStyleName()); + pXFRow->SetStyleName(pXFStyleManager->AddStyle(pNewStyle).m_pStyle->GetStyleName()); } /** diff --git a/lotuswordpro/source/filter/lwpsilverbullet.cxx b/lotuswordpro/source/filter/lwpsilverbullet.cxx index 43a3657e2aa9..c0c39e946cdb 100644 --- a/lotuswordpro/source/filter/lwpsilverbullet.cxx +++ b/lotuswordpro/source/filter/lwpsilverbullet.cxx @@ -182,7 +182,7 @@ void LwpSilverBullet::RegisterStyle() } //add style-list to style manager. - m_strStyleName = pXFStyleManager->AddStyle(pListStyle)->GetStyleName(); + m_strStyleName = pXFStyleManager->AddStyle(pListStyle).m_pStyle->GetStyleName(); } /** diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx index d3e037abbf21..6734edbdb4af 100644 --- a/lotuswordpro/source/filter/lwptablelayout.cxx +++ b/lotuswordpro/source/filter/lwptablelayout.cxx @@ -618,7 +618,7 @@ void LwpTableLayout::RegisterColumns() pColStyle->SetWidth(static_cast<float>(dDefaultColumn)); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_DefaultColumnStyleName = pXFStyleManager->AddStyle(pColStyle)->GetStyleName(); + m_DefaultColumnStyleName = pXFStyleManager->AddStyle(pColStyle).m_pStyle->GetStyleName(); // register existed column style sal_uInt16 i=0; @@ -665,7 +665,7 @@ void LwpTableLayout::RegisterRows() pRowStyle->SetRowHeight((float)pTable->GetHeight()); } XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_DefaultRowStyleName = pXFStyleManager->AddStyle(pRowStyle)->GetStyleName(); + m_DefaultRowStyleName = pXFStyleManager->AddStyle(pRowStyle).m_pStyle->GetStyleName(); // register style of rows LwpObjectID& rRowID = GetChildHead(); @@ -736,7 +736,7 @@ void LwpTableLayout::RegisterStyle() pTableStyle->SetWidth(pSuper->GetTableWidth()); } XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pTableStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pTableStyle).m_pStyle->GetStyleName(); //convert to OO table now and register row stle // traverse @@ -915,7 +915,7 @@ void LwpTableLayout::SplitRowToCells(XFTable* pTmpTable,XFTable* pXFTable, { pRowStyle->SetRowHeight((float)fHeight); } - pXFRow->SetStyleName(pXFStyleManager->AddStyle(pRowStyle)->GetStyleName()); + pXFRow->SetStyleName(pXFStyleManager->AddStyle(pRowStyle).m_pStyle->GetStyleName()); //construct headong row XFCell* pXFCell1 = new XFCell; @@ -1224,7 +1224,7 @@ void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_ } pOverStyle->SetStyleName(""); - OUString StyleName = pXFStyleManager->AddStyle(pOverStyle)->GetStyleName(); + OUString StyleName = pXFStyleManager->AddStyle(pOverStyle).m_pStyle->GetStyleName(); pXFPara->SetStyleName(StyleName); } @@ -1432,7 +1432,7 @@ void LwpColumnLayout::RegisterStyle(double dCalculatedWidth) XFColStyle * pColStyle = new XFColStyle(); pColStyle->SetWidth(static_cast<float>(dCalculatedWidth)); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_StyleName = pXFStyleManager->AddStyle(pColStyle)->GetStyleName(); + m_StyleName = pXFStyleManager->AddStyle(pColStyle).m_pStyle->GetStyleName(); } LwpTableHeadingLayout::LwpTableHeadingLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm) diff --git a/lotuswordpro/source/filter/lwptoc.cxx b/lotuswordpro/source/filter/lwptoc.cxx index d36a9659c3d7..2020e9350cb7 100644 --- a/lotuswordpro/source/filter/lwptoc.cxx +++ b/lotuswordpro/source/filter/lwptoc.cxx @@ -134,7 +134,7 @@ void LwpTocSuperLayout::RegisterStyle() XFTextStyle*pTextStyle = new XFTextStyle; pTextStyle->SetFont(pBaseStyle->GetFont()); // who delete this font????? XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_TabStyleName = pXFStyleManager->AddStyle(pTextStyle)->GetStyleName(); + m_TabStyleName = pXFStyleManager->AddStyle(pTextStyle).m_pStyle->GetStyleName(); } /** diff --git a/lotuswordpro/source/filter/xfilter/xfstylecont.cxx b/lotuswordpro/source/filter/xfilter/xfstylecont.cxx index 517d15b59036..b5f44346f733 100644 --- a/lotuswordpro/source/filter/xfilter/xfstylecont.cxx +++ b/lotuswordpro/source/filter/xfilter/xfstylecont.cxx @@ -106,13 +106,15 @@ void XFStyleContainer::Reset() m_aStyles.clear(); } -IXFStyle* XFStyleContainer::AddStyle(IXFStyle *pStyle) +IXFStyleRet XFStyleContainer::AddStyle(IXFStyle *pStyle) { + IXFStyleRet aRet; + IXFStyle *pConStyle = NULL; OUString name; if( !pStyle ) - return NULL; + return aRet; //no matter we want to delete the style or not,XFFont object should be saved first. ManageStyleFont(pStyle); @@ -122,7 +124,9 @@ IXFStyle* XFStyleContainer::AddStyle(IXFStyle *pStyle) if( pConStyle )//such a style has exist: { delete pStyle; - return pConStyle; + aRet.m_pStyle = pConStyle; + aRet.m_bOrigDeleted = true; + return aRet;; } else { @@ -144,8 +148,8 @@ IXFStyle* XFStyleContainer::AddStyle(IXFStyle *pStyle) m_aStyles.push_back(pStyle); //transform the font object to XFFontFactory - - return pStyle; + aRet.m_pStyle = pStyle; + return aRet; } } diff --git a/lotuswordpro/source/filter/xfilter/xfstylecont.hxx b/lotuswordpro/source/filter/xfilter/xfstylecont.hxx index 50dae185a30d..59af93e42ca1 100644 --- a/lotuswordpro/source/filter/xfilter/xfstylecont.hxx +++ b/lotuswordpro/source/filter/xfilter/xfstylecont.hxx @@ -65,6 +65,17 @@ class IXFStyle; +struct IXFStyleRet +{ + IXFStyle* m_pStyle; + bool m_bOrigDeleted; + IXFStyleRet() + : m_pStyle(NULL) + , m_bOrigDeleted(false) + { + } +}; + /** * @descr container object for styles. * All styles can be placed into an style container. @@ -87,7 +98,7 @@ public: * @descr Add style to container. * If the same style has exist, then pStyle will be deleted, and the same style will be return. */ - IXFStyle* AddStyle(IXFStyle *pStyle); + IXFStyleRet AddStyle(IXFStyle *pStyle); /** * @descr Find the same style. diff --git a/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx b/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx index 0e17576cc273..55038055f872 100644 --- a/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx +++ b/lotuswordpro/source/filter/xfilter/xfstylemanager.cxx @@ -104,94 +104,99 @@ void XFStyleManager::AddFontDecl(XFFontDecl& aFontDecl) s_aFontDecls.push_back(aFontDecl); } -IXFStyle* XFStyleManager::AddStyle(IXFStyle *pStyle) +IXFStyleRet XFStyleManager::AddStyle(IXFStyle *pStyle) { + IXFStyleRet aRet; + assert(pStyle); OUString name; - IXFStyle *pStyleRet = NULL; if( !pStyle ) - return NULL; + return aRet; name = pStyle->GetStyleName(); if( pStyle->GetStyleFamily() == enumXFStyleText ) { if( !name.isEmpty() ) { - pStyleRet = s_aStdTextStyles.AddStyle(pStyle); + aRet = s_aStdTextStyles.AddStyle(pStyle); } else - pStyleRet = s_aTextStyles.AddStyle(pStyle); + { + aRet = s_aTextStyles.AddStyle(pStyle); + } } else if( pStyle->GetStyleFamily() == enumXFStylePara ) { if( !name.isEmpty() ) { - pStyleRet = s_aStdParaStyles.AddStyle(pStyle); + aRet = s_aStdParaStyles.AddStyle(pStyle); } else - pStyleRet = s_aParaStyles.AddStyle(pStyle); + { + aRet = s_aParaStyles.AddStyle(pStyle); + } } else if( pStyle->GetStyleFamily() == enumXFStyleDefaultPara ) { - pStyleRet = s_aStdParaStyles.AddStyle(pStyle); + aRet = s_aStdParaStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleList ) { - pStyleRet = s_aListStyles.AddStyle(pStyle); + aRet = s_aListStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleSection ) { - pStyleRet = s_aSectionStyles.AddStyle(pStyle); + aRet = s_aSectionStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStylePageMaster ) { - pStyleRet = s_aPageMasters.AddStyle(pStyle); + aRet = s_aPageMasters.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleMasterPage ) { //Master page don't need name. - pStyleRet = s_aMasterpages.AddStyle(pStyle); + aRet = s_aMasterpages.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleDate ) { - pStyleRet = s_aDateStyles.AddStyle(pStyle); + aRet = s_aDateStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleTime ) { - pStyleRet = s_aDateStyles.AddStyle(pStyle); + aRet = s_aDateStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleNumber ) { - pStyleRet = s_aDateStyles.AddStyle(pStyle); + aRet = s_aDateStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStylePercent ) { - pStyleRet = s_aDateStyles.AddStyle(pStyle); + aRet = s_aDateStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleCurrency ) { - pStyleRet = s_aDateStyles.AddStyle(pStyle); + aRet = s_aDateStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleGraphics ) { - pStyleRet = s_aGraphicsStyles.AddStyle(pStyle); + aRet = s_aGraphicsStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleTable ) { - pStyleRet = s_aTableStyles.AddStyle(pStyle); + aRet = s_aTableStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleTableCell ) { - pStyleRet = s_aTableCellStyles.AddStyle(pStyle); + aRet = s_aTableCellStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleTableRow ) { - pStyleRet = s_aTableRowStyles.AddStyle(pStyle); + aRet = s_aTableRowStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleTableCol ) { - pStyleRet = s_aTableColStyles.AddStyle(pStyle); + aRet = s_aTableColStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleOutline ) { @@ -201,22 +206,22 @@ IXFStyle* XFStyleManager::AddStyle(IXFStyle *pStyle) } else if( pStyle->GetStyleFamily() == enumXFStyleStrokeDash ) { - pStyleRet = s_aStdStrokeDashStyles.AddStyle(pStyle); + aRet = s_aStdStrokeDashStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleArea ) { - pStyleRet = s_aStdAreaStyles.AddStyle(pStyle); + aRet = s_aStdAreaStyles.AddStyle(pStyle); } else if( pStyle->GetStyleFamily() == enumXFStyleArrow ) { - pStyleRet = s_aStdArrowStyles.AddStyle(pStyle); + aRet = s_aStdArrowStyles.AddStyle(pStyle); } else if (pStyle->GetStyleFamily() == enumXFStyleRuby) { - pStyleRet = s_aRubyStyles.AddStyle(pStyle); + aRet = s_aRubyStyles.AddStyle(pStyle); } - return pStyleRet; + return aRet; } IXFStyle* XFStyleManager::FindStyle(const OUString& name) diff --git a/lotuswordpro/source/filter/xfilter/xfstylemanager.hxx b/lotuswordpro/source/filter/xfilter/xfstylemanager.hxx index a96ad5c731a6..c3680f53f2ea 100644 --- a/lotuswordpro/source/filter/xfilter/xfstylemanager.hxx +++ b/lotuswordpro/source/filter/xfilter/xfstylemanager.hxx @@ -95,7 +95,7 @@ public: void AddFontDecl(XFFontDecl& aFontDecl); - IXFStyle* AddStyle(IXFStyle *pStyle); + IXFStyleRet AddStyle(IXFStyle *pStyle); IXFStyle* FindStyle(const OUString& name); |