summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuthu Subramanian <sumuthu@collabora.com>2013-12-12 12:50:13 +0530
committerMuthu Subramanian <sumuthu@collabora.com>2013-12-12 12:50:13 +0530
commit4e09cb4645e1b8b0393acf956c325150fe1c52fc (patch)
tree69093cea2b2f4af11d0938ca5c26c5c18e01785a
parent134558033eea2fd7c05376c13859cb1d57140321 (diff)
n#753460: Copying slides having same master page name.
-rw-r--r--sd/inc/sdpage.hxx3
-rw-r--r--sd/source/core/drawdoc3.cxx22
-rw-r--r--sd/source/core/sdpage2.cxx37
-rw-r--r--svl/inc/svl/itemset.hxx1
-rw-r--r--svl/source/items/itemset.cxx16
-rw-r--r--svx/inc/svx/svdobj.hxx2
-rw-r--r--svx/source/svdraw/svdobj.cxx40
7 files changed, 115 insertions, 6 deletions
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index f62b2aeec73b..0c99930960a4 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -382,6 +382,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 e2d7039b0781..7f493d8f5e54 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<rtl::OUString> &rLayoutsToTransfer )
: mrLayoutsToTransfer(rLayoutsToTransfer) {}
- void operator()( SdDrawDocument&, SdPage* );
+ void operator()( SdDrawDocument&, SdPage*, bool, SdDrawDocument* );
private:
std::vector<rtl::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
// ===================================================
@@ -105,7 +105,17 @@ void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc
rtl::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)
@@ -120,7 +130,7 @@ void InsertBookmarkAsPage_FindDuplicateLayouts::operator()( SdDrawDocument& rDoc
static void lcl_IterateBookmarkPages( SdDrawDocument &rDoc, SdDrawDocument* pBookmarkDoc,
const std::vector<rtl::OUString> &rBookmarkList, sal_uInt16 nBMSdPageCount,
- InsertBookmarkAsPage_FindDuplicateLayouts& rPageIterator )
+ InsertBookmarkAsPage_FindDuplicateLayouts& rPageIterator, bool bRenameDuplicates = false )
{
//
// Refactored copy'n'pasted layout name collection from InsertBookmarkAsPage
@@ -180,7 +190,7 @@ static void lcl_IterateBookmarkPages( SdDrawDocument &rDoc, SdDrawDocument* pBoo
if( pBMMPage )
{
// yes, call functor
- rPageIterator( rDoc, pBMMPage );
+ rPageIterator( rDoc, pBMMPage, bRenameDuplicates, pBookmarkDoc );
}
}
}
@@ -498,7 +508,7 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
//
std::vector<rtl::OUString> aLayoutsToTransfer;
InsertBookmarkAsPage_FindDuplicateLayouts aSearchFunctor( aLayoutsToTransfer );
- lcl_IterateBookmarkPages( *this, pBookmarkDoc, rBookmarkList, nBMSdPageCount, aSearchFunctor );
+ lcl_IterateBookmarkPages( *this, pBookmarkDoc, rBookmarkList, nBMSdPageCount, aSearchFunctor, ( rBookmarkList.empty() && pBookmarkDoc != this ) );
/**************************************************************************
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 13fda3116685..9f621fdc6ed7 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 rtl::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;
+}
+
/*************************************************************************
|*
|* SetPresentationLayout, setzt: Layoutnamen, Masterpage-Verkn�pfung und
@@ -578,6 +589,32 @@ void SdPage::setTransitionDuration ( double fTranstionDuration )
ActionChanged();
}
+OString SdPage::stringify() const
+{
+ OStringBuffer aString(100);
+ aString.append(mePageKind).append(meAutoLayout).append(mbSelected).append(mePresChange).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/inc/svl/itemset.hxx b/svl/inc/svl/itemset.hxx
index a38398ac1ce7..47ed7efe220e 100644
--- a/svl/inc/svl/itemset.hxx
+++ b/svl/inc/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/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 27f2a8d6dd08..c53104800078 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -1790,7 +1790,23 @@ SfxAllItemSet::SfxAllItemSet(const SfxItemSet &rCopy)
// -----------------------------------------------------------------------
+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;
+ }
+}
SfxAllItemSet::SfxAllItemSet(const SfxAllItemSet &rCopy)
: SfxItemSet(rCopy),
diff --git a/svx/inc/svx/svdobj.hxx b/svx/inc/svx/svdobj.hxx
index cf6d266dc815..35a023f7d14f 100644
--- a/svx/inc/svx/svdobj.hxx
+++ b/svx/inc/svx/svdobj.hxx
@@ -1056,6 +1056,8 @@ public:
/// @see mbDoNotInsertIntoPageAutomatically
bool IsDoNotInsertIntoPageAutomatically() const;
+ virtual OString stringify() const;
+
protected:
/** Sets a new UNO shape
*
diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 09cc65886c52..0f81315267dc 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -109,6 +109,7 @@
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <svx/sdrobjectfilter.hxx>
#include "svdconv.hxx"
+#include <rtl/strbuf.hxx>
using namespace ::com::sun::star;
@@ -1766,6 +1767,45 @@ 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);
+ aStream.Flush();
+ aString.append((const char *)aStream.GetData(), aStream.GetEndOfData());
+
+ return aString.makeStringAndClear();
+}
+
sal_Bool SdrObject::BegTextEdit(SdrOutliner& /*rOutl*/)
{
return false;