• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdehtml
 

tdehtml

  • tdehtml
tdehtml_factory.cpp
1/* This file is part of the KDE project
2 *
3 * Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include "tdehtml_factory.h"
22#include "tdehtml_part.h"
23#include "tdehtml_settings.h"
24
25#include "css/cssstyleselector.h"
26#include "html/html_imageimpl.h"
27#include "rendering/render_style.h"
28#include "rendering/break_lines.h"
29#include "misc/loader.h"
30#include "misc/arena.h"
31
32#include <kinstance.h>
33#include <tdeaboutdata.h>
34#include <tdelocale.h>
35
36#include <assert.h>
37
38#include <kdebug.h>
39
40template class TQPtrList<TDEHTMLPart>;
41
42extern "C" TDE_EXPORT void *init_libtdehtml()
43{
44 // We can't use a plain self() here, because that would
45 // return the global factory, which might already exist
46 // at the time init_libtdehtml is called! As soon as someone
47 // does new TDEHTMLPart() in his application and loads up
48 // an html document into that part which either embeds
49 // embeds another TDEHTMLPart instance via <object> or
50 // as html frame, then we cannot return self(), as
51 // what we return here is what the KLibLoader deletes
52 // in the end, and we don't want the libloader to
53 // delete our global instance. Anyway, the new
54 // TDEHTMLFactory we create here is very cheap :)
55 // (Simon)
56 return new TDEHTMLFactory( true );
57}
58
59TDEHTMLFactory *TDEHTMLFactory::s_self = 0;
60unsigned long int TDEHTMLFactory::s_refcnt = 0;
61TDEInstance *TDEHTMLFactory::s_instance = 0;
62TDEAboutData *TDEHTMLFactory::s_about = 0;
63TDEHTMLSettings *TDEHTMLFactory::s_settings = 0;
64TQPtrList<TDEHTMLPart> *TDEHTMLFactory::s_parts = 0;
65TQString *TDEHTMLSettings::avFamilies = 0;
66
67TDEHTMLFactory::TDEHTMLFactory( bool clone )
68{
69 if ( clone )
70 ref();
71}
72
73TDEHTMLFactory::~TDEHTMLFactory()
74{
75 if ( s_self == this )
76 {
77 assert( !s_refcnt );
78
79 delete s_instance;
80 delete s_about;
81 delete s_settings;
82 delete TDEHTMLSettings::avFamilies;
83 if ( s_parts )
84 {
85 assert( s_parts->isEmpty() );
86 delete s_parts;
87 }
88
89 s_instance = 0;
90 s_about = 0;
91 s_settings = 0;
92 s_parts = 0;
93 TDEHTMLSettings::avFamilies = 0;
94
95 // clean up static data
96 tdehtml::CSSStyleSelector::clear();
97 tdehtml::RenderStyle::cleanup();
98 tdehtml::Cache::clear();
99 tdehtml::cleanup_thaibreaks();
100 tdehtml::ArenaFinish();
101 }
102 else
103 deref();
104}
105
106KParts::Part *TDEHTMLFactory::createPartObject( TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const char *className, const TQStringList & )
107{
108 TDEHTMLPart::GUIProfile prof = TDEHTMLPart::DefaultGUI;
109 if ( strcmp( className, "Browser/View" ) == 0 )
110 prof = TDEHTMLPart::BrowserViewGUI;
111
112 return new TDEHTMLPart( parentWidget, widgetName, parent, name, prof );
113}
114
115void TDEHTMLFactory::ref()
116{
117 if ( !s_refcnt && !s_self )
118 {
119 // we can't use a staticdeleter here, because that would mean
120 // that the factory gets deleted from within a qPostRoutine, called
121 // from the TQApplication destructor. That however is too late, because
122 // we want to destruct a TDEInstance object, which involves destructing
123 // a TDEConfig object, which might call TDEGlobal::dirs() (in sync()) which
124 // probably is not going to work ;-)
125 // well, perhaps I'm wrong here, but as I'm unsure I try to stay on the
126 // safe side ;-) -> let's use a simple reference counting scheme
127 // (Simon)
128 s_self = new TDEHTMLFactory;
129 tdehtml::Cache::init();
130 }
131
132 s_refcnt++;
133}
134
135void TDEHTMLFactory::deref()
136{
137 if ( !--s_refcnt && s_self )
138 {
139 delete s_self;
140 s_self = 0;
141 }
142}
143
144void TDEHTMLFactory::registerPart( TDEHTMLPart *part )
145{
146 if ( !s_parts )
147 s_parts = new TQPtrList<TDEHTMLPart>;
148
149 if ( !s_parts->containsRef( part ) )
150 {
151 s_parts->append( part );
152 ref();
153 }
154}
155
156void TDEHTMLFactory::deregisterPart( TDEHTMLPart *part )
157{
158 assert( s_parts );
159
160 if ( s_parts->removeRef( part ) )
161 {
162 if ( s_parts->isEmpty() )
163 {
164 delete s_parts;
165 s_parts = 0;
166 }
167 deref();
168 }
169}
170
171TDEInstance *TDEHTMLFactory::instance()
172{
173 assert( s_self );
174
175 if ( !s_instance )
176 {
177 s_about = new TDEAboutData( "tdehtml", I18N_NOOP( "TDEHTML" ), "4.0",
178 I18N_NOOP( "Embeddable HTML component" ),
179 TDEAboutData::License_LGPL );
180 s_about->addAuthor( "Lars Knoll", 0, "knoll@kde.org" );
181 s_about->addAuthor( "Antti Koivisto", 0, "koivisto@kde.org" );
182 s_about->addAuthor( "Waldo Bastian", 0, "bastian@kde.org" );
183 s_about->addAuthor( "Dirk Mueller", 0, "mueller@kde.org" );
184 s_about->addAuthor( "Peter Kelly", 0, "pmk@kde.org" );
185 s_about->addAuthor( "Torben Weis", 0, "weis@kde.org" );
186 s_about->addAuthor( "Martin Jones", 0, "mjones@kde.org" );
187 s_about->addAuthor( "Simon Hausmann", 0, "hausmann@kde.org" );
188 s_about->addAuthor( "Tobias Anton", 0, "anton@stud.fbi.fh-darmstadt.de" );
189
190 s_instance = new TDEInstance( s_about );
191 }
192
193 return s_instance;
194}
195
196TDEHTMLSettings *TDEHTMLFactory::defaultHTMLSettings()
197{
198 assert( s_self );
199 if ( !s_settings )
200 s_settings = new TDEHTMLSettings();
201
202 return s_settings;
203}
204
205using namespace KParts;
206#include "tdehtml_factory.moc"
207
KParts::Part
TDEAboutData
TDEHTMLPart
This class is tdehtml's main class.
Definition: tdehtml_part.h:184
TDEHTMLSettings
Settings for the HTML view.
Definition: tdehtml_settings.h:39
TDEInstance
I18N_NOOP
#define I18N_NOOP(x)
tdelocale.h

tdehtml

Skip menu "tdehtml"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdehtml

Skip menu "tdehtml"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdehtml by doxygen 1.9.4
This website is maintained by Timothy Pearson.