1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: defdescr.cxx,v $
10 * $Revision: 1.6.18.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include "defdescr.hxx"
35 // NOT FULLY DEFINED SERVICES
47 DefineDescription::DefineDescription( const String
& i_sName
,
48 const str_vector
& i_rDefinition
)
51 aDefinition(i_rDefinition
),
52 eDefineType(type_define
)
56 DefineDescription::DefineDescription( const String
& i_sName
,
57 const str_vector
& i_rParams
,
58 const str_vector
& i_rDefinition
)
61 aDefinition(i_rDefinition
),
62 eDefineType(type_macro
)
66 DefineDescription::~DefineDescription()
71 DefineDescription::GetDefineText( csv::StreamStr
& o_rText
) const
73 if ( aDefinition
.begin() == aDefinition
.end() OR eDefineType
!= type_define
)
77 bool bSwitch_Stringify
= false;
78 bool bSwitch_Concatenate
= false;
80 for ( str_vector::const_iterator it
= aDefinition
.begin();
81 it
!= aDefinition
.end();
84 if ( HandleOperatorsBeforeTextItem( o_rText
,
94 Do_bStringify_end(o_rText
, bSwitch_Stringify
);
97 o_rText
.seekp(-1, csv::cur
);
101 DefineDescription::GetMacroText( csv::StreamStr
& o_rText
,
102 const StringVector
& i_rGivenArguments
) const
104 bool bSwitch_Stringify
= false;
105 bool bSwitch_Concatenate
= false;
106 intt nActiveParamNr
= -1;
108 if ( aDefinition
.begin() == aDefinition
.end() OR eDefineType
!= type_macro
)
111 for ( str_vector::const_iterator it
= aDefinition
.begin();
112 it
!= aDefinition
.end();
115 if ( HandleOperatorsBeforeTextItem( o_rText
,
123 for ( str_vector::const_iterator param_it
= aParams
.begin();
124 param_it
!= aParams
.end() AND nActiveParamNr
== -1;
127 if ( strcmp(*it
, *param_it
) == 0 )
128 nActiveParamNr
= param_it
- aParams
.begin();
130 if ( nActiveParamNr
== -1 )
136 o_rText
<< i_rGivenArguments
[nActiveParamNr
];
140 Do_bStringify_end(o_rText
, bSwitch_Stringify
);
143 o_rText
.seekp(-1, csv::cur
);
148 } // end namespace cpp
155 CheckForOperator( bool & o_bStringify
,
156 bool & o_bConcatenate
,
157 const String
& i_sTextItem
)
159 if ( strcmp(i_sTextItem
, "##") == 0 )
161 o_bConcatenate
= true;
164 else if ( strcmp(i_sTextItem
, "#") == 0 )
173 Do_bConcatenate( csv::StreamStr
& o_rText
,
174 bool & io_bConcatenate
)
176 if ( io_bConcatenate
)
179 for ( nPos
= o_rText
.tellp() - 1;
180 nPos
> 0 ? o_rText
.c_str()[nPos
] == ' ' : false;
182 o_rText
.seekp(nPos
+1);
183 io_bConcatenate
= false;
188 Do_bStringify_begin( csv::StreamStr
& o_rText
,
198 Do_bStringify_end( csv::StreamStr
& o_rText
,
199 bool & io_bStringify
)
204 io_bStringify
= false;
210 HandleOperatorsBeforeTextItem( csv::StreamStr
& o_rText
,
211 bool & io_bStringify
,
212 bool & io_bConcatenate
,
213 const String
& i_sTextItem
)
215 if ( CheckForOperator( io_bStringify
,
221 Do_bConcatenate(o_rText
, io_bConcatenate
);
222 Do_bStringify_begin(o_rText
, io_bStringify
);