[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3-desktop' - editeng/qa editeng/source

2018-03-13 Thread Szymon Kłos
 editeng/qa/unit/core-test.cxx   |   94 
 editeng/source/editeng/impedit3.cxx |   13 ++--
 2 files changed, 100 insertions(+), 7 deletions(-)

New commits:
commit c59f03b33abaacf82672f4276356e7ce75223bbb
Author: Szymon Kłos 
Date:   Fri Mar 9 14:48:49 2018 +0100

tdf#116101 Correct bullet position for linespacing > 100%

Change-Id: Ia900636d4013ab2a9c893c8246391db867fe1543
Reviewed-on: https://gerrit.libreoffice.org/51017
Tested-by: Jenkins 
Reviewed-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/51217
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 892293f43117..01d51eb271d3 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -19,6 +19,9 @@
 #include "editeng/eeitem.hxx"
 #include "editeng/editids.hrc"
 #include "editeng/editdoc.hxx"
+#include "editeng/fontitem.hxx"
+#include "editeng/fhgtitem.hxx"
+#include "editeng/lspcitem.hxx"
 #include "editeng/svxacorr.hxx"
 #include "editeng/unofield.hxx"
 #include "editeng/wghtitem.hxx"
@@ -45,6 +48,9 @@ public:
 virtual void setUp() override;
 virtual void tearDown() override;
 
+/// Test text portions position when percentage line spacing is set
+void testLineSpacing();
+
 void testConstruction();
 
 /// Test UNO service class that implements text field items.
@@ -63,6 +69,7 @@ public:
 
 CPPUNIT_TEST_SUITE(Test);
 CPPUNIT_TEST(testConstruction);
+CPPUNIT_TEST(testLineSpacing);
 CPPUNIT_TEST(testUnoTextFields);
 CPPUNIT_TEST(testAutocorrect);
 CPPUNIT_TEST(testHyperlinkSearch);
@@ -110,6 +117,93 @@ bool includes(const uno::Sequence& rSeq, const 
OUString& rVal)
 
 }
 
+void Test::testLineSpacing()
+{
+// Create EditEngine's instance
+EditEngine aEditEngine(mpItemPool);
+
+if(aEditEngine.GetRefDevice()->GetDPIY() != 96
+|| 
!basegfx::fTools::equal(aEditEngine.GetRefDevice()->GetDPIScaleFactor(), 1.0))
+return;
+
+// Get EditDoc for current EditEngine's instance
+EditDoc  = aEditEngine.GetEditDoc();
+
+// Initially no text should be there
+CPPUNIT_ASSERT_EQUAL(sal_uLong(0), rDoc.GetTextLen());
+CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0)));
+
+// Set initial text
+OUString aText = "This is multi-line paragraph";
+
+sal_Int32 aTextLen = aText.getLength();
+aEditEngine.SetText(aText);
+
+// Assert changes - text insertion
+CPPUNIT_ASSERT_EQUAL(sal_uLong(aTextLen), rDoc.GetTextLen());
+CPPUNIT_ASSERT_EQUAL(aText, rDoc.GetParaAsString(sal_Int32(0)));
+
+// Get ItemSet for line spacing - 60%
+std::unique_ptr pSet(new 
SfxItemSet(aEditEngine.GetEmptyItemSet()));
+SvxLineSpacingItem aLineSpacing(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL);
+aLineSpacing.SetPropLineSpace(60);
+pSet->Put(aLineSpacing);
+
+// Set font
+SvxFontItem aFont(EE_CHAR_FONTINFO);
+aFont.SetFamilyName("Liberation Sans");
+pSet->Put(aFont);
+SvxFontHeightItem aFontSize(240, 100, EE_CHAR_FONTHEIGHT);
+pSet->Put(aFontSize);
+
+CPPUNIT_ASSERT_EQUAL(static_cast(3), pSet->Count());
+
+// Select all paragraphs and set spacing
+ESelection aSelection(0, 0, 0, aTextLen);
+aEditEngine.QuickSetAttribs(*pSet, aSelection);
+
+// Force multiple lines
+aEditEngine.SetPaperSize(Size(1000, 6000));
+CPPUNIT_ASSERT_EQUAL((sal_Int32)4, aEditEngine.GetLineCount(0));
+
+// Assert changes
+ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0];
+ContentNode* const pNode = pParaPortion->GetNode();
+const SfxPoolItem& rLSItem = 
pNode->GetContentAttribs().GetItem(EE_PARA_SBL);
+const SvxLineSpacingItem* pLSItem = static_cast();
+CPPUNIT_ASSERT(SvxInterLineSpaceRule::Prop == 
pLSItem->GetInterLineSpaceRule());
+CPPUNIT_ASSERT_EQUAL((sal_uInt16)60, pLSItem->GetPropLineSpace());
+
+// Check the first line
+ParagraphInfos aInfo = aEditEngine.GetParagraphInfos(0);
+CPPUNIT_ASSERT_EQUAL((sal_uInt16)122, aInfo.nFirstLineMaxAscent);
+CPPUNIT_ASSERT_EQUAL((sal_uInt16)153, 
(sal_uInt16)aEditEngine.GetLineHeight(0));
+
+// Prepare second case - 150%
+std::unique_ptr pSet2(new 
SfxItemSet(aEditEngine.GetEmptyItemSet()));
+SvxLineSpacingItem aLineSpacing2(LINE_SPACE_DEFAULT_HEIGHT, EE_PARA_SBL);
+aLineSpacing2.SetPropLineSpace(150);
+pSet2->Put(aLineSpacing2);
+pSet2->Put(aFont);
+pSet2->Put(aFontSize);
+
+CPPUNIT_ASSERT_EQUAL(static_cast(3), pSet2->Count());
+
+// Select all paragraphs and set spacing
+aEditEngine.QuickSetAttribs(*pSet2, aSelection);
+
+// Assert changes
+const SfxPoolItem& rLSItem2 = 
pNode->GetContentAttribs().GetItem(EE_PARA_SBL);
+const SvxLineSpacingItem* pLSItem2 = 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3-desktop' - editeng/qa editeng/source include/editeng

2018-02-21 Thread Tamás Zolnai
 editeng/qa/unit/core-test.cxx   |   33 +
 editeng/source/editeng/editeng.cxx  |4 ++--
 editeng/source/editeng/impedit.hxx  |2 +-
 editeng/source/editeng/impedit2.cxx |4 ++--
 editeng/source/editeng/impedit3.cxx |4 ++--
 include/editeng/editeng.hxx |2 +-
 6 files changed, 41 insertions(+), 8 deletions(-)

New commits:
commit 24c28ff3989d97e9023416408303dc1ff4580184
Author: Tamás Zolnai 
Date:   Tue Feb 20 00:30:27 2018 +0100

tdf#115639: Handle alignment correctly for multiple paragraph case

I used the wrong calculator method to get the line width.
This commit also fixes the crashes found by crashtest.

Reviewed-on: https://gerrit.libreoffice.org/49994
Tested-by: Jenkins 
Reviewed-by: Tamás Zolnai 
(cherry picked from commit f0485ba2d90aae0312f5775588f22789016165d2)

Change-Id: I25392f86af912ee54c07b14480d82282210ac346
Reviewed-on: https://gerrit.libreoffice.org/50100
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index b6da4d4a1a8d..892293f43117 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -740,6 +740,39 @@ void Test::testHoriAlignIgnoreTrailingWhitespace()
 EditLine* pLine = >GetLines()[0];
 CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast(8815), 
pLine->GetStartPosX(), 10);
 }
+
+// Test multiple paragraph case
+{
+// Set initial text
+aText = "Some text\nMore Text   ";
+aTextLen = aText.getLength();
+aEditEngine.SetText(aText);
+
+// Assert changes - text insertion
+CPPUNIT_ASSERT_EQUAL(static_cast(aTextLen - 1), 
rDoc.GetTextLen());
+CPPUNIT_ASSERT_EQUAL(OUString("Some text"), 
rDoc.GetParaAsString(static_cast(0)));
+CPPUNIT_ASSERT_EQUAL(OUString("More Text   "), 
rDoc.GetParaAsString(static_cast(1)));
+
+aEditEngine.SetHoriAlignIgnoreTrailingWhitespace(true);
+std::unique_ptr pSet(new 
SfxItemSet(aEditEngine.GetEmptyItemSet()));
+pSet->Put(SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ));
+CPPUNIT_ASSERT_EQUAL(static_cast(1), pSet->Count());
+
+// Select all paragraphs and apply changes
+ESelection aSelection(0, 0, 0, aTextLen);
+aEditEngine.QuickSetAttribs(*pSet, aSelection);
+
+// Get one line paragraphs
+aEditEngine.SetPaperSize(Size(1, 6000));
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
aEditEngine.GetLineCount(0));
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
aEditEngine.GetLineCount(1));
+
+// Check horizontal position
+ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0];
+CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast(4527), 
pParaPortion->GetLines()[0].GetStartPosX(), 50);
+pParaPortion = aEditEngine.GetParaPortions()[1];
+CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast(8815), 
pParaPortion->GetLines()[0].GetStartPosX(), 50);
+}
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index 0232b81e84aa..9086b18835cd 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -1433,13 +1433,13 @@ sal_uInt32 EditEngine::GetTextHeightNTP() const
 return pImpEditEngine->GetTextHeightNTP();
 }
 
-sal_uInt32 EditEngine::CalcTextWidth(bool bIgnoreTrailingWhiteSpaces)
+sal_uInt32 EditEngine::CalcTextWidth()
 {
 
 if ( !pImpEditEngine->IsFormatted() )
 pImpEditEngine->FormatDoc();
 
-sal_uInt32 nWidth = !IsVertical() ? pImpEditEngine->CalcTextWidth( true, 
bIgnoreTrailingWhiteSpaces ) : pImpEditEngine->GetTextHeight();
+sal_uInt32 nWidth = !IsVertical() ? pImpEditEngine->CalcTextWidth( true ) 
: pImpEditEngine->GetTextHeight();
  return nWidth;
 }
 
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index f83cf46803dc..40f5d2514209 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -817,7 +817,7 @@ public:
 sal_uInt32  CalcTextHeight( sal_uInt32* pHeightNTP );
 sal_uInt32  GetTextHeight() const;
 sal_uInt32  GetTextHeightNTP() const;
-sal_uInt32  CalcTextWidth( bool bIgnoreExtraSpace, bool 
bIgnoreTrailingWhiteSpaces = false );
+sal_uInt32  CalcTextWidth( bool bIgnoreExtraSpace );
 sal_uInt32  CalcLineWidth( ParaPortion* pPortion, EditLine* pLine, 
bool bIgnoreExtraSpace, bool bIgnoreTrailingWhiteSpaces = false );
 sal_Int32   GetLineCount( sal_Int32 nParagraph ) const;
 sal_Int32   GetLineLen( sal_Int32 nParagraph, sal_Int32 nLine ) const;
diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3-desktop' - editeng/qa editeng/source include/editeng include/svx sd/qa sd/source svx/source

2018-02-19 Thread Tamás Zolnai
 editeng/qa/unit/core-test.cxx|  111 +++
 editeng/source/editeng/editeng.cxx   |   14 +++-
 editeng/source/editeng/impedit.hxx   |9 ++
 editeng/source/editeng/impedit2.cxx  |   16 +++--
 editeng/source/editeng/impedit3.cxx  |   12 +++
 editeng/source/outliner/outliner.cxx |   10 +++
 include/editeng/editeng.hxx  |6 +
 include/editeng/outliner.hxx |4 +
 include/svx/svdmodel.hxx |4 +
 sd/qa/unit/data/odp/tdf115639.odp|binary
 sd/qa/unit/data/ppt/tdf115639.ppt|binary
 sd/qa/unit/data/pptx/tdf115639.pptx  |binary
 sd/qa/unit/import-tests.cxx  |   33 ++
 sd/source/ui/docshell/docshel4.cxx   |   16 +
 sd/source/ui/view/Outliner.cxx   |1 
 svx/source/svdraw/svdetc.cxx |1 
 svx/source/svdraw/svdmodel.cxx   |   22 ++
 17 files changed, 246 insertions(+), 13 deletions(-)

New commits:
commit ed7fb360f9c1693355cd602de77ea680b286b55a
Author: Tamás Zolnai 
Date:   Sat Feb 17 15:49:27 2018 +0100

tdf#115639: Align right/center with trailing spaces the same as MS 
PowerPoint

* Add HoriAlignIgnoreTrailingWhitespace compatibility option.
** For MSO file formats it is set to true
** For ODP format it's set to false by default
** The flag is saved to ODP format as user data if the document
comes from an MSO format.

Reviewed-on: https://gerrit.libreoffice.org/49889
Tested-by: Jenkins 
Reviewed-by: Tamás Zolnai 
(cherry picked from commit 1da3a3cb74a415a76fa547ef0c8f61780e260e7f)

Change-Id: Ie22233d33a25e605de46120bfc2195038dffd63c
Reviewed-on: https://gerrit.libreoffice.org/49909
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 
(cherry picked from commit f26899be899f1a39ea1e6b5ad8b46bad9cf1216f)
Reviewed-on: https://gerrit.libreoffice.org/49970

diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 8048feabf131..b6da4d4a1a8d 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -26,6 +26,7 @@
 #include "editeng/section.hxx"
 #include "editeng/editobj.hxx"
 #include "editeng/flditem.hxx"
+#include 
 #include "svl/srchitem.hxx"
 
 #include 
@@ -57,12 +58,16 @@ public:
 
 void testSectionAttributes();
 
+/// Test HoriAlignIgnoreTrailingWhitespace compatibility flag
+void testHoriAlignIgnoreTrailingWhitespace();
+
 CPPUNIT_TEST_SUITE(Test);
 CPPUNIT_TEST(testConstruction);
 CPPUNIT_TEST(testUnoTextFields);
 CPPUNIT_TEST(testAutocorrect);
 CPPUNIT_TEST(testHyperlinkSearch);
 CPPUNIT_TEST(testSectionAttributes);
+CPPUNIT_TEST(testHoriAlignIgnoreTrailingWhitespace);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -631,6 +636,112 @@ void Test::testSectionAttributes()
 }
 }
 
+void Test::testHoriAlignIgnoreTrailingWhitespace()
+{
+// Create EditEngine's instance
+EditEngine aEditEngine(mpItemPool);
+
+// Get EditDoc for current EditEngine's instance
+EditDoc  = aEditEngine.GetEditDoc();
+
+// Initially no text should be there
+CPPUNIT_ASSERT_EQUAL(sal_uLong(0), rDoc.GetTextLen());
+CPPUNIT_ASSERT_EQUAL(OUString(), rDoc.GetParaAsString(sal_Int32(0)));
+
+// Set initial text
+OUString aText = "Some text";
+sal_Int32 aTextLen = aText.getLength();
+aEditEngine.SetText(aText);
+
+// Assert changes - text insertion
+CPPUNIT_ASSERT_EQUAL(static_cast(aTextLen), rDoc.GetTextLen());
+CPPUNIT_ASSERT_EQUAL(aText, 
rDoc.GetParaAsString(static_cast(0)));
+
+// First test case: center alignment with compatibility option enabled
+{
+aEditEngine.SetHoriAlignIgnoreTrailingWhitespace(true);
+std::unique_ptr pSet(new 
SfxItemSet(aEditEngine.GetEmptyItemSet()));
+pSet->Put(SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ));
+CPPUNIT_ASSERT_EQUAL(static_cast(1), pSet->Count());
+
+// Select all paragraphs and apply changes
+ESelection aSelection(0, 0, 0, aTextLen);
+aEditEngine.QuickSetAttribs(*pSet, aSelection);
+
+// Use a one line paragraph
+aEditEngine.SetPaperSize(Size(1, 6000));
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
aEditEngine.GetLineCount(0));
+
+// Check horizontal position
+ParaPortion* pParaPortion = aEditEngine.GetParaPortions()[0];
+EditLine* pLine = >GetLines()[0];
+CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast(4527), 
pLine->GetStartPosX(), 10);
+}
+
+// Second test case: center alignment with compatibility option disabled
+{
+aEditEngine.SetHoriAlignIgnoreTrailingWhitespace(false);
+std::unique_ptr pSet(new 
SfxItemSet(aEditEngine.GetEmptyItemSet()));
+pSet->Put(SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ));
+CPPUNIT_ASSERT_EQUAL(static_cast(1), pSet->Count());
+
+