summaryrefslogtreecommitdiffstats
path: root/kounavail/kounavail.h
blob: afbdbaaf3d14f4000e919afa5b584545a5f01aa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/* This file is part of the KDE project
   Copyright (C) 2001 David Faure <faure@kde.org>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef KOUNAVAIL_H
#define KOUNAVAIL_H

#include <KoDocument.h>

class KoUnavailPart : public KoDocument
{
    Q_OBJECT
  
    TQ_PROPERTY( TQCString mimetype READ nativeFormatMimeType WRITE setMimeType )
    TQ_PROPERTY( TQString unavailReason READ unavailReason WRITE setUnavailReason )
    TQ_PROPERTY( TQString realURL READ realURL WRITE setRealURL )
public:
    KoUnavailPart( TQWidget *parentWidget = 0, const char *widgetName = 0, TQObject* parent = 0, const char* name = 0 );

    virtual void paintContent( TQPainter& painter, const TQRect& rect, bool transparent = FALSE, double zoomX = 1.0, double zoomY = 1.0 );

    virtual bool initDoc(InitDocFlags, TQWidget* = 0) { return true; }
    virtual bool loadOasis( const TQDomDocument& doc, KoOasisStyles& oasisStyles, const TQDomDocument& settings, KoStore* );
    virtual bool saveOasis(KoStore*, KoXmlWriter*);

    virtual bool loadXML( TQIODevice *, const TQDomDocument & );
    virtual bool saveFile();
    virtual TQDomDocument saveXML();
    virtual bool saveChildren( KoStore* /*_store*/ ) { return true; }

    /** This is called by KoDocumentChild::save */
    virtual TQCString nativeFormatMimeType() const { return m_mimetype; }
    /** This is called by KoDocumentChild::createUnavailDocument */
    void setMimeType( const TQCString& mime );
    // keep in sync with koDocumentChild.h
    enum UnavailReason { DocumentNotFound, HandlerNotFound };
    /** This is called by KoDocumentChild::createUnavailDocument */
    void setUnavailReason( const TQString& reason ) { m_reason = reason; }
    // stupid tqmoc - I want a write-only property !
    TQString unavailReason() const { return m_reason; }
    /** This is called by KoDocumentChild::createUnavailDocument
     * Note the trick: we directly modify the URL of the document,
     * the one returned by KPart's url()
     */
    void setRealURL( const TQString& u ) { m_url = u; }
    // stupid tqmoc again
    TQString realURL() const { return m_url.url(); }

protected:
    virtual KoView* createViewInstance( TQWidget* parent, const char* name );

    TQDomDocument m_doc;
    TQCString m_mimetype;
    TQString m_reason;
};

#include <KoView.h>

class KoUnavailView : public KoView
{
    Q_OBJECT
  
public:
    KoUnavailView( KoUnavailPart* part, TQWidget* parent = 0, const char* name = 0 );

protected:
    virtual void paintEvent( TQPaintEvent* );
    virtual void updateReadWrite( bool ) {}
};

#include <KoFactory.h>

class KInstance;
class KAboutData;

class KoUnavailFactory : public KoFactory
{
    Q_OBJECT
  
public:
    KoUnavailFactory( TQObject* parent = 0, const char* name = 0 );
    ~KoUnavailFactory();

    virtual KParts::Part *createPartObject( TQWidget *parentWidget = 0, const char *widgetName = 0, TQObject *parent = 0, const char *name = 0, const char *classname = "KoDocument", const TQStringList &args = TQStringList() );

    static KInstance* global();

    // _Creates_ a KAboutData but doesn't keep ownership
    static KAboutData* aboutData();

private:
    static KInstance* s_global;
    static KAboutData* s_aboutData;
};

#endif