summaryrefslogtreecommitdiffstats
path: root/kword/KWTextParag.h
blob: de484a485485d4e65bbea7645f2ad2e47c117794 (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
/* 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 kwtextparag_h
#define kwtextparag_h

#include "KoTextParag.h"

class KoStyleCollection;
class TQDomDocument;
class KWTextFrameSet;
class KWTextDocument;
class KWDocument;
class KWTextParag;
class KoParagStyle;

// At the moment those are the same - to be discussed
typedef KoParagLayout KWParagLayout;

/**
 * This class extends KoTextParag for KWord-specific formatting stuff,
 * custom items, loading and saving.
 */
class KWTextParag : public KoTextParag
{
public:
    KWTextParag( KoTextDocument *d, KoTextParag *pr = 0, KoTextParag *nx = 0, bool updateIds = TRUE )
        : KoTextParag( d, pr, nx, updateIds ) { }
    ~KWTextParag() { }

    KWTextDocument * kwTextDocument() const;

    virtual void setParagLayout( const KoParagLayout &layout, int flags = KoParagLayout::All, int marginIndex = -1 );

    /** The type of page-breaking behaviour */
    void setPageBreaking( int pb ); // warning this sets all the flags!
    int pageBreaking() const { return m_layout.pageBreaking; }
    bool linesTogether() const { return m_layout.pageBreaking & KoParagLayout::KeepLinesTogether; }
    bool hardFrameBreakBefore() const { return m_layout.pageBreaking & KoParagLayout::HardFrameBreakBefore; }
    bool hardFrameBreakAfter() const { return m_layout.pageBreaking & KoParagLayout::HardFrameBreakAfter; }

    /** Public for loading a style (KWord-1.3 XML) */
    static KoTextFormat loadFormat( TQDomElement &formatElem, KoTextFormat *refFormat, const TQFont &defaultFont, const TQString & defaultLanguage, bool hyphanation );
    /** Public for saving a style (KWord-1.3 XML) */
    static TQDomElement saveFormat( TQDomDocument &doc, KoTextFormat *curFormat, KoTextFormat *refFormat, int pos, int len );


    /** Save (to KWord-1.3 XML) the whole paragraph */
    void save( TQDomElement &parentElem, bool saveAnchorsFramesets = false );

    /** Save (to KWord-1.3 XML) a portion of the paragraph */
    void save( TQDomElement &parentElem, int from, int to, bool saveAnchorsFramesets = false );

    /** Load (from KWord-1.3 XML) the paragraph */
    void load( TQDomElement &attributes );

    /** Load (from KWord-1.3 XML) and apply \<FORMAT\> tags (used by KWTextParag::load and by KWPasteCommand) */
    void loadFormatting( TQDomElement &attributes, int offset = 0, bool loadFootNote=true );

    /** Load (from KWord-1.3 XML) and apply paragraph layout */
    void loadLayout( TQDomElement & attributes );

    /** Load (from KWord-1.3 XML), optionally using styles from document. */
    static KoParagLayout loadParagLayout( TQDomElement & parentElem, KWDocument *doc, bool useRefStyle );

    virtual void loadOasis( const TQDomElement& e, KoOasisContext& context, KoStyleCollection *styleCollection, uint& pos );
    virtual void saveOasis( KoXmlWriter& writer, KoSavingContext& context,
                            int from, int to, bool saveAnchorsFramesets = false ) const;

    virtual void join( KoTextParag *parag );
protected:
    virtual void drawFormattingChars( TQPainter &painter, int start, int len,
                                      int lastY_pix, int baseLine_pix, int h_pix, // in pixels
                                      bool drawSelections,
                                      KoTextFormat *lastFormat, const TQMemArray<int> &selectionStarts,
                                      const TQMemArray<int> &selectionEnds, const TQColorGroup &cg,
                                      bool rightToLeft, int line, KoTextZoomHandler* zh,
                                      int whichFormattingChars );

};

#endif