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

2018-04-02 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 c1f393d899360e11e25d562d90285895f1e751e9
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

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 37ec4681d715..17e81aab7abe 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' - sw/qa sw/source

2018-03-19 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 e0b94a575024b6d20c4adb117a6d3a0079d80d39
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 

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 44a5903bcd02..a83f71f65136 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:
@@ -4757,6 +4759,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' - sw/qa sw/source writerfilter/source

2018-03-19 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 c91f81f59fac308d8ab86637b241502e68d7ab6a
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 

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 + 212 = 2541
+testProc("Standard", 847, 1482, 212);
+testProc("Converted1", 1482, 847, 212);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git 

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

2018-02-09 Thread Henry Castro
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   27 +
 sw/source/core/doc/docredln.cxx|   12 ++-
 2 files changed, 38 insertions(+), 1 deletion(-)

New commits:
commit 27fa442a86d4ffdad08feebc1841a79f7d1ce5a4
Author: Henry Castro 
Date:   Wed Jan 24 15:11:00 2018 -0400

sw lok: include the field name in the description of the redline

In tiled rendering case, when the text node is a field,
the description shows incorrect characters

Change-Id: I1e3a456b6e2a19a7629b58a8a6ae77e2090a06a1
Reviewed-on: https://gerrit.libreoffice.org/48538
Tested-by: Jenkins 
Reviewed-by: Henry Castro 
Reviewed-on: https://gerrit.libreoffice.org/48723
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 226874291be6..089537b6dc0c 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static const char* DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/";
 
@@ -93,6 +94,7 @@ public:
 void testDocumentRepair();
 void testPageHeader();
 void testPageFooter();
+void testRedlineField();
 
 CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
 CPPUNIT_TEST(testRegisterCallback);
@@ -142,6 +144,7 @@ public:
 CPPUNIT_TEST(testDocumentRepair);
 CPPUNIT_TEST(testPageHeader);
 CPPUNIT_TEST(testPageFooter);
+CPPUNIT_TEST(testRedlineField);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -2009,6 +2012,30 @@ void SwTiledRenderingTest::testPageFooter()
 }
 
 
+void SwTiledRenderingTest::testRedlineField()
+{
+// Load a document.
+comphelper::LibreOfficeKit::setActive();
+SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
+SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
+
+// Turn on track changes and type "x".
+uno::Reference xPropertySet(mxComponent, 
uno::UNO_QUERY);
+xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
+
+SwDateTimeField 
aDate(static_cast(pWrtShell->GetFieldType(0, 
RES_DATETIMEFLD)));
+//aDate->SetDateTime(::DateTime(::DateTime::SYSTEM));
+pWrtShell->Insert(aDate);
+
+// Get the redline just created
+const SwRedlineTable& rTable = 
pWrtShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
rTable.size());
+SwRangeRedline* pRedline = rTable[0];
+CPPUNIT_ASSERT(pRedline->GetDescr().indexOf(aDate.GetFieldName())!= -1);
+
+comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 0803609ae963..2d24fe55fdbd 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -57,6 +57,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "flowfrm.hxx"
 
@@ -1777,9 +1778,18 @@ OUString SwRangeRedline::GetDescr()
 bDeletePaM = true;
 }
 
+OUString sDescr = pPaM->GetText();
+if (const SwTextNode *pTextNode = pPaM->GetNode().GetTextNode())
+{
+if (const SwTextAttr* pTextAttr = 
pTextNode->GetFieldTextAttrAt(pPaM->GetPoint()->nContent.GetIndex() - 1, true ))
+{
+sDescr = pTextAttr->GetFormatField().GetField()->GetFieldName();
+}
+}
+
 // replace $1 in description by description of the redlines text
 const OUString aTmpStr = SW_RESSTR(STR_START_QUOTE)
-+ ShortenString(pPaM->GetText(), nUndoStringLength, 
SW_RESSTR(STR_LDOTS))
++ ShortenString(sDescr, nUndoStringLength, SW_RESSTR(STR_LDOTS))
 + SW_RESSTR(STR_END_QUOTE);
 
 SwRewriter aRewriter;
___
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' - 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 e690954bada93bae54e64a306c104da3d540834e
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 

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 a300ad2ba059..411c7e079df7 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().
 const SwStartNode * pSNdOld = pWasInTableNd ?
@@ -184,23 +189,34 @@ 

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

2018-01-18 Thread Mike Kaganski
 sw/qa/extras/uiwriter/data/datasource.ods |binary
 sw/qa/extras/uiwriter/uiwriter.cxx|8 +++--
 sw/source/filter/ww8/ww8atr.cxx   |   43 +-
 3 files changed, 47 insertions(+), 4 deletions(-)

New commits:
commit 2425c5cc08b150c9b1b9a6f542b2f5b46a695b40
Author: Mike Kaganski 
Date:   Wed Jan 17 12:41:41 2018 +0300

tdf#115013: quote columns with spaces and properly escape characters

Unit test updated

Change-Id: If36c90c0ff372ce4574d2487e6edf2536dbf
Reviewed-on: https://gerrit.libreoffice.org/48038
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/48078
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/uiwriter/data/datasource.ods 
b/sw/qa/extras/uiwriter/data/datasource.ods
index 076659679575..81d78440656e 100644
Binary files a/sw/qa/extras/uiwriter/data/datasource.ods and 
b/sw/qa/extras/uiwriter/data/datasource.ods differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 6a065e712bea..5c96aacf7a1e 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -4647,7 +4647,9 @@ void SwUiWriterTest::testTdf104492()
 
 void SwUiWriterTest::testTdf115013()
 {
-//create new writer document
+   const OUString sColumnName("Name with spaces, \"quotes\" and 
\\backslashes");
+
+   //create new writer document
 SwDoc* pDoc = createDoc();
 
 {
@@ -4663,7 +4665,7 @@ void SwUiWriterTest::testTdf115013()
 SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
 CPPUNIT_ASSERT(pWrtShell);
 SwDBFieldType* pFieldType = 
static_cast(pWrtShell->InsertFieldType(
-SwDBFieldType(pDoc, "Name", aDBData)));
+SwDBFieldType(pDoc, sColumnName, aDBData)));
 CPPUNIT_ASSERT(pFieldType);
 
 // Insert the field into document
@@ -4686,7 +4688,7 @@ void SwUiWriterTest::testTdf115013()
 CPPUNIT_ASSERT(pField);
 OUString sColumn = 
static_cast(pField->GetTyp())->GetColumnName();
 // The column name must come correct after round trip
-CPPUNIT_ASSERT_EQUAL(OUString("Name"), sColumn);
+CPPUNIT_ASSERT_EQUAL(sColumnName, sColumn);
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index abb637f923a4..7e90c2a27029 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2458,6 +2458,46 @@ void WW8AttributeOutput::WriteExpand( const SwField* 
pField )
 SwWW8Writer::WriteString16( m_rWW8Export.Strm(), sExpand, false );
 }
 
+namespace
+{
+// Escapes a token string for storing in Word formats. Its import counterpart
+// is lcl_ExtractToken in writerfilter/source/dmapper/DomainMapper_Impl.cxx
+OUString EscapeToken(const OUString& rCommand)
+{
+bool bWasEscaped = false;
+
+const int nBufferLen = rCommand.getLength()*1.5;
+OUStringBuffer sResult(nBufferLen);
+sResult.append('"'); // opening quote
+for (sal_Int32 i = 0; i < rCommand.getLength(); ++i)
+{
+sal_Unicode ch = rCommand[i];
+switch (ch)
+{
+case '\\':
+case '"':
+// Backslashes and doublequotes must be escaped
+bWasEscaped = true;
+sResult.append('\\');
+break;
+case ' ':
+// Spaces require quotation
+bWasEscaped = true;
+break;
+}
+sResult.append(ch);
+}
+
+if (bWasEscaped)
+{
+sResult.append('"'); // closing quote
+return sResult.makeStringAndClear();
+}
+// No escapement/quotation was required
+return rCommand;
+}
+}
+
 void AttributeOutputBase::TextField( const SwFormatField& rField )
 {
 const SwField* pField = rField.GetField();
@@ -2535,7 +2575,8 @@ void AttributeOutputBase::TextField( const SwFormatField& 
rField )
 break;
 case RES_DBFLD:
 {
-OUString sStr = FieldString(ww::eMERGEFIELD) + 
static_cast(pField->GetTyp())->GetColumnName() + " ";
+OUString sStr = FieldString(ww::eMERGEFIELD)
++ EscapeToken(static_cast(pField->GetTyp())->GetColumnName()) + " ";
 GetExport().OutputField(pField, ww::eMERGEFIELD, sStr);
 }
 break;
___
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' - sw/qa sw/source

2018-01-18 Thread Mike Kaganski
 sw/qa/extras/uiwriter/data/datasource.ods |binary
 sw/qa/extras/uiwriter/uiwriter.cxx|   47 ++
 sw/source/filter/ww8/ww8atr.cxx   |3 +
 3 files changed, 49 insertions(+), 1 deletion(-)

New commits:
commit 93c9a14134eb4afbfd7819ac3b4482d109c0c2f3
Author: Mike Kaganski 
Date:   Tue Jan 16 09:40:11 2018 +0300

tdf#115013: write merge field column into docx merge fields

Change-Id: If1e0a8968407c72e42cb7ca487541d0b8227aabc
Reviewed-on: https://gerrit.libreoffice.org/47895
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/47975
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/uiwriter/data/datasource.ods 
b/sw/qa/extras/uiwriter/data/datasource.ods
new file mode 100644
index ..076659679575
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/datasource.ods differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index d022e2fb26c6..6a065e712bea 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -55,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -240,6 +241,7 @@ public:
 void testTdf107976();
 void testCreateDocxAnnotation();
 void testTdf113790();
+void testTdf115013();
 
 CPPUNIT_TEST_SUITE(SwUiWriterTest);
 CPPUNIT_TEST(testReplaceForward);
@@ -368,6 +370,7 @@ public:
 CPPUNIT_TEST(testTdf107976);
 CPPUNIT_TEST(testCreateDocxAnnotation);
 CPPUNIT_TEST(testTdf113790);
+CPPUNIT_TEST(testTdf115013);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4642,6 +4645,50 @@ void SwUiWriterTest::testTdf104492()
 assertXPath(pXmlDoc, "//page", 3);
 }
 
+void SwUiWriterTest::testTdf115013()
+{
+//create new writer document
+SwDoc* pDoc = createDoc();
+
+{
+// Load and register data source
+const OUString 
aDataSourceURI(m_directories.getURLFromSrc(DATA_DIRECTORY) + "datasource.ods");
+OUString sDataSource = 
SwDBManager::LoadAndRegisterDataSource(aDataSourceURI, nullptr, nullptr, 
nullptr);
+CPPUNIT_ASSERT(!sDataSource.isEmpty());
+
+// Insert a new field type for the mailmerge field
+SwDBData aDBData;
+aDBData.sDataSource = sDataSource;
+aDBData.sCommand = "Sheet1";
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtShell);
+SwDBFieldType* pFieldType = 
static_cast(pWrtShell->InsertFieldType(
+SwDBFieldType(pDoc, "Name", aDBData)));
+CPPUNIT_ASSERT(pFieldType);
+
+// Insert the field into document
+SwDBField aField(pFieldType);
+pWrtShell->Insert(aField);
+}
+// Save it as DOCX & load it again
+reload("Office Open XML Text", "mm-field.docx");
+
+CPPUNIT_ASSERT(mxComponent.get());
+pDoc = 
dynamic_cast(mxComponent.get())->GetDocShell()->GetDoc();
+CPPUNIT_ASSERT(pDoc);
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+CPPUNIT_ASSERT(pWrtShell);
+SwPaM* pCursor = pDoc->GetEditShell()->GetCursor();
+CPPUNIT_ASSERT(pCursor);
+
+// Get the field at the beginning of the document
+SwDBField* pField = 
dynamic_cast(SwCursorShell::GetFieldAtCursor(pCursor, true));
+CPPUNIT_ASSERT(pField);
+OUString sColumn = 
static_cast(pField->GetTyp())->GetColumnName();
+// The column name must come correct after round trip
+CPPUNIT_ASSERT_EQUAL(OUString("Name"), sColumn);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index f8d35a0edae1..abb637f923a4 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -122,6 +122,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -2534,7 +2535,7 @@ void AttributeOutputBase::TextField( const SwFormatField& 
rField )
 break;
 case RES_DBFLD:
 {
-OUString sStr = FieldString(ww::eMERGEFIELD) + pField->GetPar1() + 
" ";
+OUString sStr = FieldString(ww::eMERGEFIELD) + 
static_cast(pField->GetTyp())->GetColumnName() + " ";
 GetExport().OutputField(pField, ww::eMERGEFIELD, sStr);
 }
 break;
___
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' - sw/qa sw/source

2017-12-07 Thread Szymon Kłos
 sw/qa/extras/uiwriter/uiwriter.cxx |4 
 sw/source/core/edit/edfcol.cxx |7 ---
 2 files changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 29bbc24dd4c5c541c45c0584754c6635edd1f15c
Author: Szymon Kłos 
Date:   Mon Dec 4 12:45:11 2017 +0100

tdf#113037 Watermark centered in DOC

Reviewed-on: https://gerrit.libreoffice.org/45804
Tested-by: Jenkins 
Reviewed-by: Szymon Kłos 
(cherry picked from commit 58784b89c22c6d63fff18fea0aa6636a1370044c)

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

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 55d14a9efd54..d022e2fb26c6 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -927,6 +927,10 @@ void SwUiWriterTest::testWatermarkPosition()
 
 // Check if Watermark is inside a page
 CPPUNIT_ASSERT_MESSAGE(aMessage.str(), nPageHeight >= rRect.Bottom());
+
+// Check if Watermark is centered
+CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::CENTER, 
getProperty(xShape, "HoriOrient"));
+CPPUNIT_ASSERT_EQUAL(text::VertOrientation::CENTER, 
getProperty(xShape, "VertOrient"));
 }
 }
 
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 1f14403f475b..e8c4c6bc6c04 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -469,7 +469,6 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& 
rWatermark,
 xPropertySet->setPropertyValue(UNO_NAME_FILLCOLOR, 
uno::makeAny(static_cast(nColor)));
 xPropertySet->setPropertyValue(UNO_NAME_FILLSTYLE, 
uno::makeAny(drawing::FillStyle_SOLID));
 xPropertySet->setPropertyValue(UNO_NAME_FILL_TRANSPARENCE, 
uno::makeAny(nTransparency));
-xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION, 
uno::makeAny(static_cast(text::RelOrientation::PAGE_PRINT_AREA)));
 xPropertySet->setPropertyValue(UNO_NAME_LINESTYLE, 
uno::makeAny(drawing::LineStyle_NONE));
 xPropertySet->setPropertyValue(UNO_NAME_OPAQUE, uno::makeAny(false));
 xPropertySet->setPropertyValue(UNO_NAME_TEXT_AUTOGROWHEIGHT, 
uno::makeAny(false));
@@ -477,13 +476,12 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& 
rWatermark,
 xPropertySet->setPropertyValue(UNO_NAME_TEXT_MINFRAMEHEIGHT, 
uno::makeAny(nFrameHeight));
 xPropertySet->setPropertyValue(UNO_NAME_TEXT_MINFRAMEWIDTH, 
uno::makeAny(nWidth));
 xPropertySet->setPropertyValue(UNO_NAME_TEXT_WRAP, 
uno::makeAny(text::WrapTextMode_THROUGHT));
+xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT_RELATION, 
uno::makeAny(static_cast(text::RelOrientation::PAGE_PRINT_AREA)));
 xPropertySet->setPropertyValue(UNO_NAME_VERT_ORIENT_RELATION, 
uno::makeAny(static_cast(text::RelOrientation::PAGE_PRINT_AREA)));
 xPropertySet->setPropertyValue(UNO_NAME_CHAR_FONT_NAME, 
uno::makeAny(sFont));
 xPropertySet->setPropertyValue(UNO_NAME_CHAR_HEIGHT, 
uno::makeAny(WATERMARK_AUTO_SIZE));
 xPropertySet->setPropertyValue(UNO_NAME_TEXT_UPPERDIST, 
uno::makeAny(sal_Int32(nFrameHeight - nHeight)));
 xPropertySet->setPropertyValue("Transformation", 
uno::makeAny(aMatrix));
-xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT, 
uno::makeAny(static_cast(text::HoriOrientation::CENTER)));
-xPropertySet->setPropertyValue(UNO_NAME_VERT_ORIENT, 
uno::makeAny(static_cast(text::VertOrientation::CENTER)));
 
 uno::Reference xTextRange(xShape, uno::UNO_QUERY);
 xTextRange->setString(rWatermark.GetText());
@@ -512,6 +510,9 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& 
rWatermark,
 xPropertySet->getPropertyValue("Transformation") >>= aMatrix;
 xPropertySet->setPropertyValue("Transformation", 
uno::makeAny(aMatrix));
 
+xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT, 
uno::makeAny(static_cast(text::HoriOrientation::CENTER)));
+xPropertySet->setPropertyValue(UNO_NAME_VERT_ORIENT, 
uno::makeAny(static_cast(text::VertOrientation::CENTER)));
+
 uno::Reference xNamed(xShape, uno::UNO_QUERY);
 xNamed->setName(sWatermark);
 xLockable->removeActionLock();
___
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' - sw/qa sw/source

2017-11-28 Thread Dimitri Bouron
 sw/qa/extras/uiwriter/data/tdf104492.docx |binary
 sw/qa/extras/uiwriter/uiwriter.cxx|9 +
 sw/source/core/layout/tabfrm.cxx  |2 ++
 3 files changed, 11 insertions(+)

New commits:
commit ba37662d05b484d8bd311464b896f3b10c5e2925
Author: Dimitri Bouron 
Date:   Thu Dec 22 11:19:05 2016 +0100

tdf#104492: Fix bad docx opening and bad layout

The problem seems to be the table's repeated rows value which is
setted to max table rows in some docx file.

Decreasing repeated rows value by one avoids loops but renders a bad
layout.
Table continuity is lost and lots of rows are hidden.

So I set repeated rows value directly to one in order to avoid bad
layout.

Reviewed-on: https://gerrit.libreoffice.org/32349
Tested-by: Jenkins 
Reviewed-by: Björn Michaelsen 
(cherry picked from commit 91a176b864ac0492f5c0d2386292118dd3095df4)

Change-Id: If4adc33febe088a866b704e87e49339710e5aaf5

diff --git a/sw/qa/extras/uiwriter/data/tdf104492.docx 
b/sw/qa/extras/uiwriter/data/tdf104492.docx
new file mode 100644
index ..a5a7af367854
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf104492.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index cb603f313d95..55d14a9efd54 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -234,6 +234,7 @@ public:
 void testTdf104032();
 void testTdf104425();
 void testTdf104814();
+void testTdf104492();
 void testTdf105417();
 void testTdf105625();
 void testTdf107976();
@@ -361,6 +362,7 @@ public:
 CPPUNIT_TEST(testTdf104032);
 CPPUNIT_TEST(testTdf104425);
 CPPUNIT_TEST(testTdf104814);
+CPPUNIT_TEST(testTdf104492);
 CPPUNIT_TEST(testTdf105417);
 CPPUNIT_TEST(testTdf105625);
 CPPUNIT_TEST(testTdf107976);
@@ -4628,6 +4630,13 @@ void SwUiWriterTest::testTdf113790()
 reload("Office Open XML Text", "tdf113790.docx");
 CPPUNIT_ASSERT(dynamic_cast(mxComponent.get()));
 }
+void SwUiWriterTest::testTdf104492()
+{
+createDoc("tdf104492.docx");
+xmlDocPtr pXmlDoc = parseLayoutDump();
+// The document should split table over 3 pages.
+assertXPath(pXmlDoc, "//page", 3);
+}
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index d08468aaa1e1..1c988ebee6e7 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -2541,6 +2541,8 @@ void SwTabFrame::MakeAll(vcl::RenderContext* 
pRenderContext)
 lcl_RecalcTable( *this, nullptr, aNotify );
 m_bLowersFormatted = true;
 m_bCalcLowers = false;
+if (!mbValidPrtArea)
+m_pTable->SetRowsToRepeat(1);
 }
 #if OSL_DEBUG_LEVEL > 0
 else
___
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' - sw/qa sw/source

2017-11-24 Thread Mike Kaganski
 sw/qa/extras/ooxmlexport/data/mailmerge.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx|   27 +++
 sw/qa/extras/ww8export/data/mailmerge.doc|binary
 sw/qa/extras/ww8export/ww8export2.cxx|   27 +++
 sw/source/filter/ww8/rtfattributeoutput.cxx  |7 ++-
 sw/source/filter/ww8/ww8atr.cxx  |6 ++
 6 files changed, 62 insertions(+), 5 deletions(-)

New commits:
commit b8b75225a4b0af7bb841cd5205adc2ad2d13b705
Author: Mike Kaganski 
Date:   Fri Nov 24 00:18:09 2017 +0300

tdf#67207: export MERGEDIELD to DOCX and DOC

Also removed a hack for i119803, because proper solution is
implemented.

This does not export data source information yet.

Unit tests for DOC and DOCX are included. RTF export is already
covered in testFdo80905.

Change-Id: Id4f6d53344edf474add7e885e8ae6f36618e569f
Reviewed-on: https://gerrit.libreoffice.org/45193
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/45243
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlexport/data/mailmerge.docx 
b/sw/qa/extras/ooxmlexport/data/mailmerge.docx
new file mode 100644
index ..7e209a1b4dc9
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/mailmerge.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index a7b36683f943..08de896708f8 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 
@@ -574,6 +575,32 @@ DECLARE_OOXMLEXPORT_TEST(testTdf111964, "tdf111964.docx")
 assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[4]/w:t", 
sWSReference);
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf67207_MERGEFIELD, "mailmerge.docx")
+{
+uno::Reference xTextField = getProperty< 
uno::Reference >(getRun(getParagraph(1), 2), "TextField");
+CPPUNIT_ASSERT(xTextField.is());
+uno::Reference xServiceInfo(xTextField, 
uno::UNO_QUERY_THROW);
+uno::Reference xDependent(xTextField, 
uno::UNO_QUERY_THROW);
+
+
CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.Database"));
+OUString sValue;
+xTextField->getPropertyValue("Content") >>= sValue;
+CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"«Name»"), sValue);
+
+uno::Reference xFiledMaster = 
xDependent->getTextFieldMaster();
+uno::Reference xFiledMasterServiceInfo(xFiledMaster, 
uno::UNO_QUERY_THROW);
+
+
CPPUNIT_ASSERT(xFiledMasterServiceInfo->supportsService("com.sun.star.text.fieldmaster.Database"));
+
+// Defined properties: DataBaseName, Name, DataTableName, DataColumnName, 
DependentTextFields, DataCommandType, InstanceName, DataBaseURL
+CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("Name") >>= sValue);
+CPPUNIT_ASSERT_EQUAL(OUString("Name"), sValue);
+CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("DataColumnName") >>= 
sValue);
+CPPUNIT_ASSERT_EQUAL(OUString("Name"), sValue);
+CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("InstanceName") >>= sValue);
+
CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.text.fieldmaster.DataBase.Name"), 
sValue);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ww8export/data/mailmerge.doc 
b/sw/qa/extras/ww8export/data/mailmerge.doc
new file mode 100644
index ..6ed882769ebb
Binary files /dev/null and b/sw/qa/extras/ww8export/data/mailmerge.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx 
b/sw/qa/extras/ww8export/ww8export2.cxx
index 2819fa3569dd..f4761cc6b381 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -161,6 +162,32 @@ DECLARE_WW8EXPORT_TEST( testActiveXCheckbox, 
"checkbox_control.odt" )
 
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AS_CHARACTER,getProperty(xPropertySet2,"AnchorType"));
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf67207_MERGEFIELD, "mailmerge.doc")
+{
+uno::Reference xTextField = getProperty< 
uno::Reference >(getRun(getParagraph(1), 2), "TextField");
+CPPUNIT_ASSERT(xTextField.is());
+uno::Reference xServiceInfo(xTextField, 
uno::UNO_QUERY_THROW);
+uno::Reference xDependent(xTextField, 
uno::UNO_QUERY_THROW);
+
+
CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.Database"));
+OUString sValue;
+xTextField->getPropertyValue("Content") >>= sValue;
+CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"«Name»"), sValue);
+
+uno::Reference xFiledMaster = 
xDependent->getTextFieldMaster();
+uno::Reference xFiledMasterServiceInfo(xFiledMaster, 
uno::UNO_QUERY_THROW);
+
+

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

2017-11-19 Thread Mike Kaganski
 sw/qa/extras/uiwriter/data/tdf113790.docx |binary
 sw/qa/extras/uiwriter/uiwriter.cxx|   25 +
 sw/source/filter/ww8/wrtw8nds.cxx |   20 
 3 files changed, 45 insertions(+)

New commits:
commit de80d677c49b445b4acea8a99aea25b582ceece0
Author: Mike Kaganski 
Date:   Tue Nov 14 12:32:41 2017 +0300

tdf#113790: skip charfmt grabbag items existing in autofmt grabbag

Change-Id: Icc0065c1da9471cb36bfef0da45e2f67381a1a31
Reviewed-on: https://gerrit.libreoffice.org/44706
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/44772
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/uiwriter/data/tdf113790.docx 
b/sw/qa/extras/uiwriter/data/tdf113790.docx
new file mode 100644
index ..b6334aae7617
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf113790.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 973c6cadb2a8..cb603f313d95 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -238,6 +238,7 @@ public:
 void testTdf105625();
 void testTdf107976();
 void testCreateDocxAnnotation();
+void testTdf113790();
 
 CPPUNIT_TEST_SUITE(SwUiWriterTest);
 CPPUNIT_TEST(testReplaceForward);
@@ -364,6 +365,7 @@ public:
 CPPUNIT_TEST(testTdf105625);
 CPPUNIT_TEST(testTdf107976);
 CPPUNIT_TEST(testCreateDocxAnnotation);
+CPPUNIT_TEST(testTdf113790);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4604,6 +4606,29 @@ void SwUiWriterTest::testTdf107976()
 CPPUNIT_ASSERT(!pTransferable2->GetShell());
 }
 
+void SwUiWriterTest::testTdf113790()
+{
+SwDoc* pDoc = createDoc("tdf113790.docx");
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+// Create the clipboard document.
+SwDoc aClipboard;
+aClipboard.SetClipBoard(true);
+
+// Go to fourth line - to "ABCD" bulleted list item
+pWrtShell->Down(/*bSelect=*/false, 4);
+pWrtShell->SelPara(nullptr);
+CPPUNIT_ASSERT_EQUAL(OUString("ABCD"), pWrtShell->GetSelText());
+pWrtShell->Copy();
+
+// Go down to next-to-last (empty) line above "Title3"
+pWrtShell->Down(/*bSelect=*/false, 4);
+pWrtShell->Paste();
+
+// Save it as DOCX & load it again
+reload("Office Open XML Text", "tdf113790.docx");
+CPPUNIT_ASSERT(dynamic_cast(mxComponent.get()));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index 87173dbef028..ecf2b2acc3f8 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -466,6 +467,25 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bRuby )
 if ( pCharFormatItem )
 ClearOverridesFromSet( *pCharFormatItem, aExportSet );
 
+// tdf#113790: AutoFormat style overwrites char style, so remove all
+// elements from CHARFMT grab bag which are set in AUTOFMT grab bag
+if (const SfxGrabBagItem *pAutoFmtGrabBag = dynamic_cast(pGrabBag))
+{
+if (const SfxGrabBagItem *pCharFmtGrabBag = 
aExportSet.GetItem(RES_CHRATR_GRABBAG, false))
+{
+std::unique_ptr pNewItem(pCharFmtGrabBag->Clone());
+SfxGrabBagItem* pNewCharFmtGrabBag = 
dynamic_cast(pNewItem.get());
+assert(pNewCharFmtGrabBag);
+auto & rNewFmtMap = pNewCharFmtGrabBag->GetGrabBag();
+for (auto const & item : pAutoFmtGrabBag->GetGrabBag())
+{
+if (item.second.hasValue())
+rNewFmtMap.erase(item.first);
+}
+aExportSet.Put(*pNewCharFmtGrabBag);
+}
+}
+
 ww8::PoolItems aExportItems;
 GetPoolItems( aExportSet, aExportItems, false );
 
___
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' - sw/qa sw/source

2017-11-03 Thread Justin Luth
 sw/qa/extras/uiwriter/data/tdf103978_backgroundTextShape.docx |binary
 sw/qa/extras/uiwriter/uiwriter.cxx|   21 ++
 sw/source/core/doc/textboxhelper.cxx  |3 +
 3 files changed, 24 insertions(+)

New commits:
commit 72276f0248c8e09fad707c500e45c5d027e7efb1
Author: Justin Luth 
Date:   Thu Jul 6 14:54:27 2017 -0400

tdf#103978 textboxhelper: syncProperty OPAQUE (wrap in background)

Although the containing shape is in the background (and thus the
normal paragraph text is still visible), the shape's text
was still painting over top of the normal paragraph text because
the textbox was set as opaque and not transparent.

Setting the textbox to sync the opacity value of its containing shape.

Change-Id: I02477e2fa7def1f13590afcaa7c6564dd79d6406
Reviewed-on: https://gerrit.libreoffice.org/39672
Tested-by: Jenkins 
Reviewed-by: Justin Luth 
(cherry picked from commit cc438f60d6ad0855f754dd32da9c9a80c7cabf92)

diff --git a/sw/qa/extras/uiwriter/data/tdf103978_backgroundTextShape.docx 
b/sw/qa/extras/uiwriter/data/tdf103978_backgroundTextShape.docx
new file mode 100644
index ..b99b65e47630
Binary files /dev/null and 
b/sw/qa/extras/uiwriter/data/tdf103978_backgroundTextShape.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 378c9feb2852..973c6cadb2a8 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -209,6 +209,7 @@ public:
 void testTdf87922();
 void testTdf77014();
 void testTdf92648();
+void testTdf103978_backgroundTextShape();
 void testTdf96515();
 void testTdf96943();
 void testTdf96536();
@@ -334,6 +335,7 @@ public:
 CPPUNIT_TEST(testTdf87922);
 CPPUNIT_TEST(testTdf77014);
 CPPUNIT_TEST(testTdf92648);
+CPPUNIT_TEST(testTdf103978_backgroundTextShape);
 CPPUNIT_TEST(testTdf96515);
 CPPUNIT_TEST(testTdf96943);
 CPPUNIT_TEST(testTdf96536);
@@ -3845,6 +3847,25 @@ void SwUiWriterTest::testTdf92648()
 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), nCount);
 }
 
+void SwUiWriterTest::testTdf103978_backgroundTextShape()
+{
+SwDoc* pDoc = createDoc("tdf103978_backgroundTextShape.docx");
+
+// there is only one shape. It has an attached textbox
+bool bShapeIsOpaque = getProperty(getShape(1), "Opaque");
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Shape is in the foreground", false, 
bShapeIsOpaque );
+sal_Int32 nCount = 0;
+for (const SwFrameFormat* pFormat : *pDoc->GetSpzFrameFormats())
+{
+if (!SwTextBoxHelper::isTextBox(pFormat, RES_FLYFRMFMT))
+continue;
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Textbox syncs the shape's transparency", 
bShapeIsOpaque, pFormat->GetOpaque().GetValue() );
+++nCount;
+}
+//ensure that we don't skip the for loop without an error
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of TextBoxes", sal_Int32(1), nCount);
+}
+
 void SwUiWriterTest::testTdf96515()
 {
 // Enable hide whitespace mode.
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index bfa3d3a1836d..bead3f97bd8a 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -517,6 +517,9 @@ void SwTextBoxHelper::syncProperty(SwFrameFormat* pShape, 
sal_uInt16 nWID, sal_u
 break;
 }
 break;
+case RES_OPAQUE:
+aPropertyName = UNO_NAME_OPAQUE;
+break;
 }
 
 if (!aPropertyName.isEmpty())
___
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' - sw/qa sw/source writerfilter/source

2017-09-12 Thread Szymon Kłos
 dev/null  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |   14 --
 sw/source/core/edit/edfcol.cxx|   15 +--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   10 +-
 4 files changed, 6 insertions(+), 33 deletions(-)

New commits:
commit 348bc3c6a8142ed605e260ae930d76e6cec7f656
Author: Szymon Kłos 
Date:   Mon Sep 11 10:53:47 2017 +0200

tdf#112304 Revert "Watermark: not visible if page background was set"

This reverts commit 39c08074a286855dd014ce1c30b8f7ef95b10242.
Fixed by: I69517efb7d82acd719d6a27a09ba61554dbf1ec9

Change-Id: Icd45b3f55292670ff7338a367eba212453a0687e
Reviewed-on: https://gerrit.libreoffice.org/42155
Tested-by: Jenkins 
Reviewed-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/42165
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sw/qa/extras/ooxmlexport/data/watermark-layer.docx 
b/sw/qa/extras/ooxmlexport/data/watermark-layer.docx
deleted file mode 100755
index 9428686c1bad..
Binary files a/sw/qa/extras/ooxmlexport/data/watermark-layer.docx and /dev/null 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 55f6e3ab3481..55f74de73635 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -28,10 +28,8 @@
 #include 
 
 #include 
-#include 
 #include 
 #include 
-#include 
 
 class Test : public SwModelTestBase
 {
@@ -558,18 +556,6 @@ DECLARE_OOXMLEXPORT_TEST(testTdf109184, "tdf109184.docx")
 CPPUNIT_ASSERT_EQUAL(static_cast(0xff), 
getProperty(xCell3, "BackColor"));
 }
 
-DECLARE_OOXMLEXPORT_TEST(testWatermarkLayer, "watermark-layer.docx")
-{
-// Watermark was not visible if page background was set.
-
-SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
-SdrPage* pPage = 
pTextDoc->GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
-SdrObject* pObject = pPage->GetObj(0);
-
-CPPUNIT_ASSERT(pObject);
-CPPUNIT_ASSERT_EQUAL(static_cast(1), pObject->GetLayer());
-}
-
 DECLARE_OOXMLEXPORT_TEST(tdf112169, "tdf112169.odt")
 {
 // LO crashed while export because of chararacter background color handling
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 1dadb1bdb8f4..06a33461430f 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -59,7 +59,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #define WATERMARK_NAME "PowerPlusWaterMarkObject"
 
@@ -348,8 +347,7 @@ SfxWatermarkItem SwEditShell::GetWatermark()
 void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark,
 const uno::Reference& xModel,
 const uno::Reference& 
xPageStyle,
-const uno::Reference& xHeaderText,
-sal_Int16 nLayer)
+const uno::Reference& xHeaderText)
 {
 uno::Reference xMultiServiceFactory(xModel, 
uno::UNO_QUERY);
 OUString aShapeServiceName = "com.sun.star.drawing.CustomShape";
@@ -471,7 +469,6 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& 
rWatermark,
 xPropertySet->setPropertyValue("Transformation", 
uno::makeAny(aMatrix));
 xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT, 
uno::makeAny(static_cast(text::HoriOrientation::CENTER)));
 xPropertySet->setPropertyValue(UNO_NAME_VERT_ORIENT, 
uno::makeAny(static_cast(text::VertOrientation::CENTER)));
-xPropertySet->setPropertyValue(UNO_NAME_MISC_OBJ_LAYERID, 
uno::makeAny(nLayer));
 
 uno::Reference xTextRange(xShape, uno::UNO_QUERY);
 xTextRange->setString(rWatermark.GetText());
@@ -517,8 +514,6 @@ void SwEditShell::SetWatermark(const SfxWatermarkItem& 
rWatermark)
 uno::Reference 
xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
 uno::Reference 
xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY);
 
-sal_Int16 nHeavenId = 
GetDoc()->getIDocumentDrawModelAccess().GetHeavenId();
-
 std::set aUsedPageStyles = lcl_getUsedPageStyles(this);
 for (const OUString& rPageStyleName : aUsedPageStyles)
 {
@@ -544,16 +539,16 @@ void SwEditShell::SetWatermark(const SfxWatermarkItem& 
rWatermark)
 uno::Reference xHeaderTextRight;
 
 xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT) >>= xHeaderText;
-lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, 
xHeaderText, nHeavenId);
+lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, 
xHeaderText);
 
 xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT_FIRST) >>= 
xHeaderTextFirst;
-

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

2017-09-12 Thread Mike Kaganski
 sw/qa/extras/ww8import/data/tdf112346.doc   |binary
 sw/qa/extras/ww8import/ww8import.cxx|8 ++
 sw/source/filter/ww8/ww8par.cxx |  103 +---
 sw/source/filter/ww8/ww8par.hxx |1 
 sw/source/filter/ww8/ww8par6.cxx|   14 ---
 writerfilter/source/dmapper/PropertyMap.cxx |   11 ++
 6 files changed, 97 insertions(+), 40 deletions(-)

New commits:
commit 21f73d47e949ef2732b778bd1ebe123473edf231
Author: Mike Kaganski 
Date:   Tue Sep 12 13:54:26 2017 +0300

tdf#112346: take Word no-wrap limit into account also for ww8

This also makes ww8 floating-table conversion decision heuristics
somewhat closer to OOXML code.

Change-Id: I29ca2ebabd1758ad98e02aaf560cf2f44daec3a8
Reviewed-on: https://gerrit.libreoffice.org/42196
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/42216
Reviewed-by: Mike Kaganski 
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ww8import/data/tdf112346.doc 
b/sw/qa/extras/ww8import/data/tdf112346.doc
new file mode 100644
index ..af0cca219acf
Binary files /dev/null and b/sw/qa/extras/ww8import/data/tdf112346.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx 
b/sw/qa/extras/ww8import/ww8import.cxx
index 751006a4a553..eb45c8172e36 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -88,6 +88,14 @@ DECLARE_WW8IMPORT_TEST(testTdf106799, "tdf106799.doc")
 }
 }
 
+DECLARE_WW8IMPORT_TEST(testTdf112346, "tdf112346.doc")
+{
+uno::Reference xDrawPageSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xDrawPage = 
xDrawPageSupplier->getDrawPage();
+// This was 1, multi-page table was imported as a floating one.
+CPPUNIT_ASSERT_EQUAL(static_cast(0), xDrawPage->getCount());
+}
+
 // tests should only be added to ww8IMPORT *if* they fail round-tripping in 
ww8EXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 88f4f4f3d22c..45c22d149874 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -91,6 +91,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -2592,6 +2593,83 @@ void SwWW8ImplReader::EndSpecial()
 OSL_ENSURE(!m_nInTable, "unclosed table!");
 }
 
+bool SwWW8ImplReader::FloatingTableConversion(WW8PLCFx_Cp_FKP* pPap)
+{
+// This is ww8 version of the code deciding if the table needs to be
+// in a floating frame.
+// For OOXML code, see SectionPropertyMap::FloatingTableConversion in
+// writerfilter/source/dmapper/PropertyMap.cxx
+// The two should do ~same, so if you make changes here, please check
+// that the other is in sync.
+
+// Note that this is just a list of heuristics till sw core can have a
+// table that is floating and can span over multiple pages at the same
+// time.
+
+bool bResult = true;
+
+const sal_uInt8 *pRes = pPap->HasSprm(NS_sprm::LN_TDefTable);
+if (nullptr != pRes)
+{
+bResult = false;
+WW8TabBandDesc aDesc;
+aDesc.ReadDef(false, pRes);
+int nTextAreaWidth = m_aSectionManager.GetTextAreaWidth();
+int nTableWidth = aDesc.nCenter[aDesc.nWwCols] - aDesc.nCenter[0];
+
+// It seems Word has a limit here, so that in case the table width is 
quite
+// close to the text area width, then it won't perform a wrapping, 
even in
+// case the content (e.g. an empty paragraph) would fit. The magic 
constant
+// here represents this limit.
+const int nMagicNumber = 469;
+
+// If the table is wider than the text area, then don't create a fly
+// for the table: no wrapping will be performed anyway, but multi-page
+// tables will be broken.
+if ((nTableWidth + nMagicNumber) < nTextAreaWidth)
+bResult = true;
+
+// If there are columns, do create a fly, as the flow of the columns
+// would otherwise restrict the table.
+if (!bResult && (m_aSectionManager.CurrentSectionColCount() >= 2))
+bResult = true;
+}
+
+if (bResult)
+{
+WW8PLCFxSave1 aSave;
+pPap->Save(aSave);
+if (SearchTableEnd(pPap))
+{
+// Table is considered to be imported into a fly frame and we
+// know where the end of the table is.
+bool bIsUnicode;
+WW8_FC nFc = m_pSBase->WW8Cp2Fc(pPap->Where(), );
+sal_uInt64 nPos = m_pStrm->Tell();
+m_pStrm->Seek(nFc);
+sal_uInt16 nUChar = 0;
+if (bIsUnicode)
+m_pStrm->ReadUInt16(nUChar);
+else
+{
+sal_uInt8 nChar = 0;
+m_pStrm->ReadUChar(nChar);
+nUChar = 

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

2017-08-25 Thread Szymon Kłos
 sw/qa/extras/ooxmlexport/data/watermark-layer.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx  |   15 +++
 sw/source/core/edit/edfcol.cxx |   15 ++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |   10 +-
 4 files changed, 34 insertions(+), 6 deletions(-)

New commits:
commit 7deade09127367cc0345033062f689db92b08d19
Author: Szymon Kłos 
Date:   Fri Aug 18 15:13:52 2017 +0200

Watermark: not visible if page background was set

Watermark was drawn under the page background.
It has to be placed on the upper layer to be visible.

Change-Id: I132a313eed6fb712aafdca14a38fe559aa4231c8
Reviewed-on: https://gerrit.libreoffice.org/41289
Tested-by: Jenkins 
Reviewed-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/41557
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sw/qa/extras/ooxmlexport/data/watermark-layer.docx 
b/sw/qa/extras/ooxmlexport/data/watermark-layer.docx
new file mode 100755
index ..9428686c1bad
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/watermark-layer.docx 
differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 9b98417a361b..a9db27e9bd85 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -27,8 +27,11 @@
 #include 
 #include 
 
+#include 
+#include 
 #include 
 #include 
+#include 
 
 class Test : public SwModelTestBase
 {
@@ -546,6 +549,18 @@ DECLARE_OOXMLEXPORT_TEST(testTdf109184, "tdf109184.docx")
 CPPUNIT_ASSERT_EQUAL(static_cast(0xff), 
getProperty(xCell3, "BackColor"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testWatermarkLayer, "watermark-layer.docx")
+{
+// Watermark was not visible if page background was set.
+
+SwXTextDocument* pTextDoc = 
dynamic_cast(mxComponent.get());
+SdrPage* pPage = 
pTextDoc->GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+SdrObject* pObject = pPage->GetObj(0);
+
+CPPUNIT_ASSERT(pObject);
+CPPUNIT_ASSERT_EQUAL(static_cast(1), pObject->GetLayer());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index 06a33461430f..1dadb1bdb8f4 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -59,6 +59,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define WATERMARK_NAME "PowerPlusWaterMarkObject"
 
@@ -347,7 +348,8 @@ SfxWatermarkItem SwEditShell::GetWatermark()
 void lcl_placeWatermarkInHeader(const SfxWatermarkItem& rWatermark,
 const uno::Reference& xModel,
 const uno::Reference& 
xPageStyle,
-const uno::Reference& xHeaderText)
+const uno::Reference& xHeaderText,
+sal_Int16 nLayer)
 {
 uno::Reference xMultiServiceFactory(xModel, 
uno::UNO_QUERY);
 OUString aShapeServiceName = "com.sun.star.drawing.CustomShape";
@@ -469,6 +471,7 @@ void lcl_placeWatermarkInHeader(const SfxWatermarkItem& 
rWatermark,
 xPropertySet->setPropertyValue("Transformation", 
uno::makeAny(aMatrix));
 xPropertySet->setPropertyValue(UNO_NAME_HORI_ORIENT, 
uno::makeAny(static_cast(text::HoriOrientation::CENTER)));
 xPropertySet->setPropertyValue(UNO_NAME_VERT_ORIENT, 
uno::makeAny(static_cast(text::VertOrientation::CENTER)));
+xPropertySet->setPropertyValue(UNO_NAME_MISC_OBJ_LAYERID, 
uno::makeAny(nLayer));
 
 uno::Reference xTextRange(xShape, uno::UNO_QUERY);
 xTextRange->setString(rWatermark.GetText());
@@ -514,6 +517,8 @@ void SwEditShell::SetWatermark(const SfxWatermarkItem& 
rWatermark)
 uno::Reference 
xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
 uno::Reference 
xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY);
 
+sal_Int16 nHeavenId = 
GetDoc()->getIDocumentDrawModelAccess().GetHeavenId();
+
 std::set aUsedPageStyles = lcl_getUsedPageStyles(this);
 for (const OUString& rPageStyleName : aUsedPageStyles)
 {
@@ -539,16 +544,16 @@ void SwEditShell::SetWatermark(const SfxWatermarkItem& 
rWatermark)
 uno::Reference xHeaderTextRight;
 
 xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT) >>= xHeaderText;
-lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, 
xHeaderText);
+lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, 
xHeaderText, nHeavenId);
 
 xPageStyle->getPropertyValue(UNO_NAME_HEADER_TEXT_FIRST) >>= 
xHeaderTextFirst;
-lcl_placeWatermarkInHeader(rWatermark, xModel, xPageStyle, 
xHeaderTextFirst);
+

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

2017-08-11 Thread Szymon Kłos
 sw/qa/extras/uiwriter/data/watermark-position.odt |binary
 sw/qa/extras/uiwriter/uiwriter.cxx|   79 ++
 sw/source/core/edit/edfcol.cxx|   22 ++
 3 files changed, 101 insertions(+)

New commits:
commit e0ac06d9c6325447253c819573dfe41eb627617d
Author: Szymon Kłos 
Date:   Sun Aug 6 16:22:38 2017 +0200

tdf#108494 fix regression

* correct watermark position
* insert also on left and right pages if headers are different

Change-Id: Ibacfa6ea14bd8e9c1fd0d0b15de020b30d0a109f
Reviewed-on: https://gerrit.libreoffice.org/40829
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/uiwriter/data/watermark-position.odt 
b/sw/qa/extras/uiwriter/data/watermark-position.odt
new file mode 100755
index ..53ff24781682
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/watermark-position.odt 
differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 90b54c38d19d..8495768570e1 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -84,6 +85,7 @@
 #include "com/sun/star/text/TextMarkupType.hpp"
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -102,6 +104,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/";
 
@@ -124,6 +127,7 @@ public:
 void testDOTMAutoText();
 void testDOCXAutoTextGallery();
 void testWatermarkDOCX();
+void testWatermarkPosition();
 void testTdf67238();
 void testFdo75110();
 void testFdo75898();
@@ -248,6 +252,7 @@ public:
 CPPUNIT_TEST(testDOTMAutoText);
 CPPUNIT_TEST(testDOCXAutoTextGallery);
 CPPUNIT_TEST(testWatermarkDOCX);
+CPPUNIT_TEST(testWatermarkPosition);
 CPPUNIT_TEST(testTdf67238);
 CPPUNIT_TEST(testFdo75110);
 CPPUNIT_TEST(testFdo75898);
@@ -844,6 +849,80 @@ void SwUiWriterTest::testWatermarkDOCX()
 CPPUNIT_ASSERT_EQUAL((sal_Int16)50, pWatermark->GetTransparency());
 }
 
+void SwUiWriterTest::testWatermarkPosition()
+{
+// tdf#108494 Watermark inserted in the document with page break was 
outside the first page
+const int aPagesInDocument = 2;
+const int aAdditionalPagesCount[] = {0, 0,1, 1,5, 
5,   20,20 };
+const bool aChangeHeader[]= { true, false, true, false, true, 
false, true, false };
+
+for (unsigned long i = 0; i < sizeof(aAdditionalPagesCount) / sizeof(int); 
++i)
+{
+int aPages = aPagesInDocument + aAdditionalPagesCount[i];
+
+// Empty document with one Page Break
+SwDoc* pDoc = createDoc("watermark-position.odt");
+SwEditShell* pEditShell = pDoc->GetEditShell();
+SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+const OUString rPageStyleName = "Default Style";
+uno::Reference xModel = 
pDoc->GetDocShell()->GetBaseModel();
+uno::Reference 
xStyleFamiliesSupplier(xModel, uno::UNO_QUERY);
+uno::Reference 
xStyleFamilies(xStyleFamiliesSupplier->getStyleFamilies(), uno::UNO_QUERY);
+uno::Reference 
xStyleFamily(xStyleFamilies->getByName("PageStyles"), uno::UNO_QUERY);
+uno::Reference 
xPageStyle(xStyleFamily->getByName(rPageStyleName), uno::UNO_QUERY);
+
+// 1. Add additional page breaks
+for (int j = 0; j < aAdditionalPagesCount[i]; ++j)
+pWrtShell->InsertPageBreak();
+
+// 2. Change header state (On, Off, On)
+if (aChangeHeader[i])
+{
+SwPageDesc aDesc(pDoc->GetPageDesc(0));
+SwFrameFormat& rMaster = aDesc.GetMaster();
+rMaster.SetFormatAttr(SwFormatHeader(true));
+pDoc->ChgPageDesc(0, aDesc);
+
+aDesc = pDoc->GetPageDesc(0);
+SwFrameFormat& rMaster2 = aDesc.GetMaster();
+rMaster2.SetFormatAttr(SwFormatHeader(false));
+pDoc->ChgPageDesc(0, aDesc);
+
+aDesc = pDoc->GetPageDesc(0);
+SwFrameFormat& rMaster3 = aDesc.GetMaster();
+rMaster3.SetFormatAttr(SwFormatHeader(true));
+pDoc->ChgPageDesc(0, aDesc);
+}
+
+// 3. Insert Watermark
+SfxWatermarkItem aWatermark;
+aWatermark.SetText("Watermark");
+aWatermark.SetFont("DejaVu Sans");
+
+pEditShell->SetWatermark(aWatermark);
+
+uno::Reference xShape(getShape(1), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT(xShape.is());
+
+SdrPage* pPage = 
pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0);
+
+// Get Watermark object
+SdrObject* pObject = pPage->GetObj(0);
+pObject->RecalcBoundRect();
+const Rectangle& rRect = pObject->GetSnapRect();
+Size 

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

2017-06-09 Thread Aron Budea
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |   12 
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx  |   12 
 sw/source/filter/ww8/docxexport.cxx   |6 ++
 3 files changed, 18 insertions(+), 12 deletions(-)

New commits:
commit 320179612c6dc8be39eaf27de0fc7c8575e160ff
Author: Aron Budea 
Date:   Tue Jun 6 23:10:02 2017 +0200

tdf#99074: export Web view to DOCX

...so document saved in Web view shows in Web Layout in Word.

Change-Id: If39d566be02966fe5d22f74aee46e6d5452a9451
Reviewed-on: https://gerrit.libreoffice.org/38469
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/38587
Tested-by: Miklos Vajna 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf99074.docx 
b/sw/qa/extras/ooxmlexport/data/tdf99074.docx
similarity index 100%
rename from sw/qa/extras/ooxmlimport/data/tdf99074.docx
rename to sw/qa/extras/ooxmlexport/data/tdf99074.docx
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index d1c70ba69a7c..4877c57639c2 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -280,6 +281,17 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106001_2, 
"tdf106001-2.odt")
 assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:rPr/w:w","val","600");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf99074, "tdf99074.docx")
+{
+uno::Reference xModel(mxComponent, uno::UNO_QUERY);
+uno::Reference const xController(
+xModel->getCurrentController(), uno::UNO_QUERY);
+uno::Reference const xViewSettings(
+xController->getViewSettings());
+// This was false, Web Layout was ignored on import.
+CPPUNIT_ASSERT(getProperty(xViewSettings, "ShowOnlineLayout"));
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf107104, "tdf107104.docx")
 {
 CPPUNIT_ASSERT(getShape(1)->getSize().Width > 0);
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 1ce389416b2d..2e900ba0b83c 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -47,7 +47,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -1302,17 +1301,6 @@ DECLARE_OOXMLIMPORT_TEST(testTdf98882, "tdf98882.docx")
 CPPUNIT_ASSERT_EQUAL(nFlyHeight, nContentHeight);
 }
 
-DECLARE_OOXMLIMPORT_TEST(testTdf99074, "tdf99074.docx")
-{
-uno::Reference xModel(mxComponent, uno::UNO_QUERY);
-uno::Reference const xController(
-xModel->getCurrentController(), uno::UNO_QUERY);
-uno::Reference const xViewSettings(
-xController->getViewSettings());
-// This was false, Web Layout was ignored on import.
-CPPUNIT_ASSERT(getProperty(xViewSettings, "ShowOnlineLayout"));
-}
-
 DECLARE_OOXMLIMPORT_TEST(testTdf100830, "tdf100830.docx")
 {
 // FillTransparence wasn't imported, this was 0.
diff --git a/sw/source/filter/ww8/docxexport.cxx 
b/sw/source/filter/ww8/docxexport.cxx
index 50048c8adcaa..b7cda742afb9 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -825,6 +825,12 @@ void DocxExport::WriteSettings()
 FSNS( XML_xmlns, XML_w ), 
"http://schemas.openxmlformats.org/wordprocessingml/2006/main;,
 FSEND );
 
+// View
+if (pViewShell && pViewShell->GetViewOptions()->getBrowseMode())
+{
+pFS->singleElementNS(XML_w, XML_view, FSNS(XML_w, XML_val), "web", 
FSEND);
+}
+
 // Zoom
 if (pViewShell)
 {
___
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' - sw/qa sw/source

2017-05-31 Thread Aron Budea
 sw/qa/extras/ww8export/data/tdf108072.doc |binary
 sw/qa/extras/ww8export/ww8export2.cxx |   14 ++
 sw/source/filter/ww8/sprmids.hxx  |4 ++--
 sw/source/filter/ww8/ww8par6.cxx  |8 
 sw/source/filter/ww8/ww8scan.cxx  |4 ++--
 5 files changed, 22 insertions(+), 8 deletions(-)

New commits:
commit 062a31fb26e0262e29f31850664479e5df20cc67
Author: Aron Budea 
Date:   Sun May 28 23:16:24 2017 +0200

tdf#108072: match sprmTFCantSplit with its correct id

The behavior was adjusted with
72ef0d88e916b320de85fe2ebf08cb7aea28ca08 , but the ids
for sprmTFCantSplit90 and sprmTFCantSplit remained mixed up.

Change-Id: Ic97224a3af39e5df707a6dba59b785580c17b739
Reviewed-on: https://gerrit.libreoffice.org/38117
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/38278
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sw/qa/extras/ww8export/data/tdf108072.doc 
b/sw/qa/extras/ww8export/data/tdf108072.doc
new file mode 100644
index ..03e8b2a532dc
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf108072.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export2.cxx 
b/sw/qa/extras/ww8export/ww8export2.cxx
index d7512db6f994..1f9082fd1ff6 100644
--- a/sw/qa/extras/ww8export/ww8export2.cxx
+++ b/sw/qa/extras/ww8export/ww8export2.cxx
@@ -11,7 +11,9 @@
 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -87,6 +89,18 @@ DECLARE_WW8EXPORT_TEST(testTdf104334, "tdf104334.doc")
 CPPUNIT_ASSERT_EQUAL(OUString("1"), getRun(getParagraph(2), 
3)->getString());
 }
 
+DECLARE_WW8EXPORT_TEST(testTdf108072, "tdf108072.doc")
+{
+// The property IsSplitAllowed was imported from an obsolete property, 
sprmTFCantSplit90
+// instead of sprmTFCantSplit. sprmTFCantSplit90 is set to true for merged 
rows, so
+// for merged rows incorrect settings were imported, which prevented them 
from breaking over pages.
+uno::Reference xTextTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
+uno::Reference xTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+uno::Reference xTableRows(xTable->getRows(), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(true, getProperty(xTableRows->getByIndex(0), 
"IsSplitAllowed"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/sprmids.hxx b/sw/source/filter/ww8/sprmids.hxx
index 3d58ab545115..ed83649de242 100644
--- a/sw/source/filter/ww8/sprmids.hxx
+++ b/sw/source/filter/ww8/sprmids.hxx
@@ -27,7 +27,7 @@ namespace NS_sprm
 const sal_uInt16 LN_PContextualSpacing = 0x246d;
 const sal_uInt16 LN_PIstdPermute = 0xc601;
 const sal_uInt16 LN_PTabProps = 0x646b;
-const sal_uInt16 LN_TFCantSplit90 = 0x3466;
+const sal_uInt16 LN_TFCantSplit90 = 0x3403;
 const sal_uInt16 LN_TCantSplit = 0x3644;
 const sal_uInt16 LN_PIncLvl = 0x2602;
 const sal_uInt16 LN_PJcExtra = 0x2461;
@@ -245,7 +245,7 @@ const sal_uInt16 LN_TJc = 0x548A;
 const sal_uInt16 LN_TJc90 = 0x5400;
 const sal_uInt16 LN_TDxaLeft = 0x9601;
 const sal_uInt16 LN_TDxaGapHalf = 0x9602;
-const sal_uInt16 LN_TFCantSplit = 0x3403;
+const sal_uInt16 LN_TFCantSplit = 0x3466;
 const sal_uInt16 LN_TTableHeader = 0x3404;
 const sal_uInt16 LN_TTableBorders80 = 0xd605;
 const sal_uInt16 LN_TDefTable10 = 0xd606;
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 5bb3eb8eb507..5cd9e4ba74fd 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -6139,12 +6139,12 @@ const wwSprmDispatcher *GetWW8SprmDispatcher()
 {0x9602, nullptr}, //"sprmTDxaGapHalf"
  //tap.dxaGapHalf,
  //tap.rgdxaCenter; dxa; 
word;
-{0x3403, nullptr}, //"sprmTFCantSplit"
- //tap.fCantSplit;1 or 
0;byte;
+{0x3403, nullptr}, 
//"sprmTFCantSplit90"
+ //tap.fCantSplit90;1 or 
0;byte;
 {0x3404, nullptr}, //"sprmTTableHeader"
  //tap.fTableHeader;1 or 
0;byte;
-{0x3466, nullptr}, 
//"sprmTFCantSplit90"
- //tap.fCantSplit90;1 or 
0;byte;
+{0x3466, nullptr}, //"sprmTFCantSplit"
+ //tap.fCantSplit;1 or 
0;byte;
 {0xD605, nullptr},

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

2017-05-12 Thread Miklos Vajna
 sw/qa/extras/ww8import/data/tdf107773.doc |binary
 sw/qa/extras/ww8import/ww8import.cxx  |8 ++
 sw/source/filter/ww8/ww8par.cxx   |   25 +++
 sw/source/filter/ww8/ww8par.hxx   |2 +
 sw/source/filter/ww8/ww8par2.cxx  |   38 ++
 5 files changed, 73 insertions(+)

New commits:
commit e01204b5252ad6288267b82c73357ee9fd29f14a
Author: Miklos Vajna 
Date:   Thu May 11 17:38:40 2017 +0200

tdf#107773 DOC import: consider page breaks for multi-page floattables

See commit 8fe8bd6c3b5b1a539b7370f8c457fa69c061d2de (Related: fdo#61594
SwWW8ImplReader::StartApo: don't always start a frame, 2013-05-13) for
the context, this is one more case where having a multi-page floattable
as a multi-page one is a better option.

The additional condition is that in case there is a break right after
the table, then always import the table as a non-floating one, as there
won't be any wrapping anyway (due to the break).

Reviewed-on: https://gerrit.libreoffice.org/37513
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins 
(cherry picked from commit 6aba29576df7a2a40e54040d4dd09d94d6594741)

Change-Id: I3dd4174226cfc1e825c00607221feeed51b7133f

diff --git a/sw/qa/extras/ww8import/data/tdf107773.doc 
b/sw/qa/extras/ww8import/data/tdf107773.doc
new file mode 100644
index ..31c7b7c5c121
Binary files /dev/null and b/sw/qa/extras/ww8import/data/tdf107773.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx 
b/sw/qa/extras/ww8import/ww8import.cxx
index fe62252d3c11..751006a4a553 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -56,6 +56,14 @@ DECLARE_WW8IMPORT_TEST(testFloatingTableSectionColumns, 
"floating-table-section-
 CPPUNIT_ASSERT( tableWidth.toInt32() > 1 );
 }
 
+DECLARE_WW8IMPORT_TEST(testTdf107773, "tdf107773.doc")
+{
+uno::Reference xDrawPageSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xDrawPage = 
xDrawPageSupplier->getDrawPage();
+// This was 1, multi-page table was imported as a floating one.
+CPPUNIT_ASSERT_EQUAL(static_cast(0), xDrawPage->getCount());
+}
+
 DECLARE_WW8IMPORT_TEST(testTdf106291, "tdf106291.doc")
 {
 // Table cell was merged vertically instead of horizontally -> had 
incorrect dimensions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 70ff38a94ad0..1b010ef149c2 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2661,6 +2661,31 @@ bool SwWW8ImplReader::ProcessSpecial(bool , 
WW8_CP nStartCp)
 if (bHasRowEnd && ParseTabPos(,pPap))
 pTabPos = 
 
+if (pTabPos && !pTabPos->bNoFly && SearchTableEnd(pPap))
+{
+// Table is considered to be imported into a fly frame and we
+// know where the end of the table is.
+bool bIsUnicode;
+WW8_FC nFc = m_pSBase->WW8Cp2Fc(pPap->Where(), );
+sal_uInt64 nPos = m_pStrm->Tell();
+m_pStrm->Seek(nFc);
+sal_uInt16 nUChar = 0;
+if (bIsUnicode)
+m_pStrm->ReadUInt16(nUChar);
+else
+{
+sal_uInt8 nChar = 0;
+m_pStrm->ReadUChar(nChar);
+nUChar = nChar;
+}
+m_pStrm->Seek(nPos);
+if (nUChar == 0xc)
+// The pap after the table starts with a page break, so
+// there will be no wrapping around the float-table.
+// Request no fly in this case, so the table can properly
+// be a multi-page one if necessary.
+pTabPos->bNoFly = true;
+}
 m_pPlcxMan->GetPap()->Restore( aSave );
 }
 
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 3b4b3dd935f4..e117ee980422 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1849,6 +1849,8 @@ public: // really private, but can only be done public
 short ImportSprm( const sal_uInt8* pPos, sal_uInt16 nId = 0 );
 
 bool SearchRowEnd(WW8PLCFx_Cp_FKP* pPap,WW8_CP , int nLevel) 
const;
+/// Seek to the end of the table with pPap, returns true on success.
+bool SearchTableEnd(WW8PLCFx_Cp_FKP* pPap) const;
 
 const WW8Fib& GetFib() const{ return *m_pWwFib; }
 SwDoc& GetDoc() const   { return m_rDoc; }
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index f93b97a01fb2..c6b8ba08c398 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -507,6 +507,44 @@ bool SwWW8ImplReader::SearchRowEnd(WW8PLCFx_Cp_FKP* pPap, 
WW8_CP ,
 return false;
 }
 
+bool 

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

2017-05-10 Thread Szymon Kłos
 sw/qa/extras/uiwriter/data/autotext-gallery.dotx  |binary
 sw/qa/extras/uiwriter/uiwriter.cxx|   18 +++
 sw/source/filter/docx/swdocxreader.cxx|   54 +-
 writerfilter/source/dmapper/DomainMapper.cxx  |   29 ++-
 writerfilter/source/dmapper/DomainMapper.hxx  |1 
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |4 -
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |2 
 writerfilter/source/ooxml/model.xml   |   10 ++--
 8 files changed, 85 insertions(+), 33 deletions(-)

New commits:
commit 5841441ed9c0b78286706145b01ddd3f8111455c
Author: Szymon Kłos 
Date:   Tue May 9 11:56:35 2017 +0200

AutoText: add only real AutoText entries

* add only autoTxT gallery type
* new test with other types of entries

Change-Id: Ibf7751c73dcf3b6ebd69eec5f4931dbeaaf098c8
Reviewed-on: https://gerrit.libreoffice.org/37425
Tested-by: Jenkins 
Reviewed-by: Szymon Kłos 
Tested-by: Szymon Kłos 
(cherry picked from commit a470d16208a78ae6893d199b3b6bc77a8559b06a)
Reviewed-on: https://gerrit.libreoffice.org/37460

diff --git a/sw/qa/extras/uiwriter/data/autotext-gallery.dotx 
b/sw/qa/extras/uiwriter/data/autotext-gallery.dotx
new file mode 100644
index ..827ec60c29f4
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/autotext-gallery.dotx 
differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index e298c322f690..3d30b96b03f0 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -119,6 +119,7 @@ public:
 void testDOCXAutoTextEmpty();
 void testDOCXAutoTextMultiple();
 void testDOTMAutoText();
+void testDOCXAutoTextGallery();
 void testTdf67238();
 void testFdo75110();
 void testFdo75898();
@@ -239,6 +240,7 @@ public:
 CPPUNIT_TEST(testDOCXAutoTextEmpty);
 CPPUNIT_TEST(testDOCXAutoTextMultiple);
 CPPUNIT_TEST(testDOTMAutoText);
+CPPUNIT_TEST(testDOCXAutoTextGallery);
 CPPUNIT_TEST(testTdf67238);
 CPPUNIT_TEST(testFdo75110);
 CPPUNIT_TEST(testFdo75898);
@@ -798,6 +800,22 @@ void SwUiWriterTest::testDOTMAutoText()
 CPPUNIT_ASSERT_EQUAL(OUString("paragraph"), 
rNode.GetTextNode()->GetText());
 }
 
+void SwUiWriterTest::testDOCXAutoTextGallery()
+{
+// this file contains one AutoText entry and other
+// entries which are not AutoText (have different "gallery" value)
+std::unique_ptr pGlossary = 
readDOCXAutotext("autotext-gallery.dotx");
+
+SwDoc* pDoc = pGlossary->GetDoc();
+CPPUNIT_ASSERT(pDoc != nullptr);
+
+// check entries count
+CPPUNIT_ASSERT_EQUAL((sal_uInt16)1, pGlossary->GetCount());
+
+// check entry name (if not contains gallery type)
+CPPUNIT_ASSERT_EQUAL(OUString("Multiple"), pGlossary->GetLongName(0));
+}
+
 void SwUiWriterTest::testFdo74981()
 {
 // create a document with an input field
diff --git a/sw/source/filter/docx/swdocxreader.cxx 
b/sw/source/filter/docx/swdocxreader.cxx
index 8939e4922b02..6646f87e7edc 100644
--- a/sw/source/filter/docx/swdocxreader.cxx
+++ b/sw/source/filter/docx/swdocxreader.cxx
@@ -39,6 +39,8 @@
 #include 
 #include 
 
+#define AUTOTEXT_GALLERY "autoTxt"
+
 using namespace css;
 
 extern "C" SAL_DLLPUBLIC_EXPORT Reader* SAL_CALL ImportDOCX()
@@ -104,6 +106,7 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks 
 )
 
 SwNodeIndex aDocEnd( pD->GetNodes().GetEndOfContent() );
 SwNodeIndex aStart( *aDocEnd.GetNode().StartOfSectionNode(), 1 );
+bool bIsAutoText = false;
 
 if( aStart < aDocEnd && ( aDocEnd.GetIndex() - aStart.GetIndex() > 2 ) )
 {
@@ -119,6 +122,10 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks 
 )
 SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
 ++rIdx;
 aLNm = aPam.GetNode().GetTextNode()->GetText();
+
+// is AutoText?
+bIsAutoText = aLNm.startsWith(AUTOTEXT_GALLERY);
+aLNm = aLNm.copy(strlen(AUTOTEXT_GALLERY) + 1);
 }
 
 // Do not copy name
@@ -154,32 +161,35 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks 
 )
 }
 aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
 
-// Now we have the right selection for one entry
-rBlocks.ClearDoc();
+if( bIsAutoText )
+{
+// Now we have the right selection for one entry
+rBlocks.ClearDoc();
 
-OUString sShortcut = aLNm;
+OUString sShortcut = aLNm;
 
-// Need to check make sure the shortcut is not already being used
-sal_Int32 nStart = 0;
-sal_uInt16 nCurPos = rBlocks.GetIndex( sShortcut );
-sal_Int32 nLen = sShortcut.getLength();
+// Need to check 

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

2017-05-05 Thread Szymon Kłos
 sw/qa/extras/uiwriter/data/autotext-dotm.dotm |binary
 sw/qa/extras/uiwriter/uiwriter.cxx|   18 ++
 sw/source/filter/docx/swdocxreader.cxx|7 ++-
 3 files changed, 24 insertions(+), 1 deletion(-)

New commits:
commit 3a654934be5581a22c50e72999ebf91ce37d0504
Author: Szymon Kłos 
Date:   Thu May 4 11:57:20 2017 +0200

AutoText: fix dotm support

+ dotm files don't contain additional empty paragraphs
  at the end of AutoText entry
+ added test for dotm import

Change-Id: I336145dcf8a5dd69aa9ed82318a0f05a6f62596c
Reviewed-on: https://gerrit.libreoffice.org/37230
Tested-by: Jenkins 
Reviewed-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/37233
Tested-by: Szymon Kłos 

diff --git a/sw/qa/extras/uiwriter/data/autotext-dotm.dotm 
b/sw/qa/extras/uiwriter/data/autotext-dotm.dotm
new file mode 100644
index ..4909296d2117
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/autotext-dotm.dotm 
differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 69b0a1eabeb3..e298c322f690 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -118,6 +118,7 @@ public:
 void testExportRTF();
 void testDOCXAutoTextEmpty();
 void testDOCXAutoTextMultiple();
+void testDOTMAutoText();
 void testTdf67238();
 void testFdo75110();
 void testFdo75898();
@@ -237,6 +238,7 @@ public:
 CPPUNIT_TEST(testExportRTF);
 CPPUNIT_TEST(testDOCXAutoTextEmpty);
 CPPUNIT_TEST(testDOCXAutoTextMultiple);
+CPPUNIT_TEST(testDOTMAutoText);
 CPPUNIT_TEST(testTdf67238);
 CPPUNIT_TEST(testFdo75110);
 CPPUNIT_TEST(testFdo75898);
@@ -780,6 +782,22 @@ void SwUiWriterTest::testDOCXAutoTextMultiple()
 CPPUNIT_ASSERT_EQUAL(OUString("complex"), 
rLastNode.GetTextNode()->GetText());
 }
 
+void SwUiWriterTest::testDOTMAutoText()
+{
+// this is dotm file difference is that in the dotm
+// there are no empty paragraphs at the end of each entry
+SwTextBlocks* pGlossary = readDOCXAutotext("autotext-dotm.dotm");
+
+SwDoc* pDoc = pGlossary->GetDoc();
+CPPUNIT_ASSERT(pDoc != nullptr);
+
+// check if content is correct
+SwNodeIndex aDocEnd(pDoc->GetNodes().GetEndOfContent());
+SwNodeIndex aStart(*aDocEnd.GetNode().StartOfSectionNode(), 1);
+SwNode& rNode = aStart.GetNode();
+CPPUNIT_ASSERT_EQUAL(OUString("paragraph"), 
rNode.GetTextNode()->GetText());
+}
+
 void SwUiWriterTest::testFdo74981()
 {
 // create a document with an input field
diff --git a/sw/source/filter/docx/swdocxreader.cxx 
b/sw/source/filter/docx/swdocxreader.cxx
index 7558b4dfba10..8939e4922b02 100644
--- a/sw/source/filter/docx/swdocxreader.cxx
+++ b/sw/source/filter/docx/swdocxreader.cxx
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -139,7 +140,11 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks 
 )
 aPam.SetMark();
 {
 SwNodeIndex& rIdx = aPam.GetPoint()->nNode;
-rIdx = aStart.GetNode().EndOfSectionIndex() - 2;
+rIdx = aStart.GetNode().EndOfSectionIndex() - 1;
+// don't add extra empty text node if exist (.dotx but not 
.dotm)
+if( rIdx.GetNode().GetTextNode() &&
+rIdx.GetNode().GetTextNode()->GetText().isEmpty() )
+rIdx = aStart.GetNode().EndOfSectionIndex() - 2;
 if( ( nullptr == ( pCNd = rIdx.GetNode().GetContentNode() ) ) )
 {
 ++rIdx;
___
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' - sw/qa sw/source

2017-03-29 Thread Mike Kaganski
 sw/qa/extras/uiwriter/uiwriter.cxx |   12 +++-
 sw/source/uibase/wrtsh/delete.cxx  |   24 ++--
 2 files changed, 33 insertions(+), 3 deletions(-)

New commits:
commit 11c4e8cc28b91e7db7d22e2ab2c8864554291f45
Author: Mike Kaganski 
Date:   Wed Feb 1 19:40:43 2017 +0300

tdf#105625: Allow Delete/Backspace to delete whole fieldmark

Previously, the fieldmarks couldn't be removed with backspace or
deletee when cursor was right/left to them.

After commits f72b866c9cf4f07fce6744fbf482c4c6488106e2 and
c34fc4520dfee4ca068f249ee0756dacaa7a60cf, deletion worked wrong
(it didn't delete the mark from mark manager; in case of text
field, it removed one field's boundary).

Now single backspace/delete properly removes the whole fieldmark,
replacing it with its contents if applicable.

Change-Id: Id26e6e4e40e274d9fd6f0224f3e2b4fe33c369b7
Reviewed-on: https://gerrit.libreoffice.org/33812
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit af42aab836626fdf7b29921dff5d344a8b0e47c6)
Reviewed-on: https://gerrit.libreoffice.org/35859
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index f758d8a8f640..b60fe47ee9ee 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -4159,7 +4159,9 @@ void SwUiWriterTest::testTdf105625()
 SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
 uno::Reference 
xComponentContext(comphelper::getProcessComponentContext());
 // Ensure correct initial setting
-comphelper::ConfigurationHelper::writeDirectKey(xComponentContext, 
"org.openoffice.Office.Writer/", "Cursor/Option", "IgnoreProtectedArea", 
css::uno::Any(false), comphelper::EConfigurationModes::Standard);
+comphelper::ConfigurationHelper::writeDirectKey(xComponentContext,
+"org.openoffice.Office.Writer/", "Cursor/Option", 
"IgnoreProtectedArea",
+css::uno::Any(false), comphelper::EConfigurationModes::Standard);
 // We should be able to edit at positions adjacent to fields.
 // Check if the start and the end of the 1st paragraph are not protected
 // (they are adjacent to FORMCHECKBOX)
@@ -4173,6 +4175,14 @@ void SwUiWriterTest::testTdf105625()
 pWrtShell->SttPara();
 pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, 
/*bBasicCall=*/false);
 CPPUNIT_ASSERT_EQUAL(true, pWrtShell->HasReadonlySel());
+// Test deletion of whole field with single backspace
+// Previously it only removed right boundary of FORMTEXT, or failed 
removal at all
+const IDocumentMarkAccess* pMarksAccess = pDoc->getIDocumentMarkAccess();
+sal_Int32 nMarksBefore = pMarksAccess->getAllMarksCount();
+pWrtShell->EndPara();
+pWrtShell->DelLeft();
+sal_Int32 nMarksAfter = pMarksAccess->getAllMarksCount();
+CPPUNIT_ASSERT_EQUAL(nMarksBefore, nMarksAfter + 1);
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
diff --git a/sw/source/uibase/wrtsh/delete.cxx 
b/sw/source/uibase/wrtsh/delete.cxx
index 17362738422b..27edcce0822c 100644
--- a/sw/source/uibase/wrtsh/delete.cxx
+++ b/sw/source/uibase/wrtsh/delete.cxx
@@ -209,8 +209,19 @@ long SwWrtShell::DelLeft()
 }
 else
 {
+// If we are just to the right to a fieldmark, then remove it 
completely
+const SwPosition* aCurPos = GetCursor()->GetPoint();
+SwPosition aPrevChar(*aCurPos);
+--aPrevChar.nContent;
+sw::mark::IFieldmark* pFm = 
getIDocumentMarkAccess()->getFieldmarkFor(aPrevChar);
+if (pFm && pFm->GetMarkEnd() == *aCurPos)
+{
+getIDocumentMarkAccess()->deleteMark(pFm);
+return 1;
+}
+
 OpenMark();
-SwCursorShell::Left(1,CRSR_SKIP_CHARS);
+SwCursorShell::Left(1, CRSR_SKIP_CHARS);
 }
 long nRet = Delete();
 if( !nRet && bSwap )
@@ -329,10 +340,19 @@ long SwWrtShell::DelRight()
 // restore cursor
 SwCursorShell::Pop( false );
 }
+
+// If we are just ahead of a fieldmark, then remove it completely
+sw::mark::IFieldmark* pFm = GetCurrentFieldmark();
+if (pFm && pFm->GetMarkStart() == *GetCursor()->GetPoint())
+{
+getIDocumentMarkAccess()->deleteMark(pFm);
+nRet = 1;
+break;
+}
 }
 
 OpenMark();
-SwCursorShell::Right(1,CRSR_SKIP_CELLS);
+SwCursorShell::Right(1, CRSR_SKIP_CELLS);
 nRet = Delete();
 CloseMark( 0 != nRet );
 break;
___
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' - sw/qa sw/source

2017-03-29 Thread Mike Kaganski
 sw/qa/extras/uiwriter/data/tdf105625.fodt |1 +
 sw/qa/extras/uiwriter/uiwriter.cxx|   12 +---
 sw/source/core/crsr/callnk.cxx|4 ++--
 sw/source/core/crsr/pam.cxx   |4 +++-
 4 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 9b2e5dcb402445d8ddb3e88509bfacd506d66497
Author: Mike Kaganski 
Date:   Wed Feb 1 13:52:22 2017 +0300

tdf#105625 related: also check selection across field boundaries

The problem in callnk.cxx was that when selecting 1 char to the right
using keyboard, and exiting field boundary, nCmp pointed to previous
position (inside field), and then compared to position to the left
(which also may be inside field), thus missing call change link (and
read-only state change). Seems that this was a mistake in commit
740efbb1daf26828f70dc785c1e107f67706286b.

In pam.cxx, if cursor was to the left of field, and then selected
1 char to the right to cross field's boundary, then both PaM's point
and mark had same fieldmark, but point was outside, and mark inside,
and as code didn't check this condition, so read-only state wasn't
properly set.

Unit test is augmented to check the second problem.

Change-Id: I7323e53eeb261b4ccdc0f9e36cc0956b373f104d
Reviewed-on: https://gerrit.libreoffice.org/33790
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit c34fc4520dfee4ca068f249ee0756dacaa7a60cf)
Reviewed-on: https://gerrit.libreoffice.org/35858
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/uiwriter/data/tdf105625.fodt 
b/sw/qa/extras/uiwriter/data/tdf105625.fodt
index 44c0577d301b..9a1d573d033f 100644
--- a/sw/qa/extras/uiwriter/data/tdf105625.fodt
+++ b/sw/qa/extras/uiwriter/data/tdf105625.fodt
@@ -3,6 +3,7 @@
  
   

+   Field
   
  
 
\ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index 158364927abe..f758d8a8f640 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -4155,18 +4155,24 @@ void SwUiWriterTest::testTdf105417()
 
 void SwUiWriterTest::testTdf105625()
 {
-// We should be able to edit at positions adjacent to fields.
-// Check if the start and the end of the only paragraph are not protected
-// (they are adjacent to FORMCHECKBOX)
 SwDoc* pDoc = createDoc("tdf105625.fodt");
 SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
 uno::Reference 
xComponentContext(comphelper::getProcessComponentContext());
 // Ensure correct initial setting
 comphelper::ConfigurationHelper::writeDirectKey(xComponentContext, 
"org.openoffice.Office.Writer/", "Cursor/Option", "IgnoreProtectedArea", 
css::uno::Any(false), comphelper::EConfigurationModes::Standard);
+// We should be able to edit at positions adjacent to fields.
+// Check if the start and the end of the 1st paragraph are not protected
+// (they are adjacent to FORMCHECKBOX)
 pWrtShell->SttPara();
 CPPUNIT_ASSERT_EQUAL(false, pWrtShell->HasReadonlySel());
 pWrtShell->EndPara();
 CPPUNIT_ASSERT_EQUAL(false, pWrtShell->HasReadonlySel());
+// 2nd paragraph - FORMTEXT
+pWrtShell->Down(/*bSelect=*/false);
+// Check selection across FORMTEXT field boundary - must be read-only
+pWrtShell->SttPara();
+pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, 
/*bBasicCall=*/false);
+CPPUNIT_ASSERT_EQUAL(true, pWrtShell->HasReadonlySel());
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index 6e97ba4f04ab..bf56e7a846d5 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -195,8 +195,8 @@ SwCallLink::~SwCallLink()
 {
 const OUString rText = pCNd->GetTextNode()->GetText();
 if( !nCmp ||
-g_pBreakIt->GetBreakIter()->getScriptType( rText, nCmp )
- != g_pBreakIt->GetBreakIter()->getScriptType( rText, nCmp 
- 1 ))
+g_pBreakIt->GetBreakIter()->getScriptType( rText, nContent 
)
+!= g_pBreakIt->GetBreakIter()->getScriptType(rText, 
nAktContent))
 {
 rShell.CallChgLnk();
 return;
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index ee5ad68010ed..7c58f1665391 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -691,7 +691,9 @@ bool SwPaM::HasReadonlySel( bool bFormView, bool 
/*bAnnotationMode*/ ) const
 bool bAtStartA = (pA != nullptr) && (pA->GetMarkStart() == 
*GetPoint());
 bool bAtStartB = (pB != nullptr) && (pB->GetMarkStart() == 
*GetMark());
 
-if (pA != pB)
+if ((pA == pB) && (bAtStartA 

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

2017-03-29 Thread Mike Kaganski
 sw/qa/extras/uiwriter/data/tdf105625.fodt |8 
 sw/qa/extras/uiwriter/data/tdf90362.fodt  |6 ++-
 sw/qa/extras/uiwriter/uiwriter.cxx|   26 +--
 sw/source/core/crsr/pam.cxx   |   52 ++
 4 files changed, 54 insertions(+), 38 deletions(-)

New commits:
commit b5529179e37864a34ca7b4f694bd6d678017bd5b
Author: Mike Kaganski 
Date:   Tue Jan 31 00:32:48 2017 +0300

tdf#105625: allow editing around field marks

This commit fixes commit aa799f64723933bbb46544f835a970cfcbb90384,
and partially reverts commits bd505fdb9f669f365ff39b0ef46f0742c638e333
and 9104d5e8905c2ec2b576b5ca452d3e23de49 that seem unnecessary
now. Unit test included, the existing unit tests of partially
reverted commits are kept.

Change-Id: I2a02cda546f5d484553c3b9467993fca36dae140
Reviewed-on: https://gerrit.libreoffice.org/33722
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit f72b866c9cf4f07fce6744fbf482c4c6488106e2)
Reviewed-on: https://gerrit.libreoffice.org/35856
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/uiwriter/data/tdf105625.fodt 
b/sw/qa/extras/uiwriter/data/tdf105625.fodt
new file mode 100644
index ..44c0577d301b
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf105625.fodt
@@ -0,0 +1,8 @@
+
+http://www.w3.org/1999/xlink; 
xmlns:dc="http://purl.org/dc/elements/1.1/; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:config="urn:oas
 is:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooo="http://openoffice.org/2004/office; 
xmlns:ooow="http://openoffice.org/2004/writer; 
xmlns:oooc="http://openoffice.org/2004/calc; 
xmlns:dom="http://www.w3.org/2001/xml-events; 
xmlns:xforms="http://www.w3.org/2002/xforms; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xmlns:rpt="http://openoffice.org/2005/report; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:xhtml="http://www.w3.org/1999/xhtml; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#; 
xmlns:officeooo="http://openoffice.org/2009/office; 
xmlns:tableooo="http://openoffice.org/2009/table; 
xmlns:drawooo="http://openoffice.org/2010/draw; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:formx="urn:openoffice:names:
 experimental:ooxml-odf-interop:xmlns:form:1.0" 
xmlns:css3t="http://www.w3.org/TR/css3-text/; office:version="1.2" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ 
+  
+   
+  
+ 
+
\ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/data/tdf90362.fodt 
b/sw/qa/extras/uiwriter/data/tdf90362.fodt
index bf74255aee7f..97db3d59a71a 100644
--- a/sw/qa/extras/uiwriter/data/tdf90362.fodt
+++ b/sw/qa/extras/uiwriter/data/tdf90362.fodt
@@ -3,8 +3,10 @@
  
   
Before
-   
+   
+Inside
+   
After
   
  
-
+
\ No newline at end of file
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx 
b/sw/qa/extras/uiwriter/uiwriter.cxx
index b345380cf44d..158364927abe 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -221,6 +221,7 @@ public:
 void testTdf104425();
 void testTdf104814();
 void testTdf105417();
+void testTdf105625();
 
 CPPUNIT_TEST_SUITE(SwUiWriterTest);
 CPPUNIT_TEST(testReplaceForward);
@@ -336,6 +337,7 @@ public:
 CPPUNIT_TEST(testTdf104425);
 CPPUNIT_TEST(testTdf104814);
 CPPUNIT_TEST(testTdf105417);
+CPPUNIT_TEST(testTdf105625);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -3020,17 +3022,21 @@ void SwUiWriterTest::testTdf88899()
 
 void SwUiWriterTest::testTdf90362()
 {
-// First check if the end of the second paragraph is indeed protected.
 SwDoc* pDoc = createDoc("tdf90362.fodt");
 SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+uno::Reference 
xComponentContext(comphelper::getProcessComponentContext());
+// Ensure correct initial setting
+comphelper::ConfigurationHelper::writeDirectKey(xComponentContext, 
"org.openoffice.Office.Writer/", "Cursor/Option", "IgnoreProtectedArea", 
css::uno::Any(false), comphelper::EConfigurationModes::Standard);
+// First check if the end of the second paragraph is indeed protected.
 

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

2017-03-29 Thread Mike Kaganski
 sw/qa/extras/ww8import/data/tdf106799.doc |binary
 sw/qa/extras/ww8import/ww8import.cxx  |   15 +++
 sw/source/filter/ww8/ww8par.cxx   |4 +++-
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit 584d8437881e44f7f57bccd8d6bed891d2054468
Author: Mike Kaganski 
Date:   Mon Mar 27 17:35:45 2017 +0300

tdf#106799 WW8: Accept TTP Mark without Cell Mark

Paragraph mark of inner table (0x0D) sometimes has
sprmPFInnerTtp, but no sprmPFInnerTableCell. This still counts
as cell end (at least, MS Word treats it that way).

Unit test included.

Reviewed-on: https://gerrit.libreoffice.org/35763
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit 59af9cbbccee600408c89e872d548d153523ab1f)

Change-Id: I5589cdd486c03ca4567d61882826cc7c245a40c9
Reviewed-on: https://gerrit.libreoffice.org/35773
Reviewed-by: Mike Kaganski 
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ww8import/data/tdf106799.doc 
b/sw/qa/extras/ww8import/data/tdf106799.doc
new file mode 100644
index ..0637e8cce692
Binary files /dev/null and b/sw/qa/extras/ww8import/data/tdf106799.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx 
b/sw/qa/extras/ww8import/ww8import.cxx
index 3727c58d090b..fe62252d3c11 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -65,6 +65,21 @@ DECLARE_WW8IMPORT_TEST(testTdf106291, "tdf106291.doc")
 CPPUNIT_ASSERT(cellHeight.toInt32() > 200); // height might depend on font 
size
 }
 
+DECLARE_WW8IMPORT_TEST(testTdf106799, "tdf106799.doc")
+{
+sal_Int32 nCellWidths[3][4] = { { 9530, 0, 0, 0 },{ 2382, 2382, 2382, 2384 
},{ 2382, 2382, 2382, 2384 } };
+sal_Int32 nCellTxtLns[3][4] = { { 1, 0, 0, 0 },{ 1, 0, 0, 0},{ 1, 1, 1, 1 
} };
+// Table was distorted because of missing sprmPFInnerTableCell at 
paragraph marks (0x0D) with sprmPFInnerTtp
+for (sal_Int32 nRow : { 0, 1, 2 })
+for (sal_Int32 nCell : { 0, 1, 2, 3 })
+{
+OString cellXPath("/root/page/body/tab/row/cell/tab/row[" + 
OString::number(nRow+1) + "]/cell[" + OString::number(nCell+1) + "]/");
+CPPUNIT_ASSERT_EQUAL_MESSAGE(cellXPath.getStr(), 
nCellWidths[nRow][nCell], parseDump(cellXPath + "infos/bounds", 
"width").toInt32());
+if (nCellTxtLns[nRow][nCell] != 0)
+CPPUNIT_ASSERT_EQUAL_MESSAGE(cellXPath.getStr(), 
nCellTxtLns[nRow][nCell], parseDump(cellXPath + "txt/Text", 
"nLength").toInt32());
+}
+}
+
 // tests should only be added to ww8IMPORT *if* they fail round-tripping in 
ww8EXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 80749085cb86..68520286567a 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -3680,7 +3680,9 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs)
 bParaMark = false;
 }
 }
-else if (m_bWasTabCellEnd)
+// tdf#106799: We expect TTP marks to be also cell marks,
+// but sometimes sprmPFInnerTtp comes without 
sprmPFInnerTableCell
+else if (m_bWasTabCellEnd || m_bWasTabRowEnd)
 {
 TabCellEnd();
 bParaMark = false;
___
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' - sw/qa sw/source

2017-03-29 Thread Mike Kaganski
 sw/qa/extras/ww8import/data/tdf106291.doc |binary
 sw/qa/extras/ww8import/ww8import.cxx  |9 +++
 sw/source/filter/ww8/ww8par2.cxx  |   88 --
 3 files changed, 82 insertions(+), 15 deletions(-)

New commits:
commit 36f2eae1cd9ffe7cee915a72454a8e743cbf9bdd
Author: Mike Kaganski 
Date:   Thu Mar 2 18:55:50 2017 +0300

tdf#106291: WW8 import: Properly treat column spans

Previous code unconditionally treated all cells in merge groups as
rows span, thus in some conditions it merged incorrectly when there
were cells from same row.

The fix is inspired by SwTable::PrepareMerge().

Also, fixed improper adjustment of too narrow cells in
WW8TabDesc::CalcDefaults(), which also happens in files where
column spans are represented by spanned 1-twip-wide cells.

Unit test included.

Reviewed-on: https://gerrit.libreoffice.org/34820
Reviewed-by: Mike Kaganski 
Tested-by: Mike Kaganski 
(cherry picked from commit bb2a3df2d5b5a01aa58fb3567686e50762186036)

Change-Id: I6c3803635f006dd396805d6847daa4d80c97cad4
Reviewed-on: https://gerrit.libreoffice.org/34863
Reviewed-by: Mike Kaganski 
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ww8import/data/tdf106291.doc 
b/sw/qa/extras/ww8import/data/tdf106291.doc
new file mode 100644
index ..893004d46118
Binary files /dev/null and b/sw/qa/extras/ww8import/data/tdf106291.doc differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx 
b/sw/qa/extras/ww8import/ww8import.cxx
index bdbf84773212..3727c58d090b 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -56,6 +56,15 @@ DECLARE_WW8IMPORT_TEST(testFloatingTableSectionColumns, 
"floating-table-section-
 CPPUNIT_ASSERT( tableWidth.toInt32() > 1 );
 }
 
+DECLARE_WW8IMPORT_TEST(testTdf106291, "tdf106291.doc")
+{
+// Table cell was merged vertically instead of horizontally -> had 
incorrect dimensions
+OUString cellWidth = 
parseDump("/root/page[1]/body/tab/row/cell[1]/infos/bounds", "width");
+OUString cellHeight = 
parseDump("/root/page[1]/body/tab/row/cell[1]/infos/bounds", "height");
+CPPUNIT_ASSERT_EQUAL(sal_Int32(8660), cellWidth.toInt32());
+CPPUNIT_ASSERT(cellHeight.toInt32() > 200); // height might depend on font 
size
+}
+
 // tests should only be added to ww8IMPORT *if* they fail round-tripping in 
ww8EXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 146d22693acc..76b7b9dffae0 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -75,10 +75,12 @@
 
 using namespace ::com::sun::star;
 
+// Gets filled in WW8TabDesc::MergeCells().
+// Algorithm must ensure proper row and column order in WW8SelBoxInfo!
 class WW8SelBoxInfo
 {
 private:
-std::vector m_vBoxes;
+std::vector > m_vRows;
 
 WW8SelBoxInfo(WW8SelBoxInfo const&) = delete;
 WW8SelBoxInfo& operator=(WW8SelBoxInfo const&) = delete;
@@ -92,11 +94,35 @@ public:
 : nGroupXStart( nXCenter ), nGroupWidth( nWidth ), bGroupLocked(false)
 {}
 
-size_t size() const { return m_vBoxes.size(); }
+size_t size() const
+{
+size_t nResult = 0;
+for (auto& it : m_vRows)
+nResult += it.size();
+return nResult;
+}
+
+size_t rowsCount() const { return m_vRows.size(); }
 
-SwTableBox* operator[]( size_t nIndex ) { return m_vBoxes[nIndex]; }
+const std::vector& row( size_t nIndex ) { return 
m_vRows[nIndex]; }
 
-void push_back( SwTableBox* pBox ) { m_vBoxes.push_back(pBox); }
+void push_back( SwTableBox* pBox )
+{
+bool bDone = false;
+for (auto& iRow : m_vRows)
+if (iRow[0]->GetUpper() == pBox->GetUpper())
+{
+iRow.push_back(pBox);
+bDone = true;
+break;
+}
+if (!bDone)
+{
+const size_t sz = m_vRows.size();
+m_vRows.resize(sz+1);
+m_vRows[sz].push_back(pBox);
+}
+}
 };
 
 WW8TabBandDesc::WW8TabBandDesc()
@@ -2120,6 +2146,15 @@ void WW8TabDesc::CalcDefaults()
 if( pR->nCenter[0] < m_nMinLeft )
 m_nMinLeft = pR->nCenter[0];
 
+// Following adjustment moves a border and then uses it to find width
+// of next cell, so collect current widths, to avoid situation when 
width
+// adjustment to too narrow cell makes next cell have negative width
+short nOrigWidth[MAX_COL + 1];
+for( short i = 0; i < pR->nWwCols; i++ )
+{
+nOrigWidth[i] = pR->nCenter[i+1] - pR->nCenter[i];
+}
+
 for( short i = 0; i < pR->nWwCols; i++ )