summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2014-09-30 17:59:08 +0200
committerMichael Stahl <mstahl@redhat.com>2014-10-08 17:52:27 +0200
commit31328c9bb0ea5802773094250350e8ffffad4c76 (patch)
tree9bae7b84dc80a13eadba36db403dfd6905ca6562
parenta7a890509c91e79dc330c2fbf1df97f0c6b08c92 (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. This is a re-implementation of 0f21f932081471b2a5eda820fa1a194fbf3ab85c because unostyle.cxx is very different on master... Reviewed-on: https://gerrit.libreoffice.org/11722 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit 902de8a1cbdb86c1eb1a05c8307b109fd75f493c) Conflicts: sw/source/core/unocore/unostyle.cxx Change-Id: I485d8089c1fb5ba3ca369fbfe8f3115bf700ba13 Reviewed-on: https://gerrit.libreoffice.org/11752 Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit ccfea9417df8e628a76e019712e862f5f0840caa)
-rw-r--r--sw/qa/extras/odfimport/data/fdo79269.odtbin0 -> 8496 bytes
-rw-r--r--sw/qa/extras/odfimport/data/fdo79269_header.odtbin0 -> 8528 bytes
-rw-r--r--sw/qa/extras/odfimport/odfimport.cxx35
-rw-r--r--sw/source/core/unocore/unostyle.cxx35
4 files changed, 55 insertions, 15 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/data/fdo79269_header.odt b/sw/qa/extras/odfimport/data/fdo79269_header.odt
new file mode 100644
index 000000000000..6f1a839ecb89
--- /dev/null
+++ b/sw/qa/extras/odfimport/data/fdo79269_header.odt
Binary files differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index e7fa8fbe4743..68ec3c17e481 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -271,6 +271,41 @@ 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(testFdo79269_header, "fdo79269_header.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());
+
+ 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, "HeaderTextFirst");
+ CPPUNIT_ASSERT_EQUAL(OUString("forst"), xFooter1->getString());
+ uno::Reference<text::XTextRange> xFooter = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "HeaderText");
+ 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 4963b68267ad..35b929c70cae 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -466,6 +466,24 @@ SwXStyleFamily::~SwXStyleFamily()
}
+static bool lcl_GetHeaderFooterItem(
+ SfxItemSet const& rSet, OUString const& rPropName, bool const bFooter,
+ SvxSetItem const*& o_rpItem)
+{
+ SfxItemState eState = rSet.GetItemState(
+ (bFooter) ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
+ false, reinterpret_cast<const SfxPoolItem**>(&o_rpItem));
+ if (SFX_ITEM_SET != eState &&
+ rPropName == "FirstIsShared")
+ { // 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**>(&o_rpItem));
+ }
+ return SFX_ITEM_SET == eState;
+}
+
+
static sal_Int32 lcl_GetCountOrName(const SwDoc &rDoc,
SfxStyleFamily eFamily, OUString *pString, sal_uInt16 nIndex = USHRT_MAX)
{
@@ -3097,20 +3115,9 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl(
break;
}
const SvxSetItem* pSetItem;
- if(SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(
- bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
- sal_False, (const SfxPoolItem**)&pSetItem))
+ if (lcl_GetHeaderFooterItem(aBaseImpl.GetItemSet(), pNames[nProp], bFooter, pSetItem))
{
lcl_putItemToSet(pSetItem, nRes, nItemType, pValues[nProp], pEntry->nMemberId, aBaseImpl);
-
- if (nRes == SID_ATTR_PAGE_SHARED_FIRST)
- {
- // Need to add this to the other as well
- if (SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState(
- bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET,
- sal_False, (const SfxPoolItem**)&pSetItem))
- lcl_putItemToSet(pSetItem, nRes, nItemType, pValues[nProp], pEntry->nMemberId, aBaseImpl);
- }
}
else if(SID_ATTR_PAGE_ON == nRes )
{
@@ -3354,9 +3361,7 @@ uno::Sequence< uno::Any > SAL_CALL SwXPageStyle::GetPropertyValues_Impl(
break;
}
const SvxSetItem* pSetItem;
- if(SFX_ITEM_SET == rSet.GetItemState(
- bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET,
- sal_False, (const SfxPoolItem**)&pSetItem))
+ if (lcl_GetHeaderFooterItem(rSet, pNames[nProp], bFooter, pSetItem))
{
const SfxItemSet& rTmpSet = pSetItem->GetItemSet();
const SfxPoolItem* pItem = 0;