1*cdf0e10cSrcweir/*************************************************************************
2*cdf0e10cSrcweir *
3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir *
5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir *
7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir *
9*cdf0e10cSrcweir * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir *
11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir *
15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir *
21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir *
26*cdf0e10cSrcweir ************************************************************************/
27*cdf0e10cSrcweir
28*cdf0e10cSrcweir#ifndef __com_sun_star_util_XStringSubstitution_idl__
29*cdf0e10cSrcweir#define __com_sun_star_util_XStringSubstitution_idl__
30*cdf0e10cSrcweir
31*cdf0e10cSrcweir#ifndef __com_sun_star_uno_XInterface_idl__
32*cdf0e10cSrcweir#include <com/sun/star/uno/XInterface.idl>
33*cdf0e10cSrcweir#endif
34*cdf0e10cSrcweir
35*cdf0e10cSrcweir#ifndef __com_sun_star_container_NoSuchElementException_idl__
36*cdf0e10cSrcweir#include <com/sun/star/container/NoSuchElementException.idl>
37*cdf0e10cSrcweir#endif
38*cdf0e10cSrcweir
39*cdf0e10cSrcweir//=============================================================================
40*cdf0e10cSrcweir
41*cdf0e10cSrcweir module com {  module sun {  module star {  module  util {
42*cdf0e10cSrcweir
43*cdf0e10cSrcweir//=============================================================================
44*cdf0e10cSrcweir/** A common interface for substituting string variables with
45*cdf0e10cSrcweir	other strings.
46*cdf0e10cSrcweir
47*cdf0e10cSrcweir	<p>
48*cdf0e10cSrcweir	The substitution algorithm and the syntax for a string variable are
49*cdf0e10cSrcweir	not part of this interface definition.	Please look at the documentation
50*cdf0e10cSrcweir	of the implementation that must	specify these parameters.
51*cdf0e10cSrcweir	</p>
52*cdf0e10cSrcweir
53*cdf0e10cSrcweir    @since OOo 1.1.2
54*cdf0e10cSrcweir*/
55*cdf0e10cSrcweirpublished interface XStringSubstitution : com::sun::star::uno::XInterface
56*cdf0e10cSrcweir{
57*cdf0e10cSrcweir	//-------------------------------------------------------------------------
58*cdf0e10cSrcweir	/** Exchanges variables inside a given text with a substitution text
59*cdf0e10cSrcweir        defined for the variables.
60*cdf0e10cSrcweir
61*cdf0e10cSrcweir		<p>
62*cdf0e10cSrcweir		The method iterates through it's internal variables list to match the
63*cdf0e10cSrcweir		variables in the given string. A match replaces the variable with the
64*cdf0e10cSrcweir		string defined for this variable. If no variable can be found in the string
65*cdf0e10cSrcweir		it will be returned unchanged. The behavior if a variable is found in
66*cdf0e10cSrcweir		the string but it is unknown for the implementation depends on the parameter
67*cdf0e10cSrcweir		bSubstRequired.
68*cdf0e10cSrcweir		</p>
69*cdf0e10cSrcweir
70*cdf0e10cSrcweir		@param aText
71*cdf0e10cSrcweir            A string containing variables that should be substituted.
72*cdf0e10cSrcweir
73*cdf0e10cSrcweir		@param bSubstRequired
74*cdf0e10cSrcweir			Specifies if a successfull substitution is required. The
75*cdf0e10cSrcweir			function throws a <type scope="com::sun::star::container">NoSuchElementException</type>
76*cdf0e10cSrcweir			if it finds a variable that is unknown. In this case it is possible
77*cdf0e10cSrcweir			that the returned string would not be what the caller expected!
78*cdf0e10cSrcweir
79*cdf0e10cSrcweir		@return
80*cdf0e10cSrcweir            Returns a string based on <var>aText</var> where all variables were
81*cdf0e10cSrcweir			exchanged with their value defined at calling time.
82*cdf0e10cSrcweir	*/
83*cdf0e10cSrcweir	string substituteVariables( [in] string aText, [in] boolean bSubstRequired )
84*cdf0e10cSrcweir		raises( com::sun::star::container::NoSuchElementException );
85*cdf0e10cSrcweir
86*cdf0e10cSrcweir	//-------------------------------------------------------------------------
87*cdf0e10cSrcweir	/** Tries to replace parts of aText with variables that represents
88*cdf0e10cSrcweir		these sub strings.
89*cdf0e10cSrcweir
90*cdf0e10cSrcweir		<p>
91*cdf0e10cSrcweir		The method iterates through it's internal variable list and tries to match
92*cdf0e10cSrcweir		parts of the given string Tries to replace parts of <var>aText</var> with
93*cdf0e10cSrcweir		variables that represents these sub strings.If more than one variable
94*cdf0e10cSrcweir		matches the one with the longest matching sub string will be chosen.
95*cdf0e10cSrcweir		</p>
96*cdf0e10cSrcweir
97*cdf0e10cSrcweir		@param aText
98*cdf0e10cSrcweir            A string where known substrings should be replaced by variables.
99*cdf0e10cSrcweir
100*cdf0e10cSrcweir        @return
101*cdf0e10cSrcweir            Returns the resubstituted string with variables for all parts
102*cdf0e10cSrcweir			that could be replaced. The unchanged argument will be returned
103*cdf0e10cSrcweir			if nothing can be resubtituted.
104*cdf0e10cSrcweir	*/
105*cdf0e10cSrcweir
106*cdf0e10cSrcweir	string reSubstituteVariables( [in] string aText );
107*cdf0e10cSrcweir
108*cdf0e10cSrcweir	//-------------------------------------------------------------------------
109*cdf0e10cSrcweir	/** Returns the current value of a variable.
110*cdf0e10cSrcweir
111*cdf0e10cSrcweir		<p>
112*cdf0e10cSrcweir		The method iterates through it's internal variable list and tries to
113*cdf0e10cSrcweir		find the given variable. If the variable is unkown a
114*cdf0e10cSrcweir		<type scope="com::sun::star::container">NoSuchElementException</type>
115*cdf0e10cSrcweir		is thrown.
116*cdf0e10cSrcweir		</p>
117*cdf0e10cSrcweir
118*cdf0e10cSrcweir        @param variable
119*cdf0e10cSrcweir            The name of a variable.
120*cdf0e10cSrcweir
121*cdf0e10cSrcweir        @return
122*cdf0e10cSrcweir            Returns a string that represents the variable. If the
123*cdf0e10cSrcweir			variable is unknown a <type scope="com::sun::star::container">NoSuchElementException</type>
124*cdf0e10cSrcweir			is thrown.
125*cdf0e10cSrcweir	*/
126*cdf0e10cSrcweir	string getSubstituteVariableValue( [in] string variable )
127*cdf0e10cSrcweir		raises (::com::sun::star::container::NoSuchElementException );
128*cdf0e10cSrcweir};
129*cdf0e10cSrcweir
130*cdf0e10cSrcweir//=============================================================================
131*cdf0e10cSrcweir
132*cdf0e10cSrcweir}; }; }; };
133*cdf0e10cSrcweir
134*cdf0e10cSrcweir#endif
135