summaryrefslogtreecommitdiff
path: root/sw/inc/paratr.hxx
blob: 6fbe6c99415d1e49759386e5d39830a98fdf6f10 (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef INCLUDED_SW_INC_PARATR_HXX
#define INCLUDED_SW_INC_PARATR_HXX
#include <svl/eitem.hxx>
#include <svl/stritem.hxx>
#include "swdllapi.h"
#include <hintids.hxx>
#include <calbck.hxx>
#include <swatrset.hxx>
#include <format.hxx>
#include <charfmt.hxx>
#include <swtypes.hxx>
#include <editeng/adjustitem.hxx>
#include <editeng/lspcitem.hxx>
#include <editeng/spltitem.hxx>
#include <editeng/widwitem.hxx>
#include <editeng/orphitem.hxx>
#include <editeng/tstpitem.hxx>
#include <editeng/hyphenzoneitem.hxx>
#include <editeng/scriptspaceitem.hxx>
#include <editeng/hngpnctitem.hxx>
#include <editeng/forbiddenruleitem.hxx>
#include <editeng/paravertalignitem.hxx>
#include <editeng/pgrditem.hxx>

class SwCharFmt;
class IntlWrapper;

#define DROP_WHOLEWORD ((sal_uInt16)0x0001)

/** If SwFmtDrop is a Client, it is the CharFmt that describes the font for the
   DropCaps. If it is not a Client, formatting uses the CharFmt of the paragraph.
   If the CharFmt is modified, this change is propagated to the paragraphs
   via the Modify of SwFmtDrop. */
class SW_DLLPUBLIC SwFmtDrop: public SfxPoolItem, public SwClient
{
    SwModify* pDefinedIn;       /**< Modify-Object, that contains DropCaps.
                                  Can only be TxtFmtCollection/TxtNode. */
    sal_uInt16 nDistance;       ///< Distance to beginning of text.
    sal_uInt16 nReadFmt;        ///< For Sw3-Reader: CharFormat-Id (load Pool!).
    sal_uInt8  nLines;          ///< Line count.
    sal_uInt8  nChars;          ///< Character count.
    bool   bWholeWord;      ///< First word with initials.
public:
    TYPEINFO_OVERRIDE(); ///< Already in base class SwClient.

    SwFmtDrop();
    virtual ~SwFmtDrop();

    // @@@ public copy ctor, but no copy assignment?
    SwFmtDrop( const SwFmtDrop & );
private:
    // @@@ public copy ctor, but no copy assignment?
    SwFmtDrop & operator= (const SwFmtDrop &) SAL_DELETED_FUNCTION;

protected:
   virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) SAL_OVERRIDE;

public:

    /// "pure virtual methods" of SfxPoolItem
    virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
    virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const SAL_OVERRIDE;
    virtual bool GetPresentation( SfxItemPresentation ePres,
                                    SfxMapUnit eCoreMetric,
                                    SfxMapUnit ePresMetric,
                                    OUString &rText,
                                    const IntlWrapper*    pIntl = 0) const SAL_OVERRIDE;
    virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
    virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;

    inline sal_uInt8 GetLines() const { return nLines; }
    inline sal_uInt8 &GetLines() { return nLines; }

    inline sal_uInt8 GetChars() const { return nChars; }
    inline sal_uInt8 &GetChars() { return nChars; }

    inline bool GetWholeWord() const { return bWholeWord; }
    inline bool &GetWholeWord() { return bWholeWord; }

    inline sal_uInt16 GetDistance() const { return nDistance; }
    inline sal_uInt16 &GetDistance() { return nDistance; }

    inline const SwCharFmt *GetCharFmt() const { return static_cast<const SwCharFmt*>(GetRegisteredIn()); }
    inline SwCharFmt *GetCharFmt()       { return static_cast<SwCharFmt*>(GetRegisteredIn()); }
    void SetCharFmt( SwCharFmt *pNew );
    /// Get information from Client.
    virtual bool GetInfo( SfxPoolItem& ) const SAL_OVERRIDE;

    /// Get and set Modify pointer.
    inline const SwModify* GetDefinedIn() const { return pDefinedIn; }
    inline void ChgDefinedIn( const SwModify* pNew )
    { pDefinedIn = const_cast<SwModify*>(pNew); }
};

class SwRegisterItem : public SfxBoolItem
{
public:
    TYPEINFO_OVERRIDE();

    inline SwRegisterItem( const bool bRegister = false );

    /// @@@ public copy assignment, but no copy ctor?
    inline SwRegisterItem& operator=( const SwRegisterItem& rRegister );

    /// "pure virtual methods" of SfxPoolItem
    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
    virtual bool GetPresentation( SfxItemPresentation ePres,
                                    SfxMapUnit eCoreMetric,
                                    SfxMapUnit ePresMetric,
                                    OUString &rText,
                                    const IntlWrapper*    pIntl = 0 ) const SAL_OVERRIDE;
};

inline SwRegisterItem::SwRegisterItem( const bool bRegister ) :
    SfxBoolItem( RES_PARATR_REGISTER, bRegister )
{}

inline SwRegisterItem& SwRegisterItem::operator=(
    const SwRegisterItem& rRegister )
{
    SetValue( rRegister.GetValue() );
    return *this;
}

class SW_DLLPUBLIC SwNumRuleItem : public SfxStringItem
{
public:
    TYPEINFO_OVERRIDE();

    SwNumRuleItem()
        : SfxStringItem( RES_PARATR_NUMRULE, OUString() ) {}

    SwNumRuleItem( const OUString& rRuleName )
        : SfxStringItem( RES_PARATR_NUMRULE, rRuleName ) {}

    SwNumRuleItem( const SwNumRuleItem& rCpy )
        : SfxStringItem( RES_PARATR_NUMRULE, rCpy.GetValue() ) {}

    SwNumRuleItem& operator=( const SwNumRuleItem& rCpy )
    { SetValue( rCpy.GetValue() ); return *this; }

    /// "pure virtual methods" of SfxPoolItem
    virtual bool            operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
    virtual bool GetPresentation( SfxItemPresentation ePres,
                                    SfxMapUnit eCoreMetric,
                                    SfxMapUnit ePresMetric,
                                    OUString &rText,
                                    const IntlWrapper*    pIntl = 0 ) const SAL_OVERRIDE;

    virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const SAL_OVERRIDE;
    virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) SAL_OVERRIDE;

    void dumpAsXml(struct _xmlTextWriter* pWriter) const SAL_OVERRIDE;
};

class SwParaConnectBorderItem : public SfxBoolItem
{
public:
    TYPEINFO_OVERRIDE();

    inline SwParaConnectBorderItem( const bool bConnect = true );

    /// @@@ public copy assignment, but no copy ctor?
    inline SwParaConnectBorderItem& operator=( const SwParaConnectBorderItem& rConnect );

    /// "pure virtual methods" of SfxPoolItem
    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
    virtual bool GetPresentation( SfxItemPresentation ePres,
                                    SfxMapUnit eCoreMetric,
                                    SfxMapUnit ePresMetric,
                                    OUString &rText,
                                    const IntlWrapper*    pIntl = 0 ) const SAL_OVERRIDE;
};

inline SwParaConnectBorderItem::SwParaConnectBorderItem( const bool bConnect ) :
    SfxBoolItem( RES_PARATR_CONNECT_BORDER, bConnect )
{}

inline SwParaConnectBorderItem& SwParaConnectBorderItem::operator=(
    const SwParaConnectBorderItem& rConnect )
{
    SetValue( rConnect.GetValue() );
    return *this;
}

//  Implementation of paragraph-attributes methods of SwAttrSet
inline const SvxLineSpacingItem &SwAttrSet::GetLineSpacing(bool bInP) const
    {   return static_cast<const SvxLineSpacingItem&>(Get( RES_PARATR_LINESPACING,bInP)); }
inline const SvxAdjustItem &SwAttrSet::GetAdjust(bool bInP) const
    {   return static_cast<const SvxAdjustItem&>(Get( RES_PARATR_ADJUST,bInP)); }
inline const SvxFmtSplitItem &SwAttrSet::GetSplit(bool bInP) const
    {   return static_cast<const SvxFmtSplitItem&>(Get( RES_PARATR_SPLIT,bInP)); }
inline const SwRegisterItem &SwAttrSet::GetRegister(bool bInP) const
    {   return static_cast<const SwRegisterItem&>(Get( RES_PARATR_REGISTER,bInP)); }
inline const SvxWidowsItem &SwAttrSet::GetWidows(bool bInP) const
    {   return static_cast<const SvxWidowsItem&>(Get( RES_PARATR_WIDOWS,bInP)); }
inline const SvxOrphansItem &SwAttrSet::GetOrphans(bool bInP) const
    {   return static_cast<const SvxOrphansItem&>(Get( RES_PARATR_ORPHANS,bInP)); }
inline const SvxTabStopItem &SwAttrSet::GetTabStops(bool bInP) const
    {   return static_cast<const SvxTabStopItem&>(Get( RES_PARATR_TABSTOP,bInP)); }
inline const SvxHyphenZoneItem &SwAttrSet::GetHyphenZone(bool bInP) const
    {   return static_cast<const SvxHyphenZoneItem&>(Get(RES_PARATR_HYPHENZONE,bInP)); }
inline const SwFmtDrop &SwAttrSet::GetDrop(bool bInP) const
    {   return static_cast<const SwFmtDrop&>(Get(RES_PARATR_DROP,bInP)); }
inline const SwNumRuleItem &SwAttrSet::GetNumRule(bool bInP) const
    {   return static_cast<const SwNumRuleItem&>(Get(RES_PARATR_NUMRULE,bInP)); }
inline const SvxScriptSpaceItem& SwAttrSet::GetScriptSpace(bool bInP) const
    {   return static_cast<const SvxScriptSpaceItem&>(Get(RES_PARATR_SCRIPTSPACE,bInP)); }
inline const SvxHangingPunctuationItem &SwAttrSet::GetHangingPunctuation(bool bInP) const
    {   return static_cast<const SvxHangingPunctuationItem&>(Get(RES_PARATR_HANGINGPUNCTUATION,bInP)); }
inline const SvxForbiddenRuleItem &SwAttrSet::GetForbiddenRule(bool bInP) const
    {   return static_cast<const SvxForbiddenRuleItem&>(Get(RES_PARATR_FORBIDDEN_RULES, bInP)); }
inline const SvxParaVertAlignItem &SwAttrSet::GetParaVertAlign(bool bInP) const
    {   return static_cast<const SvxParaVertAlignItem&>(Get( RES_PARATR_VERTALIGN, bInP )); }
inline const SvxParaGridItem &SwAttrSet::GetParaGrid(bool bInP) const
    {   return static_cast<const SvxParaGridItem&>(Get( RES_PARATR_SNAPTOGRID, bInP )); }
inline const SwParaConnectBorderItem &SwAttrSet::GetParaConnectBorder(bool bInP) const
    {   return static_cast<const SwParaConnectBorderItem&>(Get( RES_PARATR_CONNECT_BORDER, bInP )); }

// Implementation of paragraph-attributes methods of SwFmt
inline const SvxLineSpacingItem &SwFmt::GetLineSpacing(bool bInP) const
    {   return m_aSet.GetLineSpacing(bInP); }
inline const SvxAdjustItem &SwFmt::GetAdjust(bool bInP) const
    {   return m_aSet.GetAdjust(bInP); }
inline const SvxFmtSplitItem &SwFmt::GetSplit(bool bInP) const
    {   return m_aSet.GetSplit(bInP); }
inline const SwRegisterItem &SwFmt::GetRegister(bool bInP) const
    {   return m_aSet.GetRegister(bInP); }
inline const SvxWidowsItem &SwFmt::GetWidows(bool bInP) const
    {   return m_aSet.GetWidows(bInP); }
inline const SvxOrphansItem &SwFmt::GetOrphans(bool bInP) const
    {   return m_aSet.GetOrphans(bInP); }
inline const SvxTabStopItem &SwFmt::GetTabStops(bool bInP) const
    {   return m_aSet.GetTabStops(bInP); }
inline const SvxHyphenZoneItem &SwFmt::GetHyphenZone(bool bInP) const
    {   return m_aSet.GetHyphenZone(bInP); }
inline const SwFmtDrop &SwFmt::GetDrop(bool bInP) const
    {   return m_aSet.GetDrop(bInP); }
inline const SwNumRuleItem &SwFmt::GetNumRule(bool bInP) const
    {   return m_aSet.GetNumRule(bInP); }
inline const SvxScriptSpaceItem& SwFmt::GetScriptSpace(bool bInP) const
    {   return m_aSet.GetScriptSpace(bInP) ; }
inline const SvxHangingPunctuationItem &SwFmt::GetHangingPunctuation(bool bInP) const
    {   return m_aSet.GetHangingPunctuation(bInP) ; }
inline const SvxForbiddenRuleItem &SwFmt::GetForbiddenRule(bool bInP) const
    {   return static_cast<const SvxForbiddenRuleItem&>(m_aSet.Get(RES_PARATR_FORBIDDEN_RULES, bInP)); }
inline const SvxParaVertAlignItem &SwFmt::GetParaVertAlign(bool bInP) const
    {   return static_cast<const SvxParaVertAlignItem&>(m_aSet.Get( RES_PARATR_VERTALIGN, bInP )); }
inline const SvxParaGridItem &SwFmt::GetParaGrid(bool bInP) const
    {   return static_cast<const SvxParaGridItem&>(m_aSet.Get( RES_PARATR_SNAPTOGRID, bInP )); }
inline const SwParaConnectBorderItem &SwFmt::GetParaConnectBorder(bool bInP) const
    {   return static_cast<const SwParaConnectBorderItem&>(m_aSet.Get( RES_PARATR_CONNECT_BORDER, bInP )); }

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */