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: cr_metho.cxx,v $
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 ************************************************************************/
31 #include "cr_metho.hxx"
39 const char C_sFileHeader1
[]
41 const char C_sFileHeader2
[]
42 = " */\r\n/* Implementation of component_getDescriptionFunc() */\r\n\r\n"
43 "#include <sal/types.h>\r\n\r\n";
44 const char C_sFuncBegin
[]
45 = "#ifdef __cplusplus\r\n"
48 "const sal_Char * SAL_CALL\r\ncomponent_getDescriptionFunc()\r\n"
50 " return (const sal_Char*) \r\n"
52 const char C_sFuncEnd
[] = "\";\r\n"
54 "#ifdef __cplusplus\r\n"
55 "} /* end of extern \"C\" */\r\n"
60 Create_AccessMethod( const char * i_pOutputFileName
,
61 const char * i_sText
)
63 const char * pText
= i_sText
;
64 const char * pTrans
= 0;
65 const char sDescrLineChange
[] = "\"\r\n \"";
66 int sDescrLen
= (int) strlen(sDescrLineChange
);
68 std::ofstream
aFile(i_pOutputFileName
, std::ios::out
69 #if defined(WNT) || defined(OS2)
77 std::cerr
<< "Error: " << i_pOutputFileName
<< " could not be created." << std::endl
;
81 aFile
.write( C_sFileHeader1
, (int) strlen(C_sFileHeader1
) );
82 aFile
.write( i_pOutputFileName
, (int) strlen(i_pOutputFileName
) );
83 aFile
.write( C_sFileHeader2
, (int) strlen(C_sFileHeader2
) );
84 aFile
.write( C_sFuncBegin
, (int) strlen(C_sFuncBegin
) );
86 for ( pTrans
= pText
; *pTrans
!= '\0'; pTrans
++ )
90 case '"': aFile
.write( "\\\"", 2);
92 case '\n': aFile
.write( "\\n", 2);
93 aFile
.write( sDescrLineChange
, sDescrLen
);
95 case '\r': aFile
.write( "\\r", 2);
97 // case '\t': aFile.write( "\\t", 2);
99 default: aFile
.write( pTrans
, 1);
103 aFile
.write( C_sFuncEnd
, (int) strlen(C_sFuncEnd
) );