[Libreoffice-commits] core.git: 2 commits - include/oox include/svl include/svx oox/source sd/inc sd/source svl/source svx/source

Muthu Subramanian sumuthu at collabora.com
Tue Dec 10 03:48:19 PST 2013


 include/oox/core/contexthandler2.hxx     |    2 +
 include/svl/itemset.hxx                  |    1 
 include/svx/svdobj.hxx                   |    2 +
 oox/source/drawingml/textbodycontext.cxx |    1 
 sd/inc/sdpage.hxx                        |    3 ++
 sd/source/core/drawdoc3.cxx              |   22 ++++++++++++-----
 sd/source/core/sdpage2.cxx               |   37 +++++++++++++++++++++++++++++
 svl/source/items/itemset.cxx             |   16 ++++++++++++
 svx/source/svdraw/svdobj.cxx             |   39 +++++++++++++++++++++++++++++++
 9 files changed, 117 insertions(+), 6 deletions(-)

New commits:
commit aa822c44b758fe312a3a052f890f53418adc5f6b
Author: Muthu Subramanian <sumuthu at collabora.com>
Date:   Tue Dec 10 17:20:34 2013 +0530

    n#753460: Copying slides having same master page name.
    
    Has part feature of getting hashes of SdPages.
    (Misses hashing text, images, etc).

diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index c204a4f..a4261cc 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -119,6 +119,7 @@ public:
     virtual sal_uInt16              ClearItem( sal_uInt16 nWhich = 0);
     virtual void                ClearInvalidItems( sal_Bool bHardDefault = sal_False );
             void                InvalidateAllItems(); // HACK(via nWhich = 0) ???
+            void                InvalidateDefaultItems();
 
     inline void                 SetParent( const SfxItemSet* pNew );
 
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index f1b3dbb..efc5a0e 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -1035,6 +1035,8 @@ public:
     // #i121917#
     virtual bool HasText() const;
 
+    virtual OString stringify() const;
+
 protected:
     /** Sets a new UNO shape
       *
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 7a042f6..c08b48f 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -378,6 +378,9 @@ public:
     void removeAnnotation( const ::com::sun::star::uno::Reference< ::com::sun::star::office::XAnnotation >& xAnnotation );
     const sd::AnnotationVector& getAnnotations() const { return maAnnotations; }
     bool hasAnnotations() const { return !maAnnotations.empty(); }
+    sal_uInt64 getHash() const;
+    virtual OString stringify() const;
+
 
 private:
     bool mbIsPrecious;
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 9986219..7d40c85 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -72,12 +72,12 @@ class InsertBookmarkAsPage_FindDuplicateLayouts
 public:
     InsertBookmarkAsPage_FindDuplicateLayouts( std::vector<OUString> &rLayoutsToTransfer )
         : mrLayoutsToTransfer(rLayoutsToTransfer) {}
-    void operator()( SdDrawDocument&, SdPage* );
+    void operator()( SdDrawDocument&, SdPage*, bool, SdDrawDocument* );
 private:
     std::vector<OUString> &mrLayoutsToTransfer;
 };
 
-void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc, SdPage* pBMMPage )
+void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc, SdPage* pBMMPage, bool bRenameDuplicates, SdDrawDocument* pBookmarkDoc )
 {
     // now check for duplicate masterpage and layout names
     // ===================================================
@@ -107,7 +107,17 @@ void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc
         OUString aTest(aFullTest);
 
         if (aTest == aLayout)
-            bFound = true;
+        {
+            if( bRenameDuplicates && pTestPage->getHash() != pBMMPage->getHash() )
+            {
+                pBookmarkDoc->RenameLayoutTemplate( pBMMPage->GetLayoutName(), OUString(pBMMPage->GetName())+=OUString("_") );
+                aLayout = pBMMPage->GetName();
+
+                break;
+            }
+            else
+                bFound = true;
+        }
     }
 
     if (!bFound)
@@ -117,7 +127,7 @@ void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc
 // Inserts a bookmark as a page
 static void lcl_IterateBookmarkPages( SdDrawDocument &rDoc, SdDrawDocument* pBookmarkDoc,
                                const std::vector<OUString> &rBookmarkList, sal_uInt16 nBMSdPageCount,
-                               InsertBookmarkAsPage_FindDuplicateLayouts& rPageIterator )
+                               InsertBookmarkAsPage_FindDuplicateLayouts& rPageIterator, bool bRenameDuplicates = false )
 {
     //
     // Refactored copy'n'pasted layout name collection from InsertBookmarkAsPage
@@ -177,7 +187,7 @@ static void lcl_IterateBookmarkPages( SdDrawDocument &rDoc, SdDrawDocument* pBoo
         if( pBMMPage )
         {
             // yes, call functor
-            rPageIterator( rDoc, pBMMPage );
+            rPageIterator( rDoc, pBMMPage, bRenameDuplicates, pBookmarkDoc );
         }
     }
 }
@@ -466,7 +476,7 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
     //
     std::vector<OUString> aLayoutsToTransfer;
     InsertBookmarkAsPage_FindDuplicateLayouts aSearchFunctor( aLayoutsToTransfer );
-    lcl_IterateBookmarkPages( *this, pBookmarkDoc, rBookmarkList, nBMSdPageCount, aSearchFunctor );
+    lcl_IterateBookmarkPages( *this, pBookmarkDoc, rBookmarkList, nBMSdPageCount, aSearchFunctor, ( rBookmarkList.empty() && pBookmarkDoc != this ) );
 
 
     // Copy the style that we actually need.
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 994727d..2172112 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -45,6 +45,7 @@
 
 #include <tools/tenccvt.hxx>
 #include <svl/itemset.hxx>
+#include <rtl/strbuf.hxx>
 
 using namespace ::sd;
 using namespace ::com::sun::star;
@@ -53,6 +54,16 @@ using namespace ::com::sun::star::office;
 
 extern void NotifyDocumentEvent( SdDrawDocument* pDocument, const OUString& rEventName, const Reference< XInterface >& xSource );
 
+static sal_uInt64 lcl_getHash( OString aString )
+{
+    sal_Int32  len = aString.getLength();
+    sal_uInt64 nHash = 0;
+
+    for( sal_Int32 i = 0; i < len; i++ )
+        nHash = (nHash << 5) - nHash + aString[i];
+    return nHash;
+}
+
 /*************************************************************************
 |*
 |* Sets: names of layout, master page links and templates for presentation
@@ -582,6 +593,32 @@ void SdPage::setTransitionDuration ( double fTranstionDuration )
     ActionChanged();
 }
 
+OString SdPage::stringify() const
+{
+    OStringBuffer aString(100);
+    aString.append(mePageKind).append(meAutoLayout).append(mbSelected).append(mePresChange).append(mfTime).append(mbSoundOn).append(mbExcluded).
+             append(OUStringToOString( maLayoutName, RTL_TEXTENCODING_UTF8 )).
+             append(OUStringToOString(maSoundFile, RTL_TEXTENCODING_UTF8 )).
+             append(mbLoopSound).append(mbStopSound).
+             /*append(OUStringToOString(maCreatedPageName, RTL_TEXTENCODING_UTF8)).
+             append(OUStringToOString(maFileName, RTL_TEXTENCODING_UTF8)).*/
+             append(OUStringToOString(maBookmarkName, RTL_TEXTENCODING_UTF8)).
+             append(mbScaleObjects).append(mbBackgroundFullSize).append(meCharSet).append(mnPaperBin).
+             append(meOrientation).append(mnTransitionType).append(mnTransitionSubtype).append(mbTransitionDirection).
+             append(mnTransitionFadeColor).append(mfTransitionDuration);//.append(mbIsPrecious);
+
+    sal_Int32 n = GetObjCount();
+    for(sal_Int32 i = 0; i < n; i++)
+        aString.append(GetObj(i)->stringify());
+    return aString.makeStringAndClear();
+}
+
+sal_uInt64 SdPage::getHash() const
+{
+    return lcl_getHash( stringify() );
+}
+
+
 namespace sd {
 extern void createAnnotation( Reference< XAnnotation >& xAnnotation, SdPage* pPage );
 extern SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const Reference< XAnnotation >& xAnnotation, bool bInsert );
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index b9e3a9b..f275a55 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -457,7 +457,23 @@ void SfxItemSet::ClearInvalidItems( sal_Bool bHardDefault )
         }
 }
 
+void SfxItemSet::InvalidateDefaultItems()
+{
+    DBG_CHKTHIS(SfxItemSet, DbgCheckItemSet);
+    sal_uInt16* pPtr = _pWhichRanges;
+    SfxItemArray ppFnd = _aItems;
 
+    while( *pPtr )
+    {
+        for ( sal_uInt16 nWhich = *pPtr; nWhich <= *(pPtr+1); ++nWhich, ++ppFnd )
+            if ( *ppFnd && *ppFnd != (SfxPoolItem *)-1 && **ppFnd == _pPool->GetDefaultItem( nWhich ) )
+            {
+                _pPool->Remove( **ppFnd );
+                *ppFnd = (SfxPoolItem*)-1;
+            }
+        pPtr += 2;
+    }
+}
 
 void SfxItemSet::InvalidateAllItems()
 {
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index b495c5b..d94ab71 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -124,6 +124,7 @@
 #include <svx/xlntrit.hxx>
 #include <svx/xlnwtit.hxx>
 #include <svx/xpoly.hxx>
+#include <rtl/strbuf.hxx>
 
 using namespace ::com::sun::star;
 
@@ -1806,6 +1807,44 @@ bool SdrObject::HasTextEdit() const
     return false;
 }
 
+OString SdrObject::stringify() const
+{
+    OStringBuffer aString(100);
+    aString.append(aAnchor.X()).
+            append(aAnchor.Y()).
+            append(aGridOffset.X()).
+            append(aGridOffset.Y()).
+            append((sal_Int32)nOrdNum).
+            append((sal_Int32)mnNavigationPosition).
+            append(mbSupportTextIndentingOnLineWidthChange).
+            append(mbLineIsOutsideGeometry).
+            append(bMarkProt).
+            append(bIs3DObj).
+            append(bIsEdge).
+            append(bClosedObj).
+            append(bNotVisibleAsMaster).
+            append(bEmptyPresObj).
+            append(mbVisible).
+            append(bNoPrint).
+            append(bSizProt).
+            append(bMovProt).
+            append(bGrouped).
+            append(bInserted).
+            append(bNetLock).
+            append(bVirtObj).
+            //append(maBLIPSizeRectangle).
+            append(mnLayerID);
+
+    SvMemoryStream aStream;
+    OString aLine;
+    SfxItemSet aSet(GetMergedItemSet());
+    aSet.InvalidateDefaultItems();
+    aSet.Store(aStream, true);
+    aString.append((const char *)aStream.GetBuffer(), aStream.GetEndOfData());
+
+    return aString.makeStringAndClear();
+}
+
 sal_Bool SdrObject::BegTextEdit(SdrOutliner& /*rOutl*/)
 {
     return false;
commit 840f4fc4d677740fc4b0ebcb658f4a828e184dad
Author: Muthu Subramanian <sumuthu at collabora.com>
Date:   Tue Dec 10 16:56:25 2013 +0530

    n#828390: New line is dropped while importing text.

diff --git a/include/oox/core/contexthandler2.hxx b/include/oox/core/contexthandler2.hxx
index d60cf38..48edd9a 100644
--- a/include/oox/core/contexthandler2.hxx
+++ b/include/oox/core/contexthandler2.hxx
@@ -206,6 +206,8 @@ private:
 
     ContextStackRef     mxContextStack;     ///< Stack of all processed elements.
     size_t              mnRootStackSize;    ///< Stack size on construction time.
+
+protected:
     bool                mbEnableTrimSpace;  ///< True = trim whitespace in characters().
 };
 
diff --git a/oox/source/drawingml/textbodycontext.cxx b/oox/source/drawingml/textbodycontext.cxx
index d274d5a..77b5e7a 100644
--- a/oox/source/drawingml/textbodycontext.cxx
+++ b/oox/source/drawingml/textbodycontext.cxx
@@ -52,6 +52,7 @@ TextParagraphContext::TextParagraphContext( ContextHandler2Helper& rParent, Text
 : ContextHandler2( rParent )
 , mrParagraph( rPara )
 {
+    mbEnableTrimSpace = false;
 }
 
 // --------------------------------------------------------------------


More information about the Libreoffice-commits mailing list