fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / autodoc / source / display / toolkit / htmlfile.cxx
blob561c66ed92f1351b4fcbe1c5aef835d437f3afa3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <precomp.h>
21 #include <toolkit/htmlfile.hxx>
23 // NOT FULLY DECLARED SERVICES
24 #include <cosv/file.hxx>
25 #include <udm/html/htmlitem.hxx>
27 namespace
29 bool bUse_OOoFrameDiv = true;
30 const String C_sOOoFrameDiv_IdlId("adc-idlref");
33 using namespace csi;
34 using csi::xml::AnAttribute;
36 DocuFile_Html::DocuFile_Html()
37 : sFilePath(),
38 sTitle(),
39 sLocation(),
40 sStyle(),
41 sCssFile(),
42 sCopyright(),
43 aBodyData(),
44 aBuffer(60000) // Grows dynamically, when necessary.
48 void
49 DocuFile_Html::SetLocation( const csv::ploc::Path & i_rFilePath )
51 StreamLock sPath(1000);
52 i_rFilePath.Get( sPath() );
54 sFilePath = sPath().c_str();
57 void
58 DocuFile_Html::SetTitle( const char * i_sTitle )
60 sTitle = i_sTitle;
63 void
64 DocuFile_Html::SetRelativeCssPath( const char * i_sCssFile_relativePath )
66 sCssFile = i_sCssFile_relativePath;
69 void
70 DocuFile_Html::SetCopyright( const char * i_sCopyright )
72 sCopyright = i_sCopyright;
75 void
76 DocuFile_Html::EmptyBody()
78 aBodyData.SetContent(0);
80 if (bUse_OOoFrameDiv)
82 // Insert <div> tag to allow better formatting for OOo.
83 aBodyData
84 << new xml::XmlCode("<div id=\"")
85 << new xml::XmlCode(C_sOOoFrameDiv_IdlId)
86 << new xml::XmlCode("\">\n\n");
89 aBodyData
90 >> *new html::Label( "_top_" )
91 << " ";
94 bool
95 DocuFile_Html::CreateFile()
97 csv::File aFile(sFilePath, csv::CFM_CREATE);
98 if (NOT aFile.open())
100 Cerr() << "Can't create file " << sFilePath << "." << Endl();
101 return false;
104 WriteHeader(aFile);
105 WriteBody(aFile);
107 // Write end
108 static const char sCompletion[] = "\n</html>\n";
109 aFile.write( sCompletion );
111 aFile.close();
112 Cout() << '.' << Flush();
113 return true;
117 void
118 DocuFile_Html::WriteHeader( csv::File & io_aFile )
120 aBuffer.reset();
122 static const char s1[] =
123 "<html>\n<head>\n<title>";
124 static const char s2[] =
125 "</title>\n"
126 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n";
128 aBuffer.write( s1 );
129 aBuffer.write( sTitle );
130 aBuffer.write( s2 );
133 if (NOT sCssFile.empty())
135 static const char s3[] =
136 "<link rel=\"stylesheet\" type=\"text/css\" href=\"";
137 static const char s4[] =
138 "\">\n";
140 aBuffer.write(s3);
141 aBuffer.write(sCssFile);
142 aBuffer.write(s4);
145 if (NOT sStyle.empty())
147 static const char s5[] =
148 "<style>";
149 static const char s6[] =
150 "</style>\n";
152 aBuffer.write(s5);
153 aBuffer.write(sStyle);
154 aBuffer.write(s6);
157 static const char s7[] =
158 "</head>\n";
159 aBuffer.write(s7);
161 io_aFile.write(aBuffer.c_str(), aBuffer.size());
164 void
165 DocuFile_Html::WriteBody( csv::File & io_aFile )
167 aBuffer.reset();
169 aBodyData
170 >> *new html::Link( "#_top_" )
171 << "Top of Page";
173 if ( sCopyright.length() > 0 )
175 aBodyData
176 << new xml::XmlCode("<hr size=\"3\">");
178 aBodyData
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.
188 aBodyData
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: */