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