Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <node.hxx>
30 : : #include <doc.hxx>
31 : : #include <pam.hxx>
32 : : #include <ndtxt.hxx>
33 : : #include <fldbas.hxx> // UpdateFlds der KapitelNummerierung
34 : : #include <docary.hxx>
35 : :
36 : 8046 : bool CompareSwOutlineNodes::operator()( SwNode* const& lhs, SwNode* const& rhs) const
37 : : {
38 : 8046 : return lhs->GetIndex() < rhs->GetIndex();
39 : : }
40 : :
41 : 0 : bool SwOutlineNodes::Seek_Entry(SwNode* const &rP, sal_uInt16* pnPos) const
42 : : {
43 [ # # ]: 0 : const_iterator it = lower_bound(rP);
44 [ # # ]: 0 : *pnPos = it - begin();
45 [ # # ][ # # ]: 0 : return it != end() && rP->GetIndex() == (*it)->GetIndex();
[ # # ][ # # ]
[ # # ]
46 : : }
47 : :
48 : 140147 : void SwNodes::UpdateOutlineNode(SwNode & rNd)
49 : : {
50 : 140147 : SwTxtNode * pTxtNd = rNd.GetTxtNode();
51 : :
52 [ + + ][ + + ]: 140147 : if (pTxtNd && pTxtNd->IsOutlineStateChanged())
[ + - ]
53 : : {
54 [ + - ][ + - ]: 1212 : sal_Bool bFound = pOutlineNds->find(pTxtNd) != pOutlineNds->end();
[ + - ]
55 : :
56 [ + + ]: 1212 : if (pTxtNd->IsOutline())
57 : : {
58 [ + - ]: 867 : if (! bFound)
59 : : {
60 : : // assure that text is in the correct nodes array
61 [ + - ]: 867 : if ( &(pTxtNd->GetNodes()) == this )
62 : : {
63 [ + - ][ + - ]: 867 : pOutlineNds->insert(pTxtNd);
64 : : }
65 : : else
66 : : {
67 : : OSL_FAIL( "<SwNodes::UpdateOutlineNode(..)> - given text node isn't in the correct nodes array. This is a serious defect -> inform OD" );
68 : : }
69 : : }
70 : : }
71 : : else
72 : : {
73 [ + - ]: 345 : if (bFound)
74 [ + - ][ + - ]: 345 : pOutlineNds->erase(pTxtNd);
75 : : }
76 : :
77 : 1212 : pTxtNd->UpdateOutlineState();
78 : :
79 : : // die Gliederungs-Felder Updaten
80 : 1212 : GetDoc()->GetSysFldType( RES_CHAPTERFLD )->UpdateFlds();
81 : : }
82 : 140147 : }
83 : :
84 : 324 : void SwNodes::UpdtOutlineIdx( const SwNode& rNd )
85 : : {
86 [ - + ]: 324 : if( pOutlineNds->empty() ) // keine OutlineNodes vorhanden ?
87 : : return;
88 : :
89 : 0 : const SwNodePtr pSrch = (SwNodePtr)&rNd;
90 : : sal_uInt16 nPos;
91 [ # # ]: 0 : pOutlineNds->Seek_Entry( pSrch, &nPos );
92 [ # # ]: 0 : if( nPos == pOutlineNds->size() ) // keine zum Updaten vorhanden ?
93 : : return;
94 : :
95 [ # # ]: 0 : if( nPos )
96 : 0 : --nPos;
97 : :
98 [ # # ][ # # ]: 0 : if( !GetDoc()->IsInDtor() && IsDocNodes() )
[ # # ][ # # ]
99 [ # # ][ # # ]: 324 : UpdateOutlineNode( *(*pOutlineNds)[ nPos ]);
100 : : }
101 : :
102 : 31 : const SwOutlineNodes & SwNodes::GetOutLineNds() const
103 : : {
104 : 31 : return *pOutlineNds;
105 : : }
106 : :
107 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|