Kaydet (Commit) 0f21f932 authored tarafından Michael Stahl's avatar Michael Stahl

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
üst 87331efa
......@@ -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);
......
......@@ -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();
......
......@@ -68,7 +68,9 @@ XMLTextHeaderFooterContext::XMLTextHeaderFooterContext( SvXMLImport& rImport, sa
if (bLeft)
{
aAny = xPropSet->getPropertyValue( sShareContent );
sal_Bool bShared = *(sal_Bool *)aAny.getValue();
bool bShared;
if (!(aAny >>= bShared))
assert(false); // should return a value!
if( bShared )
{
// Don't share headers any longer
......@@ -80,7 +82,9 @@ XMLTextHeaderFooterContext::XMLTextHeaderFooterContext( SvXMLImport& rImport, sa
if (bFirst)
{
aAny = xPropSet->getPropertyValue( sShareContentFirst );
sal_Bool bSharedFirst = aAny.has<sal_Bool>() && *(sal_Bool *)aAny.getValue();
bool bSharedFirst;
if (!(aAny >>= bSharedFirst))
assert(false); // should return a value!
if( bSharedFirst )
{
// Don't share first/right headers any longer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment