[Libreoffice-commits] .: 7 commits - sw/inc sw/source
Nigel Hawkins
nhawkins at kemper.freedesktop.org
Tue Jun 14 05:08:45 PDT 2011
sw/inc/doc.hxx | 3
sw/inc/editsh.hxx | 4
sw/source/core/SwNumberTree/SwNodeNum.cxx | 16 +-
sw/source/core/doc/docfmt.cxx | 20 +--
sw/source/core/doc/docnum.cxx | 62 ++++------
sw/source/core/doc/docruby.cxx | 6
sw/source/core/edit/edatmisc.cxx | 4
sw/source/core/fields/reffld.cxx | 165 ++++++++++++++++----------
sw/source/core/inc/UndoAttribute.hxx | 9 -
sw/source/core/inc/UndoTable.hxx | 2
sw/source/core/inc/rolbck.hxx | 7 -
sw/source/core/layout/dbg_lay.cxx | 23 +--
sw/source/core/txtnode/atrftn.cxx | 185 +++++++++++++++---------------
sw/source/core/txtnode/ndtxt.cxx | 40 ++----
sw/source/core/undo/rolbck.cxx | 17 +-
sw/source/core/undo/unattr.cxx | 19 +--
sw/source/core/unocore/unocrsrhelper.cxx | 6
sw/source/core/unocore/unoobj.cxx | 44 +++----
sw/source/core/unocore/unoparagraph.cxx | 8 -
sw/source/ui/inc/basesh.hxx | 5
sw/source/ui/shells/basesh.cxx | 9 -
sw/source/ui/shells/langhelper.cxx | 16 +-
sw/source/ui/shells/textsh1.cxx | 12 -
sw/source/ui/uiview/view2.cxx | 6
24 files changed, 355 insertions(+), 333 deletions(-)
New commits:
commit eae3537858e5c96e501ac62d43a0102386e6c295
Author: Nigel Hawkins <n.hawkins at gmx.com>
Date: Tue Jun 14 13:01:01 2011 +0100
Replaced use of SvUShortsSort with std::set/map in reffld.cxx. LGPLv3+/MPL.
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index 180150f..fafe898 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -71,6 +71,11 @@
#include <SwNodeNum.hxx>
#include <switerator.hxx>
+#include <set>
+#include <map>
+
+#include "../../../../../libs-core/sfx2/inc/sfx2/childwin.hxx"
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::text;
using namespace ::com::sun::star::lang;
@@ -901,87 +906,127 @@ SwTxtNode* SwGetRefFieldType::FindAnchor( SwDoc* pDoc, const String& rRefMark,
struct _RefIdsMap
{
+private:
String aName;
- SvUShortsSort aIds, aDstIds, aIdsMap;
- SvUShorts aMap;
+ std::set<sal_uInt16> aIds;
+ std::set<sal_uInt16> aDstIds;
+ std::map<sal_uInt16, sal_uInt16> sequencedIds; /// ID numbers sorted by sequence number.
sal_Bool bInit;
- _RefIdsMap( const String& rName )
- : aName( rName ), aIds( 16, 16 ), aIdsMap( 16, 16 ), aMap( 16, 16 ),
- bInit( sal_False )
- {}
+ void Init(SwDoc& rDoc, SwDoc& rDestDoc, sal_Bool bField );
+ void GetNoteIdsFromDoc( SwDoc& rDoc, std::set<sal_uInt16> &rIds );
+ void GetFieldIdsFromDoc( SwDoc& rDoc, std::set<sal_uInt16> &rIds );
+ void AddId( sal_uInt16 id, sal_uInt16 seqNum );
+ sal_uInt16 GetFirstUnusedId( std::set<sal_uInt16> &rIds );
+
+public:
+ _RefIdsMap( const String& rName ) : aName( rName ), bInit( sal_False ) {}
- void Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rFld,
- sal_Bool bField = sal_True );
+ void Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rFld, sal_Bool bField );
- sal_Bool IsInit() const { return bInit; }
+ String GetName() { return aName; }
};
SV_DECL_PTRARR_DEL( _RefIdsMaps, _RefIdsMap*, 5, 5 )
SV_IMPL_PTRARR( _RefIdsMaps, _RefIdsMap* )
-void _RefIdsMap::Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rFld,
- sal_Bool bField )
+/// Get a sorted list of the field IDs from a document.
+/// @param[in] rDoc The document to search.
+/// @param[in,out] rIds The list of IDs found in the document.
+void _RefIdsMap::GetFieldIdsFromDoc( SwDoc& rDoc, std::set<sal_uInt16> &rIds)
{
+ const SwTxtNode* pNd;
+ SwFieldType* pType;
- if( !bInit )
+ if( 0 != ( pType = rDoc.GetFldType( RES_SETEXPFLD, aName, false ) ))
{
- if( bField )
- {
- const SwTxtNode* pNd;
- SwFieldType* pType;
- if( 0 != ( pType = rDestDoc.GetFldType( RES_SETEXPFLD, aName, false ) ))
- {
- SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
- for( SwFmtFld* pF = aIter.First(); pF; pF = aIter.Next() )
- if( pF->GetTxtFld() &&
- 0 != ( pNd = pF->GetTxtFld()->GetpTxtNode() ) &&
- pNd->GetNodes().IsDocNodes() )
- aIds.Insert( ((SwSetExpField*)pF->GetFld())->GetSeqNumber() );
- }
- if( 0 != ( pType = rDoc.GetFldType( RES_SETEXPFLD, aName, false ) ))
- {
- SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
- for( SwFmtFld* pF = aIter.First(); pF; pF = aIter.Next() )
- if( pF->GetTxtFld() &&
- 0 != ( pNd = pF->GetTxtFld()->GetpTxtNode() ) &&
- pNd->GetNodes().IsDocNodes() )
- aDstIds.Insert( ((SwSetExpField*)pF->GetFld())->GetSeqNumber() );
- }
- }
- else
- {
- sal_uInt16 n;
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pType );
+ for( SwFmtFld* pF = aIter.First(); pF; pF = aIter.Next() )
+ if( pF->GetTxtFld() &&
+ 0 != ( pNd = pF->GetTxtFld()->GetpTxtNode() ) &&
+ pNd->GetNodes().IsDocNodes() )
+ rIds.insert( ((SwSetExpField*)pF->GetFld())->GetSeqNumber() );
+ }
+}
+
+/// Get a sorted list of the footnote/endnote IDs from a document.
+/// @param[in] rDoc The document to search.
+/// @param[in,out] rIds The list of IDs found in the document.
+void _RefIdsMap::GetNoteIdsFromDoc( SwDoc& rDoc, std::set<sal_uInt16> &rIds)
+{
+ for( sal_uInt16 n = rDoc.GetFtnIdxs().Count(); n; )
+ rIds.insert( rDoc.GetFtnIdxs()[ --n ]->GetSeqRefNo() );
+}
- for( n = rDestDoc.GetFtnIdxs().Count(); n; )
- aIds.Insert( rDestDoc.GetFtnIdxs()[ --n ]->GetSeqRefNo() );
- for( n = rDoc.GetFtnIdxs().Count(); n; )
- aDstIds.Insert( rDoc.GetFtnIdxs()[ --n ]->GetSeqRefNo() );
+/// Initialise the aIds and aDestIds collections from the source documents.
+/// @param[in] rDoc The source document.
+/// @param[in] rDestDoc The destination document.
+/// @param[in] bField True if we're interested in all fields, false for footnotes.
+void _RefIdsMap::Init( SwDoc& rDoc, SwDoc& rDestDoc, sal_Bool bField )
+{
+ if( bInit )
+ return;
+
+ if( bField )
+ {
+ GetFieldIdsFromDoc( rDestDoc, aIds );
+ GetFieldIdsFromDoc( rDoc, aDstIds );
+ }
+ else
+ {
+ GetIdsFromDoc( rDestDoc, aIds );
+ GetIdsFromDoc( rDoc, aDstIds );
+ }
+ bInit = sal_True;
+}
+
+/// Get the lowest unused ID in the passed set.
+/// @param[in] rIds The set of used ID numbers.
+/// @returns The lowest unused ID.
+sal_uInt16 _RefIdsMap::GetFirstUnusedId( std::set<sal_uInt16> &rIds )
+{
+ sal_uInt16 num;
+ std::set<sal_uInt16>::iterator it;
+
+ for( it = rIds.begin(); it != rIds.end(); ++it )
+ {
+ if( num != *it )
+ {
+ return num;
}
- bInit = sal_True;
+ ++num;
}
+ return num;
+}
+
+/// Add a new ID and sequence number to the "occupied" collection.
+/// @param[in] id The ID number.
+/// @param[in] seqNum The sequence number.
+void _RefIdsMap::AddId( sal_uInt16 id, sal_uInt16 seqNum )
+{
+ aIds.insert( id );
+ sequencedIds[ seqNum ] = id;
+}
+
+void _RefIdsMap::Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rFld,
+ sal_Bool bField )
+{
+ Init( rDoc, rDestDoc, bField);
// dann teste mal, ob die Nummer schon vergeben ist
// oder ob eine neue bestimmt werden muss.
- sal_uInt16 nPos, nSeqNo = rFld.GetSeqNo();
- if( aIds.Seek_Entry( nSeqNo ) && aDstIds.Seek_Entry( nSeqNo ))
+ sal_uInt16 nSeqNo = rFld.GetSeqNo();
+ if( aIds.count( nSeqNo ) && aDstIds.count( nSeqNo ))
{
- // ist schon vergeben, also muss eine neue
- // erzeugt werden.
- if( aIdsMap.Seek_Entry( nSeqNo, &nPos ))
- rFld.SetSeqNo( aMap[ nPos ] );
+ // Number already taken, so need a new one.
+ if( sequencedIds.count(nSeqNo) )
+ rFld.SetSeqNo( sequencedIds[nSeqNo] );
else
{
- sal_uInt16 n;
-
- for( n = 0; n < aIds.Count(); ++n )
- if( n != aIds[ n ] )
- break;
+ sal_uInt16 n = GetFirstUnusedId( aIds );
// die neue SeqNo eintragen, damit die "belegt" ist
- aIds.Insert( n );
- aIdsMap.Insert( nSeqNo, nPos );
- aMap.Insert( n, nPos );
+ AddId( n, nSeqNo );
rFld.SetSeqNo( n );
// und noch die Felder oder Fuss-/EndNote auf die neue
@@ -1012,9 +1057,7 @@ void _RefIdsMap::Check( SwDoc& rDoc, SwDoc& rDestDoc, SwGetRefField& rFld,
}
else
{
- aIds.Insert( nSeqNo );
- aIdsMap.Insert( nSeqNo, nPos );
- aMap.Insert( nSeqNo, nPos );
+ AddId( nSeqNo, nSeqNo );
}
}
@@ -1040,7 +1083,7 @@ void SwGetRefFieldType::MergeWithOtherDoc( SwDoc& rDestDoc )
{
_RefIdsMap* pMap = 0;
for( sal_uInt16 n = aFldMap.Count(); n; )
- if( aFldMap[ --n ]->aName == rRefFld.GetSetRefName() )
+ if( aFldMap[ --n ]->GetName() == rRefFld.GetSetRefName() )
{
pMap = aFldMap[ n ];
break;
commit 797a7faf186d278fc833e544707228ab88d41fe4
Author: Nigel Hawkins <n.hawkins at gmx.com>
Date: Mon Jun 13 10:55:23 2011 +0100
Replace SvUShortsSort with std::set in basesh.[ch]xx. LGPLv3+/MPL.
diff --git a/sw/source/ui/inc/basesh.hxx b/sw/source/ui/inc/basesh.hxx
index 02336d1..9e118f0 100644
--- a/sw/source/ui/inc/basesh.hxx
+++ b/sw/source/ui/inc/basesh.hxx
@@ -40,6 +40,7 @@
#include <svl/svstdarr.hxx>
#include <mdiexp.hxx>
+#include <set>
class SwWrtShell;
class SwCrsrShell;
@@ -60,7 +61,7 @@ class SwBaseShell: public SfxShell
SfxItemSet* pGetStateSet;
// Update-Timer for graphic
- SvUShortsSort aGrfUpdateSlots;
+ std::set<sal_uInt16> aGrfUpdateSlots;
DECL_LINK( GraphicArrivedHdl, SwCrsrShell* );
@@ -70,7 +71,7 @@ protected:
inline SwView& GetView() { return rView; }
inline void SetGetStateSet( SfxItemSet* p ) { pGetStateSet = p; }
- inline sal_Bool AddGrfUpdateSlot( sal_uInt16 nSlot ){ return aGrfUpdateSlots.Insert( nSlot ); }
+ inline sal_Bool AddGrfUpdateSlot( sal_uInt16 nSlot ){ return aGrfUpdateSlots.insert( nSlot ).second; }
DECL_STATIC_LINK( SwBaseShell, InsertDBTextHdl, DBTextStruct_Impl* );
diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx
index ae621c6..87e2d2f 100644
--- a/sw/source/ui/shells/basesh.cxx
+++ b/sw/source/ui/shells/basesh.cxx
@@ -1247,16 +1247,17 @@ IMPL_LINK(SwBaseShell, GraphicArrivedHdl, SwCrsrShell* , EMPTYARG )
SwWrtShell &rSh = GetShell();
if( CNT_GRF == rSh.SwEditShell::GetCntType() &&
GRAPHIC_NONE != ( nGrfType = rSh.GetGraphicType() ) &&
- aGrfUpdateSlots.Count() )
+ !aGrfUpdateSlots.empty() )
{
sal_Bool bProtect = 0 != rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT);
SfxViewFrame* pVFrame = GetView().GetViewFrame();
sal_uInt16 nSlot;
- for( sal_uInt16 n = 0; n < aGrfUpdateSlots.Count(); ++n )
+ std::set<sal_uInt16>::iterator it;
+ for( it = aGrfUpdateSlots.begin(); it != aGrfUpdateSlots.end(); ++it )
{
sal_Bool bSetState = sal_False;
sal_Bool bState = sal_False;
- switch( nSlot = aGrfUpdateSlots[ n ] )
+ switch( nSlot = *it )
{
case SID_IMAP:
case SID_IMAP_EXEC:
@@ -1328,7 +1329,7 @@ IMPL_LINK(SwBaseShell, GraphicArrivedHdl, SwCrsrShell* , EMPTYARG )
pVFrame->GetBindings().SetState( aBool );
}
}
- aGrfUpdateSlots.RemoveAt( 0, aGrfUpdateSlots.Count() );
+ aGrfUpdateSlots.clear();
}
return 0;
}
commit 1b2e2a30a080bb249f58021add289253b96c334a
Author: Nigel Hawkins <n.hawkins at gmx.com>
Date: Sun Jun 12 12:19:26 2011 +0100
Replace SvUShortsSort with std::set in dbg_lay.cxx. LGPLv3+/MPL.
diff --git a/sw/source/core/layout/dbg_lay.cxx b/sw/source/core/layout/dbg_lay.cxx
index dfc3dae..fe2cd76 100644
--- a/sw/source/core/layout/dbg_lay.cxx
+++ b/sw/source/core/layout/dbg_lay.cxx
@@ -117,7 +117,6 @@
#ifndef _SVSTDARR_HXX
#define _SVSTDARR_USHORTS
-#define _SVSTDARR_USHORTSSORT
#include <svl/svstdarr.hxx>
#endif
@@ -151,7 +150,7 @@ sal_uLong lcl_GetFrameId( const SwFrm* pFrm )
class SwImplProtocol
{
SvFileStream *pStream; // Ausgabestream
- SvUShortsSort *pFrmIds; // welche FrmIds sollen aufgezeichnet werden ( NULL == alle )
+ std::set<sal_uInt16> *pFrmIds; // welche FrmIds sollen aufgezeichnet werden ( NULL == alle )
std::vector<long> aVars; // Variables
ByteString aLayer; // Einrueckung der Ausgabe (" " pro Start/End)
sal_uInt16 nTypes; // welche Typen sollen aufgezeichnet werden
@@ -328,6 +327,7 @@ SwImplProtocol::~SwImplProtocol()
pStream->Close();
delete pStream;
}
+ pFrmIds->clear();
delete pFrmIds;
aVars.clear();
}
@@ -349,6 +349,7 @@ void SwImplProtocol::CheckLine( ByteString& rLine )
if( "[frmid" == aTmp ) // Bereich FrmIds
{
nInitFile = 1;
+ pFrmIds->clear();
delete pFrmIds;
pFrmIds = NULL; // Default: Alle Frames aufzeichnen
}
@@ -568,7 +569,7 @@ void SwImplProtocol::_Record( const SwFrm* pFrm, sal_uLong nFunction, sal_uLong
{
case 1: InsertFrm( nId ); break;
case 2: DeleteFrm( nId ); break;
- case 3: delete pFrmIds; pFrmIds = NULL; break;
+ case 3: pFrmIds->clear(); delete pFrmIds; pFrmIds = NULL; break;
case 4: delete pStream; pStream = NULL; break;
}
return;
@@ -576,7 +577,7 @@ void SwImplProtocol::_Record( const SwFrm* pFrm, sal_uLong nFunction, sal_uLong
if( !pStream && !NewStream() )
return; // Immer noch kein Stream
- if( pFrmIds && !pFrmIds->Seek_Entry( sal_uInt16(lcl_GetFrameId( pFrm )) ) )
+ if( pFrmIds && !pFrmIds->count( sal_uInt16(lcl_GetFrameId( pFrm )) ) )
return; // gehoert nicht zu den gewuenschten FrmIds
if( !(pFrm->GetType() & nTypes) )
@@ -735,10 +736,10 @@ void SwImplProtocol::SectFunc( ByteString &rOut, const SwFrm* , sal_uLong nAct,
sal_Bool SwImplProtocol::InsertFrm( sal_uInt16 nId )
{
if( !pFrmIds )
- pFrmIds = new SvUShortsSort(5,5);
- if( pFrmIds->Seek_Entry( nId ) )
+ pFrmIds = new std::set<sal_uInt16>;
+ if( pFrmIds->count( nId ) )
return sal_False;
- pFrmIds->Insert( nId );
+ pFrmIds->insert( nId );
return sal_True;
}
@@ -748,11 +749,11 @@ sal_Bool SwImplProtocol::InsertFrm( sal_uInt16 nId )
* --------------------------------------------------*/
sal_Bool SwImplProtocol::DeleteFrm( sal_uInt16 nId )
{
- sal_uInt16 nPos;
- if( !pFrmIds || !pFrmIds->Seek_Entry( nId, &nPos ) )
+ if( !pFrmIds )
return sal_False;
- pFrmIds->Remove( nPos );
- return sal_True;
+ if ( pFrmIds->erase(nId) )
+ return sal_True;
+ return sal_False;
}
/*--------------------------------------------------
commit 7556435714eb99e7c2cd0f84a06acc3daaf992ed
Author: Nigel Hawkins <n.hawkins at gmx.com>
Date: Sun Jun 12 11:44:54 2011 +0100
Replaced use of SvUShortsSort in atrftn.cxx with stl equivalents. LGPLv3+/MPL.
diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx
index 4f29d72..d8684a9 100644
--- a/sw/source/core/txtnode/atrftn.cxx
+++ b/sw/source/core/txtnode/atrftn.cxx
@@ -50,6 +50,87 @@
#include <section.hxx>
#include <switerator.hxx>
+namespace {
+ /// Get a sorted list of the used footnote reference numbers.
+ /// @param[in] rDoc The active document.
+ /// @param[in] pExclude A footnote whose reference number should be excluded from the set.
+ /// @param[out] rInvalid A returned list of all items that had an invalid reference number.
+ /// @returns The set of used reference numbers.
+ static std::set<sal_uInt16> lcl_GetUsedFtnRefNumbers(SwDoc &rDoc,
+ SwTxtFtn *pExclude,
+ std::vector<SwTxtFtn*> &rInvalid)
+ {
+ int n;
+ std::set<sal_uInt16> aArr;
+ SwFtnIdxs& ftnIdxs = rDoc.GetFtnIdxs();
+ SwTxtFtn* pTxtFtn;
+
+ rInvalid.clear();
+
+ for( n = 0; n < ftnIdxs.Count(); ++n )
+ {
+ pTxtFtn = ftnIdxs[ n ];
+ if ( pTxtFtn != pExclude )
+ {
+ if ( USHRT_MAX == pTxtFtn->GetSeqRefNo() )
+ {
+ rInvalid.push_back(pTxtFtn);
+ }
+ else
+ {
+ aArr.insert( pTxtFtn->GetSeqRefNo() );
+ }
+ }
+ }
+ return aArr;
+ }
+
+ /// Check whether a requested reference number is available.
+ /// @param[in] rUsedNums Set of used reference numbers.
+ /// @param[in] requested The requested reference number.
+ /// @returns true if the number is available, false if not.
+ static bool lcl_IsRefNumAvailable(std::set<sal_uInt16> &rUsedNums,
+ sal_uInt16 requested)
+ {
+ if ( USHRT_MAX == requested )
+ return false; // Invalid sequence number.
+ if ( rUsedNums.count(requested) )
+ return false; // Number already used.
+ return true;
+ }
+
+ /// Get the first few unused sequential reference numbers.
+ /// @param[in] rUsedNums The set of used sequential reference numbers.
+ /// @param[in] numRequired The number of reference number required.
+ /// @returns The lowest unused sequential reference numbers.
+ static std::vector<sal_uInt16> lcl_GetUnusedSeqRefNums(std::set<sal_uInt16> &rUsedNums,
+ size_t numRequired)
+ {
+ std::vector<sal_uInt16> unusedNums;
+ sal_uInt16 newNum = 0;
+ std::set<sal_uInt16>::iterator it;
+ //Start by using numbers from gaps in rUsedNums
+ for( it = rUsedNums.begin(); it != rUsedNums.end(); ++it )
+ {
+ while ( newNum < *it )
+ {
+ unusedNums.push_back( newNum++ );
+ if ( unusedNums.size() >= numRequired )
+ return unusedNums;
+ }
+ newNum++;
+ }
+ //Filled in all gaps. Fill the rest of the list with new numbers.
+ while ( unusedNums.size() < numRequired )
+ {
+ unusedNums.push_back( newNum++ );
+ }
+
+ return unusedNums;
+ }
+
+}
+
/*************************************************************************
|*
|* class SwFmtFtn
@@ -424,7 +505,8 @@ void SwTxtFtn::DelFrms( const SwFrm* pSib )
}
}
-
+/// Set the sequence number for the current footnote.
+/// @returns The new sequence number or USHRT_MAX if invalid.
sal_uInt16 SwTxtFtn::SetSeqRefNo()
{
if( !m_pTxtNode )
@@ -434,100 +516,25 @@ sal_uInt16 SwTxtFtn::SetSeqRefNo()
if( pDoc->IsInReading() )
return USHRT_MAX;
- sal_uInt16 n, nFtnCnt = pDoc->GetFtnIdxs().Count();
-
- const sal_uInt8 nTmp = 255 < nFtnCnt ? 255 : static_cast<sal_uInt8>(nFtnCnt);
- SvUShortsSort aArr( nTmp, nTmp );
-
- // dann testmal, ob die Nummer schon vergeben ist oder ob eine neue
- // bestimmt werden muss.
- SwTxtFtn* pTxtFtn;
- for( n = 0; n < nFtnCnt; ++n )
- {
- pTxtFtn = pDoc->GetFtnIdxs()[ n ];
- if ( pTxtFtn != this )
- {
- aArr.Insert( pTxtFtn->m_nSeqNo );
- }
- }
-
- // test if number is already in use
- if ( USHRT_MAX != m_nSeqNo )
- {
- for( n = 0; n < aArr.Count(); ++n )
- {
- if ( aArr[ n ] > m_nSeqNo )
- {
- return m_nSeqNo; // free -> use
- }
- else if ( aArr[ n ] == m_nSeqNo )
- {
- break; // used -> create new one
- }
- }
-
- if ( n == aArr.Count() )
- {
- return m_nSeqNo; // free -> use
- }
- }
-
- // alle Nummern entsprechend geflag, also bestimme die richtige Nummer
- for( n = 0; n < aArr.Count(); ++n )
- if( n != aArr[ n ] )
- break;
-
- return m_nSeqNo = n;
+ std::vector<SwTxtFtn*> badRefNums;
+ std::set<sal_uInt16> aUsedNums = ::lcl_GetUsedFtnRefNumbers(*pDoc, this, badRefNums);
+ if ( ::lcl_IsRefNumAvailable(aUsedNums, m_nSeqNo) )
+ return m_nSeqNo;
+ std::vector<sal_uInt16> unused = ::lcl_GetUnusedSeqRefNums(aUsedNums, 1);
+ return m_nSeqNo = unused[0];
}
+/// Set a unique sequential reference number for every footnote in the document.
+/// @param[in] rDoc The document to be processed.
void SwTxtFtn::SetUniqueSeqRefNo( SwDoc& rDoc )
{
- sal_uInt16 n, nStt = 0, nFtnCnt = rDoc.GetFtnIdxs().Count();
+ std::vector<SwTxtFtn*> badRefNums;
+ std::set<sal_uInt16> aUsedNums = ::lcl_GetUsedFtnRefNumbers(rDoc, NULL, badRefNums);
+ std::vector<sal_uInt16> unused = ::lcl_GetUnusedSeqRefNums(aUsedNums, badRefNums.size());
- const sal_uInt8 nTmp = 255 < nFtnCnt ? 255 : static_cast<sal_uInt8>(nFtnCnt);
- SvUShortsSort aArr( nTmp, nTmp );
-
- // dann alle Nummern zusammensammeln die schon existieren
- SwTxtFtn* pTxtFtn;
- for( n = 0; n < nFtnCnt; ++n )
+ for (size_t i = 0; i < badRefNums.size(); ++i)
{
- pTxtFtn = rDoc.GetFtnIdxs()[ n ];
- if ( USHRT_MAX != pTxtFtn->m_nSeqNo )
- {
- aArr.Insert( pTxtFtn->m_nSeqNo );
- }
- }
-
-
- for( n = 0; n < nFtnCnt; ++n )
- {
- pTxtFtn = rDoc.GetFtnIdxs()[ n ];
- if ( USHRT_MAX == pTxtFtn->m_nSeqNo )
- {
- for( ; nStt < aArr.Count(); ++nStt )
- {
- if ( nStt != aArr[ nStt ] )
- {
- pTxtFtn->m_nSeqNo = nStt;
- break;
- }
- }
-
- if ( USHRT_MAX == pTxtFtn->m_nSeqNo )
- {
- break; // found nothing
- }
- }
- }
-
- // alle Nummern schon vergeben, also mit nStt++ weitermachen
- for( ; n < nFtnCnt; ++n )
- {
- pTxtFtn = rDoc.GetFtnIdxs()[ n ];
- if ( USHRT_MAX == pTxtFtn->m_nSeqNo )
- {
- pTxtFtn->m_nSeqNo = nStt++;
- }
+ badRefNums[i]->m_nSeqNo = unused[i];
}
}
commit 43836fd693b63200c15caac54710bc69dddf5eb1
Author: Nigel Hawkins <n.hawkins at gmx.com>
Date: Fri Jun 10 17:12:04 2011 +0100
Remove obsolete forward declarations of SvUShortsSort. LGPLv3+/MPL.
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index af4ad32..32d438c 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -111,7 +111,6 @@ class SfxPrinter;
class SvNumberFormatter;
class SvStringsSort;
class SvUShorts;
-class SvUShortsSort;
class SvxMacro;
class SvxMacroTableDtor;
class SwAutoCompleteWord;
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 362f41b..cb62642 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -54,7 +54,6 @@ class SwDoc;
class DateTime;
class CommandExtTextInputData;
-class SvUShortsSort;
class SvNumberFormatter;
class SfxPoolItem;
class SfxItemSet;
commit 78861b47e507d3b72162dd70bccbde5570b9f9a2
Author: Nigel Hawkins <n.hawkins at gmx.com>
Date: Fri Jun 10 17:03:10 2011 +0100
Replace SvUShortsSort with std::set in rolbck.[ch]xx. LGPLv3+/MPL.
diff --git a/sw/source/core/inc/rolbck.hxx b/sw/source/core/inc/rolbck.hxx
index df9da4b..f493f4b 100644
--- a/sw/source/core/inc/rolbck.hxx
+++ b/sw/source/core/inc/rolbck.hxx
@@ -31,11 +31,12 @@
#include <tools/solar.h>
#ifndef _SVSTDARR_HXX
#define _SVSTDARR_USHORTS
-#define _SVSTDARR_USHORTSSORT
#include <svl/svstdarr.hxx>
#endif
#include <svl/itemset.hxx>
+#include <set>
+
//Nur die History anziehen, um das docnew.cxx gegen die CLOOK's zu behaupten.
namespace sfx2 {
@@ -286,7 +287,7 @@ class SwHistorySetAttrSet : public SwHistoryHint
public:
SwHistorySetAttrSet( const SfxItemSet& rSet, sal_uLong nNode,
- const SvUShortsSort& rSetArr );
+ const std::set<sal_uInt16> &rSetArr );
virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet );
};
@@ -407,7 +408,7 @@ public:
class SwRegHistory : public SwClient
{
private:
- SvUShortsSort m_WhichIdSet;
+ std::set<sal_uInt16> m_WhichIdSet;
SwHistory * const m_pHistory;
sal_uLong m_nNodeIndex;
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index bb780f4..27f44b0 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -717,7 +717,7 @@ const ::rtl::OUString& SwHistoryBookmark::GetName() const
SwHistorySetAttrSet::SwHistorySetAttrSet( const SfxItemSet& rSet,
- sal_uLong nNodePos, const SvUShortsSort& rSetArr )
+ sal_uLong nNodePos, const std::set<sal_uInt16> &rSetArr )
: SwHistoryHint( HSTRY_SETATTRSET )
, m_OldSet( rSet )
, m_ResetArray( 0, 4 )
@@ -727,7 +727,7 @@ SwHistorySetAttrSet::SwHistorySetAttrSet( const SfxItemSet& rSet,
const SfxPoolItem* pItem = aIter.FirstItem(),
* pOrigItem = aOrigIter.FirstItem();
do {
- if( !rSetArr.Seek_Entry( pOrigItem->Which() ))
+ if( !rSetArr.count( pOrigItem->Which() ))
{
m_ResetArray.Insert( pOrigItem->Which(), m_ResetArray.Count() );
m_OldSet.ClearItem( pOrigItem->Which() );
@@ -1398,7 +1398,7 @@ void SwRegHistory::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
else
{
const SfxPoolItem* pItem = SfxItemIter( rSet ).FirstItem();
- if ( m_WhichIdSet.Seek_Entry( pItem->Which() ) )
+ if ( m_WhichIdSet.count( pItem->Which() ) )
{
pNewHstr = new SwHistorySetFmt( pItem, m_nNodeIndex );
}
@@ -1469,9 +1469,9 @@ void SwRegHistory::RegisterInModify( SwModify* pRegIn, const SwNode& rNd )
m_nNodeIndex = rNd.GetIndex();
_MakeSetWhichIds();
}
- else if ( m_WhichIdSet.Count() )
+ else
{
- m_WhichIdSet.Remove( 0, m_WhichIdSet.Count() );
+ m_WhichIdSet.clear();
}
}
@@ -1479,10 +1479,7 @@ void SwRegHistory::_MakeSetWhichIds()
{
if (!m_pHistory) return;
- if ( m_WhichIdSet.Count() )
- {
- m_WhichIdSet.Remove( 0, m_WhichIdSet.Count() );
- }
+ m_WhichIdSet.clear();
if( GetRegisteredIn() )
{
@@ -1503,7 +1500,7 @@ void SwRegHistory::_MakeSetWhichIds()
sal_uInt16 nW = aIter.FirstItem()->Which();
while( sal_True )
{
- m_WhichIdSet.Insert( nW );
+ m_WhichIdSet.insert( nW );
if( aIter.IsAtEnd() )
break;
nW = aIter.NextItem()->Which();
commit e852d40ea7397c7c0739ae737ba0827f2c4d2134
Author: Nigel Hawkins <n.hawkins at gmx.com>
Date: Fri Jun 10 15:46:15 2011 +0100
Replace SvUShortsSort with std::set<sal_uInt16> in SwDoc::ResetAttrs.
This change cascades through to a lot of other files. LGPLv3+/MPL.
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index da05449..af4ad32 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1153,7 +1153,7 @@ public:
// control, if the side effect "send data changed events" is triggered or not.
void ResetAttrs( const SwPaM &rRg,
sal_Bool bTxtAttr = sal_True,
- const SvUShortsSort* = 0,
+ const std::set<sal_uInt16> &rAttrs = std::set<sal_uInt16>(),
const bool bSendDataChangedEvents = true );
void RstTxtAttrs(const SwPaM &rRg, sal_Bool bInclRefToxMark = sal_False );
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 6b845b1..362f41b 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -45,6 +45,7 @@
#include <IMark.hxx>
#include <vector>
+#include <set>
#include <swundo.hxx>
#include <svtools/embedhlp.hxx>
@@ -258,7 +259,7 @@ public:
// Query default attribute of document.
const SfxPoolItem& GetDefault( sal_uInt16 nFmtHint ) const;
- void ResetAttr( const SvUShortsSort* pAttrs = 0 );
+ void ResetAttr( const std::set<sal_uInt16> &attrs = std::set<sal_uInt16>() );
void GCAttr();
// Returns the scripttpye of the selection.
diff --git a/sw/source/core/SwNumberTree/SwNodeNum.cxx b/sw/source/core/SwNumberTree/SwNodeNum.cxx
index 631add3..ee51a04 100644
--- a/sw/source/core/SwNumberTree/SwNodeNum.cxx
+++ b/sw/source/core/SwNumberTree/SwNodeNum.cxx
@@ -372,16 +372,16 @@ void SwNodeNum::_UnregisterMeAndChildrenDueToRootDelete( SwNodeNum& rNodeNum )
{
pTxtNode->RemoveFromList();
// --> clear all list attributes and the list style
- SvUShortsSort aResetAttrsArray;
- aResetAttrsArray.Insert( RES_PARATR_LIST_ID );
- aResetAttrsArray.Insert( RES_PARATR_LIST_LEVEL );
- aResetAttrsArray.Insert( RES_PARATR_LIST_ISRESTART );
- aResetAttrsArray.Insert( RES_PARATR_LIST_RESTARTVALUE );
- aResetAttrsArray.Insert( RES_PARATR_LIST_ISCOUNTED );
- aResetAttrsArray.Insert( RES_PARATR_NUMRULE );
+ std::set<sal_uInt16> aResetAttrsArray;
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_ID );
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_LEVEL );
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_ISRESTART );
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_RESTARTVALUE );
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_LIST_ISCOUNTED );
+ aResetAttrsArray.insert( aResetAttrsArray.end(), RES_PARATR_NUMRULE );
SwPaM aPam( *pTxtNode );
pTxtNode->GetDoc()->ResetAttrs( aPam, sal_False,
- &aResetAttrsArray,
+ aResetAttrsArray,
false );
}
}
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index d345345..1ddf3b3 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -349,12 +349,11 @@ void SwDoc::RstTxtAttrs(const SwPaM &rRg, sal_Bool bInclRefToxMark )
void SwDoc::ResetAttrs( const SwPaM &rRg,
sal_Bool bTxtAttr,
- const SvUShortsSort* pAttrs,
+ const std::set<sal_uInt16> &rAttrs,
const bool bSendDataChangedEvents )
{
SwPaM* pPam = (SwPaM*)&rRg;
- if( !bTxtAttr && pAttrs && pAttrs->Count() &&
- RES_TXTATR_END > (*pAttrs)[ 0 ] )
+ if( !bTxtAttr && !rAttrs.empty() && RES_TXTATR_END > *(rAttrs.begin()) )
bTxtAttr = sal_True;
if( !rRg.HasMark() )
@@ -417,9 +416,9 @@ void SwDoc::ResetAttrs( const SwPaM &rRg,
{
SwUndoResetAttr* pUndo = new SwUndoResetAttr( rRg,
static_cast<sal_uInt16>(bTxtAttr ? RES_CONDTXTFMTCOLL : RES_TXTFMTCOLL ));
- if( pAttrs && pAttrs->Count() )
+ if( !rAttrs.empty() )
{
- pUndo->SetAttrs( *pAttrs );
+ pUndo->SetAttrs( rAttrs );
}
pHst = &pUndo->GetHistory();
GetIDocumentUndoRedo().AppendUndo(pUndo);
@@ -443,12 +442,13 @@ void SwDoc::ResetAttrs( const SwPaM &rRg,
};
SfxItemSet aDelSet( GetAttrPool(), aResetableSetRange );
- if( pAttrs && pAttrs->Count() )
+ if( !rAttrs.empty() )
{
- for( sal_uInt16 n = pAttrs->Count(); n; )
- if( POOLATTR_END > (*pAttrs)[ --n ] )
- aDelSet.Put( *GetDfltAttr( (*pAttrs)[ n ] ));
-
+ for( std::set<sal_uInt16>::reverse_iterator it = rAttrs.rbegin(); it != rAttrs.rend(); ++it )
+ {
+ if( POOLATTR_END > *it )
+ aDelSet.Put( *GetDfltAttr( *it ));
+ }
if( aDelSet.Count() )
aPara.pDelSet = &aDelSet;
}
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 6112a42..9b0ff5b 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -66,6 +66,30 @@
#include <map>
+namespace {
+ static void lcl_ResetIndentAttrs(SwDoc *pDoc, const SwPaM &rPam, sal_uInt16 marker )
+ {
+ std::set<sal_uInt16> aResetAttrsArray;
+ aResetAttrsArray.insert( marker );
+ // #i114929#
+ // On a selection setup a corresponding Point-and-Mark in order to get
+ // the indentation attribute reset on all paragraphs touched by the selection
+ if ( rPam.HasMark() &&
+ rPam.End()->nNode.GetNode().GetTxtNode() )
+ {
+ SwPaM aPam( rPam.Start()->nNode,
+ rPam.End()->nNode );
+ aPam.Start()->nContent = 0;
+ aPam.End()->nContent = rPam.End()->nNode.GetNode().GetTxtNode()->Len();
+ pDoc->ResetAttrs( aPam, sal_False, aResetAttrsArray );
+ }
+ else
+ {
+ pDoc->ResetAttrs( rPam, sal_False, aResetAttrsArray );
+ }
+ }
+}
+
inline sal_uInt8 GetUpperLvlChg( sal_uInt8 nCurLvl, sal_uInt8 nLevel, sal_uInt16 nMask )
{
if( 1 < nLevel )
@@ -927,24 +951,7 @@ void SwDoc::SetNumRule( const SwPaM& rPam,
if ( bResetIndentAttrs &&
pNew && pNew->Get( 0 ).GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT )
{
- SvUShortsSort aResetAttrsArray;
- aResetAttrsArray.Insert( RES_LR_SPACE );
- // #i114929#
- // On a selection setup a corresponding Point-and-Mark in order to get
- // the indentation attribute reset on all paragraphs touched by the selection
- if ( rPam.HasMark() &&
- rPam.End()->nNode.GetNode().GetTxtNode() )
- {
- SwPaM aPam( rPam.Start()->nNode,
- rPam.End()->nNode );
- aPam.Start()->nContent = 0;
- aPam.End()->nContent = rPam.End()->nNode.GetNode().GetTxtNode()->Len();
- ResetAttrs( aPam, sal_False, &aResetAttrsArray );
- }
- else
- {
- ResetAttrs( rPam, sal_False, &aResetAttrsArray );
- }
+ ::lcl_ResetIndentAttrs(this, rPam, RES_LR_SPACE);
}
if (GetIDocumentUndoRedo().DoesUndo())
@@ -959,24 +966,7 @@ void SwDoc::SetCounted(const SwPaM & rPam, bool bCounted)
{
if ( bCounted )
{
- SvUShortsSort aResetAttrsArray;
- aResetAttrsArray.Insert( RES_PARATR_LIST_ISCOUNTED );
- // #i114929#
- // On a selection setup a corresponding Point-and-Mark in order to get
- // the list-is-counted attribute reset on all paragraphs touched by the selection
- if ( rPam.HasMark() &&
- rPam.End()->nNode.GetNode().GetTxtNode() )
- {
- SwPaM aPam( rPam.Start()->nNode,
- rPam.End()->nNode );
- aPam.Start()->nContent = 0;
- aPam.End()->nContent = rPam.End()->nNode.GetNode().GetTxtNode()->Len();
- ResetAttrs( aPam, sal_False, &aResetAttrsArray );
- }
- else
- {
- ResetAttrs( rPam, sal_False, &aResetAttrsArray );
- }
+ ::lcl_ResetIndentAttrs(this, rPam, RES_PARATR_LIST_ISCOUNTED);
}
else
{
diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx
index f71b1f3..abe9ab1 100644
--- a/sw/source/core/doc/docruby.cxx
+++ b/sw/source/core/doc/docruby.cxx
@@ -111,8 +111,8 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
sal_uInt16 nMode )
{
GetIDocumentUndoRedo().StartUndo( UNDO_SETRUBYATTR, NULL );
- SvUShortsSort aDelArr;
- aDelArr.Insert( RES_TXTATR_CJK_RUBY );
+ std::set<sal_uInt16> aDelArr;
+ aDelArr.insert( RES_TXTATR_CJK_RUBY );
sal_uInt16 nListEntry = 0;
@@ -147,7 +147,7 @@ sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
}
else
{
- ResetAttrs( aPam, sal_True, &aDelArr );
+ ResetAttrs( aPam, sal_True, aDelArr );
}
}
diff --git a/sw/source/core/edit/edatmisc.cxx b/sw/source/core/edit/edatmisc.cxx
index a7aca2d..ca7ae78 100644
--- a/sw/source/core/edit/edatmisc.cxx
+++ b/sw/source/core/edit/edatmisc.cxx
@@ -44,7 +44,7 @@
*************************************/
-void SwEditShell::ResetAttr( const SvUShortsSort* pAttrs )
+void SwEditShell::ResetAttr( const std::set<sal_uInt16> &attrs )
{
SET_CURR_SHELL( this );
StartAllAction();
@@ -56,7 +56,7 @@ void SwEditShell::ResetAttr( const SvUShortsSort* pAttrs )
FOREACHPAM_START(this)
- GetDoc()->ResetAttrs(*PCURCRSR, sal_True, pAttrs);
+ GetDoc()->ResetAttrs(*PCURCRSR, sal_True, attrs);
FOREACHPAM_END()
if( bUndoGroup )
diff --git a/sw/source/core/inc/UndoAttribute.hxx b/sw/source/core/inc/UndoAttribute.hxx
index 24f01b0..3566eb8 100644
--- a/sw/source/core/inc/UndoAttribute.hxx
+++ b/sw/source/core/inc/UndoAttribute.hxx
@@ -35,16 +35,13 @@
#ifndef _SVSTDARR_HXX
#define _SVSTDARR_USHORTS
#define _SVSTDARR_ULONGS
-#define _SVSTDARR_BOOLS
-#define _SVSTDARR_BYTES
-#define _SVSTDARR_USHORTSSORT
#include <svl/svstdarr.hxx>
#endif
#include <svl/itemset.hxx>
#include <swtypes.hxx>
#include <calbck.hxx>
-
+#include <set>
class SvxTabStopItem;
class SwFmt;
@@ -82,7 +79,7 @@ public:
class SwUndoResetAttr : public SwUndo, private SwUndRng
{
const ::std::auto_ptr<SwHistory> m_pHistory;
- SvUShortsSort m_Ids;
+ std::set<sal_uInt16> m_Ids;
const sal_uInt16 m_nFormatId; // Format-Id for Redo
public:
@@ -95,7 +92,7 @@ public:
virtual void RedoImpl( ::sw::UndoRedoContext & );
virtual void RepeatImpl( ::sw::RepeatContext & );
- void SetAttrs( const SvUShortsSort& rArr );
+ void SetAttrs( const std::set<sal_uInt16> &rAttrs );
SwHistory& GetHistory() { return *m_pHistory; }
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index d7705a3..c96184c 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -33,8 +33,6 @@
#ifndef _SVSTDARR_HXX
#define _SVSTDARR_USHORTS
#define _SVSTDARR_ULONGS
-#define _SVSTDARR_BOOLS
-#define _SVSTDARR_BYTES
#define _SVSTDARR_USHORTSSORT
#include <svl/svstdarr.hxx>
#endif
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index a1de353..a1de18f 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -3272,6 +3272,20 @@ void SwTxtNode::ReplaceText( const SwIndex& rStart, const xub_StrLen nDelLen,
}
namespace {
+ static void lcl_ResetParAttrs( SwTxtNode &rTxtNode )
+ {
+ std::set<sal_uInt16> aAttrs;
+ aAttrs.insert( aAttrs.end(), RES_PARATR_LIST_ID );
+ aAttrs.insert( aAttrs.end(), RES_PARATR_LIST_LEVEL );
+ aAttrs.insert( aAttrs.end(), RES_PARATR_LIST_ISRESTART );
+ aAttrs.insert( aAttrs.end(), RES_PARATR_LIST_RESTARTVALUE );
+ aAttrs.insert( aAttrs.end(), RES_PARATR_LIST_ISCOUNTED );
+ SwPaM aPam( rTxtNode );
+ // #i96644#
+ // suppress side effect "send data changed events"
+ rTxtNode.GetDoc()->ResetAttrs( aPam, sal_False, aAttrs, false );
+ }
+
// Helper method for special handling of modified attributes at text node.
// The following is handled:
// (1) on changing the paragraph style - RES_FMT_CHG:
@@ -3388,18 +3402,7 @@ namespace {
rTxtNode.RemoveFromList();
if ( bParagraphStyleChanged )
{
- SvUShortsSort aResetAttrsArray;
- aResetAttrsArray.Insert( RES_PARATR_LIST_ID );
- aResetAttrsArray.Insert( RES_PARATR_LIST_LEVEL );
- aResetAttrsArray.Insert( RES_PARATR_LIST_ISRESTART );
- aResetAttrsArray.Insert( RES_PARATR_LIST_RESTARTVALUE );
- aResetAttrsArray.Insert( RES_PARATR_LIST_ISCOUNTED );
- SwPaM aPam( rTxtNode );
- // #i96644#
- // suppress side effect "send data changed events"
- rTxtNode.GetDoc()->ResetAttrs( aPam, sal_False,
- &aResetAttrsArray,
- false );
+ ::lcl_ResetParAttrs(rTxtNode);
}
}
else
@@ -3428,18 +3431,7 @@ namespace {
rTxtNode.RemoveFromList();
if ( bParagraphStyleChanged )
{
- SvUShortsSort aResetAttrsArray;
- aResetAttrsArray.Insert( RES_PARATR_LIST_ID );
- aResetAttrsArray.Insert( RES_PARATR_LIST_LEVEL );
- aResetAttrsArray.Insert( RES_PARATR_LIST_ISRESTART );
- aResetAttrsArray.Insert( RES_PARATR_LIST_RESTARTVALUE );
- aResetAttrsArray.Insert( RES_PARATR_LIST_ISCOUNTED );
- SwPaM aPam( rTxtNode );
- // #i96644#
- // suppress side effect "send data changed events"
- rTxtNode.GetDoc()->ResetAttrs( aPam, sal_False,
- &aResetAttrsArray,
- false );
+ ::lcl_ResetParAttrs(rTxtNode);
// #i70748#
if ( dynamic_cast<const SfxUInt16Item &>(rTxtNode.GetAttr( RES_PARATR_OUTLINELEVEL, sal_False )).GetValue() > 0 )
{
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index b4ab7dc..2b878f8 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -701,7 +701,6 @@ void SwUndoResetAttr::RedoImpl(::sw::UndoRedoContext & rContext)
{
SwDoc & rDoc = rContext.GetDoc();
SwPaM & rPam = AddUndoRedoPaM(rContext);
- SvUShortsSort* pIdArr = m_Ids.Count() ? &m_Ids : 0;
switch ( m_nFormatId )
{
@@ -709,10 +708,10 @@ void SwUndoResetAttr::RedoImpl(::sw::UndoRedoContext & rContext)
rDoc.RstTxtAttrs(rPam);
break;
case RES_TXTFMTCOLL:
- rDoc.ResetAttrs(rPam, sal_False, pIdArr );
+ rDoc.ResetAttrs(rPam, sal_False, m_Ids );
break;
case RES_CONDTXTFMTCOLL:
- rDoc.ResetAttrs(rPam, sal_True, pIdArr );
+ rDoc.ResetAttrs(rPam, sal_True, m_Ids );
break;
case RES_TXTATR_TOXMARK:
@@ -763,29 +762,25 @@ void SwUndoResetAttr::RepeatImpl(::sw::RepeatContext & rContext)
return;
}
- SvUShortsSort* pIdArr = m_Ids.Count() ? &m_Ids : 0;
switch ( m_nFormatId )
{
case RES_CHRFMT:
rContext.GetDoc().RstTxtAttrs(rContext.GetRepeatPaM());
break;
case RES_TXTFMTCOLL:
- rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), false, pIdArr);
+ rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), false, m_Ids);
break;
case RES_CONDTXTFMTCOLL:
- rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), true, pIdArr);
+ rContext.GetDoc().ResetAttrs(rContext.GetRepeatPaM(), true, m_Ids);
break;
}
}
-void SwUndoResetAttr::SetAttrs( const SvUShortsSort& rArr )
+void SwUndoResetAttr::SetAttrs( const std::set<sal_uInt16> &rAttrs )
{
- if ( m_Ids.Count() )
- {
- m_Ids.Remove( 0, m_Ids.Count() );
- }
- m_Ids.Insert( &rArr );
+ m_Ids.clear();
+ m_Ids.insert( rAttrs.begin(), rAttrs.end() );
}
// -----------------------------------------------------
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 398db6f..87aeefc 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -770,9 +770,9 @@ void resetCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry, SwPaM& rPa
break;
case FN_UNO_CHARFMT_SEQUENCE:
{
- SvUShortsSort aWhichIds;
- aWhichIds.Insert(RES_TXTATR_CHARFMT);
- pDoc->ResetAttrs(rPam, sal_True, &aWhichIds);
+ std::set<sal_uInt16> aWhichIds;
+ aWhichIds.insert( RES_TXTATR_CHARFMT);
+ pDoc->ResetAttrs(rPam, sal_True, aWhichIds);
}
break;
}
diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx
index 1577b10..759b160 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -2045,7 +2045,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException)
static void
lcl_SelectParaAndReset( SwPaM &rPaM, SwDoc & rDoc,
- SvUShortsSort const*const pWhichIds = 0 )
+ std::set<sal_uInt16> const &rWhichIds )
{
// if we are reseting paragraph attributes, we need to select the full paragraph first
SwPosition aStart = *rPaM.Start();
@@ -2062,7 +2062,7 @@ lcl_SelectParaAndReset( SwPaM &rPaM, SwDoc & rDoc,
{
pTemp->MovePara(fnParaCurr, fnParaEnd);
}
- rDoc.ResetAttrs(*pTemp, sal_True, pWhichIds);
+ rDoc.ResetAttrs(*pTemp, sal_True, rWhichIds);
}
void SwUnoCursorHelper::SetPropertyToDefault(
@@ -2089,15 +2089,15 @@ throw (beans::UnknownPropertyException, uno::RuntimeException)
if (pEntry->nWID < RES_FRMATR_END)
{
- SvUShortsSort aWhichIds;
- aWhichIds.Insert(pEntry->nWID);
+ std::set<sal_uInt16> aWhichIds;
+ aWhichIds.insert( pEntry->nWID );
if (pEntry->nWID < RES_PARATR_BEGIN)
{
- rDoc.ResetAttrs(rPaM, sal_True, &aWhichIds);
+ rDoc.ResetAttrs(rPaM, sal_True, aWhichIds);
}
else
{
- lcl_SelectParaAndReset ( rPaM, rDoc, &aWhichIds );
+ lcl_SelectParaAndReset ( rPaM, rDoc, aWhichIds );
}
}
else
@@ -2328,7 +2328,7 @@ static sal_uInt16 g_ResetableSetRange[] = {
};
static void
-lcl_EnumerateIds(sal_uInt16 const* pIdRange, SvUShortsSort & rWhichIds)
+lcl_EnumerateIds(sal_uInt16 const* pIdRange, std::set<sal_uInt16> &rWhichIds)
{
while (*pIdRange)
{
@@ -2336,7 +2336,7 @@ lcl_EnumerateIds(sal_uInt16 const* pIdRange, SvUShortsSort & rWhichIds)
const sal_uInt16 nEnd = sal::static_int_cast<sal_uInt16>(*pIdRange++);
for (sal_uInt16 nId = nStart + 1; nId <= nEnd; ++nId)
{
- rWhichIds.Insert( nId );
+ rWhichIds.insert( rWhichIds.end(), nId );
}
}
}
@@ -2349,18 +2349,18 @@ throw (uno::RuntimeException)
SwUnoCrsr & rUnoCursor( m_pImpl->GetCursorOrThrow() );
- SvUShortsSort aParaWhichIds;
- SvUShortsSort aWhichIds;
+ std::set<sal_uInt16> aParaWhichIds;
+ std::set<sal_uInt16> aWhichIds;
lcl_EnumerateIds(g_ParaResetableSetRange, aParaWhichIds);
lcl_EnumerateIds(g_ResetableSetRange, aWhichIds);
- if (aParaWhichIds.Count())
+ if (!aParaWhichIds.empty())
{
lcl_SelectParaAndReset(rUnoCursor, *rUnoCursor.GetDoc(),
- &aParaWhichIds);
+ aParaWhichIds);
}
- if (aWhichIds.Count())
+ if (!aWhichIds.empty())
{
- rUnoCursor.GetDoc()->ResetAttrs(rUnoCursor, sal_True, &aWhichIds);
+ rUnoCursor.GetDoc()->ResetAttrs(rUnoCursor, sal_True, aWhichIds);
}
}
@@ -2378,8 +2378,8 @@ throw (beans::UnknownPropertyException, uno::RuntimeException)
{
SwDoc & rDoc = *rUnoCursor.GetDoc();
const OUString * pNames = rPropertyNames.getConstArray();
- SvUShortsSort aWhichIds;
- SvUShortsSort aParaWhichIds;
+ std::set<sal_uInt16> aWhichIds;
+ std::set<sal_uInt16> aParaWhichIds;
for (sal_Int32 i = 0; i < nCount; i++)
{
SfxItemPropertySimpleEntry const*const pEntry =
@@ -2411,11 +2411,11 @@ throw (beans::UnknownPropertyException, uno::RuntimeException)
{
if (pEntry->nWID < RES_PARATR_BEGIN)
{
- aWhichIds.Insert(pEntry->nWID);
+ aWhichIds.insert( pEntry->nWID );
}
else
{
- aParaWhichIds.Insert(pEntry->nWID);
+ aParaWhichIds.insert( pEntry->nWID );
}
}
else if (pEntry->nWID == FN_UNO_NUM_START_VALUE)
@@ -2424,13 +2424,13 @@ throw (beans::UnknownPropertyException, uno::RuntimeException)
}
}
- if (aParaWhichIds.Count())
+ if (!aParaWhichIds.empty())
{
- lcl_SelectParaAndReset(rUnoCursor, rDoc, &aParaWhichIds);
+ lcl_SelectParaAndReset(rUnoCursor, rDoc, aParaWhichIds);
}
- if (aWhichIds.Count())
+ if (!aWhichIds.empty())
{
- rDoc.ResetAttrs(rUnoCursor, sal_True, &aWhichIds);
+ rDoc.ResetAttrs(rUnoCursor, sal_True, aWhichIds);
}
}
}
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index 01e9183..629fa3f 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -1021,11 +1021,11 @@ throw (beans::UnknownPropertyException, uno::RuntimeException)
if (pEntry->nWID < RES_FRMATR_END)
{
- SvUShortsSort aWhichIds;
- aWhichIds.Insert(pEntry->nWID);
+ std::set<sal_uInt16> aWhichIds;
+ aWhichIds.insert( pEntry->nWID );
if (pEntry->nWID < RES_PARATR_BEGIN)
{
- aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, &aWhichIds);
+ aCursor.GetDoc()->ResetAttrs(aCursor, sal_True, aWhichIds);
}
else
{
@@ -1047,7 +1047,7 @@ throw (beans::UnknownPropertyException, uno::RuntimeException)
{
pTemp->MovePara(fnParaCurr, fnParaEnd);
}
- pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, &aWhichIds);
+ pTemp->GetDoc()->ResetAttrs(*pTemp, sal_True, aWhichIds);
}
}
else
diff --git a/sw/source/ui/shells/langhelper.cxx b/sw/source/ui/shells/langhelper.cxx
index fec2969..e17f6a5 100644
--- a/sw/source/ui/shells/langhelper.cxx
+++ b/sw/source/ui/shells/langhelper.cxx
@@ -377,16 +377,16 @@ namespace SwLangHelper
}
else // change language for all text
{
- SvUShortsSort aAttribs;
+ std::set<sal_uInt16> aAttribs;
for (sal_uInt16 i = 0; i < 3; ++i)
{
rWrtSh.SetDefault( SvxLanguageItem( LANGUAGE_NONE, aLangWhichId_Writer[i] ) );
- aAttribs.Insert( aLangWhichId_Writer[i] );
+ aAttribs.insert( aLangWhichId_Writer[i] );
}
// set all language attributes to default
// (for all text in the document - which should be selected by now...)
- rWrtSh.ResetAttr( &aAttribs );
+ rWrtSh.ResetAttr( aAttribs );
}
}
@@ -414,11 +414,11 @@ namespace SwLangHelper
}
else
{
- SvUShortsSort aAttribs;
- aAttribs.Insert( RES_CHRATR_LANGUAGE );
- aAttribs.Insert( RES_CHRATR_CJK_LANGUAGE );
- aAttribs.Insert( RES_CHRATR_CTL_LANGUAGE );
- rWrtSh.ResetAttr( &aAttribs );
+ std::set<sal_uInt16> aAttribs;
+ aAttribs.insert( RES_CHRATR_LANGUAGE );
+ aAttribs.insert( RES_CHRATR_CJK_LANGUAGE );
+ aAttribs.insert( RES_CHRATR_CTL_LANGUAGE );
+ rWrtSh.ResetAttr( aAttribs );
}
}
diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx
index d9debe2..3ad74b1 100644
--- a/sw/source/ui/shells/textsh1.cxx
+++ b/sw/source/ui/shells/textsh1.cxx
@@ -490,7 +490,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
// #i78856, reset all attributes but not the language attributes
// (for this build an array of all relevant attributes and
// remove the languages from that)
- SvUShortsSort aAttribs;
+ std::set<sal_uInt16> aAttribs;
sal_uInt16 aResetableSetRange[] = {
RES_FRMATR_BEGIN, RES_FRMATR_END-1,
@@ -510,11 +510,11 @@ void SwTextShell::Execute(SfxRequest &rReq)
sal_uInt16 nL = pUShorts[1] - pUShorts[0] + 1;
sal_uInt16 nE = pUShorts[0];
for (sal_uInt16 i = 0; i < nL; ++i)
- aAttribs.Insert( nE++ );
+ aAttribs.insert( aAttribs.end(), nE++ );
pUShorts += 2;
}
- rWrtSh.ResetAttr( &aAttribs );
+ rWrtSh.ResetAttr( aAttribs );
rReq.Done();
break;
}
@@ -809,9 +809,9 @@ void SwTextShell::Execute(SfxRequest &rReq)
rWrtSh.SelWrd();
}
//now remove the attribute
- SvUShortsSort aAttribs;
- aAttribs.Insert( RES_TXTATR_INETFMT );
- rWrtSh.ResetAttr( &aAttribs );
+ std::set<sal_uInt16> aAttribs;
+ aAttribs.insert( RES_TXTATR_INETFMT );
+ rWrtSh.ResetAttr( aAttribs );
if(!bSel)
{
rWrtSh.Pop(sal_False);
diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx
index 6498ddc..c0e7f03 100644
--- a/sw/source/ui/uiview/view2.cxx
+++ b/sw/source/ui/uiview/view2.cxx
@@ -176,9 +176,9 @@ static void lcl_SetAllTextToDefaultLanguage( SwWrtShell &rWrtSh, sal_uInt16 nWhi
rWrtSh.ExtendedSelectAll();
// set language attribute to default for all text
- SvUShortsSort aAttribs;
- aAttribs.Insert( nWhichId );
- rWrtSh.ResetAttr( &aAttribs );
+ std::set<sal_uInt16> aAttribs;
+ aAttribs.insert( nWhichId );
+ rWrtSh.ResetAttr( aAttribs );
rWrtSh.Pop( sal_False );
rWrtSh.LockView( sal_False );
More information about the Libreoffice-commits
mailing list