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

2018-06-29 Thread Justin Luth
 sw/qa/extras/ww8export/data/tdf70838b_verticalRotation.odt |binary
 sw/qa/extras/ww8export/ww8export2.cxx  |   12 
 sw/source/filter/ww8/wrtw8esh.cxx  |3 ++-
 3 files changed, 14 insertions(+), 1 deletion(-)

New commits:
commit 8d1fecd51fbce7d4bb0013e59589a88f7b29f5db
Author: Justin Luth 
Date:   Thu Jun 28 15:48:40 2018 +0300

tdf#118421 ww8export: rotate vertically: not Lines or groups

Lines and Groups often are exceptions.
Normally, the import code swaps vertical rotations also. In the case
of lines (from the tests that I observed) lines don't have a rotation
value at that point during import, so no correction is made.
Grouping always messes things up.

Change-Id: I344c5a29f887294b751ffc87c01b30e472cfb4c2
Reviewed-on: https://gerrit.libreoffice.org/56595
Reviewed-by: Justin Luth 
Tested-by: Justin Luth 
(cherry picked from commit 1cedd88d40a26a55ce433f8b742215aea83a5382)
Reviewed-on: https://gerrit.libreoffice.org/56655
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/ww8export/data/tdf70838b_verticalRotation.odt 
b/sw/qa/extras/ww8export/data/tdf70838b_verticalRotation.odt
new file mode 100644
index ..556f2564c7a2
Binary files /dev/null and 
b/sw/qa/extras/ww8export/data/tdf70838b_verticalRotation.odt differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx 
b/sw/qa/extras/ww8export/ww8export2.cxx
index e02b0c15b709..f2c8ffdf3998 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -144,6 +144,18 @@ DECLARE_WW8EXPORT_TEST(testTdf70838, "tdf70838.odt")
 CPPUNIT_ASSERT( aRect.GetHeight() > aRect.GetWidth() );
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf70838b_verticalRotation, 
"tdf70838b_verticalRotation.odt")
+{
+SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get());
+SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+SdrPage* pPage = 
pDoc->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+Rectangle aGroupShape = pPage->GetObj(0)->GetSnapRect();
+Rectangle aLine = pPage->GetObj(2)->GetSnapRect();
+
+CPPUNIT_ASSERT_MESSAGE("Smiley faces are round", aGroupShape.GetHeight() > 
aGroupShape.GetWidth());
+CPPUNIT_ASSERT_MESSAGE("Line is taller, not wider", aLine.GetHeight() > 
aLine.GetWidth());
+}
+
 DECLARE_WW8EXPORT_TEST( testActiveXCheckbox, "checkbox_control.odt" )
 {
 // First check box anchored as a floating object
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx 
b/sw/source/filter/ww8/wrtw8esh.cxx
index 091f5300faae..519c11604425 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -694,7 +694,8 @@ void PlcDrawObj::WritePlc( WW8Export& rWrt ) const
 
 // rotating to vertical means swapping height and width as 
seen in SvxMSDffManager::ImportShape
 const long nAngle = NormAngle360( pObj->GetRotateAngle() );
-if ( ( nAngle > 4500 && nAngle <= 13500 ) || ( nAngle > 
22500 && nAngle <= 31500 ) )
+const bool bAllowSwap = pObj->GetObjIdentifier() != 
OBJ_LINE && pObj->GetObjIdentifier() != OBJ_GRUP;
+if ( bAllowSwap && (( nAngle > 4500 && nAngle <= 13500 ) 
|| ( nAngle > 22500 && nAngle <= 31500 )) )
 {
 const long nWidth  = aRect.getWidth();
 const long nHeight = aRect.getHeight();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-04-03 Thread Luke Deller
 sw/qa/extras/ooxmlexport/data/tdf107035.docx |binary
 sw/source/core/unocore/unotext.cxx   |4 
 2 files changed, 4 insertions(+)

New commits:
commit c51cd09e36e37226c79609899440e8d4458cb7ad
Author: Luke Deller 
Date:   Mon Mar 5 00:14:28 2018 +1100

tdf#107035 Fix field character style DOCX import

Reinstate a call to DontExpandFormat which was removed from
appendTextContent in commit 232ad2f2588beff50cb5c1f3b689c581ba317583

This ensures that direct character formatting which ended immediately
before the insertion point will not be expanded to cover the inserted
content.

Reviewed-on: https://gerrit.libreoffice.org/50729
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 18cbb8fe699131a234355e1d00fa917fede6ac46)

Change-Id: Ie5fa6b5c5acee4f885f9e67535e98801af23661a
(cherry picked from commit c1f393d899360e11e25d562d90285895f1e751e9)

diff --git a/sw/qa/extras/ooxmlexport/data/tdf107035.docx 
b/sw/qa/extras/ooxmlexport/data/tdf107035.docx
new file mode 100644
index ..a8ab045b61c9
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf107035.docx differ
diff --git a/sw/source/core/unocore/unotext.cxx 
b/sw/source/core/unocore/unotext.cxx
index baf80081d18b..9aa0b591f246 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -527,6 +527,10 @@ throw (lang::IllegalArgumentException, 
uno::RuntimeException, std::exception)
 aIllegal.Message = "first parameter invalid";
 throw aIllegal;
 }
+// Any direct formatting ending at the insert position (xRange) should not
+// be expanded to cover the inserted content (xContent)
+GetDoc()->DontExpandFormat( *aPam.Start() );
+
 // first test if the range is at the right position, then call
 // xContent->attach
 const SwStartNode* pOwnStartNode = GetStartNode();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-03-22 Thread Mike Kaganski
 sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx   |   26 +++
 sw/source/core/tox/ToxTabStopTokenHandler.cxx|5 ++
 3 files changed, 31 insertions(+)

New commits:
commit 67e89d90731df5379173eb561512fd6cdc38c37d
Author: Mike Kaganski 
Date:   Fri Mar 16 11:22:41 2018 +0300

tdf#116403: consider borders when updating right-aligned tab in index

Change-Id: I415d8fcfdd75e6d608ec2e3ba228146cf8139278
Reviewed-on: https://gerrit.libreoffice.org/51388
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/51488
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/51687
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt 
b/sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt
new file mode 100644
index ..c0fb91ad7eb3
Binary files /dev/null and 
b/sw/qa/extras/uiwriter/data/tdf116403-considerborders.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index bf98a565b1f2..d1211da8af61 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -243,6 +243,7 @@ public:
 void testTdf113790();
 void testTdf115013();
 void testTdf115132();
+void testTdf116403();
 
 CPPUNIT_TEST_SUITE(SwUiWriterTest);
 CPPUNIT_TEST(testReplaceForward);
@@ -373,6 +374,7 @@ public:
 CPPUNIT_TEST(testTdf113790);
 CPPUNIT_TEST(testTdf115013);
 CPPUNIT_TEST(testTdf115132);
+CPPUNIT_TEST(testTdf116403);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4754,6 +4756,30 @@ void SwUiWriterTest::testTdf115132()
 }
 }
 
+void SwUiWriterTest::testTdf116403()
+{
+createDoc("tdf116403-considerborders.odt");
+// Check that before ToX update, the tab stop position is the old one
+uno::Reference xParagraph = getParagraph(2, "1\t1");
+auto aTabs = getProperty(xParagraph, 
"ParaTabStops");
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aTabs.getLength());
+CPPUNIT_ASSERT_EQUAL(static_cast(17000), aTabs[0].Position);
+
+SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get());
+CPPUNIT_ASSERT(pTextDoc);
+SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+const SwTOXBase* pTOX = pWrtShell->GetTOX(0);
+CPPUNIT_ASSERT(pTOX);
+pWrtShell->UpdateTableOf(*pTOX);
+
+xParagraph = getParagraph(2, "1\t1");
+aTabs = getProperty(xParagraph, 
"ParaTabStops");
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aTabs.getLength());
+// This was still 17000, refreshing ToX didn't take borders spacings and 
widths into account
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Page borders must be considered for 
right-aligned tabstop",
+static_cast(17000 - 2 * 500 - 2 * 1), aTabs[0].Position);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/tox/ToxTabStopTokenHandler.cxx 
b/sw/source/core/tox/ToxTabStopTokenHandler.cxx
index f31e0456fcc3..53bae640e396 100644
--- a/sw/source/core/tox/ToxTabStopTokenHandler.cxx
+++ b/sw/source/core/tox/ToxTabStopTokenHandler.cxx
@@ -93,6 +93,11 @@ 
DefaultToxTabStopTokenHandler::CalculatePageMarginFromPageDescription(const SwTe
 const SwFrameFormat& rPgDscFormat = pPageDesc->GetMaster();
 long result = rPgDscFormat.GetFrameSize().GetWidth() - 
rPgDscFormat.GetLRSpace().GetLeft()
 - rPgDscFormat.GetLRSpace().GetRight();
+// Also consider borders
+const SvxBoxItem& rBox = rPgDscFormat.GetBox();
+for (SvxBoxItemLine eLine : { SvxBoxItemLine::LEFT, SvxBoxItemLine::RIGHT 
})
+if (const editeng::SvxBorderLine* pBorder = rBox.GetLine(eLine))
+result -= pBorder->GetWidth() + rBox.GetDistance(eLine);
 return result;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-03-22 Thread Mike Kaganski
 sw/qa/extras/ooxmlexport/data/tdf112118.docx   |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx  |   37 
 sw/source/filter/ww8/docxattributeoutput.cxx   |  165 +
 sw/source/filter/ww8/docxattributeoutput.hxx   |   18 +-
 writerfilter/source/dmapper/DomainMapper.cxx   |1 
 writerfilter/source/dmapper/PageBordersHandler.cxx |   16 +-
 writerfilter/source/dmapper/PageBordersHandler.hxx |8 -
 writerfilter/source/dmapper/PropertyMap.cxx|   79 ++
 writerfilter/source/dmapper/PropertyMap.hxx|   24 ++-
 9 files changed, 235 insertions(+), 113 deletions(-)

New commits:
commit 83205787d5dd457128ef606de047454e220f4dcf
Author: Mike Kaganski 
Date:   Wed Mar 14 10:18:15 2018 +0300

tdf#112118: DOCX: properly import/export border distance

https://wiki.openoffice.org/wiki/Writer/MSInteroperability/PageBorder
discusses implementation differences between ODF model and MS formats
wrt dealing with page margins and distances to borders.

This patch corrects import from DOCX, so that the border distance and
width doesn't add to the margin size imported from file anymore. It
takes care to preserve size from page edge to text (the most important
size that affects document layout). When borders go outside of range
valid for ODF, the margin is set to keep text area intact, and the
border is placed as close to intended position as possible.

Export code now also properly handles border width. Also, an improved
heuristic implemented to better export cases unsupported by Word, so
that the result would look closer to ODF original. We still write
correct sizes to OOXML, so that when reopened by LO, the borders will
be in correct places; but as Word cannot handle sizes more than 31 pt,
it will show borders shifted.

This prevents from adding border widths and distances to page margins
at each opening of DOCX, saving back the changed value, increasing
the margins each time.

Change-Id: Ia978ab119dd661949d6c321aea91397f28d205b0
Reviewed-on: https://gerrit.libreoffice.org/51267
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/51399
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 
(cherry picked from commit c91f81f59fac308d8ab86637b241502e68d7ab6a)
Reviewed-on: https://gerrit.libreoffice.org/51400
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf112118.docx 
b/sw/qa/extras/ooxmlexport/data/tdf112118.docx
new file mode 100644
index ..87081d8c6dd9
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf112118.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index be729d8ecd33..11d073ec8b9e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -11,6 +11,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -647,6 +648,42 @@ DECLARE_OOXMLEXPORT_TEST(testGraphicObjectFliph, 
"graphic-object-fliph.docx")
 CPPUNIT_ASSERT(getProperty(getShape(1), "HoriMirroredOnOddPages"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf112118, "tdf112118.docx")
+{
+auto xStyles = getStyles("PageStyles");
+const std::initializer_list sides = {
+OUStringLiteral("Top"),
+OUStringLiteral("Left"),
+OUStringLiteral("Bottom"),
+OUStringLiteral("Right")
+};
+auto testProc = [&](const OUString& sStyleName, sal_Int32 nMargin, 
sal_Int32 nBorderDistance,
+sal_Int16 nBorderWidth)
+{
+uno::Reference 
xStyle(xStyles->getByName(sStyleName), uno::UNO_QUERY_THROW);
+for (const auto& side : sides)
+{
+table::BorderLine aBorder = getProperty(xStyle, 
side + "Border");
+CPPUNIT_ASSERT_EQUAL(sal_Int16(nBorderWidth), 
aBorder.OuterLineWidth);
+CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aBorder.InnerLineWidth);
+CPPUNIT_ASSERT_EQUAL(sal_Int16(0), aBorder.LineDistance);
+
+sal_Int32 nMarginActual = getProperty(xStyle, side + 
"Margin");
+CPPUNIT_ASSERT_EQUAL(nMargin, nMarginActual);
+
+sal_Int32 nBorderDistanceActual = getProperty(xStyle, 
side + "BorderDistance");
+CPPUNIT_ASSERT_EQUAL(nBorderDistance, nBorderDistanceActual);
+}
+};
+
+// For both styles used in document, the total distance from page edge to 
text must be 2.54 cm.
+// The first style uses "from edge" border distance; the second uses "from 
text" border distance
+// Border distances in both cases are 24 pt = 847 mm100; line widths are 6 
pt = 212 mm100.
+// 1482 + 847 + 

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

2018-02-06 Thread Mike Kaganski
 sw/qa/extras/uiwriter/uiwriter.cxx |   58 +
 sw/source/uibase/wrtsh/delete.cxx  |  126 ++---
 2 files changed, 121 insertions(+), 63 deletions(-)

New commits:
commit 3eedec8f4da95664ce553e3650990603e7f5c684
Author: Mike Kaganski 
Date:   Mon Feb 5 22:27:14 2018 +0300

tdf#115132: don't move out from current cell on Backspace/Delete

The behavior that cursor jumps out of current table box on Del/Backspace
introduced in commit 80a4b3b589a516392bcf1ad932619701eb95e250 is
not intuitive, and differs from what other word processors do.

Unit test included.

Change-Id: Icb53b6733f0d7394abe011fa067089e6693cf648
Reviewed-on: https://gerrit.libreoffice.org/49257
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/49292
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 
(cherry picked from commit e690954bada93bae54e64a306c104da3d540834e)

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 95206bf7944d..bf98a565b1f2 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -242,6 +242,7 @@ public:
 void testCreateDocxAnnotation();
 void testTdf113790();
 void testTdf115013();
+void testTdf115132();
 
 CPPUNIT_TEST_SUITE(SwUiWriterTest);
 CPPUNIT_TEST(testReplaceForward);
@@ -371,6 +372,7 @@ public:
 CPPUNIT_TEST(testCreateDocxAnnotation);
 CPPUNIT_TEST(testTdf113790);
 CPPUNIT_TEST(testTdf115013);
+CPPUNIT_TEST(testTdf115132);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4696,6 +4698,62 @@ void SwUiWriterTest::testTdf115013()
 utl::removeTree(aWorkDir);
 }
 
+void SwUiWriterTest::testTdf115132()
+{
+SwDoc* pDoc = createDoc();
+CPPUNIT_ASSERT(pDoc);
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtShell);
+
+std::vector vTestTableNames;
+
+// Create an empty paragraph that will separate first table from the rest
+pWrtShell->SplitNode();
+pWrtShell->SttDoc();
+// Create a table at the start of document body
+SwInsertTableOptions TableOpt(tabopts::DEFAULT_BORDER, 0);
+const SwTable* pTable = >InsertTable(TableOpt, 2, 3);
+const SwTableFormat* pFormat = pTable->GetFrameFormat();
+CPPUNIT_ASSERT(pFormat);
+vTestTableNames.push_back(pFormat->GetName());
+pWrtShell->EndDoc();
+// Create a table after a paragraph
+pTable = >InsertTable(TableOpt, 2, 3);
+pFormat = pTable->GetFrameFormat();
+CPPUNIT_ASSERT(pFormat);
+vTestTableNames.push_back(pFormat->GetName());
+// Create a table immediately after the previous
+pTable = >InsertTable(TableOpt, 2, 3);
+pFormat = pTable->GetFrameFormat();
+CPPUNIT_ASSERT(pFormat);
+vTestTableNames.push_back(pFormat->GetName());
+// Create a nested table in the middle of last row
+pWrtShell->GotoTable(vTestTableNames.back());
+for (int i = 0; i < 4; ++i)
+pWrtShell->GoNextCell(false);
+pTable = >InsertTable(TableOpt, 2, 3);
+pFormat = pTable->GetFrameFormat();
+CPPUNIT_ASSERT(pFormat);
+vTestTableNames.push_back(pFormat->GetName());
+
+// Now check that in any cell in all tables we don't go out of a cell
+// using Delete or Backspace. We test cases when a table is the first node;
+// when we are in a first/middle/last cell in a row; when there's a 
paragraph
+// before/after this cell; when there's another table before/after this 
cell;
+// in nested table.
+for (const auto& rTableName : vTestTableNames)
+{
+pWrtShell->GotoTable(rTableName);
+do {
+const SwStartNode* pNd = 
pWrtShell->GetSwCursor()->GetNode().FindTableBoxStartNode();
+pWrtShell->DelRight();
+CPPUNIT_ASSERT_EQUAL(pNd, 
pWrtShell->GetSwCursor()->GetNode().FindTableBoxStartNode());
+pWrtShell->DelLeft();
+CPPUNIT_ASSERT_EQUAL(pNd, 
pWrtShell->GetSwCursor()->GetNode().FindTableBoxStartNode());
+} while (pWrtShell->GoNextCell(false));
+}
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/uibase/wrtsh/delete.cxx 
b/sw/source/uibase/wrtsh/delete.cxx
index e4833ae2d4dc..985dee6a9817 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 inline void SwWrtShell::OpenMark()
 {
@@ -176,6 +177,10 @@ long SwWrtShell::DelLeft()
 
 if( SwCursorShell::IsSttPara())
 {
+// Start/EndAllAction to avoid cursor flickering
+UnoActionContext c(GetDoc());
+SwCursorShell::Push();
+
 // #i4032# Don't actually call a 'delete' if we
 // changed the table cell, compare DelRight().