1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <toolkit/htmlfile.hxx>
32 // NOT FULLY DECLARED SERVICES
33 #include <cosv/file.hxx>
34 #include <udm/html/htmlitem.hxx>
38 bool bUse_OOoFrameDiv
= true;
39 const String
C_sOOoFrameDiv_IdlId("adc-idlref");
43 using csi::xml::AnAttribute
;
45 DocuFile_Html::DocuFile_Html()
53 aBuffer(60000) // Grows dynamically, when necessary.
58 DocuFile_Html::SetLocation( const csv::ploc::Path
& i_rFilePath
)
60 StreamLock
sPath(1000);
61 i_rFilePath
.Get( sPath() );
63 sFilePath
= sPath().c_str();
67 DocuFile_Html::SetTitle( const char * i_sTitle
)
73 DocuFile_Html::SetRelativeCssPath( const char * i_sCssFile_relativePath
)
75 sCssFile
= i_sCssFile_relativePath
;
79 DocuFile_Html::SetCopyright( const char * i_sCopyright
)
81 sCopyright
= i_sCopyright
;
85 DocuFile_Html::EmptyBody()
87 aBodyData
.SetContent(0);
91 // Insert <div> tag to allow better formatting for OOo.
93 << new xml::XmlCode("<div id=\"")
94 << new xml::XmlCode(C_sOOoFrameDiv_IdlId
)
95 << new xml::XmlCode("\">\n\n");
99 >> *new html::Label( "_top_" )
104 DocuFile_Html::CreateFile()
106 csv::File
aFile(sFilePath
, csv::CFM_CREATE
);
107 if (NOT aFile
.open())
109 Cerr() << "Can't create file " << sFilePath
<< "." << Endl();
117 static const char sCompletion
[] = "\n</html>\n";
118 aFile
.write( sCompletion
);
121 Cout() << '.' << Flush();
127 DocuFile_Html::WriteHeader( csv::File
& io_aFile
)
131 static const char s1
[] =
132 "<html>\n<head>\n<title>";
133 static const char s2
[] =
135 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n";
138 aBuffer
.write( sTitle
);
142 if (NOT sCssFile
.empty())
144 static const char s3
[] =
145 "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
146 static const char s4
[] =
150 aBuffer
.write(sCssFile
);
154 if (NOT sStyle
.empty())
156 static const char s5
[] =
158 static const char s6
[] =
162 aBuffer
.write(sStyle
);
166 static const char s7
[] =
170 io_aFile
.write(aBuffer
.c_str(), aBuffer
.size());
174 DocuFile_Html::WriteBody( csv::File
& io_aFile
)
179 >> *new html::Link( "#_top_" )
182 if ( sCopyright
.length() > 0 )
185 << new xml::XmlCode("<hr size=\"3\">");
188 >> *new html::Paragraph
189 << new html::ClassAttr( "copyright" )
190 << new xml::AnAttribute( "align", "center" )
191 << new xml::XmlCode(sCopyright
);
194 if (bUse_OOoFrameDiv
)
196 // Insert <div> tag to allow better formatting for OOo.
198 << new xml::XmlCode("\n</div> <!-- id=\"")
199 << new xml::XmlCode(C_sOOoFrameDiv_IdlId
)
200 << new xml::XmlCode("\" -->\n");
203 aBodyData
.WriteOut(aBuffer
);
204 io_aFile
.write(aBuffer
.c_str(), aBuffer
.size());
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */