Kaydet (Commit) 7e488767 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

tdf#103083 - EDITING: Cut and Paste changes bullet point formatting

The bug is that, on paste, the incorrect stylesheet is set on a paragraph
node, leading to the loss of bullet formatting information.

There are two copies of this style-resetting code, one in
   sd::View::OnEndPasteOrDrop
and the other in
    Outliner::ImplSetLevelDependendStyleSheet.

The first one was introduced by:
    commit 8aa3d121
    Author: Rüdiger Timm <rt@openoffice.org>
    Date:   Fri Jun 6 11:11:54 2008 +0000
    INTEGRATION: CWS impressodf12 (1.62.4); FILE MERGED

And the second one by:
   commit a6b3e8c1
   Author: Rüdiger Timm <rt@openoffice.org>
   Date:   Fri Jun 6 11:30:58 2008 +0000
   INTEGRATION: CWS impressodf12 (1.70.350); FILE MERGED

The second one appears to do the right thing, and fixes this bug,
so I am deleting the first one.

Change-Id: I5eede7fe7bd3aa24696b495e740d1a4df124bd3a
Reviewed-on: https://gerrit.libreoffice.org/30009Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 930f0242
This diff is collapsed.
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <svl/srchitem.hxx> #include <svl/srchitem.hxx>
#include <comphelper/lok.hxx> #include <comphelper/lok.hxx>
#include <svx/svdotable.hxx> #include <svx/svdotable.hxx>
#include <svx/svdoutl.hxx>
#include <DrawDocShell.hxx> #include <DrawDocShell.hxx>
#include <ViewShellBase.hxx> #include <ViewShellBase.hxx>
...@@ -78,6 +79,7 @@ public: ...@@ -78,6 +79,7 @@ public:
void testCreateViewTextCursor(); void testCreateViewTextCursor();
void testTdf102223(); void testTdf102223();
void testPostKeyEventInvalidation(); void testPostKeyEventInvalidation();
void testTdf103083();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback); CPPUNIT_TEST(testRegisterCallback);
...@@ -107,6 +109,7 @@ public: ...@@ -107,6 +109,7 @@ public:
CPPUNIT_TEST(testCreateViewTextCursor); CPPUNIT_TEST(testCreateViewTextCursor);
CPPUNIT_TEST(testTdf102223); CPPUNIT_TEST(testTdf102223);
CPPUNIT_TEST(testPostKeyEventInvalidation); CPPUNIT_TEST(testPostKeyEventInvalidation);
CPPUNIT_TEST(testTdf103083);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -1337,6 +1340,73 @@ void SdTiledRenderingTest::testPostKeyEventInvalidation() ...@@ -1337,6 +1340,73 @@ void SdTiledRenderingTest::testPostKeyEventInvalidation()
comphelper::LibreOfficeKit::setActive(false); comphelper::LibreOfficeKit::setActive(false);
} }
/**
* tests a cut/paste bug around bullet items in a list
*/
void SdTiledRenderingTest::testTdf103083()
{
// Load the document.
comphelper::LibreOfficeKit::setActive();
SdXImpressDocument* pXImpressDocument = createDoc("tdf103083.fodp");
sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
SdPage* pActualPage = pViewShell->GetActualPage();
SdrObject* pObject1 = pActualPage->GetObj(1);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(OBJ_OUTLINETEXT), pObject1->GetObjIdentifier());
SdrTextObj* pTextObject = static_cast<SdrTextObj*>(pObject1);
SdrView* pView = pViewShell->GetView();
// select contents of bullet item
Rectangle aRect = pTextObject->GetCurrentBoundRect();
pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
convertMm100ToTwip(aRect.getX() + 2), convertMm100ToTwip(aRect.getY() + 2),
1, MOUSE_LEFT, 0);
pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP,
convertMm100ToTwip(aRect.getX() + 2), convertMm100ToTwip(aRect.getY() + 2),
1, MOUSE_LEFT, 0);
pView->SdrBeginTextEdit(pTextObject);
CPPUNIT_ASSERT(pView->GetTextEditObject());
EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
rEditView.SetSelection(ESelection(2, 0, 2, 33)); // start para, start char, end para, end char.
CPPUNIT_ASSERT_EQUAL(OUString("They have all the same formatting"), rEditView.GetSelected());
SdrOutliner* pOutliner = pView->GetTextEditOutliner();
CPPUNIT_ASSERT_EQUAL(OUString("No-Logo Content~LT~Gliederung 2"),
pOutliner->GetStyleSheet(2)->GetName());
const SfxItemSet& rParagraphItemSet1 = pTextObject->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(2);
CPPUNIT_ASSERT_EQUAL((sal_uInt16)3, rParagraphItemSet1.Count());
// cut contents of bullet item
comphelper::dispatchCommand(".uno:Cut", uno::Sequence<beans::PropertyValue>());
CPPUNIT_ASSERT(pView->GetTextEditObject());
EditView& rEditView2 = pView->GetTextEditOutlinerView()->GetEditView();
rEditView2.SetSelection(ESelection(2, 0, 2, 10)); // start para, start char, end para, end char.
CPPUNIT_ASSERT_EQUAL(OUString(""), rEditView2.GetSelected());
// paste contents of bullet item
comphelper::dispatchCommand(".uno:Paste", uno::Sequence<beans::PropertyValue>());
// send an ESC key to trigger the commit of the edit to the main model
pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::ESCAPE);
pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::ESCAPE);
Scheduler::ProcessEventsToIdle();
pView->SdrBeginTextEdit(pTextObject);
CPPUNIT_ASSERT(pView->GetTextEditObject());
pOutliner = pView->GetTextEditOutliner();
EditView& rEditView3 = pView->GetTextEditOutlinerView()->GetEditView();
rEditView3.SetSelection(ESelection(2, 0, 2, 33)); // start para, start char, end para, end char.
CPPUNIT_ASSERT_EQUAL(OUString("They have all the same formatting"), rEditView3.GetSelected());
CPPUNIT_ASSERT_EQUAL(OUString("No-Logo Content~LT~Gliederung 2"),
pOutliner->GetStyleSheet(2)->GetName());
const SfxItemSet& rParagraphItemSet2 = pTextObject->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(2);
CPPUNIT_ASSERT_EQUAL((sal_uInt16)3, rParagraphItemSet2.Count());
comphelper::LibreOfficeKit::setActive(false);
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -1210,44 +1210,15 @@ void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfo ) ...@@ -1210,44 +1210,15 @@ void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfo )
if( pOutliner && pTextObj && pTextObj->GetPage() ) if( pOutliner && pTextObj && pTextObj->GetPage() )
{ {
SdPage* pPage = static_cast< SdPage* >( pTextObj->GetPage() ); SdPage* pPage = static_cast< SdPage* >( pTextObj->GetPage() );
SfxStyleSheet* pStyleSheet = nullptr;
const PresObjKind eKind = pPage->GetPresObjKind(pTextObj); const PresObjKind eKind = pPage->GetPresObjKind(pTextObj);
if( eKind != PRESOBJ_NONE ) // outline kinds are taken care of in Outliner::ImplSetLevelDependendStyleSheet
pStyleSheet = pPage->GetStyleSheetForPresObj(eKind); if( eKind != PRESOBJ_OUTLINE )
else
pStyleSheet = pTextObj->GetStyleSheet();
if( eKind == PRESOBJ_OUTLINE )
{
// for outline shapes, set the correct outline style sheet for each
// new paragraph, depending on the paragraph depth
SfxStyleSheetBasePool* pStylePool = GetDoc().GetStyleSheetPool();
for ( sal_Int32 nPara = pInfo->nStartPara; nPara <= pInfo->nEndPara; nPara++ )
{
sal_Int16 nDepth = pOutliner->GetDepth( nPara );
SfxStyleSheet* pStyle = nullptr;
if( nDepth > 0 )
{
OUString aStyleSheetName( pStyleSheet->GetName() );
if (!aStyleSheetName.isEmpty())
aStyleSheetName = aStyleSheetName.copy(0, aStyleSheetName.getLength() - 1);
aStyleSheetName += OUString::number( nDepth );
pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() ) );
DBG_ASSERT( pStyle, "sd::View::OnEndPasteOrDrop(), Style not found!" );
}
if( !pStyle )
pStyle = pStyleSheet;
pOutliner->SetStyleSheet( nPara, pStyle );
}
}
else
{ {
SfxStyleSheet* pStyleSheet = nullptr;
if( eKind != PRESOBJ_NONE )
pStyleSheet = pPage->GetStyleSheetForPresObj(eKind);
else
pStyleSheet = pTextObj->GetStyleSheet();
// just put the object style on each new paragraph // just put the object style on each new paragraph
for ( sal_Int32 nPara = pInfo->nStartPara; nPara <= pInfo->nEndPara; nPara++ ) for ( sal_Int32 nPara = pInfo->nStartPara; nPara <= pInfo->nEndPara; nPara++ )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment