2008-12-19 10:32:51 +0100 od r265718 : #i70748# method <SwWW8Writer::StartTOX(..)>
- correction for custom to outline style
assigned paragraph styles
2008-12-19 09:24:41 +0100 od r265715 : #i70748# method <HandleModifyAtTxtNode(..)>
- retrieve former applied list style before potential
reset of empty list style due to set outline level
2008-12-17 15:33:57 +0100 hde r265608 : #i97013#
2008-12-17 14:43:42 +0100 od r265603 : #i70748# adjust fix i44177 - adjustment of to outline style assigned
paragraph styles only for OOo-Templates.
2008-12-17 12:59:42 +0100 od r265598 : #i70748# method <XMLTextImportHelper::SetStyleAndAttrs(..)>
- special handling of OOo 2.x document regarding
outline numbering of headings.
2008-12-17 12:45:53 +0100 od r265597 : #i70748# method <HandleModifyAtTxtNode(..)>
- correct determination of new and former applied list style
2008-12-17 10:18:41 +0100 od r265581 : #i97312# method <XMLTextNumRuleInfo::Set(..)>
- check, if numbering rules instance contains any numbering rule.
2008-12-16 14:34:22 +0100 hde r265542 : #i97013
2008-12-16 14:20:24 +0100 od r265541 : #i70748# adjust documentation of "Which"-ID numbers
2008-12-16 14:19:49 +0100 od r265539 : #i70748# Adjust Attribute-Function-Mapping table due to new attribute
2008-12-16 14:06:24 +0100 od r265538 : #i70748# - Correct handling of to outline style assigned paragraph styles
on reset of all paragraph style attributes
- WW8 import: Consider refactoring of paragraph style's outline
level attribute - NO_NUMBERING define no longer exsits.
2008-12-16 10:37:19 +0100 od r265530 : #i70478# Correction on moving outline paragraph up respectively down
in its outline level:
- Check also outline paragraph, which are not an outline via
a to outline style assigned paragraph style, if action is applicable.
2008-12-16 09:10:13 +0100 hde r265523 : #i97277
2008-12-16 09:09:30 +0100 hde r265522 : #i97277
2008-12-16 09:07:40 +0100 hde r265521 : Added control and purged obsolete id's
2008-12-10 13:09:36 +0100 od r265174 : #i70748# correction of previous fix due to warning-free code
2008-12-10 13:03:30 +0100 od r265172 : #i70748# method <XMLTextImportHelper::SetStyleAndAttrs(..)>
- Due to performance issues avoid retrieving outline level value from paragraph's paragraph
style for each paragraph. Instead retrieve current outline level value from paragraph,
which is the inherited value from its paragraph style, and only when it is needed.
2008-12-09 16:50:36 +0100 ufi r265117 : help
2008-12-09 16:49:50 +0100 ufi r265116 : help
2008-12-09 15:45:05 +0100 od r265107 : #i70748# method <XMLTextImportHelper::SetStyleAndAttrs(..)>
- some minor rework and check access to paragraph styles
2008-12-09 15:42:04 +0100 od r265106 : #i70748# adjust name of local variable to avoid hiding of class variable
2008-12-09 15:40:51 +0100 od r265105 : #i70748# correct initialization order
2008-12-09 15:35:07 +0100 od r265101 : #i70748# remove duplicate entry in certain property map
2008-12-09 15:33:39 +0100 od r265100 : #i70748# add end of file token
2008-12-07 15:11:54 +0100 zhaojianwei r264952 : conflicts left not to be resolved when cws rebase
2008-12-04 14:52:21 +0100 zhaojianwei r264846 : CWS-TOOLING: rebase CWS outlinelevel to trunk@264325 (milestone: DEV300:m36)
2008-11-28 03:42:09 +0100 zhaojianwei r264525 : #i70748#: migrate CWS outlinelevel to SVN
2008-11-28 03:41:39 +0100 zhaojianwei r264524 : #i70748#: migrate CWS outlinelevel to SVN
2008-11-28 03:41:11 +0100 zhaojianwei r264523 : #i70748#: migrate CWS outlinelevel to SVN
402 lines
13 KiB
C++
402 lines
13 KiB
C++
/*************************************************************************
|
||
*
|
||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||
*
|
||
* Copyright 2008 by Sun Microsystems, Inc.
|
||
*
|
||
* OpenOffice.org - a multi-platform office productivity suite
|
||
*
|
||
* $RCSfile: ftnidx.cxx,v $
|
||
* $Revision: 1.11 $
|
||
*
|
||
* This file is part of OpenOffice.org.
|
||
*
|
||
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||
* it under the terms of the GNU Lesser General Public License version 3
|
||
* only, as published by the Free Software Foundation.
|
||
*
|
||
* OpenOffice.org is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU Lesser General Public License version 3 for more details
|
||
* (a copy is included in the LICENSE file that accompanied this code).
|
||
*
|
||
* You should have received a copy of the GNU Lesser General Public License
|
||
* version 3 along with OpenOffice.org. If not, see
|
||
* <http://www.openoffice.org/license.html>
|
||
* for a copy of the LGPLv3 License.
|
||
*
|
||
************************************************************************/
|
||
|
||
// MARKER(update_precomp.py): autogen include statement, do not remove
|
||
#include "precompiled_sw.hxx"
|
||
|
||
|
||
#include <txtftn.hxx>
|
||
#include <fmtftn.hxx>
|
||
#include <ftninfo.hxx>
|
||
#include <doc.hxx>
|
||
#include <ftnidx.hxx>
|
||
#include <ndtxt.hxx>
|
||
#include <ndindex.hxx>
|
||
#include <section.hxx>
|
||
#include <fmtftntx.hxx>
|
||
#include <rootfrm.hxx>
|
||
|
||
|
||
_SV_IMPL_SORTAR_ALG( _SwFtnIdxs, SwTxtFtnPtr )
|
||
BOOL _SwFtnIdxs::Seek_Entry( const SwTxtFtnPtr rSrch, USHORT* pFndPos ) const
|
||
{
|
||
ULONG nIdx = _SwTxtFtn_GetIndex( rSrch );
|
||
xub_StrLen nCntIdx = *rSrch->GetStart();
|
||
|
||
USHORT nO = Count(), nM, nU = 0;
|
||
if( nO > 0 )
|
||
{
|
||
nO--;
|
||
while( nU <= nO )
|
||
{
|
||
nM = nU + ( nO - nU ) / 2;
|
||
ULONG nFndIdx = _SwTxtFtn_GetIndex( (*this)[ nM ] );
|
||
if( nFndIdx == nIdx && *(*this)[ nM ]->GetStart() == nCntIdx )
|
||
{
|
||
if( pFndPos )
|
||
*pFndPos = nM;
|
||
return TRUE;
|
||
}
|
||
else if( nFndIdx < nIdx ||
|
||
(nFndIdx == nIdx && *(*this)[ nM ]->GetStart() < nCntIdx ))
|
||
nU = nM + 1;
|
||
else if( nM == 0 )
|
||
{
|
||
if( pFndPos )
|
||
*pFndPos = nU;
|
||
return FALSE;
|
||
}
|
||
else
|
||
nO = nM - 1;
|
||
}
|
||
}
|
||
if( pFndPos )
|
||
*pFndPos = nU;
|
||
return FALSE;
|
||
}
|
||
|
||
|
||
void SwFtnIdxs::UpdateFtn( const SwNodeIndex& rStt )
|
||
{
|
||
if( !Count() )
|
||
return;
|
||
|
||
// besorge erstmal das Nodes-Array ueber den StartIndex der ersten Fussnote
|
||
SwDoc* pDoc = rStt.GetNode().GetDoc();
|
||
if( pDoc->IsInReading() )
|
||
return ;
|
||
SwTxtFtn* pTxtFtn;
|
||
|
||
const SwEndNoteInfo& rEndInfo = pDoc->GetEndNoteInfo();
|
||
const SwFtnInfo& rFtnInfo = pDoc->GetFtnInfo();
|
||
|
||
//Fuer normale Fussnoten werden Chapter- und Dokumentweise Nummerierung
|
||
//getrennt behandelt. Fuer Endnoten gibt es nur die Dokumentweise
|
||
//Nummerierung.
|
||
if( FTNNUM_CHAPTER == rFtnInfo.eNum )
|
||
{
|
||
const SwOutlineNodes& rOutlNds = pDoc->GetNodes().GetOutLineNds();
|
||
const SwNode* pCapStt = &pDoc->GetNodes().GetEndOfExtras();
|
||
ULONG nCapEnd = pDoc->GetNodes().GetEndOfContent().GetIndex();
|
||
if( rOutlNds.Count() )
|
||
{
|
||
// suche den Start des Kapitels, in den rStt steht.
|
||
USHORT n;
|
||
|
||
for( n = 0; n < rOutlNds.Count(); ++n )
|
||
if( rOutlNds[ n ]->GetIndex() > rStt.GetIndex() )
|
||
break; // gefunden
|
||
//else if( !rOutlNds[ n ]->GetTxtNode()->GetTxtColl()->GetOutlineLevel() ) //#outline level,zhaojianwei
|
||
else if ( rOutlNds[ n ]->GetTxtNode()->GetAttrOutlineLevel() == 1 ) //<-end,zhaojianwei
|
||
pCapStt = rOutlNds[ n ]; // Start eines neuen Kapitels
|
||
// dann suche jetzt noch das Ende vom Bereich
|
||
for( ; n < rOutlNds.Count(); ++n )
|
||
//if( !rOutlNds[ n ]->GetTxtNode()->GetTxtColl()->GetOutlineLevel() )//#outline level,zhaojianwei
|
||
if ( rOutlNds[ n ]->GetTxtNode()->GetAttrOutlineLevel() == 1 )//<-end,zhaojianwei
|
||
{
|
||
nCapEnd = rOutlNds[ n ]->GetIndex(); // Ende des gefundenen Kapitels
|
||
break;
|
||
}
|
||
}
|
||
|
||
USHORT nPos, nFtnNo = 1;
|
||
if( SeekEntry( *pCapStt, &nPos ) && nPos )
|
||
{
|
||
// gehe nach vorne bis der Index nicht mehr gleich ist
|
||
const SwNode* pCmpNd = &rStt.GetNode();
|
||
while( nPos && pCmpNd == &((*this)[ --nPos ]->GetTxtNode()) )
|
||
;
|
||
++nPos;
|
||
}
|
||
|
||
if( nPos == Count() ) // nichts gefunden
|
||
return;
|
||
|
||
if( !rOutlNds.Count() )
|
||
nFtnNo = nPos+1;
|
||
|
||
for( ; nPos < Count(); ++nPos )
|
||
{
|
||
pTxtFtn = (*this)[ nPos ];
|
||
if( pTxtFtn->GetTxtNode().GetIndex() >= nCapEnd )
|
||
break;
|
||
|
||
const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
|
||
if( !rFtn.GetNumStr().Len() && !rFtn.IsEndNote() &&
|
||
!SwUpdFtnEndNtAtEnd::FindSectNdWithEndAttr( *pTxtFtn ))
|
||
pTxtFtn->SetNumber( rFtnInfo.nFtnOffset + nFtnNo++,
|
||
&rFtn.GetNumStr() );
|
||
}
|
||
}
|
||
|
||
SwUpdFtnEndNtAtEnd aNumArr;
|
||
|
||
// BOOL, damit hier auch bei Chapter-Einstellung die Endnoten
|
||
// durchlaufen.
|
||
const BOOL bEndNoteOnly = FTNNUM_DOC != rFtnInfo.eNum;
|
||
|
||
USHORT nPos, nFtnNo = 1, nEndNo = 1;
|
||
ULONG nUpdNdIdx = rStt.GetIndex();
|
||
for( nPos = 0; nPos < Count(); ++nPos )
|
||
{
|
||
pTxtFtn = (*this)[ nPos ];
|
||
if( nUpdNdIdx <= pTxtFtn->GetTxtNode().GetIndex() )
|
||
break;
|
||
|
||
const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
|
||
if( !rFtn.GetNumStr().Len() )
|
||
{
|
||
if( !aNumArr.ChkNumber( *pTxtFtn ) )
|
||
{
|
||
if( pTxtFtn->GetFtn().IsEndNote() )
|
||
nEndNo++;
|
||
else
|
||
nFtnNo++;
|
||
}
|
||
}
|
||
}
|
||
|
||
// ab nPos bei allen FootNotes die Array-Nummer setzen
|
||
for( ; nPos < Count(); ++nPos )
|
||
{
|
||
pTxtFtn = (*this)[ nPos ];
|
||
const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
|
||
if( !rFtn.GetNumStr().Len() )
|
||
{
|
||
USHORT nSectNo = aNumArr.ChkNumber( *pTxtFtn );
|
||
if( !nSectNo && ( rFtn.IsEndNote() || !bEndNoteOnly ))
|
||
nSectNo = rFtn.IsEndNote()
|
||
? rEndInfo.nFtnOffset + nEndNo++
|
||
: rFtnInfo.nFtnOffset + nFtnNo++;
|
||
|
||
if( nSectNo )
|
||
{
|
||
if( rFtn.IsEndNote() )
|
||
pTxtFtn->SetNumber( nSectNo, &rFtn.GetNumStr() );
|
||
else
|
||
pTxtFtn->SetNumber( nSectNo, &rFtn.GetNumStr() );
|
||
}
|
||
}
|
||
}
|
||
// Pageweise wird vom MA erfuellt !!
|
||
}
|
||
|
||
|
||
void SwFtnIdxs::UpdateAllFtn()
|
||
{
|
||
if( !Count() )
|
||
return;
|
||
|
||
// besorge erstmal das Nodes-Array ueber den StartIndex der
|
||
// ersten Fussnote
|
||
SwDoc* pDoc = (SwDoc*) (*this)[ 0 ]->GetTxtNode().GetDoc();
|
||
SwTxtFtn* pTxtFtn;
|
||
const SwEndNoteInfo& rEndInfo = pDoc->GetEndNoteInfo();
|
||
const SwFtnInfo& rFtnInfo = pDoc->GetFtnInfo();
|
||
|
||
SwUpdFtnEndNtAtEnd aNumArr;
|
||
|
||
//Fuer normale Fussnoten werden Chapter- und Dokumentweise Nummerierung
|
||
//getrennt behandelt. Fuer Endnoten gibt es nur die Dokumentweise
|
||
//Nummerierung.
|
||
if( FTNNUM_CHAPTER == rFtnInfo.eNum )
|
||
{
|
||
const SwOutlineNodes& rOutlNds = pDoc->GetNodes().GetOutLineNds();
|
||
USHORT nNo = 1, // Nummer fuer die Fussnoten
|
||
nFtnIdx = 0; // Index in das FtnIdx-Array
|
||
for( USHORT n = 0; n < rOutlNds.Count(); ++n )
|
||
{
|
||
//if( !rOutlNds[ n ]->GetTxtNode()->GetTxtColl()->GetOutlineLevel() )//#outline level,zhaojianwei
|
||
if ( rOutlNds[ n ]->GetTxtNode()->GetAttrOutlineLevel() == 1 )//<-end,zhaojianwei
|
||
{
|
||
ULONG nCapStt = rOutlNds[ n ]->GetIndex(); // Start eines neuen Kapitels
|
||
for( ; nFtnIdx < Count(); ++nFtnIdx )
|
||
{
|
||
pTxtFtn = (*this)[ nFtnIdx ];
|
||
if( pTxtFtn->GetTxtNode().GetIndex() >= nCapStt )
|
||
break;
|
||
|
||
// Endnoten nur Dokumentweise
|
||
const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
|
||
if( !rFtn.IsEndNote() && !rFtn.GetNumStr().Len() &&
|
||
!SwUpdFtnEndNtAtEnd::FindSectNdWithEndAttr( *pTxtFtn ))
|
||
pTxtFtn->SetNumber( rFtnInfo.nFtnOffset + nNo++,
|
||
&rFtn.GetNumStr() );
|
||
}
|
||
if( nFtnIdx >= Count() )
|
||
break; // ok alles geupdatet
|
||
nNo = 1;
|
||
}
|
||
}
|
||
|
||
for( nNo = 1; nFtnIdx < Count(); ++nFtnIdx )
|
||
{
|
||
//Endnoten nur Dokumentweise
|
||
pTxtFtn = (*this)[ nFtnIdx ];
|
||
const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
|
||
if( !rFtn.IsEndNote() && !rFtn.GetNumStr().Len() &&
|
||
!SwUpdFtnEndNtAtEnd::FindSectNdWithEndAttr( *pTxtFtn ))
|
||
pTxtFtn->SetNumber( rFtnInfo.nFtnOffset + nNo++,
|
||
&rFtn.GetNumStr() );
|
||
}
|
||
|
||
}
|
||
|
||
// BOOL, damit hier auch bei Chapter-Einstellung die Endnoten
|
||
// durchlaufen.
|
||
const BOOL bEndNoteOnly = FTNNUM_DOC != rFtnInfo.eNum;
|
||
USHORT nFtnNo = 0, nEndNo = 0;
|
||
for( USHORT nPos = 0; nPos < Count(); ++nPos )
|
||
{
|
||
pTxtFtn = (*this)[ nPos ];
|
||
const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
|
||
if( !rFtn.GetNumStr().Len() )
|
||
{
|
||
USHORT nSectNo = aNumArr.ChkNumber( *pTxtFtn );
|
||
if( !nSectNo && ( rFtn.IsEndNote() || !bEndNoteOnly ))
|
||
nSectNo = rFtn.IsEndNote()
|
||
? rEndInfo.nFtnOffset + (++nEndNo)
|
||
: rFtnInfo.nFtnOffset + (++nFtnNo);
|
||
|
||
if( nSectNo )
|
||
{
|
||
if( rFtn.IsEndNote() )
|
||
pTxtFtn->SetNumber( nSectNo, &rFtn.GetNumStr() );
|
||
else
|
||
pTxtFtn->SetNumber( nSectNo, &rFtn.GetNumStr() );
|
||
}
|
||
}
|
||
}
|
||
|
||
if( pDoc->GetRootFrm() && FTNNUM_PAGE == rFtnInfo.eNum )
|
||
pDoc->GetRootFrm()->UpdateFtnNums();
|
||
}
|
||
|
||
SwTxtFtn* SwFtnIdxs::SeekEntry( const SwNodeIndex& rPos, USHORT* pFndPos ) const
|
||
{
|
||
ULONG nIdx = rPos.GetIndex();
|
||
|
||
USHORT nO = Count(), nM, nU = 0;
|
||
if( nO > 0 )
|
||
{
|
||
nO--;
|
||
while( nU <= nO )
|
||
{
|
||
nM = nU + ( nO - nU ) / 2;
|
||
ULONG nNdIdx = _SwTxtFtn_GetIndex( (*this)[ nM ] );
|
||
if( nNdIdx == nIdx )
|
||
{
|
||
if( pFndPos )
|
||
*pFndPos = nM;
|
||
return (*this)[ nM ];
|
||
}
|
||
else if( nNdIdx < nIdx )
|
||
nU = nM + 1;
|
||
else if( nM == 0 )
|
||
{
|
||
if( pFndPos )
|
||
*pFndPos = nU;
|
||
return 0;
|
||
}
|
||
else
|
||
nO = nM - 1;
|
||
}
|
||
}
|
||
if( pFndPos )
|
||
*pFndPos = nU;
|
||
return 0;
|
||
}
|
||
|
||
/* */
|
||
|
||
const SwSectionNode* SwUpdFtnEndNtAtEnd::FindSectNdWithEndAttr(
|
||
const SwTxtFtn& rTxtFtn )
|
||
{
|
||
USHORT nWh = static_cast<USHORT>( rTxtFtn.GetFtn().IsEndNote() ?
|
||
RES_END_AT_TXTEND : RES_FTN_AT_TXTEND );
|
||
USHORT nVal;
|
||
const SwSectionNode* pNd = rTxtFtn.GetTxtNode().FindSectionNode();
|
||
while( pNd && FTNEND_ATTXTEND_OWNNUMSEQ != ( nVal =
|
||
((const SwFmtFtnAtTxtEnd&)pNd->GetSection().GetFmt()->
|
||
GetFmtAttr( nWh, TRUE )).GetValue() ) &&
|
||
FTNEND_ATTXTEND_OWNNUMANDFMT != nVal )
|
||
pNd = pNd->StartOfSectionNode()->FindSectionNode();
|
||
|
||
return pNd;
|
||
}
|
||
|
||
USHORT SwUpdFtnEndNtAtEnd::GetNumber( const SwTxtFtn& rTxtFtn,
|
||
const SwSectionNode& rNd )
|
||
{
|
||
USHORT nRet = 0, nWh;
|
||
SvPtrarr* pArr;
|
||
SvUShorts* pNum;
|
||
if( rTxtFtn.GetFtn().IsEndNote() )
|
||
{
|
||
pArr = &aEndSects;
|
||
pNum = &aEndNums;
|
||
nWh = RES_END_AT_TXTEND;
|
||
}
|
||
else
|
||
{
|
||
pArr = &aFtnSects;
|
||
pNum = &aFtnNums;
|
||
nWh = RES_FTN_AT_TXTEND;
|
||
}
|
||
void* pNd = (void*)&rNd;
|
||
|
||
for( USHORT n = pArr->Count(); n; )
|
||
if( pArr->GetObject( --n ) == pNd )
|
||
{
|
||
nRet = ++pNum->GetObject( n );
|
||
break;
|
||
}
|
||
|
||
if( !nRet )
|
||
{
|
||
pArr->Insert( pNd, pArr->Count() );
|
||
nRet = ((SwFmtFtnEndAtTxtEnd&)rNd.GetSection().GetFmt()->
|
||
GetFmtAttr( nWh )).GetOffset();
|
||
++nRet;
|
||
pNum->Insert( nRet, pNum->Count() );
|
||
}
|
||
return nRet;
|
||
}
|
||
|
||
USHORT SwUpdFtnEndNtAtEnd::ChkNumber( const SwTxtFtn& rTxtFtn )
|
||
{
|
||
const SwSectionNode* pSectNd = FindSectNdWithEndAttr( rTxtFtn );
|
||
return pSectNd ? GetNumber( rTxtFtn, *pSectNd ) : 0;
|
||
}
|
||
|
||
|
||
|
||
|