[Libreoffice-commits] core.git: editeng/source
Varun Dhall
varun.dhall at studentpartner.com
Fri Jul 7 08:34:55 UTC 2017
editeng/source/xml/xmltxtimp.cxx | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
New commits:
commit 9479171a09ba4c73afa8b40a5c2590df3b6d5415
Author: Varun Dhall <varun.dhall at studentpartner.com>
Date: Thu Jul 6 20:49:03 2017 +0530
EditEngine: Added para break/connect during ODF paste
Change-Id: I6ff7fb81425b7788da27ca297d5f08b80b96f795
Reviewed-on: https://gerrit.libreoffice.org/39662
Reviewed-by: Michael Stahl <mstahl at redhat.com>
Tested-by: Jenkins <ci at libreoffice.org>
diff --git a/editeng/source/xml/xmltxtimp.cxx b/editeng/source/xml/xmltxtimp.cxx
index fd757e86493c..54fe45c5ec97 100644
--- a/editeng/source/xml/xmltxtimp.cxx
+++ b/editeng/source/xml/xmltxtimp.cxx
@@ -37,10 +37,12 @@
#include <xmloff/xmlstyle.hxx>
#include "editsource.hxx"
#include "editxml.hxx"
+#include <editdoc.hxx>
#include <editeng/editeng.hxx>
#include <editeng/unotext.hxx>
#include <editeng/unoprnms.hxx>
#include <editeng/unoipset.hxx>
+#include <cassert>
using namespace com::sun::star;
using namespace com::sun::star::document;
@@ -148,9 +150,17 @@ void SvxReadXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& r
};
static SvxItemPropertySet aSvxXMLTextImportComponentPropertySet( SvxXMLTextImportComponentPropertyMap, EditEngine::GetGlobalItemPool() );
+ assert(!rSel.HasRange());
+ //get the initial para count before paste
+ sal_uInt32 initialParaCount = rEditEngine.GetEditDoc().Count();
+ //insert para breaks before inserting the copied text
+ rEditEngine.InsertParaBreak( rEditEngine.CreateSelection( rSel ).Max() );
+ rEditEngine.InsertParaBreak( rEditEngine.CreateSelection( rSel ).Max() );
+
+ ESelection aSel(rSel.nStartPara+1, 0, rSel.nEndPara+1, 0);
uno::Reference<text::XText > xParent;
SvxUnoText* pUnoText = new SvxUnoText( &aEditSource, &aSvxXMLTextImportComponentPropertySet, xParent );
- pUnoText->SetSelection( rSel );
+ pUnoText->SetSelection( aSel );
uno::Reference<text::XText > xText( pUnoText );
try
@@ -206,6 +216,17 @@ void SvxReadXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& r
xParser->parseStream( aParserInput );
}
while(false);
+
+ //remove the extra para breaks
+ EditDoc& pDoc = rEditEngine.GetEditDoc();
+ rEditEngine.ParaAttribsToCharAttribs( pDoc.GetObject( rSel.nEndPara ) );
+ rEditEngine.ConnectParagraphs( pDoc.GetObject( rSel.nEndPara ),
+ pDoc.GetObject( rSel.nEndPara + 1 ), true );
+ rEditEngine.ParaAttribsToCharAttribs( pDoc.GetObject( pDoc.Count() - initialParaCount + aSel.nEndPara - 2 ) );
+ rEditEngine.ConnectParagraphs( pDoc.GetObject( pDoc.Count() - initialParaCount + aSel.nEndPara - 2 ),
+ pDoc.GetObject( pDoc.Count() - initialParaCount + aSel.nEndPara -1 ), true );
+ rEditEngine.ConnectParagraphs( pDoc.GetObject( pDoc.Count() - initialParaCount + aSel.nEndPara - 2 ),
+ pDoc.GetObject( pDoc.Count() - initialParaCount + aSel.nEndPara -1 ), true );
}
catch( const uno::Exception& )
{
More information about the Libreoffice-commits
mailing list