From 49f453755b72654ba454acc321210e8b040df714 Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Wed, 11 Nov 2015 15:49:43 +0300 Subject: tdf#89714 - enable Widow/Orphan in default style For new Writer documents only, turn on the widow/orphan settings. This has been the default in MS Word since at least 2003. Change-Id: I1e873e7e4f0eac5e558732444594ef84e9ffe6c7 Reviewed-on: https://gerrit.libreoffice.org/19794 Tested-by: Jenkins Reviewed-by: Oliver Specht --- sw/qa/extras/uiwriter/uiwriter.cxx | 13 +++++++++++++ sw/source/uibase/app/docshini.cxx | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index aac00f04b0be..9ca85ee7fd9c 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -149,6 +149,7 @@ public: void testTdf90808(); void testTdf75137(); void testTdf83798(); + void testTdf89714(); void testPropertyDefaults(); void testTableBackgroundColor(); void testTdf88899(); @@ -226,6 +227,7 @@ public: CPPUNIT_TEST(testTdf90808); CPPUNIT_TEST(testTdf75137); CPPUNIT_TEST(testTdf83798); + CPPUNIT_TEST(testTdf89714); CPPUNIT_TEST(testPropertyDefaults); CPPUNIT_TEST(testTableBackgroundColor); CPPUNIT_TEST(testTdf88899); @@ -2269,6 +2271,17 @@ void SwUiWriterTest::testTdf83798() pCrsr->DeleteMark(); } +void SwUiWriterTest::testTdf89714() +{ + createDoc(); + uno::Reference xFact(mxComponent, uno::UNO_QUERY); + uno::Reference xInterface(xFact->createInstance("com.sun.star.text.Defaults"), uno::UNO_QUERY); + uno::Reference xPropState(xInterface, uno::UNO_QUERY); + //enabled Paragraph Orphan and Widows by default starting in LO5.1 + CPPUNIT_ASSERT_EQUAL( uno::makeAny(sal_Int8(2)), xPropState->getPropertyDefault(OUString("ParaOrphans")) ); + CPPUNIT_ASSERT_EQUAL( uno::makeAny(sal_Int8(2)), xPropState->getPropertyDefault(OUString("ParaWidows")) ); +} + void SwUiWriterTest::testPropertyDefaults() { createDoc(); diff --git a/sw/source/uibase/app/docshini.cxx b/sw/source/uibase/app/docshini.cxx index a9183054bce6..2844b23cde5b 100644 --- a/sw/source/uibase/app/docshini.cxx +++ b/sw/source/uibase/app/docshini.cxx @@ -49,6 +49,8 @@ #include #include #include +#include +#include #include #include #include @@ -688,6 +690,13 @@ void SwDocShell::SubInitNew() { bool bSquaredPageMode = SW_MOD()->GetUsrPref(false)->IsSquaredPageMode(); m_pDoc->SetDefaultPageMode( bSquaredPageMode ); + + // only set Widow/Orphan defaults on a new, non-web document - not an opened one + if( GetMedium() && GetMedium()->GetOrigURL().isEmpty() ) + { + m_pDoc->SetDefault( SvxWidowsItem( (sal_uInt8) 2, RES_PARATR_WIDOWS) ); + m_pDoc->SetDefault( SvxOrphansItem( (sal_uInt8) 2, RES_PARATR_ORPHANS) ); + } } m_pDoc->getIDocumentState().ResetModified(); -- cgit v1.2.1