loplugin:flatten in lotuswordpro

Change-Id: I8b86d54c1c2706fde8b4288bb3349e2ed89d3c95
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91798
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-04-07 10:06:09 +02:00
parent 320563f857
commit 9f424bf2d7
18 changed files with 588 additions and 593 deletions

View File

@@ -131,24 +131,24 @@ void LwpBorderStuff::Read(LwpObjectStream *pStrm)
m_nValid = pStrm->QuickReaduInt16(); m_nValid = pStrm->QuickReaduInt16();
pStrm->SkipExtra(); pStrm->SkipExtra();
if( LwpFileHeader::m_nFileRevision < 0x0010 ) if( LwpFileHeader::m_nFileRevision >= 0x0010 )
return;
if( m_nBorderGroupIDLeft&EXTERNAL_ID )
{ {
if( m_nBorderGroupIDLeft&EXTERNAL_ID ) m_nBorderGroupIDLeft = BGRP_SOLID;
{ }
m_nBorderGroupIDLeft = BGRP_SOLID; if( m_nBorderGroupIDRight&EXTERNAL_ID )
} {
if( m_nBorderGroupIDRight&EXTERNAL_ID ) m_nBorderGroupIDRight = BGRP_SOLID;
{ }
m_nBorderGroupIDRight = BGRP_SOLID; if( m_nBorderGroupIDTop&EXTERNAL_ID )
} {
if( m_nBorderGroupIDTop&EXTERNAL_ID ) m_nBorderGroupIDTop = BGRP_SOLID;
{ }
m_nBorderGroupIDTop = BGRP_SOLID; if( m_nBorderGroupIDBottom&EXTERNAL_ID )
} {
if( m_nBorderGroupIDBottom&EXTERNAL_ID ) m_nBorderGroupIDBottom = BGRP_SOLID;
{
m_nBorderGroupIDBottom = BGRP_SOLID;
}
} }
} }

View File

@@ -260,19 +260,19 @@ void LwpDocument::RegisterLayoutStyles()
//set initial pagelayout in story for parsing pagelayout //set initial pagelayout in story for parsing pagelayout
LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (m_DivInfo.obj( VO_DIVISIONINFO).get()); LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*> (m_DivInfo.obj( VO_DIVISIONINFO).get());
if (pDivInfo) if (!pDivInfo)
return;
LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID().obj(VO_PAGELAYOUT).get());
if(pPageLayout)
{ {
LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pDivInfo->GetInitialLayoutID().obj(VO_PAGELAYOUT).get()); //In Ole division, the content of pagelayout is VO_OLEOBJECT
if(pPageLayout) LwpStory* pStory = dynamic_cast<LwpStory*>(pPageLayout->GetContent().obj(VO_STORY).get());
if(pStory)
{ {
//In Ole division, the content of pagelayout is VO_OLEOBJECT //add all the pagelayout in order into the pagelayout list;
LwpStory* pStory = dynamic_cast<LwpStory*>(pPageLayout->GetContent().obj(VO_STORY).get()); pStory->SortPageLayout();
if(pStory) pStory->SetCurrentLayout(pPageLayout);
{
//add all the pagelayout in order into the pagelayout list;
pStory->SortPageLayout();
pStory->SetCurrentLayout(pPageLayout);
}
} }
} }
} }
@@ -285,20 +285,20 @@ void LwpDocument::RegisterStylesInPara()
rtl::Reference<LwpHeadContent> xContent(m_xOwnedFoundry rtl::Reference<LwpHeadContent> xContent(m_xOwnedFoundry
? dynamic_cast<LwpHeadContent*> (m_xOwnedFoundry->GetContentManager().GetContentList().obj().get()) ? dynamic_cast<LwpHeadContent*> (m_xOwnedFoundry->GetContentManager().GetContentList().obj().get())
: nullptr); : nullptr);
if (xContent.is()) if (!xContent.is())
return;
rtl::Reference<LwpStory> xStory(dynamic_cast<LwpStory*>(xContent->GetChildHead().obj(VO_STORY).get()));
o3tl::sorted_vector<LwpStory*> aSeen;
while (xStory.is())
{ {
rtl::Reference<LwpStory> xStory(dynamic_cast<LwpStory*>(xContent->GetChildHead().obj(VO_STORY).get())); aSeen.insert(xStory.get());
o3tl::sorted_vector<LwpStory*> aSeen; //Register the child para
while (xStory.is()) xStory->SetFoundry(m_xOwnedFoundry.get());
{ xStory->DoRegisterStyle();
aSeen.insert(xStory.get()); xStory.set(dynamic_cast<LwpStory*>(xStory->GetNext().obj(VO_STORY).get()));
//Register the child para if (aSeen.find(xStory.get()) != aSeen.end())
xStory->SetFoundry(m_xOwnedFoundry.get()); throw std::runtime_error("loop in conversion");
xStory->DoRegisterStyle();
xStory.set(dynamic_cast<LwpStory*>(xStory->GetNext().obj(VO_STORY).get()));
if (aSeen.find(xStory.get()) != aSeen.end())
throw std::runtime_error("loop in conversion");
}
} }
} }
/** /**
@@ -368,21 +368,21 @@ void LwpDocument::RegisterFootnoteStyles()
//Register endnote page style for endnote configuration, use the last division that has endnote for the endnote page style //Register endnote page style for endnote configuration, use the last division that has endnote for the endnote page style
//This page style must register after its division default styles have registered //This page style must register after its division default styles have registered
LwpDocument* pEndnoteDiv = GetLastDivisionThatHasEndnote(); LwpDocument* pEndnoteDiv = GetLastDivisionThatHasEndnote();
if(this == pEndnoteDiv) if(this != pEndnoteDiv)
return;
LwpDLVListHeadTailHolder* pHeadTail = dynamic_cast<LwpDLVListHeadTailHolder*>(GetPageHintsID().obj().get());
if(!pHeadTail)
return;
LwpPageHint* pPageHint = dynamic_cast<LwpPageHint*>(pHeadTail->GetTail().obj().get());
if(pPageHint && !pPageHint->GetPageLayoutID().IsNull())
{ {
LwpDLVListHeadTailHolder* pHeadTail = dynamic_cast<LwpDLVListHeadTailHolder*>(GetPageHintsID().obj().get()); LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pPageHint->GetPageLayoutID().obj().get());
if(pHeadTail) if(pPageLayout)
{ {
LwpPageHint* pPageHint = dynamic_cast<LwpPageHint*>(pHeadTail->GetTail().obj().get()); pPageLayout->SetFoundry(GetFoundry());
if(pPageHint && !pPageHint->GetPageLayoutID().IsNull()) pPageLayout->RegisterEndnoteStyle();
{
LwpPageLayout* pPageLayout = dynamic_cast<LwpPageLayout*>(pPageHint->GetPageLayoutID().obj().get());
if(pPageLayout)
{
pPageLayout->SetFoundry(GetFoundry());
pPageLayout->RegisterEndnoteStyle();
}
}
} }
} }
} }
@@ -392,20 +392,19 @@ void LwpDocument::RegisterFootnoteStyles()
*/ */
void LwpDocument::RegisterDefaultParaStyles() void LwpDocument::RegisterDefaultParaStyles()
{ {
if(!IsChildDoc()) if(IsChildDoc())
{ return;
//Get First Division
//LwpDocument* pFirstDoc = GetFirstDivision();
LwpDocument* pFirstDoc = GetFirstDivisionWithContentsThatIsNotOLE();
if(pFirstDoc)
{
LwpVerDocument* pVerDoc = dynamic_cast<LwpVerDocument*>(pFirstDoc->GetVerDoc().obj().get());
if(pVerDoc)
{
pVerDoc->RegisterStyle();
}
}
//Get First Division
//LwpDocument* pFirstDoc = GetFirstDivision();
LwpDocument* pFirstDoc = GetFirstDivisionWithContentsThatIsNotOLE();
if(pFirstDoc)
{
LwpVerDocument* pVerDoc = dynamic_cast<LwpVerDocument*>(pFirstDoc->GetVerDoc().obj().get());
if(pVerDoc)
{
pVerDoc->RegisterStyle();
}
} }
} }

View File

@@ -102,31 +102,31 @@ void LwpFribFootnote::RegisterNewStyle()
void LwpFribFootnote::XFConvert(XFContentContainer* pCont) void LwpFribFootnote::XFConvert(XFContentContainer* pCont)
{ {
LwpFootnote* pFootnote = GetFootnote(); LwpFootnote* pFootnote = GetFootnote();
if(pFootnote) if(!pFootnote)
return;
rtl::Reference<XFContentContainer> xContent;
if(pFootnote->GetType() == FN_FOOTNOTE)
{ {
rtl::Reference<XFContentContainer> xContent; xContent.set(new XFFootNote);
if(pFootnote->GetType() == FN_FOOTNOTE) }
{ else
xContent.set(new XFFootNote); {
} xContent.set(new XFEndNote);
else }
{ pFootnote->XFConvert(xContent.get());
xContent.set(new XFEndNote); if (m_ModFlag)
} {
pFootnote->XFConvert(xContent.get()); //set footnote number font style
if (m_ModFlag) rtl::Reference<XFTextSpan> xSpan(new XFTextSpan);
{ xSpan->SetStyleName(GetStyleName());
//set footnote number font style //add the xffootnote into the content container
rtl::Reference<XFTextSpan> xSpan(new XFTextSpan); xSpan->Add(xContent.get());
xSpan->SetStyleName(GetStyleName()); pCont->Add(xSpan.get());
//add the xffootnote into the content container }
xSpan->Add(xContent.get()); else
pCont->Add(xSpan.get()); {
} pCont->Add(xContent.get());
else
{
pCont->Add(xContent.get());
}
} }
} }

View File

@@ -792,18 +792,17 @@ void LwpFrameLayout::Read()
*/ */
void LwpFrameLayout::XFConvert(XFContentContainer* pCont) void LwpFrameLayout::XFConvert(XFContentContainer* pCont)
{ {
if(m_pFrame) if(!m_pFrame)
{ return;
//parse the frame which anchor to paragraph
if(IsRelativeAnchored())
{
XFConvertFrame(pCont);
}
else
{
m_pFrame->XFConvert(pCont);
}
//parse the frame which anchor to paragraph
if(IsRelativeAnchored())
{
XFConvertFrame(pCont);
}
else
{
m_pFrame->XFConvert(pCont);
} }
} }
/** /**
@@ -814,32 +813,32 @@ void LwpFrameLayout::Read()
*/ */
void LwpFrameLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart , sal_Int32 nEnd, bool bAll ) void LwpFrameLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart , sal_Int32 nEnd, bool bAll )
{ {
if(m_pFrame) if(!m_pFrame)
{ return;
rtl::Reference<XFFrame> xXFFrame;
if(nEnd < nStart)
{
xXFFrame.set(new XFFrame);
}
else
{
xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
}
m_pFrame->Parse(xXFFrame.get(), nStart); rtl::Reference<XFFrame> xXFFrame;
//if it is a link frame, parse contents only once if(nEnd < nStart)
if(!HasPreviousLinkLayout()) {
{ xXFFrame.set(new XFFrame);
rtl::Reference<LwpObject> content = m_Content.obj();
if (content.is())
{
content->DoXFConvert(xXFFrame.get());
//set frame size according to ole size
ApplyGraphicSize(xXFFrame.get());
}
}
pCont->Add(xXFFrame.get());
} }
else
{
xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
}
m_pFrame->Parse(xXFFrame.get(), nStart);
//if it is a link frame, parse contents only once
if(!HasPreviousLinkLayout())
{
rtl::Reference<LwpObject> content = m_Content.obj();
if (content.is())
{
content->DoXFConvert(xXFFrame.get());
//set frame size according to ole size
ApplyGraphicSize(xXFFrame.get());
}
}
pCont->Add(xXFFrame.get());
} }
/** /**
* @descr register frame style * @descr register frame style
@@ -985,38 +984,38 @@ double LwpFrameLayout::GetMaxWidth()
void LwpFrameLayout::ApplyGraphicSize(XFFrame * pXFFrame) void LwpFrameLayout::ApplyGraphicSize(XFFrame * pXFFrame)
{ {
rtl::Reference<LwpObject> content = m_Content.obj(); rtl::Reference<LwpObject> content = m_Content.obj();
if(content.is() && (content->GetTag() == VO_GRAPHIC if(!(content.is() && (content->GetTag() == VO_GRAPHIC
|| content->GetTag() == VO_OLEOBJECT )) || content->GetTag() == VO_OLEOBJECT )))
return;
LwpGraphicOleObject* pGraOle = static_cast<LwpGraphicOleObject*>(content.get());
//Get frame geometry size
double fWidth = 0;
double fHeight = 0;
pGraOle->GetGrafScaledSize(fWidth, fHeight);
if( IsFitGraphic())
{ {
LwpGraphicOleObject* pGraOle = static_cast<LwpGraphicOleObject*>(content.get()); //graphic scaled sze
//Get frame geometry size fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
double fWidth = 0; fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
double fHeight = 0;
pGraOle->GetGrafScaledSize(fWidth, fHeight);
if( IsFitGraphic())
{
//graphic scaled sze
fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
}
else if(IsAutoGrowDown() || IsAutoGrowUp())
{
fWidth = GetWidth();
fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
}
else if( IsAutoGrowLeft() || IsAutoGrowRight())
{
fHeight = GetHeight();
fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
}
else
{
fWidth = GetWidth();
fHeight = GetHeight();
}
pXFFrame->SetWidth(fWidth);
pXFFrame->SetHeight(fHeight);
} }
else if(IsAutoGrowDown() || IsAutoGrowUp())
{
fWidth = GetWidth();
fHeight += GetMarginsValue(MARGIN_TOP) + GetMarginsValue(MARGIN_BOTTOM);
}
else if( IsAutoGrowLeft() || IsAutoGrowRight())
{
fHeight = GetHeight();
fWidth += GetMarginsValue(MARGIN_LEFT) + GetMarginsValue(MARGIN_RIGHT);
}
else
{
fWidth = GetWidth();
fHeight = GetHeight();
}
pXFFrame->SetWidth(fWidth);
pXFFrame->SetHeight(fHeight);
} }
LwpGroupLayout::LwpGroupLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm) LwpGroupLayout::LwpGroupLayout(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)
@@ -1061,18 +1060,17 @@ void LwpGroupLayout::RegisterStyle()
*/ */
void LwpGroupLayout::XFConvert(XFContentContainer *pCont) void LwpGroupLayout::XFConvert(XFContentContainer *pCont)
{ {
if(m_pFrame) if(!m_pFrame)
{ return;
//parse the frame which anchor to paragraph
if(IsRelativeAnchored())
{
XFConvertFrame(pCont);
}
else
{
m_pFrame->XFConvert(pCont);
}
//parse the frame which anchor to paragraph
if(IsRelativeAnchored())
{
XFConvertFrame(pCont);
}
else
{
m_pFrame->XFConvert(pCont);
} }
} }
/** /**
@@ -1083,31 +1081,31 @@ void LwpGroupLayout::XFConvert(XFContentContainer *pCont)
*/ */
void LwpGroupLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart , sal_Int32 nEnd, bool bAll) void LwpGroupLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart , sal_Int32 nEnd, bool bAll)
{ {
if(m_pFrame) if(!m_pFrame)
return;
rtl::Reference<XFFrame> xXFFrame;
if(nEnd < nStart)
{ {
rtl::Reference<XFFrame> xXFFrame; xXFFrame.set(new XFFrame);
if(nEnd < nStart)
{
xXFFrame.set(new XFFrame);
}
else
{
xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
}
m_pFrame->Parse(xXFFrame.get(), nStart);
//add child frame into group
LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get());
while (pLayout && pLayout != this)
{
pLayout->DoXFConvert(xXFFrame.get());
pLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext().obj().get());
}
pCont->Add(xXFFrame.get());
} }
else
{
xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
}
m_pFrame->Parse(xXFFrame.get(), nStart);
//add child frame into group
LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get());
while (pLayout && pLayout != this)
{
pLayout->DoXFConvert(xXFFrame.get());
pLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext().obj().get());
}
pCont->Add(xXFFrame.get());
} }
LwpGroupFrame::LwpGroupFrame(LwpObjectHeader const &objHdr, LwpSvStream* pStrm) LwpGroupFrame::LwpGroupFrame(LwpObjectHeader const &objHdr, LwpSvStream* pStrm)

View File

@@ -291,29 +291,29 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
} }
} }
if (m_pModifiers->HasHighlight) if (!m_pModifiers->HasHighlight)
{ return;
XFColor aColor = GetHighlightColor();//right yellow
if (pStyle)//change the style directly
pStyle->GetFont()->SetBackColor(aColor);
else //register a new style
{
std::unique_ptr<XFTextStyle> pNewStyle(new XFTextStyle());
if (!m_StyleName.isEmpty()) XFColor aColor = GetHighlightColor();//right yellow
{ if (pStyle)//change the style directly
XFTextStyle* pOldStyle = pXFStyleManager->FindTextStyle(m_StyleName); pStyle->GetFont()->SetBackColor(aColor);
*pNewStyle = *pOldStyle; else //register a new style
pNewStyle->GetFont()->SetBackColor(aColor); {
} std::unique_ptr<XFTextStyle> pNewStyle(new XFTextStyle());
else
{ if (!m_StyleName.isEmpty())
pFont = new XFFont; {
pFont->SetBackColor(aColor); XFTextStyle* pOldStyle = pXFStyleManager->FindTextStyle(m_StyleName);
pNewStyle->SetFont(pFont); *pNewStyle = *pOldStyle;
} pNewStyle->GetFont()->SetBackColor(aColor);
m_StyleName = pXFStyleManager->AddStyle(std::move(pNewStyle)).m_pStyle->GetStyleName();
} }
else
{
pFont = new XFFont;
pFont->SetBackColor(aColor);
pNewStyle->SetFont(pFont);
}
m_StyleName = pXFStyleManager->AddStyle(std::move(pNewStyle)).m_pStyle->GetStyleName();
} }
} }

View File

@@ -1213,19 +1213,19 @@ void LwpFribField::ConvertDocFieldStart(XFContentContainer* pXFPara,LwpFieldMark
break; break;
} }
} }
if (pContent) if (!pContent)
return;
if (m_ModFlag)//(m_pModifiers)
{ {
if (m_ModFlag)//(m_pModifiers) XFTextSpanStart* pSpan = new XFTextSpanStart;
{ pSpan->SetStyleName(GetStyleName());
XFTextSpanStart* pSpan = new XFTextSpanStart; pSpan->Add(pContent);
pSpan->SetStyleName(GetStyleName()); pXFPara->Add(pSpan);
pSpan->Add(pContent); pFieldMark->SetStyleFlag(true);
pXFPara->Add(pSpan);
pFieldMark->SetStyleFlag(true);
}
else
pXFPara->Add(pContent);
} }
else
pXFPara->Add(pContent);
} }
void LwpFribField::ConvertDocFieldEnd(XFContentContainer* pXFPara, const LwpFieldMark* pFieldMark) void LwpFribField::ConvertDocFieldEnd(XFContentContainer* pXFPara, const LwpFieldMark* pFieldMark)
@@ -1299,19 +1299,19 @@ void LwpFribField::ConvertDateTimeStart(XFContentContainer* pXFPara,LwpFieldMark
default: default:
break; break;
} }
if (pContent) if (!pContent)
return;
if (m_ModFlag)
{ {
if (m_ModFlag) XFTextSpanStart* pSpan = new XFTextSpanStart;
{ pSpan->SetStyleName(GetStyleName());
XFTextSpanStart* pSpan = new XFTextSpanStart; pSpan->Add(pContent);
pSpan->SetStyleName(GetStyleName()); pXFPara->Add(pSpan);
pSpan->Add(pContent); pFieldMark->SetStyleFlag(true);
pXFPara->Add(pSpan);
pFieldMark->SetStyleFlag(true);
}
else
pXFPara->Add(pContent);
} }
else
pXFPara->Add(pContent);
} }

View File

@@ -304,27 +304,27 @@ void LwpMasterPage::RegisterMasterPage(LwpFrib* pFrib)
XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName(); m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
//register section style here //register section style here
if(m_bNewSection) if(!m_bNewSection)
{ return;
std::unique_ptr<XFSectionStyle> pSectStyle(new XFSectionStyle());
//set margin
pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
LwpPageLayout* pCurrentLayout = pStory ? pStory->GetCurrentLayout() : nullptr;
if (pCurrentLayout)
{
double fLeft = m_pLayout->GetMarginsValue(MARGIN_LEFT) - pCurrentLayout->GetMarginsValue(MARGIN_LEFT);
double fRight = m_pLayout->GetMarginsValue(MARGIN_RIGHT) - pCurrentLayout->GetMarginsValue(MARGIN_RIGHT);
pSectStyle->SetMarginLeft(fLeft);
pSectStyle->SetMarginRight(fRight);
}
XFColumns* pColumns = m_pLayout->GetXFColumns(); std::unique_ptr<XFSectionStyle> pSectStyle(new XFSectionStyle());
if(pColumns) //set margin
{ pStory = dynamic_cast<LwpStory*>(m_pPara->GetStoryID().obj().get());
pSectStyle->SetColumns(pColumns); LwpPageLayout* pCurrentLayout = pStory ? pStory->GetCurrentLayout() : nullptr;
} if (pCurrentLayout)
m_SectionStyleName = pXFStyleManager->AddStyle(std::move(pSectStyle)).m_pStyle->GetStyleName(); {
double fLeft = m_pLayout->GetMarginsValue(MARGIN_LEFT) - pCurrentLayout->GetMarginsValue(MARGIN_LEFT);
double fRight = m_pLayout->GetMarginsValue(MARGIN_RIGHT) - pCurrentLayout->GetMarginsValue(MARGIN_RIGHT);
pSectStyle->SetMarginLeft(fLeft);
pSectStyle->SetMarginRight(fRight);
} }
XFColumns* pColumns = m_pLayout->GetXFColumns();
if(pColumns)
{
pSectStyle->SetColumns(pColumns);
}
m_SectionStyleName = pXFStyleManager->AddStyle(std::move(pSectStyle)).m_pStyle->GetStyleName();
} }
/** /**

View File

@@ -83,23 +83,23 @@ LwpFribText::LwpFribText( LwpPara *pPara, bool bNoUnicode )
void LwpFribText::Read(LwpObjectStream* pObjStrm, sal_uInt16 len) void LwpFribText::Read(LwpObjectStream* pObjStrm, sal_uInt16 len)
{ {
if( len>=1 ) if( len<1 )
return;
rtl_TextEncoding rEncode;
if(m_bNoUnicode)
{ {
rtl_TextEncoding rEncode; rEncode = RTL_TEXTENCODING_ISO_8859_1;
if(m_bNoUnicode)
{
rEncode = RTL_TEXTENCODING_ISO_8859_1;
}
else
{
if (m_pModifiers && m_pModifiers->CodePage)
rEncode = LwpCharSetMgr::GetInstance()->
GetTextCharEncoding(m_pModifiers->CodePage);
else
rEncode = LwpCharSetMgr::GetTextCharEncoding();
}
LwpTools::QuickReadUnicode(pObjStrm, m_Content, len, rEncode);
} }
else
{
if (m_pModifiers && m_pModifiers->CodePage)
rEncode = LwpCharSetMgr::GetInstance()->
GetTextCharEncoding(m_pModifiers->CodePage);
else
rEncode = LwpCharSetMgr::GetTextCharEncoding();
}
LwpTools::QuickReadUnicode(pObjStrm, m_Content, len, rEncode);
} }
void LwpFribText::XFConvert(XFContentContainer* pXFPara,LwpStory* pStory) void LwpFribText::XFConvert(XFContentContainer* pXFPara,LwpStory* pStory)

View File

@@ -638,49 +638,49 @@ void LwpGraphicObject::XFConvertEquation(XFContentContainer * pCont)
{ {
std::unique_ptr<sal_uInt8[]> pGrafData; std::unique_ptr<sal_uInt8[]> pGrafData;
sal_uInt32 nDataLen = GetGrafData(pGrafData); sal_uInt32 nDataLen = GetGrafData(pGrafData);
if(pGrafData) if(!pGrafData)
return;
//convert equation
XFParagraph* pXFPara = new XFParagraph;
pXFPara->Add("Formula:");
//add notes
XFAnnotation* pXFNote = new XFAnnotation;
//add equation to comment notes
XFParagraph* pXFNotePara = new XFParagraph;
//equation header text: Times New Roman,
// 18,12,0,0,0,0,0.
// .TCIformat{2}
//total head length = 45
bool bOk = true;
sal_uInt32 nBegin = 45;
sal_uInt32 nEnd = 0;
if (nDataLen >= 1)
nEnd = nDataLen - 1;
else
bOk = false;
if (bOk && pGrafData[nEnd] == '$' && nEnd > 0 && pGrafData[nEnd-1] != '\\')
{ {
//convert equation //equation body is contained by '$';
XFParagraph* pXFPara = new XFParagraph; nBegin++;
pXFPara->Add("Formula:"); nEnd--;
//add notes
XFAnnotation* pXFNote = new XFAnnotation;
//add equation to comment notes
XFParagraph* pXFNotePara = new XFParagraph;
//equation header text: Times New Roman,
// 18,12,0,0,0,0,0.
// .TCIformat{2}
//total head length = 45
bool bOk = true;
sal_uInt32 nBegin = 45;
sal_uInt32 nEnd = 0;
if (nDataLen >= 1)
nEnd = nDataLen - 1;
else
bOk = false;
if (bOk && pGrafData[nEnd] == '$' && nEnd > 0 && pGrafData[nEnd-1] != '\\')
{
//equation body is contained by '$';
nBegin++;
nEnd--;
}
bOk &= nEnd >= nBegin;
if (bOk)
{
std::unique_ptr<sal_uInt8[]> pEquData( new sal_uInt8[nEnd - nBegin + 1] );
for(sal_uInt32 nIndex = 0; nIndex < nEnd - nBegin +1 ; nIndex++)
{
pEquData[nIndex] = pGrafData[nBegin + nIndex];
}
pXFNotePara->Add(OUString(reinterpret_cast<char*>(pEquData.get()), (nEnd - nBegin + 1), osl_getThreadTextEncoding()));
}
pXFNote->Add(pXFNotePara);
pXFPara->Add(pXFNote);
pCont->Add(pXFPara);
} }
bOk &= nEnd >= nBegin;
if (bOk)
{
std::unique_ptr<sal_uInt8[]> pEquData( new sal_uInt8[nEnd - nBegin + 1] );
for(sal_uInt32 nIndex = 0; nIndex < nEnd - nBegin +1 ; nIndex++)
{
pEquData[nIndex] = pGrafData[nBegin + nIndex];
}
pXFNotePara->Add(OUString(reinterpret_cast<char*>(pEquData.get()), (nEnd - nBegin + 1), osl_getThreadTextEncoding()));
}
pXFNote->Add(pXFNotePara);
pXFPara->Add(pXFNote);
pCont->Add(pXFPara);
} }
void LwpGraphicObject::GetGrafOrgSize(double & rWidth, double & rHeight) void LwpGraphicObject::GetGrafOrgSize(double & rWidth, double & rHeight)

View File

@@ -210,20 +210,20 @@ LwpExternalBorder::~LwpExternalBorder()
void LwpExternalBorder:: Read(LwpObjectStream *pStrm) void LwpExternalBorder:: Read(LwpObjectStream *pStrm)
{ {
if( LwpFileHeader::m_nFileRevision >= 0x000F ) if( LwpFileHeader::m_nFileRevision < 0x000F )
{ return;
//enum {BORDER,JOIN};
m_LeftName.Read(pStrm); //enum {BORDER,JOIN};
m_TopName.Read(pStrm); m_LeftName.Read(pStrm);
m_RightName.Read(pStrm); m_TopName.Read(pStrm);
m_BottomName.Read(pStrm); m_RightName.Read(pStrm);
// TODO: Do not know what it is for m_BottomName.Read(pStrm);
/*cLeftName = CStyleMgr::GetUniqueMetaFileName(cLeftName,BORDER); // TODO: Do not know what it is for
cRightName = CStyleMgr::GetUniqueMetaFileName(cRightName,BORDER); /*cLeftName = CStyleMgr::GetUniqueMetaFileName(cLeftName,BORDER);
cTopName = CStyleMgr::GetUniqueMetaFileName(cTopName,BORDER); cRightName = CStyleMgr::GetUniqueMetaFileName(cRightName,BORDER);
cBottomName = CStyleMgr::GetUniqueMetaFileName(cBottomName,BORDER);*/ cTopName = CStyleMgr::GetUniqueMetaFileName(cTopName,BORDER);
pStrm->SkipExtra(); cBottomName = CStyleMgr::GetUniqueMetaFileName(cBottomName,BORDER);*/
} pStrm->SkipExtra();
} }
LwpLayoutExternalBorder::LwpLayoutExternalBorder(LwpObjectHeader const & objHdr, LwpSvStream* pStrm) LwpLayoutExternalBorder::LwpLayoutExternalBorder(LwpObjectHeader const & objHdr, LwpSvStream* pStrm)

View File

@@ -99,29 +99,29 @@ void LwpFribNote::RegisterNewStyle()
void LwpFribNote::XFConvert(XFContentContainer* pCont) void LwpFribNote::XFConvert(XFContentContainer* pCont)
{ {
LwpNoteLayout* pLayout = dynamic_cast<LwpNoteLayout*>(m_Layout.obj().get()); LwpNoteLayout* pLayout = dynamic_cast<LwpNoteLayout*>(m_Layout.obj().get());
if(pLayout) if(!pLayout)
{ return;
XFAnnotation* pXFNote = new XFAnnotation;
pXFNote->SetAuthor(pLayout->GetAuthor());
LtTm aTm;
long nTime = pLayout->GetTime();
if(LtgLocalTime(nTime, aTm))
{
pXFNote->SetDate(LwpTools::DateTimeToOUString(aTm));
}
pLayout->XFConvert(pXFNote); XFAnnotation* pXFNote = new XFAnnotation;
if(m_pModifiers) pXFNote->SetAuthor(pLayout->GetAuthor());
{ LtTm aTm;
XFTextSpan *pSpan = new XFTextSpan(); long nTime = pLayout->GetTime();
pSpan->SetStyleName(GetStyleName()); if(LtgLocalTime(nTime, aTm))
pSpan->Add(pXFNote); {
pCont->Add(pSpan); pXFNote->SetDate(LwpTools::DateTimeToOUString(aTm));
} }
else
{ pLayout->XFConvert(pXFNote);
pCont->Add(pXFNote); if(m_pModifiers)
} {
XFTextSpan *pSpan = new XFTextSpan();
pSpan->SetStyleName(GetStyleName());
pSpan->Add(pXFNote);
pCont->Add(pSpan);
}
else
{
pCont->Add(pXFNote);
} }
} }

View File

@@ -232,22 +232,22 @@ void LwpNumericFormat::GetCurrencyStr(LwpNumericFormatSubset aNumber, OUString&
} }
} }
} }
if ( aNumber.IsDefaultSuffix()) if ( !aNumber.IsDefaultSuffix())
return;
if (bPost)
{ {
if (bPost) aSuffix = aSymbol;
if (bShowSpace)
{ {
aSuffix = aSymbol; aSuffix = " " + aSuffix;
if (bShowSpace)
{
aSuffix = " " + aSuffix;
}
} }
if (bNegtive) }
{
aSuffix += ")"; if (bNegtive)
} {
aSuffix += ")";
} }
} }
void LwpNumericFormat::SetNumberType(XFNumberStyle* pStyle) void LwpNumericFormat::SetNumberType(XFNumberStyle* pStyle)

View File

@@ -258,52 +258,52 @@ void LwpPageLayout::ParseFootNoteSeparator(XFPageMaster * pm1)
{ {
//Get the footnoteoptions for the root document //Get the footnoteoptions for the root document
LwpDocument* pDocument = m_pFoundry ? m_pFoundry->GetDocument() : nullptr; LwpDocument* pDocument = m_pFoundry ? m_pFoundry->GetDocument() : nullptr;
if (pDocument) if (!pDocument)
return;
LwpObjectID* pFontnodeId = pDocument->GetValidFootnoteOpts();
LwpFootnoteOptions* pFootnoteOpts = pFontnodeId ? dynamic_cast<LwpFootnoteOptions*>(pFontnodeId->obj().get()) : nullptr;
if(!pFootnoteOpts)
return;
LwpFootnoteSeparatorOptions& rFootnoteSep = pFootnoteOpts->GetFootnoteSeparator();
//set length
sal_uInt32 nLengthPercent = 100;
double fWidth = 0;
if(rFootnoteSep.HasSeparator())
{ {
LwpObjectID* pFontnodeId = pDocument->GetValidFootnoteOpts(); fWidth = rFootnoteSep.GetTopBorderWidth();
}
if(rFootnoteSep.HasCustomLength())
{
const double fMarginWidth = GetMarginWidth();
if (fMarginWidth == 0.0)
throw o3tl::divide_by_zero();
LwpFootnoteOptions* pFootnoteOpts = pFontnodeId ? dynamic_cast<LwpFootnoteOptions*>(pFontnodeId->obj().get()) : nullptr; nLengthPercent = static_cast<sal_uInt32>(100*LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetLength()) / fMarginWidth);
if(pFootnoteOpts) if (nLengthPercent > 100)
{ nLengthPercent = 100;
LwpFootnoteSeparatorOptions& rFootnoteSep = pFootnoteOpts->GetFootnoteSeparator(); }
//set length double fAbove = LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetAbove());
sal_uInt32 nLengthPercent = 100; double fBelow = LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetBelow());
double fWidth = 0; LwpColor aColor = rFootnoteSep.GetTopBorderColor();
if(rFootnoteSep.HasSeparator()) enumXFAlignType eAlignType = enumXFAlignStart;
{ if(rFootnoteSep.GetIndent() > 0)
fWidth = rFootnoteSep.GetTopBorderWidth(); {
} const double fMarginWidth = GetMarginWidth();
if(rFootnoteSep.HasCustomLength()) if (fMarginWidth == 0.0)
{ throw o3tl::divide_by_zero();
const double fMarginWidth = GetMarginWidth();
if (fMarginWidth == 0.0)
throw o3tl::divide_by_zero();
nLengthPercent = static_cast<sal_uInt32>(100*LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetLength()) / fMarginWidth); //SODC don't support indent
if (nLengthPercent > 100) sal_uInt32 nIndentPercent = static_cast<sal_uInt32>(100*LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetIndent()) / fMarginWidth);
nLengthPercent = 100; if (nIndentPercent + nLengthPercent >= 100)
} eAlignType = enumXFAlignEnd;
double fAbove = LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetAbove()); }
double fBelow = LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetBelow()); if(aColor.IsValidColor())
LwpColor aColor = rFootnoteSep.GetTopBorderColor(); {
enumXFAlignType eAlignType = enumXFAlignStart; XFColor aXFColor(aColor.To24Color());
if(rFootnoteSep.GetIndent() > 0) pm1->SetFootNoteSeparator(eAlignType,fWidth, nLengthPercent, fAbove, fBelow, aXFColor);
{
const double fMarginWidth = GetMarginWidth();
if (fMarginWidth == 0.0)
throw o3tl::divide_by_zero();
//SODC don't support indent
sal_uInt32 nIndentPercent = static_cast<sal_uInt32>(100*LwpTools::ConvertFromUnitsToMetric(rFootnoteSep.GetIndent()) / fMarginWidth);
if (nIndentPercent + nLengthPercent >= 100)
eAlignType = enumXFAlignEnd;
}
if(aColor.IsValidColor())
{
XFColor aXFColor(aColor.To24Color());
pm1->SetFootNoteSeparator(eAlignType,fWidth, nLengthPercent, fAbove, fBelow, aXFColor);
}
}
} }
} }
@@ -469,18 +469,18 @@ bool LwpPageLayout::HasFillerPageText(LwpFoundry const * pFoundry)
*/ */
void LwpPageLayout::ConvertFillerPageText(XFContentContainer* pCont) void LwpPageLayout::ConvertFillerPageText(XFContentContainer* pCont)
{ {
if(HasFillerPageText(m_pFoundry)) if(!HasFillerPageText(m_pFoundry))
{ return;
//get fillerpage story from division info
LwpDocument* pDoc = m_pFoundry->GetDocument();
LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pDoc->GetDivInfoID().obj().get());
LwpStory* pStory = pDivInfo ? dynamic_cast<LwpStory*>(pDivInfo->GetFillerPageTextID().obj().get()) : nullptr;
//parse fillerpage story //get fillerpage story from division info
if(pStory) LwpDocument* pDoc = m_pFoundry->GetDocument();
{ LwpDivInfo* pDivInfo = dynamic_cast<LwpDivInfo*>(pDoc->GetDivInfoID().obj().get());
pStory->XFConvert(pCont); LwpStory* pStory = pDivInfo ? dynamic_cast<LwpStory*>(pDivInfo->GetFillerPageTextID().obj().get()) : nullptr;
}
//parse fillerpage story
if(pStory)
{
pStory->XFConvert(pCont);
} }
} }
/** /**

View File

@@ -264,25 +264,25 @@ void LwpPara::RegisterMasterPage(XFParaStyle const * pBaseStyle)
//get story //get story
LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj().get()); LwpStory* pStory = dynamic_cast<LwpStory*>(m_Story.obj().get());
//if pagelayout is modified, register the pagelayout //if pagelayout is modified, register the pagelayout
if(pStory && pStory->IsPMModified()) if(!(pStory && pStory->IsPMModified()))
{ return;
bool bNewSection = pStory->IsNeedSection();
LwpPageLayout* pLayout = pStory->GetCurrentLayout();
if(bNewSection)
{
RegisterNewSectionStyle(pLayout);
}
//register master page style bool bNewSection = pStory->IsNeedSection();
std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle); LwpPageLayout* pLayout = pStory->GetCurrentLayout();
*xOverStyle = *pBaseStyle; if(bNewSection)
xOverStyle->SetStyleName( ""); {
xOverStyle->SetMasterPage(pLayout->GetStyleName()); RegisterNewSectionStyle(pLayout);
if (!m_ParentStyleName.isEmpty())
xOverStyle->SetParentStyleName(m_ParentStyleName);
XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
} }
//register master page style
std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);
*xOverStyle = *pBaseStyle;
xOverStyle->SetStyleName( "");
xOverStyle->SetMasterPage(pLayout->GetStyleName());
if (!m_ParentStyleName.isEmpty())
xOverStyle->SetParentStyleName(m_ParentStyleName);
XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
m_StyleName = pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
} }
/** /**
* @short register paragraph style * @short register paragraph style

View File

@@ -326,37 +326,36 @@ void LwpParaStyle::ApplyParaBorder(XFParaStyle* pParaStyle, LwpParaBorderOverrid
//convert to XFBorders object: //convert to XFBorders object:
LwpBorderStuff *pBorderStuff = pBorder->GetBorderStuff(); LwpBorderStuff *pBorderStuff = pBorder->GetBorderStuff();
if( pBorderStuff && pBorderStuff->GetSide() != 0 ) if( !(pBorderStuff && pBorderStuff->GetSide() != 0) )
return;
XFBorders *pXFBorders = new XFBorders();
pParaStyle->SetBorders(pXFBorders);
LwpMargins* pMargins = pBorder->GetMargins();
// apply 4 borders respectively
LwpBorderStuff::BorderType pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
float pMarginValue[4] = { 0.0, 0.0, 0.0, 0.0 };
for (sal_uInt8 nC = 0; nC < 4; nC++)
{ {
XFBorders *pXFBorders = new XFBorders(); if (pBorderStuff->HasSide(pType[nC]))
pParaStyle->SetBorders(pXFBorders);
LwpMargins* pMargins = pBorder->GetMargins();
// apply 4 borders respectively
LwpBorderStuff::BorderType pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
float pMarginValue[4] = { 0.0, 0.0, 0.0, 0.0 };
for (sal_uInt8 nC = 0; nC < 4; nC++)
{ {
if (pBorderStuff->HasSide(pType[nC])) ApplySubBorder(pBorderStuff, pType[nC], pXFBorders);
//get border spacing to text content
if (pMargins)
{ {
ApplySubBorder(pBorderStuff, pType[nC], pXFBorders); pMarginValue[nC] = static_cast<float>(pMargins->GetMarginsValue(nC));
//get border spacing to text content
if (pMargins)
{
pMarginValue[nC] = static_cast<float>(pMargins->GetMarginsValue(nC));
}
} }
} }
//apply border spacing to text content
pParaStyle->SetPadding(pMarginValue[0], pMarginValue[1], pMarginValue[2], pMarginValue[3]);
} }
//apply border spacing to text content
pParaStyle->SetPadding(pMarginValue[0], pMarginValue[1], pMarginValue[2], pMarginValue[3]);
} }
void LwpParaStyle::ApplyBreaks(XFParaStyle* pParaStyle, const LwpBreaksOverride* pBreaks) void LwpParaStyle::ApplyBreaks(XFParaStyle* pParaStyle, const LwpBreaksOverride* pBreaks)

View File

@@ -81,21 +81,21 @@ void LwpSdwFileLoader::CreateDrawObjects(std::vector< rtl::Reference<XFFrame> >*
unsigned char BinSignature[2]; unsigned char BinSignature[2];
m_pStream->ReadBytes(BinSignature, 2); m_pStream->ReadBytes(BinSignature, 2);
if (BinSignature[0] == 'S' && BinSignature[1] == 'M') if (!(BinSignature[0] == 'S' && BinSignature[1] == 'M'))
{ return;
unsigned short nVersion;
m_pStream->ReadUInt16(nVersion);
m_pStream->Seek(0); unsigned short nVersion;
if (nVersion<0x0102) m_pStream->ReadUInt16(nVersion);
{
assert(false); m_pStream->Seek(0);
} if (nVersion<0x0102)
if (nVersion>=0x0102) {
{ assert(false);
LwpSdwGroupLoaderV0102 sdwGroupLoader(m_pStream, m_pGraphicObj); }
sdwGroupLoader.BeginDrawObjects(pDrawObjVector); if (nVersion>=0x0102)
} {
LwpSdwGroupLoaderV0102 sdwGroupLoader(m_pStream, m_pGraphicObj);
sdwGroupLoader.BeginDrawObjects(pDrawObjVector);
} }
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -381,28 +381,28 @@ void LwpSuperTableLayout::XFConvert(XFContentContainer* pCont)
*/ */
void LwpSuperTableLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart, sal_Int32 nEnd, bool bAll) void LwpSuperTableLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart, sal_Int32 nEnd, bool bAll)
{ {
if(m_pFrame) if(!m_pFrame)
{ return;
rtl::Reference<XFFrame> xXFFrame;
if(nEnd < nStart)
{
xXFFrame.set(new XFFrame);
}
else
{
xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
}
m_pFrame->Parse(xXFFrame.get(), static_cast<sal_uInt16>(nStart)); rtl::Reference<XFFrame> xXFFrame;
//parse table, and add table to frame if(nEnd < nStart)
LwpTableLayout * pTableLayout = GetTableLayout(); {
if (pTableLayout) xXFFrame.set(new XFFrame);
{
pTableLayout->XFConvert(xXFFrame.get());
}
//add frame to the container
pCont->Add(xXFFrame.get());
} }
else
{
xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
}
m_pFrame->Parse(xXFFrame.get(), static_cast<sal_uInt16>(nStart));
//parse table, and add table to frame
LwpTableLayout * pTableLayout = GetTableLayout();
if (pTableLayout)
{
pTableLayout->XFConvert(xXFFrame.get());
}
//add frame to the container
pCont->Add(xXFFrame.get());
} }
/** /**
@@ -1190,17 +1190,16 @@ void LwpTableLayout::PutCellVals(LwpFoundry* pFoundry, LwpObjectID aTableID)
sal_uInt16 nColID = pCellList->GetColumnID(); sal_uInt16 nColID = pCellList->GetColumnID();
XFCell* pCell = GetCellsMap(nRowID,static_cast<sal_uInt8>(nColID)); XFCell* pCell = GetCellsMap(nRowID,static_cast<sal_uInt8>(nColID));
if (pCell) if (!pCell)
{
pCellList->Convert(pCell, this);
//process paragraph
PostProcessParagraph(pCell, nRowID, nColID);
}
else
{ {
throw std::runtime_error("Hidden cell would not be in cellsmap"); throw std::runtime_error("Hidden cell would not be in cellsmap");
} }
pCellList->Convert(pCell, this);
//process paragraph
PostProcessParagraph(pCell, nRowID, nColID);
} }
pCellList = dynamic_cast<LwpCellList*>(pCellList->GetNextID().obj().get()); pCellList = dynamic_cast<LwpCellList*>(pCellList->GetNextID().obj().get());
if (aSeen.find(pCellList) != aSeen.end()) if (aSeen.find(pCellList) != aSeen.end())
@@ -1227,63 +1226,63 @@ void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_
{ {
// if number right, set alignment to right // if number right, set alignment to right
LwpCellLayout * pCellLayout = GetCellByRowCol(nRowID, nColID); LwpCellLayout * pCellLayout = GetCellByRowCol(nRowID, nColID);
if(pCellLayout) if(!pCellLayout)
return;
rtl::Reference<XFContent> first(
pCell->FindFirstContent(enumXFContentPara));
XFParagraph * pXFPara = static_cast<XFParagraph*>(first.get());
if (!pXFPara)
return;
XFColor aNullColor;
OUString sNumfmt = pCellLayout->GetNumfmtName();
bool bColorMod = false;
XFNumberStyle* pNumStyle = nullptr;
XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
if (!sNumfmt.isEmpty())
{ {
rtl::Reference<XFContent> first( pNumStyle = static_cast<XFNumberStyle*>(pXFStyleManager->FindStyle(sNumfmt));
pCell->FindFirstContent(enumXFContentPara)); XFColor aColor = pNumStyle->GetColor();
XFParagraph * pXFPara = static_cast<XFParagraph*>(first.get()); if ( aColor != aNullColor )
if (!pXFPara) bColorMod = true;//end
return; }
XFColor aNullColor;
OUString sNumfmt = pCellLayout->GetNumfmtName(); XFParaStyle * pStyle = pXFStyleManager->FindParaStyle(pXFPara->GetStyleName());
bool bColorMod = false; if (!((pStyle && pStyle->GetNumberRight()) || bColorMod))
XFNumberStyle* pNumStyle = nullptr; return;
XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
if (!sNumfmt.isEmpty()) std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);
if (pStyle)
{
*xOverStyle = *pStyle;
if (pStyle->GetNumberRight())
xOverStyle->SetAlignType(enumXFAlignEnd);
}
if (bColorMod)
{
rtl::Reference<XFFont> xFont = xOverStyle->GetFont();
if (xFont.is())
{ {
pNumStyle = static_cast<XFNumberStyle*>(pXFStyleManager->FindStyle(sNumfmt)); XFColor aColor = xFont->GetColor();
XFColor aColor = pNumStyle->GetColor(); if (aColor == aNullColor)
if ( aColor != aNullColor )
bColorMod = true;//end
}
XFParaStyle * pStyle = pXFStyleManager->FindParaStyle(pXFPara->GetStyleName());
if ((pStyle && pStyle->GetNumberRight()) || bColorMod)
{
std::unique_ptr<XFParaStyle> xOverStyle(new XFParaStyle);
if (pStyle)
{ {
*xOverStyle = *pStyle; rtl::Reference<XFFont> pNewFont(new XFFont);
aColor = pNumStyle->GetColor();
if (pStyle->GetNumberRight()) pNewFont->SetColor(aColor);
xOverStyle->SetAlignType(enumXFAlignEnd); xOverStyle->SetFont(pNewFont);
} }
if (bColorMod)
{
rtl::Reference<XFFont> xFont = xOverStyle->GetFont();
if (xFont.is())
{
XFColor aColor = xFont->GetColor();
if (aColor == aNullColor)
{
rtl::Reference<XFFont> pNewFont(new XFFont);
aColor = pNumStyle->GetColor();
pNewFont->SetColor(aColor);
xOverStyle->SetFont(pNewFont);
}
}
}
xOverStyle->SetStyleName("");
OUString StyleName
= pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
pXFPara->SetStyleName(StyleName);
} }
} }
xOverStyle->SetStyleName("");
OUString StyleName
= pXFStyleManager->AddStyle(std::move(xOverStyle)).m_pStyle->GetStyleName();
pXFPara->SetStyleName(StyleName);
} }
/** /**

View File

@@ -261,44 +261,44 @@ void LwpTocSuperLayout::XFConvert(XFContentContainer* pCont)
*/ */
void LwpTocSuperLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart, sal_Int32 nEnd, bool bAll) void LwpTocSuperLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart, sal_Int32 nEnd, bool bAll)
{ {
if (m_pFrame) if (!m_pFrame)
return;
rtl::Reference<XFFrame> xXFFrame;
if(nEnd < nStart)
{ {
rtl::Reference<XFFrame> xXFFrame; xXFFrame.set(new XFFrame);
if(nEnd < nStart)
{
xXFFrame.set(new XFFrame);
}
else
{
xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
}
m_pFrame->Parse(xXFFrame.get(), static_cast<sal_uInt16>(nStart));
//parse table, and add table to frame or TOC
LwpTableLayout * pTableLayout = GetTableLayout();
if (pTableLayout)
{
XFContentContainer* pTableContainer = xXFFrame.get();
// if *this is a TOCSuperTableLayout and it's located in a cell
// add the frame to upper level and add TOCSuperTableLayout into the frame
rtl::Reference<LwpVirtualLayout> xContainer(GetContainerLayout());
if (!xContainer.is())
return;
if (xContainer->IsCell())
{
pTableContainer = pCont; // TOC contain table directly
xXFFrame->Add(pCont);
m_pCont->Add(xXFFrame.get());
}
else
{
//add frame to the container
pCont->Add(xXFFrame.get());
}
pTableLayout->XFConvert(pTableContainer);
}
} }
else
{
xXFFrame.set(new XFFloatFrame(nStart, nEnd, bAll));
}
m_pFrame->Parse(xXFFrame.get(), static_cast<sal_uInt16>(nStart));
//parse table, and add table to frame or TOC
LwpTableLayout * pTableLayout = GetTableLayout();
if (!pTableLayout)
return;
XFContentContainer* pTableContainer = xXFFrame.get();
// if *this is a TOCSuperTableLayout and it's located in a cell
// add the frame to upper level and add TOCSuperTableLayout into the frame
rtl::Reference<LwpVirtualLayout> xContainer(GetContainerLayout());
if (!xContainer.is())
return;
if (xContainer->IsCell())
{
pTableContainer = pCont; // TOC contain table directly
xXFFrame->Add(pCont);
m_pCont->Add(xXFFrame.get());
}
else
{
//add frame to the container
pCont->Add(xXFFrame.get());
}
pTableLayout->XFConvert(pTableContainer);
} }
@@ -318,22 +318,22 @@ void LwpTocSuperLayout::AddSourceStyle(XFIndex* pToc, LwpTocLevelData * pLevel,
OUString sLwpStyleName = pLevel->GetSearchStyle(); OUString sLwpStyleName = pLevel->GetSearchStyle();
if (pFoundry) if (!pFoundry)
return;
LwpDocument * pDoc = pFoundry->GetDocument();
if (pDoc && pDoc->IsChildDoc())
{ {
LwpDocument * pDoc = pFoundry->GetDocument(); OUString sSodcStyleName = pFoundry->FindActuralStyleName(sLwpStyleName);
if (pDoc && pDoc->IsChildDoc()) pToc->AddTocSource(pLevel->GetLevel(), sSodcStyleName);
}
else
{
pDoc = pDoc->GetFirstDivision();
while (pDoc)
{ {
OUString sSodcStyleName = pFoundry->FindActuralStyleName(sLwpStyleName); AddSourceStyle(pToc, pLevel, pDoc->GetFoundry() );
pToc->AddTocSource(pLevel->GetLevel(), sSodcStyleName); pDoc = pDoc->GetNextDivision();
}
else
{
pDoc = pDoc->GetFirstDivision();
while (pDoc)
{
AddSourceStyle(pToc, pLevel, pDoc->GetFoundry() );
pDoc = pDoc->GetNextDivision();
}
} }
} }
} }