diff options
-rw-r--r-- | include/svl/itemset.hxx | 1 | ||||
-rw-r--r-- | include/svx/svdobj.hxx | 2 | ||||
-rw-r--r-- | sd/inc/sdpage.hxx | 3 | ||||
-rw-r--r-- | sd/source/core/drawdoc3.cxx | 22 | ||||
-rw-r--r-- | sd/source/core/sdpage2.cxx | 37 | ||||
-rw-r--r-- | svl/source/items/itemset.cxx | 16 | ||||
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 39 |
7 files changed, 114 insertions, 6 deletions
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index c204a4f31712..a4261cc67706 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 f1b3dbbad506..efc5a0e41fcc 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 7a042f64c1c9..c08b48f71bd1 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 998621904da5..7d40c85d5bbd 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 994727dc63ec..2172112cbdd0 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 b9e3a9b310ec..f275a55d529b 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 b495c5b98b8f..d94ab718910e 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; |