| 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | /* |
| 3 | * This file is part of the LibreOffice project. |
| 4 | * |
| 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/. |
| 8 | * |
| 9 | * This file incorporates work covered by the following license notice: |
| 10 | * |
| 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 . |
| 18 | */ |
| 19 | #ifndef INCLUDED_SW_INC_PARATR_HXX |
| 20 | #define INCLUDED_SW_INC_PARATR_HXX |
| 21 | #include <svl/eitem.hxx> |
| 22 | #include <svl/stritem.hxx> |
| 23 | #include "swdllapi.h" |
| 24 | #include "hintids.hxx" |
| 25 | #include "calbck.hxx" |
| 26 | #include "swatrset.hxx" |
| 27 | #include "format.hxx" |
| 28 | #include "charfmt.hxx" |
| 29 | #include <editeng/autodiritem.hxx> |
| 30 | #include <editeng/adjustitem.hxx> |
| 31 | #include <editeng/lspcitem.hxx> |
| 32 | #include <editeng/spltitem.hxx> |
| 33 | #include <editeng/widwitem.hxx> |
| 34 | #include <editeng/orphitem.hxx> |
| 35 | #include <editeng/tstpitem.hxx> |
| 36 | #include <editeng/hyphenzoneitem.hxx> |
| 37 | #include <editeng/scriptspaceitem.hxx> |
| 38 | #include <editeng/hngpnctitem.hxx> |
| 39 | #include <editeng/forbiddenruleitem.hxx> |
| 40 | #include <editeng/paravertalignitem.hxx> |
| 41 | #include <editeng/pgrditem.hxx> |
| 42 | #include <o3tl/typed_flags_set.hxx> |
| 43 | |
| 44 | class SwFormatDrop; |
| 45 | |
| 46 | namespace sw { |
| 47 | |
| 48 | enum class ListLevelIndents { No, FirstLine, LeftMargin }; |
| 49 | |
| 50 | class SW_DLLPUBLIC FormatDropDefiner { |
| 51 | protected: |
| 52 | virtual ~FormatDropDefiner() {}; |
| 53 | public: |
| 54 | virtual void FormatDropNotify(const SwFormatDrop&) =0; |
| 55 | }; |
| 56 | } |
| 57 | |
| 58 | namespace o3tl |
| 59 | { |
| 60 | template<> struct typed_flags<sw::ListLevelIndents> : is_typed_flags<sw::ListLevelIndents, 0x03> {}; |
| 61 | } |
| 62 | |
| 63 | /** If SwFormatDrop is a Client, it is the CharFormat that describes the font for the |
| 64 | DropCaps. If it is not a Client, formatting uses the CharFormat of the paragraph. |
| 65 | If the CharFormat is modified, this change is propagated to the paragraphs |
| 66 | via the Modify of SwFormatDrop. */ |
| 67 | class SW_DLLPUBLIC SwFormatDrop final : public SfxPoolItem, public SwClient |
| 68 | { |
| 69 | sw::FormatDropDefiner* m_pDefinedIn; ///< TextNode or FormatColl that contains the CapDrops. |
| 70 | sal_uInt16 m_nDistance; ///< Distance to beginning of text. |
| 71 | sal_uInt8 m_nLines; ///< Line count. |
| 72 | sal_uInt8 m_nChars; ///< Character count. |
| 73 | bool m_bWholeWord; ///< First word with initials. |
| 74 | public: |
| 75 | static SfxPoolItem* CreateDefault(); |
| 76 | |
| 77 | DECLARE_ITEM_TYPE_FUNCTION(SwFormatDrop) |
| 78 | SwFormatDrop(); |
| 79 | virtual ~SwFormatDrop() override; |
| 80 | |
| 81 | // @@@ public copy ctor, but no copy assignment? |
| 82 | SwFormatDrop( const SwFormatDrop & ); |
| 83 | private: |
| 84 | // @@@ public copy ctor, but no copy assignment? |
| 85 | SwFormatDrop & operator= (const SwFormatDrop &) = delete; |
| 86 | |
| 87 | virtual void SwClientNotify(const SwModify&, const SfxHint&) override |
| 88 | { |
| 89 | if (!m_pDefinedIn) |
| 90 | return; |
| 91 | m_pDefinedIn->FormatDropNotify(*this); |
| 92 | } |
| 93 | |
| 94 | public: |
| 95 | |
| 96 | /// "pure virtual methods" of SfxPoolItem |
| 97 | virtual bool operator==( const SfxPoolItem& ) const override; |
| 98 | virtual bool supportsHashCode() const override { return true; } |
| 99 | virtual size_t hashCode() const override; |
| 100 | virtual SwFormatDrop* Clone( SfxItemPool* pPool = nullptr ) const override; |
| 101 | virtual bool GetPresentation( SfxItemPresentation ePres, |
| 102 | MapUnit eCoreMetric, |
| 103 | MapUnit ePresMetric, |
| 104 | OUString &rText, |
| 105 | const IntlWrapper& rIntl ) const override; |
| 106 | virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; |
| 107 | virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; |
| 108 | |
| 109 | sal_uInt8 GetLines() const { return m_nLines; } |
| 110 | void SetLines(sal_uInt8 n) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nLines = n; } |
| 111 | |
| 112 | sal_uInt8 GetChars() const { return m_nChars; } |
| 113 | void SetChars(sal_uInt8 n) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nChars = n; } |
| 114 | |
| 115 | bool GetWholeWord() const { return m_bWholeWord; } |
| 116 | void SetWholeWord(bool b) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_bWholeWord = b; } |
| 117 | |
| 118 | sal_uInt16 GetDistance() const { return m_nDistance; } |
| 119 | void SetDistance(sal_uInt16 n) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nDistance = n; } |
| 120 | |
| 121 | const SwCharFormat *GetCharFormat() const { return static_cast<const SwCharFormat*>(GetRegisteredIn()); } |
| 122 | SwCharFormat *GetCharFormat() { return static_cast<SwCharFormat*>(GetRegisteredIn()); } |
| 123 | void SetCharFormat( SwCharFormat *pNew ); |
| 124 | /// Get information from Client. |
| 125 | virtual bool GetInfo( SwFindNearestNode& ) const override; |
| 126 | |
| 127 | /// Get and set Modify pointer. |
| 128 | void ChgDefinedIn( const sw::FormatDropDefiner* pDefiner ) |
| 129 | { m_pDefinedIn = const_cast<sw::FormatDropDefiner*>(pDefiner); }; |
| 130 | }; |
| 131 | |
| 132 | class SwRegisterItem final : public SfxBoolItem |
| 133 | { |
| 134 | public: |
| 135 | static SfxPoolItem* CreateDefault(); |
| 136 | DECLARE_ITEM_TYPE_FUNCTION(SwRegisterItem) |
| 137 | inline SwRegisterItem( const bool bRegister = false ); |
| 138 | |
| 139 | /// "pure virtual methods" of SfxPoolItem |
| 140 | virtual SwRegisterItem* Clone( SfxItemPool *pPool = nullptr ) const override; |
| 141 | virtual bool GetPresentation( SfxItemPresentation ePres, |
| 142 | MapUnit eCoreMetric, |
| 143 | MapUnit ePresMetric, |
| 144 | OUString &rText, |
| 145 | const IntlWrapper& rIntl ) const override; |
| 146 | }; |
| 147 | |
| 148 | inline SwRegisterItem::SwRegisterItem( const bool bRegister ) : |
| 149 | SfxBoolItem( RES_PARATR_REGISTER, bRegister ) |
| 150 | {} |
| 151 | |
| 152 | class SW_DLLPUBLIC SwNumRuleItem final : public SfxStringItem |
| 153 | { |
| 154 | public: |
| 155 | static SfxPoolItem* CreateDefault(); |
| 156 | DECLARE_ITEM_TYPE_FUNCTION(SwNumRuleItem) |
| 157 | SwNumRuleItem() |
| 158 | : SfxStringItem( RES_PARATR_NUMRULE, OUString() ) {} |
| 159 | |
| 160 | SwNumRuleItem( const UIName& rRuleName ) |
| 161 | : SfxStringItem( RES_PARATR_NUMRULE, rRuleName.toString() ) {} |
| 162 | |
| 163 | SwNumRuleItem(SwNumRuleItem const &) = default; // SfxPoolItem copy function dichotomy |
| 164 | |
| 165 | /// "pure virtual methods" of SfxPoolItem |
| 166 | virtual bool operator==( const SfxPoolItem& ) const override; |
| 167 | virtual SwNumRuleItem* Clone( SfxItemPool *pPool = nullptr ) const override; |
| 168 | // Marked as false since the SfxStringItem superclass supports hashing, but |
| 169 | // this class has not been checked for safety under hashing yet. |
| 170 | virtual bool supportsHashCode() const override { return false; } |
| 171 | virtual bool GetPresentation( SfxItemPresentation ePres, |
| 172 | MapUnit eCoreMetric, |
| 173 | MapUnit ePresMetric, |
| 174 | OUString &rText, |
| 175 | const IntlWrapper& rIntl ) const override; |
| 176 | |
| 177 | virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; |
| 178 | virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; |
| 179 | UIName GetValue() const { return UIName(SfxStringItem::GetValue()); } |
| 180 | |
| 181 | void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
| 182 | }; |
| 183 | |
| 184 | class SwParaConnectBorderItem final : public SfxBoolItem |
| 185 | { |
| 186 | public: |
| 187 | DECLARE_ITEM_TYPE_FUNCTION(SwParaConnectBorderItem) |
| 188 | inline SwParaConnectBorderItem( const bool bConnect = true ); |
| 189 | |
| 190 | /// "pure virtual methods" of SfxPoolItem |
| 191 | virtual SwParaConnectBorderItem* Clone( SfxItemPool *pPool = nullptr ) const override; |
| 192 | virtual bool GetPresentation( SfxItemPresentation ePres, |
| 193 | MapUnit eCoreMetric, |
| 194 | MapUnit ePresMetric, |
| 195 | OUString &rText, |
| 196 | const IntlWrapper& rIntl ) const override; |
| 197 | }; |
| 198 | |
| 199 | inline SwParaConnectBorderItem::SwParaConnectBorderItem( const bool bConnect ) : |
| 200 | SfxBoolItem( RES_PARATR_CONNECT_BORDER, bConnect ) |
| 201 | {} |
| 202 | |
| 203 | // Implementation of paragraph-attributes methods of SwAttrSet |
| 204 | inline const SvxLineSpacingItem &SwAttrSet::GetLineSpacing(bool bInP) const |
| 205 | { return Get( RES_PARATR_LINESPACING,bInP); } |
| 206 | inline const SvxAdjustItem &SwAttrSet::GetAdjust(bool bInP) const |
| 207 | { return Get( RES_PARATR_ADJUST,bInP); } |
| 208 | inline const SvxFormatSplitItem &SwAttrSet::GetSplit(bool bInP) const |
| 209 | { return Get( RES_PARATR_SPLIT,bInP); } |
| 210 | inline const SwRegisterItem &SwAttrSet::GetRegister(bool bInP) const |
| 211 | { return Get( RES_PARATR_REGISTER,bInP); } |
| 212 | inline const SvxWidowsItem &SwAttrSet::GetWidows(bool bInP) const |
| 213 | { return Get( RES_PARATR_WIDOWS,bInP); } |
| 214 | inline const SvxOrphansItem &SwAttrSet::GetOrphans(bool bInP) const |
| 215 | { return Get( RES_PARATR_ORPHANS,bInP); } |
| 216 | inline const SvxTabStopItem &SwAttrSet::GetTabStops(bool bInP) const |
| 217 | { return Get( RES_PARATR_TABSTOP,bInP); } |
| 218 | inline const SvxHyphenZoneItem &SwAttrSet::GetHyphenZone(bool bInP) const |
| 219 | { return Get(RES_PARATR_HYPHENZONE,bInP); } |
| 220 | inline const SwFormatDrop &SwAttrSet::GetDrop(bool bInP) const |
| 221 | { return Get(RES_PARATR_DROP,bInP); } |
| 222 | inline const SwNumRuleItem &SwAttrSet::GetNumRule(bool bInP) const |
| 223 | { return Get(RES_PARATR_NUMRULE,bInP); } |
| 224 | inline const SvxScriptSpaceItem& SwAttrSet::GetScriptSpace(bool bInP) const |
| 225 | { return Get(RES_PARATR_SCRIPTSPACE,bInP); } |
| 226 | inline const SvxHangingPunctuationItem &SwAttrSet::GetHangingPunctuation(bool bInP) const |
| 227 | { return Get(RES_PARATR_HANGINGPUNCTUATION,bInP); } |
| 228 | inline const SvxForbiddenRuleItem &SwAttrSet::GetForbiddenRule(bool bInP) const |
| 229 | { return Get(RES_PARATR_FORBIDDEN_RULES, bInP); } |
| 230 | inline const SvxParaVertAlignItem &SwAttrSet::GetParaVertAlign(bool bInP) const |
| 231 | { return Get( RES_PARATR_VERTALIGN, bInP ); } |
| 232 | inline const SvxParaGridItem &SwAttrSet::GetParaGrid(bool bInP) const |
| 233 | { return Get( RES_PARATR_SNAPTOGRID, bInP ); } |
| 234 | inline const SwParaConnectBorderItem &SwAttrSet::GetParaConnectBorder(bool bInP) const |
| 235 | { return Get( RES_PARATR_CONNECT_BORDER, bInP ); } |
| 236 | inline const SvxAutoFrameDirectionItem &SwAttrSet::GetAutoFrameDirection(bool bInP) const |
| 237 | { return Get( RES_PARATR_AUTOFRAMEDIR, bInP ); } |
| 238 | |
| 239 | // Implementation of paragraph-attributes methods of SwFormat |
| 240 | inline const SvxLineSpacingItem &SwFormat::GetLineSpacing(bool bInP) const |
| 241 | { return m_aSet.GetLineSpacing(bInP); } |
| 242 | inline const SvxTabStopItem &SwFormat::GetTabStops(bool bInP) const |
| 243 | { return m_aSet.GetTabStops(bInP); } |
| 244 | inline const SwFormatDrop &SwFormat::GetDrop(bool bInP) const |
| 245 | { return m_aSet.GetDrop(bInP); } |
| 246 | inline const SwNumRuleItem &SwFormat::GetNumRule(bool bInP) const |
| 247 | { return m_aSet.GetNumRule(bInP); } |
| 248 | |
| 249 | #endif |
| 250 | |
| 251 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |