[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sw/qa sw/source

2012-12-07 Thread Libreoffice Gerrit user
 sw/qa/core/macros-test.cxx |   43 +
 sw/source/core/unocore/unodraw.cxx |7 +-
 2 files changed, 49 insertions(+), 1 deletion(-)

New commits:
commit 4273e1411fbcbad9159925ccadb2e78b3fa9c0e4
Author: Michael Stahl mst...@redhat.com
Date:   Fri Dec 7 12:23:21 2012 +0100

fdo#55289: fix crash in SwXShape::setPropertyValue:

In the libreoffice-3-6 branch the docx import crashes here when setting
the anchor position of a shape, because the previous setting of the
AnchorType was not done properly: the position of the anchor in the
SwFmt did not match the actual position of the text attribute, so we get
these assertions: Missing FlyInCnt-Hint. and crash.

This cannot be reproduced with the docx import on master, because on
master a different intermediate AnchorType is set, and transitioning
from that happens not to cause the crash.  But it can be reproduced with
a unit test.

The regression was introduced in libreoffice-3-6 with
backport commit 10a0774b9da546557632cd09c4f6958f8939.

Change-Id: I394643e11862543177ba57958a26cd8ce06dc09c
(cherry picked from commit 01cd24df1ec7eaa53e9e2156d4d6890a7cc5996a)
Reviewed-on: https://gerrit.libreoffice.org/1264
Reviewed-by: Caolán McNamara caol...@redhat.com
Tested-by: Caolán McNamara caol...@redhat.com

diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 3f9262e..cbabeaf 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -37,8 +37,15 @@
 #include com/sun/star/frame/XDesktop.hpp
 
 #include com/sun/star/lang/XComponent.hpp
+#include com/sun/star/lang/XMultiServiceFactory.hpp
+#include com/sun/star/beans/XPropertySet.hpp
 #include com/sun/star/frame/XComponentLoader.hpp
 #include com/sun/star/document/MacroExecMode.hpp
+#include com/sun/star/drawing/XDrawPageSupplier.hpp
+#include com/sun/star/drawing/XShapes.hpp
+#include com/sun/star/drawing/XShape.hpp
+#include com/sun/star/text/XTextDocument.hpp
+#include com/sun/star/text/TextContentAnchorType.hpp
 
 #include sfx2/app.hxx
 #include sfx2/docfilt.hxx
@@ -48,6 +55,7 @@
 
 #include basic/sbxdef.hxx
 
+#include doc.hxx
 #include docsh.hxx
 
 SO2_DECL_REF(SwDocShell)
@@ -73,6 +81,7 @@ public:
 
 //void testStarBasic();
 void testVba();
+void testFdo55289();
 CPPUNIT_TEST_SUITE(SwMacrosTest);
 #if !defined(MACOSX)  !defined(WNT)
 //enable this test if you want to play with star basic macros in unit tests
@@ -80,6 +89,7 @@ public:
 //CPPUNIT_TEST(testStarBasic);
 CPPUNIT_TEST(testVba);
 #endif
+CPPUNIT_TEST(testFdo55289);
 
 CPPUNIT_TEST_SUITE_END();
 
@@ -162,6 +172,39 @@ void SwMacrosTest::testVba()
 }
 }
 
+void SwMacrosTest::testFdo55289()
+{
+SwDoc *const pDoc = new SwDoc;
+SwDocShellRef pDocShell = new SwDocShell(pDoc, SFX_CREATE_MODE_EMBEDDED);
+// this needs to run with no layout to tickle the bugs in the special
+// cases in SwXShape re-anchoring
+assert(!pDoc-GetCurrentLayout());
+
+uno::Referenceframe::XModel const xModel(pDocShell-GetModel());
+uno::Referencedrawing::XDrawPageSupplier const xDPS(xModel, UNO_QUERY);
+uno::Referencedrawing::XShapes const xShapes(xDPS-getDrawPage(),
+UNO_QUERY);
+uno::Referencebeans::XPropertySet const xShape(
+uno::Referencelang::XMultiServiceFactory(xModel, UNO_QUERY)-
+createInstance(com.sun.star.drawing.GraphicObjectShape),
+UNO_QUERY);
+xShape-setPropertyValue(AnchorType,
+makeAny(text::TextContentAnchorType_AT_PAGE));
+xShapes-add(uno::Referencedrawing::XShape(xShape, UNO_QUERY));
+xShape-setPropertyValue(AnchorType,
+makeAny(text::TextContentAnchorType_AT_CHARACTER));
+xShape-setPropertyValue(AnchorType,
+makeAny(text::TextContentAnchorType_AS_CHARACTER));
+xShape-setPropertyValue(AnchorType,
+makeAny(text::TextContentAnchorType_AT_CHARACTER));
+xShape-setPropertyValue(AnchorType,
+makeAny(text::TextContentAnchorType_AS_CHARACTER));
+uno::Referencetext::XTextRange const xEnd =
+uno::Referencetext::XTextDocument(xModel, 
UNO_QUERY)-getText()-getEnd();
+uno::Referencetext::XTextContent const xShapeContent(xShape, UNO_QUERY);
+xShapeContent-attach(xEnd);
+}
+
 SwMacrosTest::SwMacrosTest()
   : m_aBaseString(RTL_CONSTASCII_USTRINGPARAM(/sw/qa/core/data))
 {
diff --git a/sw/source/core/unocore/unodraw.cxx 
b/sw/source/core/unocore/unodraw.cxx
index 267f6f2..769bf14 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1366,7 +1366,12 @@ void SwXShape::setPropertyValue(const rtl::OUString 
rPropertyName, const uno::A
 SwFmtFlyCnt aFmt( pFlyFmt );
 pNd-InsertItem(aFmt,
 aPam.GetPoint()-nContent.GetIndex(), 0 );
-

[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sw/qa sw/source

2012-08-28 Thread Libreoffice Gerrit user
 sw/qa/core/swdoc-test.cxx |   10 --
 sw/source/core/txtnode/txtedt.cxx |   13 +++--
 2 files changed, 11 insertions(+), 12 deletions(-)

New commits:
commit 48d1979dc3fb4618e04f37e5090c66ddf2fdad3a
Author: Muhammad Haggag mhag...@gmail.com
Date:   Wed Aug 22 16:46:23 2012 +0200

fdo#53399 Word count is inconsistent and wrong with non-breaking space

This change replaces lcl_IsSkippableWhitespace with a call to ICU's 
u_isspace, which covers all Unicode separators. It also updates and fixes one 
of the SwScanner unit tests.

Bug details:
SwScanner::NextWord skips whitespace before calling into ICU's 
BreakIterator. The function used to identify whitespace 
(lcl_IsSkippableWhitespace) doesn't cover the full category of Unicode 
separators (code [Zs], 18 in total. See: 
http://www.fileformat.info/info/unicode/category/Zs/index.htm).

Since 0xA0 (no-break space) is not identified as whitespace and not 
skipped, we end up calling ICU starting at the position 0xA0, asking it to get 
us the boundary of the next word forward. ICU sees that it's called at the end 
of a word, and reverses the query direction to backward, and returns the word 
before. This causes NextWord to think we've hit the end of the string and call 
it a day, terminating word count for the rest of the line.

Change-Id: I29c89ddb0b26e88da822501253898856b28e3fa5
Reviewed-on: https://gerrit.libreoffice.org/453
Reviewed-by: Andras Timar ati...@suse.com
Tested-by: Andras Timar ati...@suse.com
(cherry picked from commit 3ba107606682b5e675127483a514f0e6580ecfd1)

Signed-off-by: Caolán McNamara caol...@redhat.com

diff --git a/sw/qa/core/swdoc-test.cxx b/sw/qa/core/swdoc-test.cxx
index a3f795a..f19e9e5 100644
--- a/sw/qa/core/swdoc-test.cxx
+++ b/sw/qa/core/swdoc-test.cxx
@@ -307,6 +307,7 @@ void SwDocTest::testSwScanner()
 }
 
 //See https://issues.apache.org/ooo/show_bug.cgi?id=89042
+//See https://bugs.freedesktop.org/show_bug.cgi?id=53399
 {
 SwDocStat aDocStat;
 
@@ -323,15 +324,20 @@ void SwDocTest::testSwScanner()
 CPPUNIT_ASSERT_MESSAGE(Should be 3, aDocStat.nWord == 3);
 
 const sal_Unicode aShouldBeFive[] = {
+// fr   e   n   c   h   space
 0x0046, 0x0072, 0x0065, 0x006E, 0x0063, 0x0068, 0x0020,
+//nbsps   a   v   o   i
 0x00AB, 0x00A0, 0x0073, 0x0061, 0x0076, 0x006F, 0x0069,
-0x0072, 0x0020, 0x0063, 0x0061, 0x006C, 0x0063, 0x0075,
-0x006C, 0x0065, 0x0072, 0x00A0, 0x00BB
+// rnnbsp   c   a   l   c   u
+0x0072, 0x202f, 0x0063, 0x0061, 0x006C, 0x0063, 0x0075,
+// le   r   idspace 
+0x006C, 0x0065, 0x0072, 0x3000, 0x00BB
 };
 
 m_pDoc-AppendTxtNode(*aPaM.GetPoint());
 m_pDoc-InsertString(aPaM, rtl::OUString(aShouldBeFive, 
SAL_N_ELEMENTS(aShouldBeFive)));
 pTxtNode = aPaM.GetNode()-GetTxtNode();
+aDocStat.Reset();
 pTxtNode-CountWords(aDocStat, 0, SAL_N_ELEMENTS(aShouldBeFive));
 CPPUNIT_ASSERT_MESSAGE(Should be 5, aDocStat.nWord == 5);
 }
diff --git a/sw/source/core/txtnode/txtedt.cxx 
b/sw/source/core/txtnode/txtedt.cxx
index 7f350c6..2cbe32a 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -71,6 +71,7 @@
 #include txtatr.hxx
 #include fmtautofmt.hxx
 #include istyleaccess.hxx
+#include unicode/uchar.h
 
 #include unomid.h
 
@@ -96,14 +97,6 @@ using namespace ::com::sun::star::smarttags;
 extern const SwTxtNode *pLinguNode;
 extern   SwTxtFrm  *pLinguFrm;
 
-bool lcl_IsSkippableWhiteSpace( xub_Unicode cCh )
-{
-return 0x3000 == cCh ||
-   ' ' == cCh ||
-   '\t' == cCh ||
-   0x0a == cCh;
-}
-
 /*
  * This has basically the same function as SwScriptInfo::MaskHiddenRanges,
  * only for deleted redlines
@@ -731,7 +724,7 @@ sal_Bool SwScanner::NextWord()
 // skip non-letter characters:
 while ( nBegin  aText.getLength() )
 {
-if ( !lcl_IsSkippableWhiteSpace( aText[nBegin] ) )
+if ( !u_isspace( aText[nBegin] ) )
 {
 if ( !pLanguage )
 {
@@ -1879,7 +1872,7 @@ void SwTxtNode::CountWords( SwDocStat rStat,
 //do the count
 // all counts exclude hidden paras and hidden+redlined within para
 // definition of space/white chars in SwScanner (and BreakIter!)
-// uses both lcl_IsSkippableWhiteSpace and BreakIter getWordBoundary in 
SwScanner
+// uses both u_isspace and BreakIter getWordBoundary in SwScanner
 sal_uInt32 nTmpWords = 0;// count of all words
 sal_uInt32 nTmpAsianWords = 0;   //count of all Asian codepoints
 sal_uInt32 nTmpChars = 0;// count of all chars
___
Libreoffice-commits mailing list