Kaydet (Commit) f5c174ac authored tarafından Oliver-Rainer Wittmann's avatar Oliver-Rainer Wittmann Kaydeden (comit) Caolán McNamara

Resolves: #i124451# apply correct index entry template patterns...

which are used for e.g. TOC

(cherry picked from commit 52c89c2a)

Conflicts:
	sw/inc/tox.hxx
	sw/source/core/tox/tox.cxx
	sw/source/filter/ww8/ww8par5.cxx

Change-Id: Id14cecc07d09d3461c091a6451143cbce206e308
üst a5a52ba1
...@@ -348,10 +348,8 @@ public: ...@@ -348,10 +348,8 @@ public:
void SetPattern(sal_uInt16 nLevel, const OUString& rStr); void SetPattern(sal_uInt16 nLevel, const OUString& rStr);
const SwFormTokens& GetPattern(sal_uInt16 nLevel) const; const SwFormTokens& GetPattern(sal_uInt16 nLevel) const;
// fill tab stop positions from template to pattern // fill tab stop positions from template to pattern- #i21237#
// #i21237# void AdjustTabStops( SwDoc& rDoc );
void AdjustTabStops(SwDoc& rDoc,
sal_Bool bInsertNewTabStops = sal_False);
inline TOXTypes GetTOXType() const; inline TOXTypes GetTOXType() const;
inline sal_uInt16 GetFormMax() const; inline sal_uInt16 GetFormMax() const;
...@@ -565,8 +563,12 @@ public: ...@@ -565,8 +563,12 @@ public:
OUString GetSortAlgorithm()const {return sSortAlgorithm;} OUString GetSortAlgorithm()const {return sSortAlgorithm;}
void SetSortAlgorithm(const OUString& rSet) {sSortAlgorithm = rSet;} void SetSortAlgorithm(const OUString& rSet) {sSortAlgorithm = rSet;}
// #i21237# // #i21237#
void AdjustTabStops(SwDoc & rDoc, sal_Bool bDefaultRightTabStop); void AdjustTabStops( SwDoc & rDoc )
SwTOXBase& operator=(const SwTOXBase& rSource); {
aForm.AdjustTabStops( rDoc );
}
SwTOXBase& operator=(const SwTOXBase& rSource);
void RegisterToTOXType( SwTOXType& rMark ); void RegisterToTOXType( SwTOXType& rMark );
}; };
...@@ -734,11 +736,6 @@ inline OUString SwTOXBase::GetTypeName() const ...@@ -734,11 +736,6 @@ inline OUString SwTOXBase::GetTypeName() const
inline const SwForm& SwTOXBase::GetTOXForm() const inline const SwForm& SwTOXBase::GetTOXForm() const
{ return aForm; } { return aForm; }
inline void SwTOXBase::AdjustTabStops(SwDoc & rDoc, sal_Bool bDefaultRightTabStop)
{
aForm.AdjustTabStops(rDoc, bDefaultRightTabStop);
}
inline void SwTOXBase::SetCreate(sal_uInt16 nCreate) inline void SwTOXBase::SetCreate(sal_uInt16 nCreate)
{ nCreateType = nCreate; } { nCreateType = nCreate; }
......
...@@ -406,76 +406,53 @@ bool operator == (const SwFormToken & rToken, FormTokenType eType) ...@@ -406,76 +406,53 @@ bool operator == (const SwFormToken & rToken, FormTokenType eType)
return rToken.eTokenType == eType; return rToken.eTokenType == eType;
} }
void SwForm::AdjustTabStops(SwDoc& rDoc, sal_Bool bInsertNewTapStops) // #i21237# void SwForm::AdjustTabStops( SwDoc& rDoc ) // #i21237#
{ {
for(sal_uInt16 nLevel = 1; nLevel < GetFormMax(); nLevel++) for(sal_uInt16 nLevel = 1; nLevel < GetFormMax(); nLevel++)
{ {
const OUString sTemplateName = GetTemplate(nLevel); const OUString sTemplateName = GetTemplate(nLevel);
SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( sTemplateName ); SwTxtFmtColl* pColl = rDoc.FindTxtFmtCollByName( sTemplateName );
if( !pColl ) if( pColl == NULL )
{ {
sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName const sal_uInt16 nId =
( sTemplateName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL ); // #i21237# SwStyleNameMapper::GetPoolIdFromUIName( sTemplateName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
if( USHRT_MAX != nId ) if ( USHRT_MAX != nId )
pColl = rDoc.GetTxtCollFromPool( nId ); pColl = rDoc.GetTxtCollFromPool( nId );
} }
const SvxTabStopItem* pTabStops = 0; const SvxTabStopItem* pTabStops = pColl != NULL ? &pColl->GetTabStops(sal_False) : 0;
sal_uInt16 nTabCount = 0; const sal_uInt16 nTabCount = pTabStops != NULL ? pTabStops->Count() : 0;
if( pColl && if( pTabStops != NULL
0 != ( pTabStops = &pColl->GetTabStops(sal_False) ) && && nTabCount != 0 )
0 != ( nTabCount = pTabStops->Count() ) )
{ {
// #i21237#
SwFormTokens aCurrentPattern = GetPattern(nLevel); SwFormTokens aCurrentPattern = GetPattern(nLevel);
SwFormTokens::iterator aIt = aCurrentPattern.begin(); SwFormTokens::iterator aIt = aCurrentPattern.begin();
bool bChanged = false; bool bChanged = false;
for(sal_uInt16 nTab = 0; nTab < nTabCount; ++nTab) for(sal_uInt16 nTab = 0; nTab < nTabCount; ++nTab)
{ {
const SvxTabStop& rTab = (*pTabStops)[nTab]; const SvxTabStop& rTab = (*pTabStops)[nTab];
// #i29178# aIt = find_if( aIt, aCurrentPattern.end(), SwFormTokenEqualToFormTokenType(TOKEN_TAB_STOP) );
// For Word import, we do not want to replace existing tokens, if ( aIt != aCurrentPattern.end() )
// we insert new tabstop tokens without a tabstop character:
if ( bInsertNewTapStops )
{ {
if ( SVX_TAB_ADJUST_DEFAULT != rTab.GetAdjustment() ) bChanged = true;
{ aIt->nTabStopPosition = rTab.GetTabPos();
bChanged = true; aIt->eTabAlign =
SwFormToken aToken(TOKEN_TAB_STOP); ( nTab == nTabCount - 1
aToken.bWithTab = sal_False; && rTab.GetAdjustment() == SVX_TAB_ADJUST_RIGHT )
aToken.nTabStopPosition = rTab.GetTabPos(); ? SVX_TAB_ADJUST_END
aToken.eTabAlign = rTab.GetAdjustment(); : rTab.GetAdjustment();
aToken.cTabFillChar = rTab.GetFill(); aIt->cTabFillChar = rTab.GetFill();
aCurrentPattern.push_back(aToken); ++aIt;
}
} }
else else
{ break; // no more tokens to replace
aIt = find_if(aIt, aCurrentPattern.end(),
SwFormTokenEqualToFormTokenType
(TOKEN_TAB_STOP));
if ( aIt != aCurrentPattern.end() )
{
bChanged = true;
aIt->nTabStopPosition = rTab.GetTabPos();
aIt->eTabAlign = nTab == nTabCount - 1 &&
SVX_TAB_ADJUST_RIGHT == rTab.GetAdjustment() ?
SVX_TAB_ADJUST_END :
rTab.GetAdjustment();
aIt->cTabFillChar = rTab.GetFill();
++aIt;
}
else
break; // no more tokens to replace
}
} }
if(bChanged) if ( bChanged )
SetPattern(nLevel, aCurrentPattern); // #i21237# SetPattern( nLevel, aCurrentPattern );
} }
} }
} }
......
...@@ -3232,17 +3232,11 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr ) ...@@ -3232,17 +3232,11 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
for(sal_uInt16 nLevel = 1; nLevel <= nNewEnd; ++nLevel) for(sal_uInt16 nLevel = 1; nLevel <= nNewEnd; ++nLevel)
{ {
SwFormTokens aPattern = aOldForm.GetPattern(nLevel); SwFormTokens aPattern = aOldForm.GetPattern(nLevel);
SwFormTokens::iterator new_end =
SwFormTokens::iterator new_end=remove_if(aPattern.begin(), aPattern.end(), remove_if(aPattern.begin(), aPattern.end(), SwFormTokenEqualToFormTokenType(TOKEN_ENTRY_NO));
SwFormTokenEqualToFormTokenType(TOKEN_ENTRY_NO)); aPattern.erase(new_end, aPattern.end() ); // table index imported with wrong page number format
aForm.SetPattern( nLevel, aPattern );
// table index imported with wrong page number format aForm.SetTemplate( nLevel, aOldForm.GetTemplate(nLevel) );
aPattern.erase (new_end, aPattern.end() );
aNewForm.SetPattern(nLevel, aPattern);
aNewForm.SetTemplate( nLevel,
aOldForm.GetTemplate(nLevel));
} }
pBase->SetTOXForm( aNewForm ); pBase->SetTOXForm( aNewForm );
...@@ -3261,16 +3255,10 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr ) ...@@ -3261,16 +3255,10 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, OUString& rStr )
break; break;
} // ToxBase fertig } // ToxBase fertig
// no Update of TOC anymore as its actual content is imported and kept. // #i21237# - propagate tab stops from paragraph styles used in TOX to patterns of the TOX
//rDoc.SetUpdateTOX(true); pBase->AdjustTabStops( rDoc );
// #i21237# - propagate tab stops from paragraph styles
// used in TOX to patterns of the TOX
pBase->AdjustTabStops(rDoc, sal_True);
// #i10028# - inserting a toc implictly acts like a parabreak in word and writer
//#i10028# inserting a toc implicltly acts like a parabreak in word and writer
if ( pPaM->End() && if ( pPaM->End() &&
pPaM->End()->nNode.GetNode().GetTxtNode() && pPaM->End()->nNode.GetNode().GetTxtNode() &&
pPaM->End()->nNode.GetNode().GetTxtNode()->Len() != 0 ) pPaM->End()->nNode.GetNode().GetTxtNode()->Len() != 0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment