merge the formfield patch from ooo-build
[ooovba.git] / xml2cmp / source / xcd / cr_metho.cxx
blobbfad50400c61386e8952a8613a99da4b8991ac61
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cr_metho.cxx,v $
10 * $Revision: 1.10 $
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"
33 #include <string.h>
34 #include <fstream>
35 #include <iostream>
39 const char C_sFileHeader1[]
40 = "/* ";
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"
46 "extern \"C\" {\r\n"
47 "#endif\r\n\r\n"
48 "const sal_Char * SAL_CALL\r\ncomponent_getDescriptionFunc()\r\n"
49 "{\r\n"
50 " return (const sal_Char*) \r\n"
51 " \"";
52 const char C_sFuncEnd[] = "\";\r\n"
53 "}\r\n\r\n"
54 "#ifdef __cplusplus\r\n"
55 "} /* end of extern \"C\" */\r\n"
56 "#endif\r\n";
59 void
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)
70 | std::ios::binary
71 #endif
75 if ( !aFile )
77 std::cerr << "Error: " << i_pOutputFileName << " could not be created." << std::endl;
78 return;
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++ )
88 switch (*pTrans)
90 case '"': aFile.write( "\\\"", 2);
91 break;
92 case '\n': aFile.write( "\\n", 2);
93 aFile.write( sDescrLineChange, sDescrLen);
94 break;
95 case '\r': aFile.write( "\\r", 2);
96 break;
97 // case '\t': aFile.write( "\\t", 2);
98 // break;
99 default: aFile.write( pTrans, 1);
101 } /* end for */
103 aFile.write( C_sFuncEnd, (int) strlen(C_sFuncEnd) );
106 aFile.close();