1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef ADC_CPP_SRECOVER_HXX
29 #define ADC_CPP_SRECOVER_HXX
30 
31 
32 
33 // USED SERVICES
34 	// BASE CLASSES
35 #include "cxt2ary.hxx"
36 #include <ary/info/docstore.hxx>
37 	// COMPONENTS
38 	// PARAMETERS
39 
40 namespace cpp
41 {
42 
43 /** Implementation struct for cpp::ContextForAry.
44 */
45 struct ContextForAry::S_RecoveryGuard
46 {
47   public:
48                         S_RecoveryGuard();
49                         ~S_RecoveryGuard();
50 
51     void                Reset()                 { bIsWithinRecovery = false; nBlockBracketsCounter = 0; }
52 
53     void                StartWaitingFor_Recovery();
54 
55     void                Hdl_SwBracketOpen();
56     void                Hdl_SwBracketClose();
57     void                Hdl_Semicolon();
58 
59     bool                IsWithinRecovery() const;
60 
61   private:
62     // DATA
63     bool                bIsWithinRecovery;
64     intt                nBlockBracketsCounter;
65 };
66 
67 
68 
69 // IMPLEMENTATION
70 
71 /*  The implementation is in header, though not all inline, because this file
72     is included in cxt2ary.cxx only!
73 */
74 
75 ContextForAry::
76 S_RecoveryGuard::S_RecoveryGuard()
77     :   bIsWithinRecovery(false),
78         nBlockBracketsCounter(0)
79 {
80 }
81 
82 ContextForAry::
83 S_RecoveryGuard::~S_RecoveryGuard()
84 {
85 }
86 
87 inline void
88 ContextForAry::
89 S_RecoveryGuard::StartWaitingFor_Recovery()
90 {
91     bIsWithinRecovery = true;
92     nBlockBracketsCounter = 0;
93 }
94 
95 void
96 ContextForAry::
97 S_RecoveryGuard::Hdl_SwBracketOpen()
98 {
99     if ( bIsWithinRecovery )
100         ++nBlockBracketsCounter;
101 }
102 
103 void
104 ContextForAry::
105 S_RecoveryGuard::Hdl_SwBracketClose()
106 {
107     if ( bIsWithinRecovery )
108         --nBlockBracketsCounter;
109 }
110 
111 inline void
112 ContextForAry::
113 S_RecoveryGuard::Hdl_Semicolon()
114 {
115     if (bIsWithinRecovery AND nBlockBracketsCounter == 0)
116        bIsWithinRecovery = false;
117 }
118 
119 inline bool
120 ContextForAry::
121 S_RecoveryGuard::IsWithinRecovery() const
122 {
123     return bIsWithinRecovery;
124 }
125 
126 
127 
128 }   // namespace cpp
129 
130 
131 #endif
132 
133