1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <toolkit/htmlfile.hxx>
23 // NOT FULLY DECLARED SERVICES
24 #include <cosv/file.hxx>
25 #include <udm/html/htmlitem.hxx>
29 bool bUse_OOoFrameDiv
= true;
30 const String
C_sOOoFrameDiv_IdlId("adc-idlref");
34 using csi::xml::AnAttribute
;
36 DocuFile_Html::DocuFile_Html()
44 aBuffer(60000) // Grows dynamically, when necessary.
49 DocuFile_Html::SetLocation( const csv::ploc::Path
& i_rFilePath
)
51 StreamLock
sPath(1000);
52 i_rFilePath
.Get( sPath() );
54 sFilePath
= sPath().c_str();
58 DocuFile_Html::SetTitle( const char * i_sTitle
)
64 DocuFile_Html::SetRelativeCssPath( const char * i_sCssFile_relativePath
)
66 sCssFile
= i_sCssFile_relativePath
;
70 DocuFile_Html::SetCopyright( const char * i_sCopyright
)
72 sCopyright
= i_sCopyright
;
76 DocuFile_Html::EmptyBody()
78 aBodyData
.SetContent(0);
82 // Insert <div> tag to allow better formatting for OOo.
84 << new xml::XmlCode("<div id=\"")
85 << new xml::XmlCode(C_sOOoFrameDiv_IdlId
)
86 << new xml::XmlCode("\">\n\n");
90 >> *new html::Label( "_top_" )
95 DocuFile_Html::CreateFile()
97 csv::File
aFile(sFilePath
, csv::CFM_CREATE
);
100 Cerr() << "Can't create file " << sFilePath
<< "." << Endl();
108 static const char sCompletion
[] = "\n</html>\n";
109 aFile
.write( sCompletion
);
112 Cout() << '.' << Flush();
118 DocuFile_Html::WriteHeader( csv::File
& io_aFile
)
122 static const char s1
[] =
123 "<html>\n<head>\n<title>";
124 static const char s2
[] =
126 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n";
129 aBuffer
.write( sTitle
);
133 if (NOT sCssFile
.empty())
135 static const char s3
[] =
136 "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
137 static const char s4
[] =
141 aBuffer
.write(sCssFile
);
145 if (NOT sStyle
.empty())
147 static const char s5
[] =
149 static const char s6
[] =
153 aBuffer
.write(sStyle
);
157 static const char s7
[] =
161 io_aFile
.write(aBuffer
.c_str(), aBuffer
.size());
165 DocuFile_Html::WriteBody( csv::File
& io_aFile
)
170 >> *new html::Link( "#_top_" )
173 if ( sCopyright
.length() > 0 )
176 << new xml::XmlCode("<hr size=\"3\">");
179 >> *new html::Paragraph
180 << new html::ClassAttr( "copyright" )
181 << new xml::AnAttribute( "align", "center" )
182 << new xml::XmlCode(sCopyright
);
185 if (bUse_OOoFrameDiv
)
187 // Insert <div> tag to allow better formatting for OOo.
189 << new xml::XmlCode("\n</div> <!-- id=\"")
190 << new xml::XmlCode(C_sOOoFrameDiv_IdlId
)
191 << new xml::XmlCode("\" -->\n");
194 aBodyData
.WriteOut(aBuffer
);
195 io_aFile
.write(aBuffer
.c_str(), aBuffer
.size());
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */