summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editeng/source/editeng/eehtml.cxx12
-rw-r--r--editeng/source/editeng/eehtml.hxx1
-rw-r--r--editeng/source/editeng/impedit4.cxx16
3 files changed, 22 insertions, 7 deletions
diff --git a/editeng/source/editeng/eehtml.cxx b/editeng/source/editeng/eehtml.cxx
index 11cf8811bf9d..d7f7bda645f6 100644
--- a/editeng/source/editeng/eehtml.cxx
+++ b/editeng/source/editeng/eehtml.cxx
@@ -42,6 +42,7 @@ EditHTMLParser::EditHTMLParser( SvStream& rIn, OUString _aBaseURL, SvKeyValueIte
bInPara(false),
bWasInPara(false),
mbBreakForDivs(false),
+ mbNewBlockNeeded(false),
bFieldsInserted(false),
bInTitle(false),
nInTable(0),
@@ -313,8 +314,7 @@ void EditHTMLParser::NextToken( HtmlTokenId nToken )
case HtmlTokenId::DIVISION_ON:
case HtmlTokenId::DIVISION_OFF:
{
- if (mbBreakForDivs)
- Newline();
+ mbNewBlockNeeded = true;
break;
}
@@ -531,6 +531,7 @@ void EditHTMLParser::ImpInsertParaBreak()
mpEditEngine->CallHtmlImportHandler(aImportInfo);
}
aCurSel = mpEditEngine->InsertParaBreak(aCurSel);
+ mbNewBlockNeeded = false;
}
void EditHTMLParser::ImpSetAttribs( const SfxItemSet& rItems )
@@ -676,6 +677,13 @@ void EditHTMLParser::ImpSetStyleSheet( sal_uInt16 nHLevel )
void EditHTMLParser::ImpInsertText( const OUString& rText )
{
+ if (mbNewBlockNeeded)
+ {
+ if (mbBreakForDivs)
+ Newline();
+ mbNewBlockNeeded = false;
+ }
+
if (mpEditEngine->IsHtmlImportHandlerSet())
{
HtmlImportInfo aImportInfo(HtmlImportState::InsertText, this, mpEditEngine->CreateESelection(aCurSel));
diff --git a/editeng/source/editeng/eehtml.hxx b/editeng/source/editeng/eehtml.hxx
index 7b6591e2ccf4..9d77ebdaf68c 100644
--- a/editeng/source/editeng/eehtml.hxx
+++ b/editeng/source/editeng/eehtml.hxx
@@ -46,6 +46,7 @@ private:
bool bInPara:1;
bool bWasInPara:1; // Remember bInPara before HeadingStart, because afterwards it will be gone.
bool mbBreakForDivs:1; // Create newlines on encountering divs
+ bool mbNewBlockNeeded:1;
bool bFieldsInserted:1;
bool bInTitle:1;
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 8ffb3faf47b8..22e99ccf894f 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1087,7 +1087,7 @@ OString ImpEditEngine::GetSimpleHtml() const
sal_Int32 nIndex = 0;
sal_Int32 nEndPortion = pParaPortion->GetTextPortions().Count() - 1;
- aOutput.append("<div>");
+ OStringBuffer aPara;
for (sal_Int32 n = 0; n <= nEndPortion; n++)
{
const TextPortion& rTextPortion = pParaPortion->GetTextPortions()[n];
@@ -1106,17 +1106,23 @@ OString ImpEditEngine::GetSimpleHtml() const
OUString aRTFStr = EditDoc::GetParaAsString(pNode, nIndex, nIndex + rTextPortion.GetLen());
if (pURLField)
- aOutput.append("<a href=\"" + HTMLOutFuncs::ConvertStringToHTML(pURLField->GetURL()) + "\">");
+ aPara.append("<a href=\"" + HTMLOutFuncs::ConvertStringToHTML(pURLField->GetURL()) + "\">");
- aOutput.append(HTMLOutFuncs::ConvertStringToHTML(aRTFStr));
+ aPara.append(HTMLOutFuncs::ConvertStringToHTML(aRTFStr));
if (pURLField)
- aOutput.append("</a>");
+ aPara.append("</a>");
nIndex = nIndex + rTextPortion.GetLen();
}
- aOutput.append("</div>");
+ if (aPara.isEmpty())
+ {
+ if (nEndNode == 0) // only one empty blank line
+ break;
+ aPara.append("<br/>");
+ }
+ aOutput.append("<div>" + aPara + "</div>");
}
return aOutput.makeStringAndClear();