[Libreoffice-commits] core.git: 4 commits - sc/qa sc/source sw/qa sw/source writerfilter/source

Caolán McNamara caolanm at redhat.com
Mon Dec 8 08:25:00 PST 2014


 sc/qa/unit/ucalc.cxx                              |    2 -
 sc/source/core/data/dptabres.cxx                  |    3 +-
 sw/qa/core/data/ooxml/pass/fdo63164-1.docx        |binary
 sw/source/core/draw/dpage.cxx                     |    4 +-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   32 +++++++++++++++++++---
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    2 +
 6 files changed, 35 insertions(+), 8 deletions(-)

New commits:
commit af64f430181088460d5c574683dd1fdfd377ebcd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Dec 8 16:11:41 2014 +0000

    writer won't allow us to enter multiple CrossRefBookmarks on the same node
    
    e.g. fdo63164-1.docx and loads more like that, and the .docx genuinely has
    multiple bookmarks at the same place, so just allow the first one and discard
    the following ones
    
    Change-Id: Ida2f5d79fdef4ed3e2d8c1e96ca6a086004f6c7d

diff --git a/sw/qa/core/data/ooxml/pass/fdo63164-1.docx b/sw/qa/core/data/ooxml/pass/fdo63164-1.docx
new file mode 100644
index 0000000..768ec6c
Binary files /dev/null and b/sw/qa/core/data/ooxml/pass/fdo63164-1.docx differ
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 7176485..6c7bbdb 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -55,6 +55,7 @@
 #include <com/sun/star/text/XParagraphCursor.hpp>
 #include <com/sun/star/text/XRedline.hpp>
 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
+#include <com/sun/star/text/XTextRangeCompare.hpp>
 #include <com/sun/star/style/DropCapFormat.hpp>
 #include <com/sun/star/util/NumberFormatter.hpp>
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
@@ -4416,11 +4417,34 @@ void DomainMapper_Impl::StartOrEndBookmark( const OUString& rId )
                 {
                     xCursor->goLeft( 1, false );
                 }
+
                 uno::Reference< container::XNamed > xBkmNamed( xBookmark, uno::UNO_QUERY_THROW );
-                assert(!aBookmarkIter->second.m_sBookmarkName.isEmpty());
-                //todo: make sure the name is not used already!
-                xBkmNamed->setName( aBookmarkIter->second.m_sBookmarkName );
-                xTextAppend->insertTextContent( uno::Reference< text::XTextRange >( xCursor, uno::UNO_QUERY_THROW), xBookmark, !xCursor->isCollapsed() );
+
+                bool bAllowInsert = true;
+                uno::Reference<text::XTextRange> xRange(xCursor, uno::UNO_QUERY_THROW);
+                if (m_xPrevBookmark.is())
+                {
+                    fprintf(stderr, "ok here\n");
+                    uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xRange->getText(), uno::UNO_QUERY_THROW);
+                    fprintf(stderr, "still ok here\n");
+
+                    if (xTextRangeCompare->compareRegionStarts(m_xPrevBookmark, xRange) == 0 &&
+                        xTextRangeCompare->compareRegionEnds(m_xPrevBookmark, xRange) == 0)
+                    {
+                        SAL_WARN("writerfilter", "Cannot insert bookmark " << aBookmarkIter->second.m_sBookmarkName
+                                                 << " because another one is already inserted at this point");
+                        bAllowInsert = false;
+                    }
+                }
+
+                if (bAllowInsert)
+                {
+                    assert(!aBookmarkIter->second.m_sBookmarkName.isEmpty());
+                    //todo: make sure the name is not used already!
+                    xBkmNamed->setName( aBookmarkIter->second.m_sBookmarkName );
+                    xTextAppend->insertTextContent(xRange, xBookmark, !xCursor->isCollapsed());
+                    m_xPrevBookmark = xRange;
+                }
             }
             m_aBookmarkMap.erase( aBookmarkIter );
             m_sCurrentBkmkId.clear();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 11e58cd..c218f53 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -349,6 +349,8 @@ private:
     LineNumberSettings                                                              m_aLineNumberSettings;
 
     BookmarkMap_t                                                                   m_aBookmarkMap;
+    /// Detect attempt to insert multiple bookmarks at the same position
+    css::uno::Reference<css::text::XTextRange>                                      m_xPrevBookmark;
     OUString                                                                        m_sCurrentBkmkId;
     OUString                                                                        m_sCurrentBkmkName;
 
commit 93913ce2a71c66f57c9fe6a4b12c12ca6f7f473e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Dec 8 14:56:44 2014 +0000

    coverity#735379 annotate to dismiss Copy-paste error
    
    on the basis that it doesn't look obviously wrong to the original author after
    a once-over
    
    Change-Id: If333a17a2a9954d33ebefc6846e40e0e1e29c857

diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 818da53..e953e48 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -2698,7 +2698,8 @@ bool ScDPGroupCompare::TestIncluded( const ScDPMember& rMember )
         {
             if (pResultData->GetGroupBase(it->mnSrcIndex) == nGroupBase)
             {
-                // same base (hierarchy between the two groups is irrelevant)
+                // coverity[copy_paste_error] - same base (hierarchy between
+                // the two groups is irrelevant)
                 bInclude = pResultData->HasCommonElement(
                     it->mnNameIndex, it->mnSrcIndex, aMemberData, nDimSource);
             }
commit ad56f8de7b927cc32c2d67ffb13268c2a0b564c4
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Dec 8 13:58:34 2014 +0000

    coverity#1257114 Result is not floating-point
    
    Change-Id: I420fa77d52ca72a4c4609b4610572b8735911b4b

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index d2c66bb..b35bc11 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -4504,7 +4504,7 @@ void Test::testAutoFillSimple()
         if (nRow % 2 == 0)
         {
             double nVal = m_pDoc->GetValue(0, nRow, 0);
-            CPPUNIT_ASSERT_EQUAL(double((nRow+2)/2), nVal);
+            CPPUNIT_ASSERT_EQUAL((nRow+2)/2.0, nVal);
         }
         else
         {
commit d9ae37a3cc9b1157bf431fee59748716f83f37ec
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Dec 8 13:56:55 2014 +0000

    coverity#1257109 Unchecked dynamic_cast
    
    and
    
    coverity#1257108 Unchecked dynamic_cast
    
    Change-Id: Ib0d42b7fcd3b2b87a95301b111cebe80f54dd13f

diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx
index df6f577..ac547c5 100644
--- a/sw/source/core/draw/dpage.cxx
+++ b/sw/source/core/draw/dpage.cxx
@@ -81,7 +81,7 @@ void SwDPage::lateInit(const SwDPage& rPage, SwDrawModel* const pNewModel)
     SwDrawModel* pSwDrawModel = pNewModel;
     if ( !pModel )
     {
-        pSwDrawModel = dynamic_cast< SwDrawModel* >( GetModel() );
+        pSwDrawModel = &dynamic_cast<SwDrawModel&>(*GetModel());
         assert( pSwDrawModel );
     }
     pDoc = &pSwDrawModel->GetDoc();
@@ -98,7 +98,7 @@ SwDPage* SwDPage::Clone(SdrModel* const pNewModel) const
     SwDrawModel* pSwDrawModel = 0;
     if ( pNewModel )
     {
-        pSwDrawModel = dynamic_cast< SwDrawModel* >( pNewModel );
+        pSwDrawModel = &dynamic_cast<SwDrawModel&>(*pNewModel);
         assert( pSwDrawModel );
     }
     pNewPage->lateInit( *this, pSwDrawModel );


More information about the Libreoffice-commits mailing list