[Libreoffice-commits] .: 4 commits - sw/qa sw/source writerfilter/source
Lubos Lunak
llunak at kemper.freedesktop.org
Thu May 24 08:59:55 PDT 2012
sw/qa/extras/ooxmltok/data/n652364.docx |binary
sw/qa/extras/ooxmltok/data/n750255.docx |binary
sw/qa/extras/ooxmltok/ooxmltok.cxx | 88 +++++++++++++++++++++++++++-
sw/qa/extras/ww8tok/data/n652364.doc |binary
sw/qa/extras/ww8tok/data/n750255.doc |binary
sw/qa/extras/ww8tok/ww8tok.cxx | 82 ++++++++++++++++++++++++++
sw/source/filter/ww8/ww8par.cxx | 6 +
writerfilter/source/dmapper/PropertyMap.cxx | 18 +++++
8 files changed, 189 insertions(+), 5 deletions(-)
New commits:
commit fe7a4aad76c051bc46ae46b175fb182b6e7e3f89
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Thu May 24 17:58:27 2012 +0200
testcases for bnc#652364 and bnc#750255 for .docx too
Change-Id: I4a98f4df6fde3f52b099fa627baa861f496bb452
diff --git a/sw/qa/extras/ooxmltok/data/n652364.docx b/sw/qa/extras/ooxmltok/data/n652364.docx
new file mode 100644
index 0000000..0845509
Binary files /dev/null and b/sw/qa/extras/ooxmltok/data/n652364.docx differ
diff --git a/sw/qa/extras/ooxmltok/data/n750255.docx b/sw/qa/extras/ooxmltok/data/n750255.docx
new file mode 100644
index 0000000..a0c7370
Binary files /dev/null and b/sw/qa/extras/ooxmltok/data/n750255.docx differ
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index abd1a2d..fb5e3d2 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -59,6 +59,8 @@ public:
void testN705956_1();
void testN705956_2();
void testN747461();
+ void testN750255();
+ void testN652364();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -72,6 +74,8 @@ public:
CPPUNIT_TEST(testN705956_1);
CPPUNIT_TEST(testN705956_2);
CPPUNIT_TEST(testN747461);
+ CPPUNIT_TEST(testN750255);
+ CPPUNIT_TEST(testN652364);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -321,6 +325,84 @@ after they are loaded.
CPPUNIT_ASSERT_EQUAL( OUString( "Green" ), descr3 );
}
+void Test::testN750255()
+{
+ load( "n750255.docx" );
+
+/*
+Column break without columns on the page is a page break, so check those paragraphs
+are on page 2 (page style 'Converted1') and page 3 (page style 'Converted2')
+enum = ThisComponent.Text.createEnumeration
+enum.nextElement
+para1 = enum.nextElement
+xray para1.String
+xray para1.PageStyleName
+para2 = enum.nextElement
+xray para2.String
+xray para2.PageStyleName
+*/
+ uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
+ // list of paragraphs
+ uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
+ // go to 1st paragraph
+ (void) paraEnum->nextElement();
+ // get the 2nd and 3rd paragraph
+ uno::Reference<uno::XInterface> paragraph1(paraEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<uno::XInterface> paragraph2(paraEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> text1(paragraph1, uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> text2(paragraph2, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL( OUString( "one" ), text1->getString());
+ CPPUNIT_ASSERT_EQUAL( OUString( "two" ), text2->getString());
+ uno::Reference<beans::XPropertySet> paragraphProperties1(paragraph1, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> paragraphProperties2(paragraph2, uno::UNO_QUERY);
+ OUString pageStyle1, pageStyle2;
+ paragraphProperties1->getPropertyValue( "PageStyleName" ) >>= pageStyle1;
+ paragraphProperties2->getPropertyValue( "PageStyleName" ) >>= pageStyle2;
+ CPPUNIT_ASSERT_EQUAL( OUString( "Converted1" ), pageStyle1 );
+ CPPUNIT_ASSERT_EQUAL( OUString( "Converted2" ), pageStyle2 );
+
+}
+
+void Test::testN652364()
+{
+ load( "n652364.docx" );
+
+/*
+Related to 750255 above, column break with columns on the page however should be a column break.
+enum = ThisComponent.Text.createEnumeration
+enum.nextElement
+para1 = enum.nextElement
+xray para1.String
+xray para1.PageStyleName
+enum.nextElement
+para2 = enum.nextElement
+xray para2.String
+xray para2.PageStyleName
+*/
+ uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
+ // list of paragraphs
+ uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
+ // get the 2nd and 4th paragraph
+ (void) paraEnum->nextElement();
+ uno::Reference<uno::XInterface> paragraph1(paraEnum->nextElement(), uno::UNO_QUERY);
+ (void) paraEnum->nextElement();
+ uno::Reference<uno::XInterface> paragraph2(paraEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> text1(paragraph1, uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> text2(paragraph2, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL( OUString( "text1" ), text1->getString());
+ CPPUNIT_ASSERT_EQUAL( OUString( "text2" ), text2->getString());
+ uno::Reference<beans::XPropertySet> paragraphProperties1(paragraph1, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> paragraphProperties2(paragraph2, uno::UNO_QUERY);
+ OUString pageStyle1, pageStyle2;
+ paragraphProperties1->getPropertyValue( "PageStyleName" ) >>= pageStyle1;
+ paragraphProperties2->getPropertyValue( "PageStyleName" ) >>= pageStyle2;
+ // "Standard" is the style for the first page (2nd is "Converted1").
+ CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle1 );
+ CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle2 );
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
commit d4798414f2705ee987d79617ae2e76da2524e26d
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Thu May 24 17:57:41 2012 +0200
handle column break in .docx properly too
related to d8cac25ed29dbeca16161f62173a7e341793b8b6
Change-Id: I56b02a450e96acec0346d6a36c29ad8e0326b0c8
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index fd58d97..58dd2b4 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -850,6 +850,24 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
uno::Reference<beans::XPropertySet> xRangeProperties(lcl_GetRangeProperties(m_bIsFirstSection, rDM_Impl, m_xStartingRange));
xRangeProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_PAGE_DESC_NAME), uno::makeAny(m_bTitlePage ? m_sFirstPageStyleName : m_sFollowPageStyleName));
}
+ // If the section is of type "New column" (0x01), then simply insert a column break.
+ // But only if there actually are columns on the page, otherwise a column break
+ // seems to be handled like a page break by MSO.
+ else if(m_nBreakType == 1 && m_nColumnCount > 0 )
+ {
+ uno::Reference< beans::XPropertySet > xRangeProperties;
+ if( m_xStartingRange.is() )
+ {
+ xRangeProperties = uno::Reference< beans::XPropertySet >( m_xStartingRange, uno::UNO_QUERY_THROW );
+ }
+ else
+ {
+ //set the start value at the beginning of the document
+ xRangeProperties = uno::Reference< beans::XPropertySet >( rDM_Impl.GetTextDocument()->getText()->getStart(), uno::UNO_QUERY_THROW );
+ }
+ xRangeProperties->setPropertyValue( rPropNameSupplier.GetName( PROP_BREAK_TYPE ),
+ uno::makeAny( com::sun::star::style::BreakType_COLUMN_BEFORE));
+ }
else
{
//get the properties and create appropriate page styles
commit ac6c57e12fb18a8294c57f79ec979128c735ec68
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Thu May 24 16:07:06 2012 +0200
testcases for bnc#652364 and bnc#750255
Change-Id: I1be5de3e09e3eb0d52de5fb57b390c2c5fde98cb
diff --git a/sw/qa/extras/ooxmltok/ooxmltok.cxx b/sw/qa/extras/ooxmltok/ooxmltok.cxx
index da85c14..abd1a2d 100644
--- a/sw/qa/extras/ooxmltok/ooxmltok.cxx
+++ b/sw/qa/extras/ooxmltok/ooxmltok.cxx
@@ -234,15 +234,15 @@ xray para.PageStyleName
(void) paraEnum->nextElement();
// get the 2nd paragraph
uno::Reference<uno::XInterface> paragraph(paraEnum->nextElement(), uno::UNO_QUERY);
- OUString value;
// text of the paragraph
uno::Reference<text::XTextRange> text(paragraph, uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL( OUString( "TEXT1" ), text->getString());
// we want to test the paragraph is on the first page (it was put onto another page without the fix),
// use a small trick and instead of checking the page layout, check the page style
uno::Reference<beans::XPropertySet> paragraphProperties(paragraph, uno::UNO_QUERY);
- paragraphProperties->getPropertyValue( "PageStyleName" ) >>= value;
- CPPUNIT_ASSERT_EQUAL( OUString( "First Page" ), value );
+ OUString pageStyle;
+ paragraphProperties->getPropertyValue( "PageStyleName" ) >>= pageStyle;
+ CPPUNIT_ASSERT_EQUAL( OUString( "First Page" ), pageStyle );
}
void Test::testN705956_1()
diff --git a/sw/qa/extras/ww8tok/data/n652364.doc b/sw/qa/extras/ww8tok/data/n652364.doc
new file mode 100644
index 0000000..f7a0fe0
Binary files /dev/null and b/sw/qa/extras/ww8tok/data/n652364.doc differ
diff --git a/sw/qa/extras/ww8tok/data/n750255.doc b/sw/qa/extras/ww8tok/data/n750255.doc
new file mode 100644
index 0000000..c0475c4
Binary files /dev/null and b/sw/qa/extras/ww8tok/data/n750255.doc differ
diff --git a/sw/qa/extras/ww8tok/ww8tok.cxx b/sw/qa/extras/ww8tok/ww8tok.cxx
index dfc047e..fc9f650 100644
--- a/sw/qa/extras/ww8tok/ww8tok.cxx
+++ b/sw/qa/extras/ww8tok/ww8tok.cxx
@@ -44,11 +44,15 @@ class Test : public SwModelTestBase
public:
void testN757910();
void testN760294();
+ void testN750255();
+ void testN652364();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
CPPUNIT_TEST(testN757910);
CPPUNIT_TEST(testN760294);
+ CPPUNIT_TEST(testN750255);
+ CPPUNIT_TEST(testN652364);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -93,6 +97,84 @@ void Test::testN760294()
CPPUNIT_ASSERT_EQUAL(aTableBorder.TopLine.InnerLineWidth, aTableBorder.TopLine.LineDistance);
}
+void Test::testN750255()
+{
+ load( "n750255.doc" );
+
+/*
+Column break without columns on the page is a page break, so check those paragraphs
+are on page 2 (page style 'Convert 1') and page 3 (page style 'Convert 2')
+enum = ThisComponent.Text.createEnumeration
+enum.nextElement
+para1 = enum.nextElement
+xray para1.String
+xray para1.PageStyleName
+para2 = enum.nextElement
+xray para2.String
+xray para2.PageStyleName
+*/
+ uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
+ // list of paragraphs
+ uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
+ // go to 1st paragraph
+ (void) paraEnum->nextElement();
+ // get the 2nd and 3rd paragraph
+ uno::Reference<uno::XInterface> paragraph1(paraEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<uno::XInterface> paragraph2(paraEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> text1(paragraph1, uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> text2(paragraph2, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL( OUString( "one" ), text1->getString());
+ CPPUNIT_ASSERT_EQUAL( OUString( "two" ), text2->getString());
+ uno::Reference<beans::XPropertySet> paragraphProperties1(paragraph1, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> paragraphProperties2(paragraph2, uno::UNO_QUERY);
+ OUString pageStyle1, pageStyle2;
+ paragraphProperties1->getPropertyValue( "PageStyleName" ) >>= pageStyle1;
+ paragraphProperties2->getPropertyValue( "PageStyleName" ) >>= pageStyle2;
+ CPPUNIT_ASSERT_EQUAL( OUString( "Convert 1" ), pageStyle1 );
+ CPPUNIT_ASSERT_EQUAL( OUString( "Convert 2" ), pageStyle2 );
+
+}
+
+void Test::testN652364()
+{
+ load( "n652364.doc" );
+
+/*
+Related to 750255 above, column break with columns on the page however should be a column break.
+enum = ThisComponent.Text.createEnumeration
+enum.nextElement
+para1 = enum.nextElement
+xray para1.String
+xray para1.PageStyleName
+enum.nextElement
+para2 = enum.nextElement
+xray para2.String
+xray para2.PageStyleName
+*/
+ uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
+ // list of paragraphs
+ uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
+ // get the 2nd and 4th paragraph
+ (void) paraEnum->nextElement();
+ uno::Reference<uno::XInterface> paragraph1(paraEnum->nextElement(), uno::UNO_QUERY);
+ (void) paraEnum->nextElement();
+ uno::Reference<uno::XInterface> paragraph2(paraEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> text1(paragraph1, uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> text2(paragraph2, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL( OUString( "text1" ), text1->getString());
+ CPPUNIT_ASSERT_EQUAL( OUString( "text2" ), text2->getString());
+ uno::Reference<beans::XPropertySet> paragraphProperties1(paragraph1, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> paragraphProperties2(paragraph2, uno::UNO_QUERY);
+ OUString pageStyle1, pageStyle2;
+ paragraphProperties1->getPropertyValue( "PageStyleName" ) >>= pageStyle1;
+ paragraphProperties2->getPropertyValue( "PageStyleName" ) >>= pageStyle2;
+ // "Standard" is the style for the first page (2nd is "Convert 1").
+ CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle1 );
+ CPPUNIT_ASSERT_EQUAL( OUString( "Standard" ), pageStyle2 );
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
commit 5935a6db64830ac5b932803cdcac5813aa033594
Author: LuboÅ¡ LuÅák <l.lunak at suse.cz>
Date: Thu May 24 15:27:57 2012 +0200
column break without columns seems to be a page break (bnc#750255)
That at least seems to be my conclusion after testing the doc
and bnc#652364 in MSO2k7.
Change-Id: Iec172dad32ba47c1f843df49a4eaff688c094373
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index e7ae45c..fdeafca 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -3886,8 +3886,10 @@ void wwSectionManager::InsertSegments()
mySegIter aStart = maSegments.begin();
for (mySegIter aIter = aStart; aIter != aEnd; ++aIter)
{
- // If the section is of type "New column" (0x01), then simply insert a column break
- if ( aIter->maSep.bkc == 1 )
+ // If the section is of type "New column" (0x01), then simply insert a column break.
+ // But only if there actually are columns on the page, otherwise a column break
+ // seems to be handled like a page break by MSO.
+ if ( aIter->maSep.bkc == 1 && aIter->maSep.ccolM1 > 0 )
{
SwPaM start( aIter->maStart );
mrReader.rDoc.InsertPoolItem( start, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0);
More information about the Libreoffice-commits
mailing list