sd/qa/unit/tiledrendering/data/tdf102223.odp |binary
 sd/qa/unit/tiledrendering/tiledrendering.cxx |   47 +++++++++++++++++++++++++++
 svx/source/table/svdotable.cxx               |   18 +---------
 3 files changed, 49 insertions(+), 16 deletions(-)

New commits:
commit 6a361f874debed3863b55f741552faf8170d19bc
Author: Noel Grandin <n...@peralex.com>
Date:   Fri Sep 16 13:20:18 2016 +0200

    tdf#102223 EDITING Deleting all content from a cell changes font formatting
    
    The code in question was added in:
      commit 48ea88c8c8194d65105aa22108583369575926e1
      Author: Rüdiger Timm <r...@openoffice.org>
      Date:   Wed Mar 12 09:02:20 2008 +0000
      INTEGRATION: CWS impresstables2 (1.1.2); FILE ADDED
    
    So hard to tell what its original purpose was. Probably trying to clean
    up the model, but had the unintended side effect of removing styles.
    
    Change-Id: I7d774706c22cf72e914b356df9bbc5947ee2c1a5
    Reviewed-on: https://gerrit.libreoffice.org/28950
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-on: https://gerrit.libreoffice.org/29086
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>

diff --git a/sd/qa/unit/tiledrendering/data/tdf102223.odp 
b/sd/qa/unit/tiledrendering/data/tdf102223.odp
new file mode 100644
index 0000000..6b8570f
Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/tdf102223.odp differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index b4b2ec6..73e246c 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -19,7 +19,11 @@
 #include <comphelper/string.hxx>
 #include <editeng/editids.hrc>
 #include <editeng/editview.hxx>
+#include <editeng/editobj.hxx>
 #include <editeng/outliner.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/outlobj.hxx>
 #include <osl/conditn.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/viewfrm.hxx>
@@ -64,6 +68,7 @@ public:
     void testPartHash();
     void testResizeTable();
     void testResizeTableColumn();
+    void testTdf102223();
 #endif
 
     CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
@@ -85,6 +90,7 @@ public:
     CPPUNIT_TEST(testPartHash);
     CPPUNIT_TEST(testResizeTable);
     CPPUNIT_TEST(testResizeTableColumn);
+    CPPUNIT_TEST(testTdf102223);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -815,6 +821,47 @@ void SdTiledRenderingTest::testResizeTableColumn()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SdTiledRenderingTest::testTdf102223()
+{
+    // Load the document.
+    comphelper::LibreOfficeKit::setActive();
+    SdXImpressDocument* pXImpressDocument = createDoc("tdf102223.odp");
+    sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+    SdPage* pActualPage = pViewShell->GetActualPage();
+    auto pTableObject = 
dynamic_cast<sdr::table::SdrTableObj*>(pActualPage->GetObj(2));
+    CPPUNIT_ASSERT(pTableObject);
+    SdrView* pView = pViewShell->GetView();
+
+    // select contents of cell
+    Rectangle aRect = pTableObject->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(pTableObject);
+    CPPUNIT_ASSERT(pView->GetTextEditObject());
+    EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
+    rEditView.SetSelection(ESelection(0, 0, 0, 3)); // start para, start char, 
end para, end char.
+    CPPUNIT_ASSERT_EQUAL(OUString("Red"), rEditView.GetSelected());
+    const SvxFontHeightItem& rItem = static_cast<const 
SvxFontHeightItem&>(rEditView.GetAttribs().Get(EE_CHAR_FONTHEIGHT));
+    CPPUNIT_ASSERT_EQUAL((int)1411, (int)rItem.GetHeight());
+
+    // cut contents of cell
+    uno::Sequence<beans::PropertyValue> aArgs;
+    comphelper::dispatchCommand(".uno:Cut", aArgs);
+
+    pView->SdrBeginTextEdit(pTableObject);
+    CPPUNIT_ASSERT(pView->GetTextEditObject());
+    EditView& rEditView2 = pView->GetTextEditOutlinerView()->GetEditView();
+    rEditView2.SetSelection(ESelection(0, 0, 0, 1)); // start para, start 
char, end para, end char.
+    const SvxFontHeightItem& rItem2 = static_cast<const 
SvxFontHeightItem&>(rEditView2.GetAttribs().Get(EE_CHAR_FONTHEIGHT));
+    CPPUNIT_ASSERT_EQUAL((int)1411, (int)rItem2.GetHeight());
+
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 #endif
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx
index 8793f83..f828907 100644
--- a/svx/source/table/svdotable.cxx
+++ b/svx/source/table/svdotable.cxx
@@ -1826,25 +1826,11 @@ void SdrTableObj::EndTextEdit(SdrOutliner& rOutl)
 
         if(p1stPara)
         {
-            if(nParaAnz == 1)
-            {
-                // if its only one paragraph, check if it is empty
-                OUString aStr(rOutl.GetText(p1stPara));
-                if (aStr.isEmpty())
-                {
-                    // gotcha!
-                    nParaAnz = 0;
-                }
-            }
-
             // to remove the grey field background
             rOutl.UpdateFields();
 
-            if(nParaAnz != 0)
-            {
-                // create new text object
-                pNewText = rOutl.CreateParaObject( 0, nParaAnz );
-            }
+            // create new text object
+            pNewText = rOutl.CreateParaObject( 0, nParaAnz );
         }
         SetOutlinerParaObject(pNewText);
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to