[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - 8 commits - include/rtl include/svl include/svx sal/rtl sd/inc sd/source svl/source svx/source
Stephan Bergmann
sbergman at redhat.com
Fri Mar 7 04:49:34 PST 2014
include/rtl/strbuf.hxx | 17 +++++++
include/svl/itemset.hxx | 3 +
include/svx/svdobj.hxx | 2
sal/rtl/strtmpl.cxx | 13 ++++++
sd/inc/sdpage.hxx | 3 +
sd/inc/stlpool.hxx | 5 ++
sd/source/core/drawdoc3.cxx | 62 +++++++++++++++++++++++++---
sd/source/core/sdpage2.cxx | 27 ++++++++++++
sd/source/core/stlpool.cxx | 93 ++++++++++++++++++++++++++++++++++++++++++-
svl/source/items/itemset.cxx | 39 ++++++++++++++++++
svx/source/svdraw/svdobj.cxx | 39 ++++++++++++++++++
11 files changed, 295 insertions(+), 8 deletions(-)
New commits:
commit 795a2b1e7389d2639396ad8663d0f29edc1fba4d
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Mar 7 18:18:00 2014 +0530
Stick to a single O[U]String hash function.
Ported from 98554820e6109c3e3f4ea83bf036d9f20ef1685e
Change-Id: I22a6ffd71828295e92798fb1201133c0a5e25eda
diff --git a/include/rtl/string.h b/include/rtl/string.h
index f0d3e76..9cd81aa 100644
--- a/include/rtl/string.h
+++ b/include/rtl/string.h
@@ -277,24 +277,6 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode(
SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode_WithLength(
const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
-/** Return a hash code (64bit) for a string.
-
- It is not allowed to store the hash code persistently, because later
- versions could return other hash codes.
-
- @param str
- a string. Need not be null-terminated, but must be at least as long as
- the specified len.
-
- @param len
- the length of the string.
-
- @return
- a hash code for the given string.
- */
-SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_str_hashCode64_WithLength(
- const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
-
/** Search for the first occurrence of a character within a string.
The string must be null-terminated.
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 7e07748..7228fe7 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -880,21 +880,6 @@ public:
}
/**
- Returns a 64bit hash of the string data.
- This hashes the entire data, while hashCode would do sampling for larger string sizes.
-
- @return a hash code value of the string data
-
- @see hashCode() for simple hashes
-
- @since LibreOffice 4.3
- */
- sal_uInt64 hashCode64() const SAL_THROW(())
- {
- return rtl_str_hashCode64_WithLength( pData->buffer, pData->length );
- }
-
- /**
Returns a hashcode for this string.
@return a hash code value for this object.
diff --git a/include/rtl/ustring.h b/include/rtl/ustring.h
index da5e912..da6720b 100644
--- a/include/rtl/ustring.h
+++ b/include/rtl/ustring.h
@@ -551,24 +551,6 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode(
SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength(
const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
-/** Return a hash code (64bit) for a string.
-
- It is not allowed to store the hash code persistently, because later
- versions could return other hash codes.
-
- @param str
- a string. Need not be null-terminated, but must be at least as long as
- the specified len.
-
- @param len
- the length of the string.
-
- @return
- a hash code for the given string.
- */
-SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_ustr_hashCode64_WithLength(
- const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
-
/** Search for the first occurrence of a character within a string.
The string must be null-terminated.
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 4a6309a..06ba97b 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -1187,21 +1187,6 @@ public:
}
/**
- Returns a 64bit hash of the string data.
- This hashes the entire data, while hashCode would do sampling for larger string sizes.
-
- @return a hash code value of the string data
-
- @see hashCode() for simple hashes
-
- @since LibreOffice 4.3
- */
- sal_uInt64 hashCode64() const SAL_THROW(())
- {
- return rtl_ustr_hashCode64_WithLength( pData->buffer, pData->length );
- }
-
- /**
Returns a hashcode for this string.
@return a hash code value for this object.
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 89ad83d..13b6988 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -151,7 +151,7 @@ public:
virtual SvStream & Store( SvStream &, bool bDirect = false ) const;
virtual int operator==(const SfxItemSet &) const;
- virtual sal_uInt64 getHash() const;
+ sal_Int32 getHash() const;
virtual OString stringify() const;
};
diff --git a/sal/util/sal.map b/sal/util/sal.map
index c052a93..f2790d5 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -664,12 +664,6 @@ LIBO_UDK_4.1 { # symbols available in >= LibO 4.1
rtl_ustr_toUInt64;
} LIBO_UDK_4.0;
-LIBO_UDK_4.3 { #symbols available in >= LibO 4.3
- global:
- rtl_str_hashCode64_WithLength;
- rtl_ustr_hashCode64_WithLength;
-} LIBO_UDK_4.2;
-
PRIVATE_1.0 {
global:
osl_detail_ObjectRegistry_storeAddresses;
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 9e1f6f1..cf5f979 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -380,7 +380,7 @@ 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;
+ sal_Int32 getHash() const;
virtual OString stringify() const;
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 506d0fe..3299f42 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -599,9 +599,9 @@ OString SdPage::stringify() const
return aString.makeStringAndClear();
}
-sal_uInt64 SdPage::getHash() const
+sal_Int32 SdPage::getHash() const
{
- return stringify().hashCode64();
+ return stringify().hashCode();
}
diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx
index 2c44fb6..56c9e93 100644
--- a/sd/source/core/stlpool.cxx
+++ b/sd/source/core/stlpool.cxx
@@ -677,7 +677,7 @@ void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily
SfxStyleSheetBase* pExistingSheet = Find(aName, eFamily);
if( pExistingSheet && !rRenameSuffix.isEmpty() )
{
- sal_uInt64 nHash = xSheet->GetItemSet().getHash();
+ sal_Int32 nHash = xSheet->GetItemSet().getHash();
if( pExistingSheet->GetItemSet().getHash() != nHash )
{
OUString aTmpName = aName + rRenameSuffix;
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 33bc621..8edaa2a 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -2050,9 +2050,9 @@ SfxItemSet *SfxAllItemSet::Clone(sal_Bool bItems, SfxItemPool *pToPool ) const
// -----------------------------------------------------------------------
-sal_uInt64 SfxItemSet::getHash() const
+sal_Int32 SfxItemSet::getHash() const
{
- return stringify().hashCode64();
+ return stringify().hashCode();
}
// -----------------------------------------------------------------------
commit 49b4c64a4bc47f6d1c6d2e121bc567da17b1cf8c
Author: Muthu Subramanian <sumuthu at collabora.com>
Date: Fri Mar 7 18:14:17 2014 +0530
String cleanups.
Ported from 4cf0d8edaf1581c42949ad2cbb40183a2f657ddd
Change-Id: I4aa32fdeafdd17135c56b9f113f1abd06df892cf
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index f44ac54..7e07748 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -886,6 +886,8 @@ public:
@return a hash code value of the string data
@see hashCode() for simple hashes
+
+ @since LibreOffice 4.3
*/
sal_uInt64 hashCode64() const SAL_THROW(())
{
diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx
index 06ba97b..4a6309a 100644
--- a/include/rtl/ustring.hxx
+++ b/include/rtl/ustring.hxx
@@ -1187,6 +1187,21 @@ public:
}
/**
+ Returns a 64bit hash of the string data.
+ This hashes the entire data, while hashCode would do sampling for larger string sizes.
+
+ @return a hash code value of the string data
+
+ @see hashCode() for simple hashes
+
+ @since LibreOffice 4.3
+ */
+ sal_uInt64 hashCode64() const SAL_THROW(())
+ {
+ return rtl_ustr_hashCode64_WithLength( pData->buffer, pData->length );
+ }
+
+ /**
Returns a hashcode for this string.
@return a hash code value for this object.
diff --git a/sal/util/sal.map b/sal/util/sal.map
index 73595f2..c052a93 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -221,7 +221,6 @@ UDK_3_0_0 {
rtl_str_shortenedCompareIgnoreAsciiCase_WithLength;
rtl_str_hashCode;
rtl_str_hashCode_WithLength;
- rtl_str_hashCode64_WithLength;
rtl_str_indexOfChar;
rtl_str_indexOfChar_WithLength;
rtl_str_indexOfStr;
@@ -665,6 +664,12 @@ LIBO_UDK_4.1 { # symbols available in >= LibO 4.1
rtl_ustr_toUInt64;
} LIBO_UDK_4.0;
+LIBO_UDK_4.3 { #symbols available in >= LibO 4.3
+ global:
+ rtl_str_hashCode64_WithLength;
+ rtl_ustr_hashCode64_WithLength;
+} LIBO_UDK_4.2;
+
PRIVATE_1.0 {
global:
osl_detail_ObjectRegistry_storeAddresses;
commit 1d0d89457fdbd4491ff4227d926b76c574f78f1f
Author: Muthu Subramanian <sumuthu at collabora.com>
Date: Fri Mar 7 18:08:47 2014 +0530
n#757432: Styles (rename &) copy to different decks.
Ported from: 9f8baf0ed263889e3e77ea12ccb908020fee05a8 and
a4cd841541a729d7b8126d27d91fa28e30b01403
Change-Id: If0e56cd8b2aab1ff4c6166b8c84a41b39c2f1414
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 47ed7ef..89ad83d 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -151,6 +151,8 @@ public:
virtual SvStream & Store( SvStream &, bool bDirect = false ) const;
virtual int operator==(const SfxItemSet &) const;
+ virtual sal_uInt64 getHash() const;
+ virtual OString stringify() const;
};
// --------------- Inline Implementierungen ------------------------
diff --git a/sd/inc/stlpool.hxx b/sd/inc/stlpool.hxx
index 624d5da..6276d87 100644
--- a/sd/inc/stlpool.hxx
+++ b/sd/inc/stlpool.hxx
@@ -82,6 +82,8 @@ public:
void CopyTableStyles(SdStyleSheetPool& rSourcePool);
void CopyGraphicSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets);
void CopyCellSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets);
+ void RenameAndCopyGraphicSheets(SdStyleSheetPool& rSourcePool, OUString &rRenameSuffix);
+ void RenameAndCopyGraphicSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets, OUString &rRenameSuffix);
void CreatePseudosIfNecessary();
void UpdateStdNames();
@@ -122,8 +124,11 @@ public:
virtual void SAL_CALL acquire (void) throw ();
virtual void SAL_CALL release (void) throw ();
protected:
+ void RenameAndCopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets, OUString &rRenameSuffix);
+ void RenameAndCopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, OUString &rRenameSuffix);
void CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily );
void CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets );
+ void CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets, OUString &rRenameSuffix );
virtual SfxStyleSheetBase* Create(const String& rName, SfxStyleFamily eFamily, sal_uInt16 nMask);
virtual SfxStyleSheetBase* Create(const SdStyleSheet& rStyle);
diff --git a/sd/source/core/drawdoc3.cxx b/sd/source/core/drawdoc3.cxx
index 6d64078..2794f5b 100644
--- a/sd/source/core/drawdoc3.cxx
+++ b/sd/source/core/drawdoc3.cxx
@@ -358,6 +358,16 @@ lcl_removeUnusedStyles(SfxStyleSheetBasePool* const pStyleSheetPool, SdStyleShee
rStyles = aUsedStyles;
}
+SfxStyleSheet *lcl_findStyle(SdStyleSheetVector& rStyles, OUString aStyleName)
+{
+ for(SdStyleSheetVector::const_iterator aIt(rStyles.begin()), aLast(rStyles.end()); aIt != aLast; ++aIt)
+ {
+ if(OUString((*aIt)->GetName()).startsWith(aStyleName))
+ return (*aIt).get();
+ }
+ return NULL;
+}
+
}
sal_Bool SdDrawDocument::InsertBookmarkAsPage(
@@ -511,7 +521,10 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
// are then removed at the end of the function, where we also create
// undo records for the inserted styles.
SdStyleSheetVector aNewGraphicStyles;
- pStyleSheetPool->CopyGraphicSheets(*pBookmarkStyleSheetPool, aNewGraphicStyles);
+ OUString aRenameStr;
+ if(!bReplace && !bNoDialogs)
+ aRenameStr = OUString("_");
+ pStyleSheetPool->RenameAndCopyGraphicSheets(*pBookmarkStyleSheetPool, aNewGraphicStyles, aRenameStr);
SdStyleSheetVector aNewCellStyles;
pStyleSheetPool->CopyCellSheets(*pBookmarkStyleSheetPool, aNewCellStyles);
@@ -909,6 +922,31 @@ sal_Bool SdDrawDocument::InsertBookmarkAsPage(
// Make absolutely sure no double masterpages are there
RemoveUnnecessaryMasterPages(NULL, sal_True, sal_True);
+ // Rename object styles if necessary
+ if(!aRenameStr.isEmpty())
+ {
+ try
+ {
+ for(sal_uInt32 p = nInsertPos; p < (nInsertPos + nBMSdPageCount); p++)
+ {
+ SdPage *pPg = (SdPage *) GetPage(p);
+ for(sal_uIntPtr i = 0; i < pPg->GetObjCount(); i++)
+ {
+ if(pPg->GetObj(i)->GetStyleSheet())
+ {
+ OUString aStyleName = pPg->GetObj(i)->GetStyleSheet()->GetName();
+ SfxStyleSheet *pSheet = lcl_findStyle(aNewGraphicStyles, aStyleName + aRenameStr);
+ if(pSheet != NULL)
+ pPg->GetObj(i)->SetStyleSheet(pSheet, true);
+ }
+ }
+ }
+ }
+ catch(...)
+ {
+ OSL_FAIL("Exception while renaming styles @ SdDrawDocument::InsertBookmarkAsPage");
+ }
+ }
// remove copied styles not used on any inserted page and create
// undo records
// WARNING: SdMoveStyleSheetsUndoAction clears the passed list of
diff --git a/sd/source/core/stlpool.cxx b/sd/source/core/stlpool.cxx
index 9abf9ba..2c44fb6 100644
--- a/sd/source/core/stlpool.cxx
+++ b/sd/source/core/stlpool.cxx
@@ -70,6 +70,34 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::style;
using namespace ::com::sun::star::container;
+namespace
+{
+
+OUString lcl_findRenamedStyleName(std::vector< std::pair< OUString, OUString > > &rRenamedList, OUString aOriginalName )
+{
+ std::vector< std::pair< OUString, OUString > >::iterator aIter;
+ for( aIter = rRenamedList.begin(); aIter != rRenamedList.end(); ++aIter )
+ {
+ if((*aIter).first == aOriginalName )
+ return (*aIter).second;
+ }
+ return OUString();
+}
+
+SfxStyleSheet *lcl_findStyle(SdStyleSheetVector& rStyles, OUString aStyleName)
+{
+ if( aStyleName.isEmpty() )
+ return NULL;
+ for(SdStyleSheetVector::const_iterator aIt(rStyles.begin()), aLast(rStyles.end()); aIt != aLast; ++aIt)
+ {
+ if(OUString((*aIt)->GetName()) == aStyleName)
+ return (*aIt).get();
+ }
+ return NULL;
+}
+
+}
+
// ----------------------------------------------------------
SdStyleSheetPool::SdStyleSheetPool(SfxItemPool const& _rPool, SdDrawDocument* pDocument)
@@ -524,6 +552,11 @@ void SdStyleSheetPool::CopyGraphicSheets(SdStyleSheetPool& rSourcePool)
CopySheets( rSourcePool, SD_STYLE_FAMILY_GRAPHICS );
}
+void SdStyleSheetPool::RenameAndCopyGraphicSheets(SdStyleSheetPool& rSourcePool, OUString &rRenameSuffix)
+{
+ RenameAndCopySheets( rSourcePool, SD_STYLE_FAMILY_GRAPHICS, rRenameSuffix );
+}
+
void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool& rSourcePool)
{
CopySheets( rSourcePool, SD_STYLE_FAMILY_CELL );
@@ -596,19 +629,42 @@ void SdStyleSheetPool::CopyCellSheets(SdStyleSheetPool& rSourcePool, SdStyleShee
CopySheets( rSourcePool, SD_STYLE_FAMILY_CELL, rCreatedSheets );
}
+void SdStyleSheetPool::RenameAndCopyGraphicSheets(SdStyleSheetPool& rSourcePool, SdStyleSheetVector& rCreatedSheets, OUString &rRenameSuffix)
+{
+ RenameAndCopySheets( rSourcePool, SD_STYLE_FAMILY_GRAPHICS, rCreatedSheets, rRenameSuffix );
+}
+
+void SdStyleSheetPool::RenameAndCopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, OUString &rRenameSuffix)
+{
+ SdStyleSheetVector aTmpSheets;
+ RenameAndCopySheets( rSourcePool, eFamily, aTmpSheets, rRenameSuffix );
+}
+
void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily )
{
SdStyleSheetVector aTmpSheets;
CopySheets(rSourcePool, eFamily, aTmpSheets);
}
+void SdStyleSheetPool::RenameAndCopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets, OUString &rRenameSuffix)
+{
+ CopySheets( rSourcePool, eFamily, rCreatedSheets, rRenameSuffix );
+}
+
void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets)
{
+ OUString emptyName;
+ CopySheets(rSourcePool, eFamily, rCreatedSheets, emptyName);
+}
+
+void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily eFamily, SdStyleSheetVector& rCreatedSheets, OUString& rRenameSuffix)
+{
OUString aHelpFile;
sal_uInt32 nCount = rSourcePool.aStyles.size();
std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, String > > aNewStyles;
+ std::vector< std::pair< OUString, OUString > > aRenamedList;
for (sal_uInt32 n = 0; n < nCount; n++)
{
@@ -616,8 +672,27 @@ void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily
if( xSheet->GetFamily() == eFamily )
{
+ bool bAddToList = false;
String aName( xSheet->GetName() );
- if ( !Find( aName, eFamily ) )
+ SfxStyleSheetBase* pExistingSheet = Find(aName, eFamily);
+ if( pExistingSheet && !rRenameSuffix.isEmpty() )
+ {
+ sal_uInt64 nHash = xSheet->GetItemSet().getHash();
+ if( pExistingSheet->GetItemSet().getHash() != nHash )
+ {
+ OUString aTmpName = aName + rRenameSuffix;
+ sal_Int32 nSuffix = 1;
+ do
+ {
+ aTmpName = aName + rRenameSuffix + OUString::valueOf(nSuffix);
+ pExistingSheet = Find(aTmpName, eFamily);
+ nSuffix++;
+ } while( pExistingSheet && pExistingSheet->GetItemSet().getHash() != nHash );
+ aName = aTmpName;
+ bAddToList = true;
+ }
+ }
+ if ( !pExistingSheet )
{
rtl::Reference< SfxStyleSheetBase > xNewSheet( &Make( aName, eFamily ) );
@@ -632,6 +707,13 @@ void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily
xNewSheet->GetItemSet().Put( xSheet->GetItemSet() );
rCreatedSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( xNewSheet.get() ) ) );
+ aRenamedList.push_back( std::pair< OUString, OUString >( xSheet->GetName(), aName ) );
+ }
+ else if( bAddToList )
+ {
+ // Add to list - used for renaming
+ rCreatedSheets.push_back( SdStyleSheetRef( static_cast< SdStyleSheet* >( pExistingSheet ) ) );
+ aRenamedList.push_back( std::pair< OUString, OUString >( xSheet->GetName(), aName ) );
}
}
}
@@ -640,6 +722,15 @@ void SdStyleSheetPool::CopySheets(SdStyleSheetPool& rSourcePool, SfxStyleFamily
std::vector< std::pair< rtl::Reference< SfxStyleSheetBase >, String > >::iterator aIter;
for( aIter = aNewStyles.begin(); aIter != aNewStyles.end(); ++aIter )
{
+ if( !rRenameSuffix.isEmpty() )
+ {
+ SfxStyleSheet *pParent = lcl_findStyle(rCreatedSheets, lcl_findRenamedStyleName(aRenamedList, (*aIter).second));
+ if( pParent )
+ {
+ (*aIter).first->SetParent( pParent->GetName() );
+ continue;
+ }
+ }
DBG_ASSERT( rSourcePool.Find( (*aIter).second, eFamily ), "StyleSheet has invalid parent: Family mismatch" );
(*aIter).first->SetParent( (*aIter).second );
}
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 12e5453..33bc621 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -31,6 +31,7 @@
#include <tools/stream.hxx>
#include <tools/solar.h>
+#include <rtl/strbuf.hxx>
// STATIC DATA -----------------------------------------------------------
@@ -2047,4 +2048,26 @@ SfxItemSet *SfxAllItemSet::Clone(sal_Bool bItems, SfxItemPool *pToPool ) const
return bItems ? new SfxAllItemSet(*this) : new SfxAllItemSet(*_pPool);
}
+// -----------------------------------------------------------------------
+
+sal_uInt64 SfxItemSet::getHash() const
+{
+ return stringify().hashCode64();
+}
+
+// -----------------------------------------------------------------------
+
+OString SfxItemSet::stringify() const
+{
+ rtl::OStringBuffer aString(100);
+ SvMemoryStream aStream;
+ OString aLine;
+ SfxItemSet aSet(*this);
+ aSet.InvalidateDefaultItems();
+ aSet.Store(aStream, true);
+ aStream.Flush();
+ aString.append((const char *)aStream.GetData(), aStream.GetEndOfData());
+
+ return aString.makeStringAndClear();
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3096631b27f5ac6f320c704ccc26c1be31831b0b
Author: Muthu Subramanian <sumuthu at collabora.com>
Date: Thu Feb 13 13:13:53 2014 +0530
Move string hash function into String class.
hashCode() seems to do sampling while creating the hash.
hashCode64() will not.
Change-Id: Id30f5a2a774cf5244dbc00da9649e95a532484be
diff --git a/include/rtl/string.h b/include/rtl/string.h
index 9cd81aa..f0d3e76 100644
--- a/include/rtl/string.h
+++ b/include/rtl/string.h
@@ -277,6 +277,24 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode(
SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode_WithLength(
const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+/** Return a hash code (64bit) for a string.
+
+ It is not allowed to store the hash code persistently, because later
+ versions could return other hash codes.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @return
+ a hash code for the given string.
+ */
+SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_str_hashCode64_WithLength(
+ const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
/** Search for the first occurrence of a character within a string.
The string must be null-terminated.
diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx
index 7228fe7..f44ac54 100644
--- a/include/rtl/string.hxx
+++ b/include/rtl/string.hxx
@@ -880,6 +880,19 @@ public:
}
/**
+ Returns a 64bit hash of the string data.
+ This hashes the entire data, while hashCode would do sampling for larger string sizes.
+
+ @return a hash code value of the string data
+
+ @see hashCode() for simple hashes
+ */
+ sal_uInt64 hashCode64() const SAL_THROW(())
+ {
+ return rtl_str_hashCode64_WithLength( pData->buffer, pData->length );
+ }
+
+ /**
Returns a hashcode for this string.
@return a hash code value for this object.
diff --git a/include/rtl/ustring.h b/include/rtl/ustring.h
index da6720b..da5e912 100644
--- a/include/rtl/ustring.h
+++ b/include/rtl/ustring.h
@@ -551,6 +551,24 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode(
SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength(
const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+/** Return a hash code (64bit) for a string.
+
+ It is not allowed to store the hash code persistently, because later
+ versions could return other hash codes.
+
+ @param str
+ a string. Need not be null-terminated, but must be at least as long as
+ the specified len.
+
+ @param len
+ the length of the string.
+
+ @return
+ a hash code for the given string.
+ */
+SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_ustr_hashCode64_WithLength(
+ const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C();
+
/** Search for the first occurrence of a character within a string.
The string must be null-terminated.
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index 47bbc9b..6b654a8 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -274,6 +274,19 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode )( const IMPL_RTL_STRCODE* pStr )
/* ----------------------------------------------------------------------- */
+sal_uInt64 SAL_CALL IMPL_RTL_STRNAME( hashCode64_WithLength )( const IMPL_RTL_STRCODE* pStr,
+ sal_Int32 nLen )
+ SAL_THROW_EXTERN_C()
+{
+ sal_uInt64 nHash = 0;
+
+ for( sal_Int32 i = 0; i < nLen; i++ )
+ nHash = (nHash << 5) - nHash + *pStr++;
+ return nHash;
+}
+
+/* ----------------------------------------------------------------------- */
+
sal_Int32 SAL_CALL IMPL_RTL_STRNAME( hashCode_WithLength )( const IMPL_RTL_STRCODE* pStr,
sal_Int32 nLen )
SAL_THROW_EXTERN_C()
diff --git a/sal/util/sal.map b/sal/util/sal.map
index f2790d5..73595f2 100644
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -221,6 +221,7 @@ UDK_3_0_0 {
rtl_str_shortenedCompareIgnoreAsciiCase_WithLength;
rtl_str_hashCode;
rtl_str_hashCode_WithLength;
+ rtl_str_hashCode64_WithLength;
rtl_str_indexOfChar;
rtl_str_indexOfChar_WithLength;
rtl_str_indexOfStr;
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index be4da74..506d0fe 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -54,16 +54,6 @@ 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
@@ -611,7 +601,7 @@ OString SdPage::stringify() const
sal_uInt64 SdPage::getHash() const
{
- return lcl_getHash( stringify() );
+ return stringify().hashCode64();
}
commit 51f07074ded09171ecfb6ec2e3718a6acba14c75
Author: Muthu Subramanian <sumuthu at collabora.com>
Date: Tue Dec 10 20:53:55 2013 +0530
Force int16 as int32
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index 45787e1..be4da74 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -599,8 +599,8 @@ OString SdPage::stringify() const
/*append(OUStringToOString(maCreatedPageName, RTL_TEXTENCODING_UTF8)).
append(OUStringToOString(maFileName, RTL_TEXTENCODING_UTF8)).*/
append(OUStringToOString(maBookmarkName, RTL_TEXTENCODING_UTF8)).
- append(mbScaleObjects).append(mbBackgroundFullSize).append((sal_Int32)meCharSet).append(mnPaperBin).
- append((sal_Int32)meOrientation).append(mnTransitionType).append(mnTransitionSubtype).append(mbTransitionDirection).
+ append(mbScaleObjects).append(mbBackgroundFullSize).append((sal_Int32)meCharSet).append((sal_Int32)mnPaperBin).
+ append((sal_Int32)meOrientation).append((sal_Int32)mnTransitionType).append((sal_Int32)mnTransitionSubtype).append(mbTransitionDirection).
append(mnTransitionFadeColor).append(mfTransitionDuration);//.append(mbIsPrecious);
sal_Int32 n = GetObjCount();
commit e4c521ec3ee9f0db347c31a1c304c75ae4dea314
Author: Muthu Subramanian <sumuthu at collabora.com>
Date: Tue Dec 10 19:09:01 2013 +0530
Force enums as ints - to avoid warning/errors.
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index fec7c71..45787e1 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -592,15 +592,15 @@ void SdPage::setTransitionDuration ( double fTranstionDuration )
OString SdPage::stringify() const
{
OStringBuffer aString(100);
- aString.append(mePageKind).append(meAutoLayout).append(mbSelected).append(mePresChange).append(mfTime).append(mbSoundOn).append(mbExcluded).
+ aString.append((sal_Int32)mePageKind).append((sal_Int32)meAutoLayout).append(mbSelected).append((sal_Int32)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(mbScaleObjects).append(mbBackgroundFullSize).append((sal_Int32)meCharSet).append(mnPaperBin).
+ append((sal_Int32)meOrientation).append(mnTransitionType).append(mnTransitionSubtype).append(mbTransitionDirection).
append(mnTransitionFadeColor).append(mfTransitionDuration);//.append(mbIsPrecious);
sal_Int32 n = GetObjCount();
commit e11566ac3210f06696122657002c29942df705b4
Author: Muthu Subramanian <sumuthu at collabora.com>
Date: Tue Dec 10 18:59:44 2013 +0530
Add append(bool) to OStringBuffer.
diff --git a/include/rtl/strbuf.hxx b/include/rtl/strbuf.hxx
index 9ebd495..4e0b55c 100644
--- a/include/rtl/strbuf.hxx
+++ b/include/rtl/strbuf.hxx
@@ -531,6 +531,23 @@ public:
}
/**
+ Appends the string representation of the <code>bool</code>
+ argument to the string buffer.
+
+ The argument is converted to a string as if by the method
+ <code>String.valueOf</code>, and the characters of that
+ string are then appended to this string buffer.
+
+ @param b a <code>bool</code>.
+ @return this string buffer.
+ */
+ OStringBuffer & append(bool b)
+ {
+ sal_Char sz[RTL_STR_MAX_VALUEOFBOOLEAN];
+ return append( sz, rtl_str_valueOfBoolean( sz, b ) );
+ }
+
+ /**
Appends the string representation of the <code>char</code>
argument to this string buffer.
commit cb471d3420d4bd10f03eb69534bdd20d9ffd2e4d
Author: Muthu Subramanian <sumuthu at collabora.com>
Date: Fri Mar 7 17:58:45 2014 +0530
n#753460: Copying slides having same master page name.
Ported from: aa822c44b758fe312a3a052f890f53418adc5f6b
Change-Id: I36862355255222a36e4e10685741e0da67e8fbe7
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index a38398a..47ed7ef 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 081fe76..1d686e7 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -1060,6 +1060,8 @@ public:
/// @see mbDoNotInsertIntoPageAutomatically
bool IsDoNotInsertIntoPageAutomatically() const;
+ virtual OString stringify() const;
+
protected:
/** Sets a new UNO shape
*
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 0b5d631..9e1f6f1 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -380,6 +380,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 903998c..6d64078 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
// ===================================================
@@ -103,7 +103,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)
@@ -113,7 +123,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
@@ -173,7 +183,7 @@ static void lcl_IterateBookmarkPages( SdDrawDocument &rDoc, SdDrawDocument* pBoo
if( pBMMPage )
{
// yes, call functor
- rPageIterator( rDoc, pBMMPage );
+ rPageIterator( rDoc, pBMMPage, bRenameDuplicates, pBookmarkDoc );
}
}
}
@@ -467,7 +477,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 cb4259d..fec7c71 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
@@ -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(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 de2e1ae..12e5453 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -1786,7 +1786,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/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx
index 98e3b9a..c3f3d42 100644
--- a/svx/source/svdraw/svdobj.cxx
+++ b/svx/source/svdraw/svdobj.cxx
@@ -110,6 +110,7 @@
#include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <svx/sdrobjectfilter.hxx>
#include "svdconv.hxx"
+#include <rtl/strbuf.hxx>
using namespace ::com::sun::star;
@@ -1762,6 +1763,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;
More information about the Libreoffice-commits
mailing list