xref: /aoo41x/main/basic/inc/basic/ttstrhlp.hxx (revision 234bd5c5)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _BASIC_TTSTRHLP_HXX
24 #define _BASIC_TTSTRHLP_HXX
25 
26 #include <tools/string.hxx>
27 
28 #define CByteString( constAsciiStr ) ByteString( RTL_CONSTASCII_STRINGPARAM ( constAsciiStr ) )
29 #define CUniString( constAsciiStr ) UniString( RTL_CONSTASCII_USTRINGPARAM ( constAsciiStr ) )
30 #define Str2Id( Str ) rtl::OUStringToOString( Str, RTL_TEXTENCODING_ASCII_US )
31 #define Id2Str( Id ) String( rtl::OStringToOUString( Id, RTL_TEXTENCODING_ASCII_US ) )
32 
33 #define StartKenn			CUniString("%")
34 #define EndKenn				CUniString("%")
35 #define UIdKenn				( StartKenn.AppendAscii("UId") )
36 #define MethodKenn			( StartKenn.AppendAscii("Method") )
37 #define TypeKenn			( StartKenn.AppendAscii("RType") )
38 #define SlotKenn			( StartKenn.AppendAscii("SlotId") )
39 #define RcKenn				( StartKenn.AppendAscii("RCommand") )
40 #define TabKenn				( StartKenn.AppendAscii("Tab") )
41 #define MakeStringParam(Type,aText)	( Type.AppendAscii("=").Append( aText ).Append( EndKenn ) )
42 #define MakeStringNumber(Type,nNumber)	MakeStringParam (Type, UniString::CreateFromInt32(nNumber))
43 #define UIdString(aID) MakeStringParam(UIdKenn,String(rtl::OStringToOUString( aID, RTL_TEXTENCODING_ASCII_US )))
44 #define MethodString(nNumber) MakeStringNumber(MethodKenn,nNumber)
45 #define TypeString(nNumber) MakeStringNumber(TypeKenn,nNumber)
46 #define SlotString(nNumber) MakeStringNumber(SlotKenn,nNumber)
47 #define RcString(nNumber) MakeStringNumber(RcKenn,nNumber)
48 #define TabString(nNumber) MakeStringNumber(TabKenn,nNumber)
49 
50 #define ResKenn				( StartKenn.AppendAscii("ResId") )
51 #define BaseArgKenn			( StartKenn.AppendAscii("Arg") )
52 #define ArgKenn(nNumber)	( BaseArgKenn.Append( UniString::CreateFromInt32(nNumber) ) )
53 #define ResString(nNumber) MakeStringNumber(ResKenn,nNumber)
54 #define ArgString(nNumber, aText) MakeStringParam(ArgKenn(nNumber),aText)
55 
56 UniString GEN_RES_STR0( sal_uIntPtr nResId );
57 UniString GEN_RES_STR1( sal_uIntPtr nResId, const String &Text1 );
58 UniString GEN_RES_STR2( sal_uIntPtr nResId, const String &Text1, const String &Text2 );
59 UniString GEN_RES_STR3( sal_uIntPtr nResId, const String &Text1, const String &Text2, const String &Text3 );
60 
61 #define GEN_RES_STR1c( nResId, Text1 ) GEN_RES_STR1( nResId, CUniString(Text1) )
62 #define GEN_RES_STR2c2( nResId, Text1, Text2 ) GEN_RES_STR2( nResId, Text1, CUniString(Text2) )
63 #define GEN_RES_STR3c3( nResId, Text1, Text2, Text3 ) GEN_RES_STR3( nResId, Text1, Text2, CUniString(Text3) )
64 
65 #define IMPL_GEN_RES_STR \
66 UniString GEN_RES_STR0( sal_uIntPtr nResId ) { return ResString( nResId ); } \
67 UniString GEN_RES_STR1( sal_uIntPtr nResId, const UniString &Text1 ) { return GEN_RES_STR0( nResId ).Append( ArgString( 1, Text1 ) ); } \
68 UniString GEN_RES_STR2( sal_uIntPtr nResId, const UniString &Text1, const UniString &Text2 ) { return GEN_RES_STR1( nResId, Text1 ).Append( ArgString( 2, Text2 ) ); } \
69 UniString GEN_RES_STR3( sal_uIntPtr nResId, const UniString &Text1, const UniString &Text2, const UniString &Text3 ) { return GEN_RES_STR2( nResId, Text1, Text2 ).Append( ArgString( 3, Text3 ) );}
70 
71 #endif
72 
73