path: root/editeng
diff options
authorJustin Luth <>2019-07-03 15:33:35 +0300
committerJustin Luth <>2019-07-22 06:07:29 +0200
commit82c3e68642de445064313e353812b54df76c7fe9 (patch)
treeaffbde4996b940f506cd40409fc077d095b11f01 /editeng
parent382aceb80d3c0f420d51762e1f88eee2334ff11b (diff)
tdf#118370 Draw: add option to consolidate multiple textObjs
This gives the user a tool to consolidate multiple textboxes into a single textbox. First the user selects a group of textframes, and then runs the consolidate text function. This will REPLACE the marked textframes with a single textbox combining all of the text. The function inspects the text fragments to see if they end in sentence-ending punctuation. If not, then the next textbox's content is appended to it instead of starting a new pargraph. It is the user's responsibility to afterwards fix up paragraphing, and set paragraph properties. The rational for this patch is to simplify making major text changes on PDFs imported into Draw, since each paragraph is currently broken into tiny character-property textbox fragments. Copy/paste from the PDF itself doesn't keep character attributes, so it is hard for a user to re-create the text. This is related to tdf#32249, but as a comment says, a better solution would be to write an entire text-focused PDF import, rather than just pick up the pieces. And I agree, but considering this simple patch took me a couple of weeks of frustration, I'm obviously not the person to do that. And since the bug has been open for 9 years, likely no one else will either. Thus, this pick-up-the-pieces tool to help the end user. This initial patch works only with textFrames, but can easily be adjusted to consolidate other HasText() SdrObjects. However, that tended to produce unexpected results, so everything other than OBJ_TEXT is explicitly excluded. (Thus general shapes with text, callouts, text-along-path etc are ignored.) Change-Id: I68a9a5b187bf320a8e671414c5cb22b07725fd52 Reviewed-on: Tested-by: Jenkins Reviewed-by: Justin Luth <>
Diffstat (limited to 'editeng')
3 files changed, 15 insertions, 4 deletions
diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx
index cae8822cd48e..84b2f39df32d 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1666,7 +1666,7 @@ bool EditEngine::IsInSelectionMode() const
pImpEditEngine->GetSelEngine().IsInSelection() );
-void EditEngine::InsertParagraph( sal_Int32 nPara, const EditTextObject& rTxtObj )
+void EditEngine::InsertParagraph( sal_Int32 nPara, const EditTextObject& rTxtObj, bool bAppend )
if ( nPara > GetParagraphCount() )
@@ -1683,6 +1683,9 @@ void EditEngine::InsertParagraph( sal_Int32 nPara, const EditTextObject& rTxtObj
pImpEditEngine->RemoveCharAttribs( nPara );
pImpEditEngine->InsertText( rTxtObj, EditSelection( aPaM, aPaM ) );
+ if ( bAppend && nPara )
+ pImpEditEngine->ConnectContents( nPara-1, /*bBackwards=*/false );
diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx
index 976a94ea2f1a..99603db06493 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -3921,7 +3921,6 @@ EditPaM ImpEditEngine::ConnectContents( sal_Int32 nLeftNode, bool bBackward )
ContentNode* pRightNode = aEditDoc.GetObject( nLeftNode+1 );
DBG_ASSERT( pLeftNode, "Invalid left node in ConnectContents ");
DBG_ASSERT( pRightNode, "Invalid right node in ConnectContents ");
- DBG_ASSERT( IsInUndo(), "ConnectContent only for Undo()!" );
return ImpConnectParagraphs( pLeftNode, pRightNode, bBackward );
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 2d757fb23c9d..320dc6958355 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -602,7 +602,7 @@ void Outliner::SetText( const OutlinerParaObject& rPObj )
DBG_ASSERT( pEditEngine->GetParagraphCount()==rPObj.Count(),"SetText failed");
-void Outliner::AddText( const OutlinerParaObject& rPObj )
+void Outliner::AddText( const OutlinerParaObject& rPObj, bool bAppend )
bool bUpdate = pEditEngine->GetUpdateMode();
@@ -615,16 +615,25 @@ void Outliner::AddText( const OutlinerParaObject& rPObj )
nPara = 0;
+ bAppend = false;
nPara = pParaList->GetParagraphCount();
- pEditEngine->InsertParagraph( EE_PARA_APPEND, rPObj.GetTextObject() );
+ pEditEngine->InsertParagraph( EE_PARA_APPEND, rPObj.GetTextObject(), bAppend );
bFirstParaIsEmpty = false;
for( sal_Int32 n = 0; n < rPObj.Count(); n++ )
+ if ( n == 0 && bAppend )
+ {
+ // This first "paragraph" was just appended to an existing (incomplete) paragraph.
+ // Since no new paragraph will be added, the assumed increase-by-1 also won't happen.
+ --nPara;
+ continue;
+ }
Paragraph* pPara = new Paragraph( rPObj.GetParagraphData(n) );
sal_Int32 nP = nPara+n;