diff options
author | Varun Dhall <varun.dhall@studentpartner.com> | 2017-07-06 20:49:03 +0530 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-07-07 10:34:28 +0200 |
commit | 9479171a09ba4c73afa8b40a5c2590df3b6d5415 (patch) | |
tree | 5d44f1b3db23240fa2e18e38bb8f2e46e90e1fb0 /editeng/source/xml/xmltxtimp.cxx | |
parent | e37539b3f0066abe29b737d4194ee766d5b09028 (diff) |
EditEngine: Added para break/connect during ODF paste
Change-Id: I6ff7fb81425b7788da27ca297d5f08b80b96f795
Reviewed-on: https://gerrit.libreoffice.org/39662
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'editeng/source/xml/xmltxtimp.cxx')
-rw-r--r-- | editeng/source/xml/xmltxtimp.cxx | 23 |
1 files changed, 22 insertions, 1 deletions
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& ) { |