[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sw/qa sw/source

Michael Stahl mstahl at redhat.com
Wed Oct 8 08:25:07 PDT 2014


 sw/qa/extras/odfimport/data/fdo79269.odt        |binary
 sw/qa/extras/odfimport/data/fdo79269_header.odt |binary
 sw/qa/extras/odfimport/odfimport.cxx            |   35 ++++++++++++++++++++++++
 sw/source/core/unocore/unostyle.cxx             |   35 +++++++++++++-----------
 4 files changed, 55 insertions(+), 15 deletions(-)

New commits:
commit ccfea9417df8e628a76e019712e862f5f0840caa
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Sep 30 17:59:08 2014 +0200

    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 at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at 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 at canonical.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/qa/extras/odfimport/data/fdo79269.odt b/sw/qa/extras/odfimport/data/fdo79269.odt
new file mode 100644
index 0000000..2e3bf1e
Binary files /dev/null and b/sw/qa/extras/odfimport/data/fdo79269.odt 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 0000000..6f1a839
Binary files /dev/null and b/sw/qa/extras/odfimport/data/fdo79269_header.odt differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx
index e7fa8fb..68ec3c1 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 4963b68..35b929c 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;


More information about the Libreoffice-commits mailing list