summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 f1651bdcb6e7..4fa36000c6ed 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -272,6 +272,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 d5589ec3d0c9..97d161cd8742 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -467,6 +467,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;