summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-09-29 23:22:12 +0200
committerMichael Stahl <mstahl@redhat.com>2014-09-29 23:59:29 +0200
commit0f21f932081471b2a5eda820fa1a194fbf3ab85c (patch)
tree6c84c713a42a25eb3d7b24cbebf756f3347ca32a /sw
parent87331efa9b190793c1719b31a62a2eef6a66f92d (diff)
fdo#79269: fix ODF import of style:footer-first
The implementation of SwXStyle's FirstIsShared property is busted, and that causes xmloff to write the footer-first content into the master footer. Change-Id: I520a4929d9d7313da65bcdcf4094f8244382377d
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/odfimport/data/fdo79269.odtbin0 -> 8496 bytes
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx18
-rw-r--r--sw/source/core/unocore/unostyle.cxx26
3 files changed, 40 insertions, 4 deletions
diff --git a/sw/qa/extras/odfimport/data/fdo79269.odt b/sw/qa/extras/odfimport/data/fdo79269.odt
new file mode 100644
index 000000000000..2e3bf1e80985
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/fdo79269.odt
Binary files differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index 76f00bb96cd4..94eeb83d0031 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -272,6 +272,24 @@ DECLARE_ODFIMPORT_TEST(testFdo60842, "fdo60842.odt")
getCell(xTable, "E1", "01/04/2012");
}
+DECLARE_ODFIMPORT_TEST(testFdo79269, "fdo79269.odt")
+{
+ uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
+ uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
+ xCursor->jumpToLastPage();
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
+
+ // The problem was that the first-footer was shared.
+ uno::Reference<beans::XPropertySet> xPropSet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPropSet, "FirstIsShared"));
+
+ uno::Reference<text::XTextRange> xFooter1 = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "FooterTextFirst");
+ CPPUNIT_ASSERT_EQUAL(OUString("forst"), xFooter1->getString());
+ uno::Reference<text::XTextRange> xFooter = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "FooterText");
+ CPPUNIT_ASSERT_EQUAL(OUString("second"), xFooter->getString());
+}
+
DECLARE_ODFIMPORT_TEST(testFdo56272, "fdo56272.odt")
{
uno::Reference<drawing::XShape> xShape = getShape(1);
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index e17fce95de7a..81c14ac2eab0 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -3421,9 +3421,17 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl(
// it is a Header/Footer entry, access the SvxSetItem containing it's information
const SvxSetItem* pSetItem = 0;
- if (SfxItemState::SET == aBaseImpl.GetItemSet().GetItemState(
- bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
- false, (const SfxPoolItem**)&pSetItem))
+ SfxItemState eState = aBaseImpl.GetItemSet().GetItemState(
+ (bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
+ false, reinterpret_cast<const SfxPoolItem**>(&pSetItem));
+ if (SfxItemState::SET != eState &&
+ rPropName == UNO_NAME_FIRST_IS_SHARED)
+ { // fdo#79269 header may not exist, check footer then
+ eState = aBaseImpl.GetItemSet().GetItemState(
+ (!bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
+ false, reinterpret_cast<const SfxPoolItem**>(&pSetItem));
+ }
+ if (SfxItemState::SET == eState)
{
lcl_putItemToSet(pSetItem, *pPropSet, *pEntry, pValues[nProp], aBaseImpl, GetBasePool(), GetDoc(), GetFamily());
@@ -3728,7 +3736,17 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl(
const SfxItemSet& rSet = xStyle->GetItemSet();
const SvxSetItem* pSetItem;
- if(SfxItemState::SET == rSet.GetItemState(bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, false, (const SfxPoolItem**)&pSetItem))
+ SfxItemState eState = rSet.GetItemState(
+ (bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
+ false, reinterpret_cast<const SfxPoolItem**>(&pSetItem));
+ if (SfxItemState::SET != eState &&
+ rPropName == UNO_NAME_FIRST_IS_SHARED)
+ { // fdo#79269 header may not exist, check footer then
+ eState = rSet.GetItemState(
+ (!bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
+ false, reinterpret_cast<const SfxPoolItem**>(&pSetItem));
+ }
+ if (SfxItemState::SET == eState)
{
// get from SfxItemSet of the corresponding SfxSetItem
const SfxItemSet& rSetSet = pSetItem->GetItemSet();