LibreOffice Module sw (master) 1
hints.cxx
Go to the documentation of this file.
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
20#include <com/sun/star/i18n/ScriptType.hpp>
21#include <hintids.hxx>
22#include <hints.hxx>
23#include <ndtxt.hxx>
24#include <swtypes.hxx>
26#include <utility>
27#include <vcl/outdev.hxx>
28#include <osl/diagnose.h>
29
31 : SwMsgPoolItem( RES_FMT_CHG ), pChangedFormat( pFormat )
32{
33}
34
35
36
37namespace sw {
38
39MoveText::MoveText(SwTextNode *const pD, sal_Int32 const nD, sal_Int32 const nS, sal_Int32 const nL)
40 : pDestNode(pD), nDestStart(nD), nSourceStart(nS), nLen(nL)
41{
42}
43
44InsertText::InsertText(const sal_Int32 nP, const sal_Int32 nL, const bool isInFMCommand, const bool isInFMResult)
46 , nPos( nP ), nLen( nL )
47 , isInsideFieldmarkCommand(isInFMCommand)
48 , isInsideFieldmarkResult(isInFMResult)
49{
50}
51
52DeleteText::DeleteText( const sal_Int32 nS, const sal_Int32 nL )
53 : SfxHint( SfxHintId::SwDeleteText ), nStart( nS ), nLen( nL )
54{
55}
56
57DeleteChar::DeleteChar( const sal_Int32 nPos )
59{
60}
61
62RedlineDelText::RedlineDelText(sal_Int32 const nS, sal_Int32 const nL)
63 : nStart(nS), nLen(nL)
64{
65}
66
67RedlineUnDelText::RedlineUnDelText(sal_Int32 const nS, sal_Int32 const nL)
68 : nStart(nS), nLen(nL)
69{
70}
71
72} // namespace sw
73
74SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW )
75 : SwMsgPoolItem( RES_UPDATE_ATTR ), m_nStart( nS ), m_nEnd( nE ), m_nWhichAttr( nW )
76{
77}
78
79SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW, std::vector<sal_uInt16> aW )
80 : SwMsgPoolItem( RES_UPDATE_ATTR ), m_nStart( nS ), m_nEnd( nE ), m_nWhichAttr( nW ), m_aWhichFmtAttrs(std::move( aW ))
81{
82}
83
85 : m_pTable(pNewTable)
86 , m_nSplitLine(USHRT_MAX)
87 , m_eFlags(TBL_CALC)
88{
89 m_aData.pDelTable = nullptr;
91 OSL_ENSURE( m_pTable, "No Table pointer" );
92}
93
95 : SwMsgPoolItem( RES_AUTOFMT_DOCNODE ), pNodes( pNds )
96{
97}
98
101 m_bDelSet( false ),
102 m_pChgSet( &rSet ),
103 m_pTheChgdSet( &rTheSet )
104{
105}
106
109 m_bDelSet( true ),
110 m_pTheChgdSet( rChgSet.m_pTheChgdSet )
111{
112 m_pChgSet = new SwAttrSet( *rChgSet.m_pChgSet );
113}
114
116{
117 if( m_bDelSet )
118 delete m_pChgSet;
119}
120
121#ifdef DBG_UTIL
122void SwAttrSetChg::ClearItem( sal_uInt16 nWhch )
123{
124 OSL_ENSURE( m_bDelSet, "The Set may not be changed!" );
125 m_pChgSet->ClearItem( nWhch );
126}
127#endif
128
130 : SfxPoolItem( nWhch )
131{
132}
133
135{
136 assert( false && "SwMsgPoolItem knows no ==" );
137 return false;
138}
139
141{
142 OSL_FAIL( "SwMsgPoolItem knows no Clone" );
143 return nullptr;
144}
145
146#if OSL_DEBUG_LEVEL > 0
147const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
148{
149 OSL_ASSERT( nWhich < POOLATTR_END && nWhich >= POOLATTR_BEGIN );
150
151 SfxPoolItem *pHt = aAttrTab[ nWhich - POOLATTR_BEGIN ];
152 OSL_ENSURE( pHt, "GetDfltFormatAttr(): Dflt == 0" );
153 return pHt;
154}
155#else
156const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
157{
158 return aAttrTab[ nWhich - POOLATTR_BEGIN ];
159}
160#endif
161
163 SwMsgPoolItem( RES_VIRTPAGENUM_INFO ), m_pPage( nullptr ), m_pOrigPage( pPg ), m_pFrame( nullptr )
164{
165}
166
168 : SwMsgPoolItem( RES_FINDNEARESTNODE ), m_pNode( &rNd ), m_pFound( nullptr )
169{
170}
171
173{
174 if( &m_pNode->GetNodes() == &rNd.GetNodes() )
175 {
176 SwNodeOffset nIdx = rNd.GetIndex();
177 if( nIdx < m_pNode->GetIndex() &&
178 ( !m_pFound || nIdx > m_pFound->GetIndex() ) &&
179 nIdx > rNd.GetNodes().GetEndOfExtras().GetIndex() )
180 m_pFound = &rNd;
181 }
182}
183
184sal_uInt16 GetWhichOfScript( sal_uInt16 nWhich, sal_uInt16 nScript )
185{
186 static const sal_uInt16 aLangMap[3] =
188 static const sal_uInt16 aFontMap[3] =
190 static const sal_uInt16 aFontSizeMap[3] =
192 static const sal_uInt16 aWeightMap[3] =
194 static const sal_uInt16 aPostureMap[3] =
196
197 const sal_uInt16* pM;
198 switch( nWhich )
199 {
203 pM = aLangMap;
204 break;
205
206 case RES_CHRATR_FONT:
209 pM = aFontMap;
210 break;
211
215 pM = aFontSizeMap;
216 break;
217
221 pM = aWeightMap;
222 break;
223
227 pM = aPostureMap;
228 break;
229
230 default:
231 pM = nullptr;
232 }
233
234 sal_uInt16 nRet;
235 if( pM )
236 {
237 using namespace ::com::sun::star;
238 {
239 if( i18n::ScriptType::WEAK == nScript )
241 switch( nScript)
242 {
243 case i18n::ScriptType::COMPLEX:
244 ++pM;
245 [[fallthrough]];
246 case i18n::ScriptType::ASIAN:
247 ++pM;
248 [[fallthrough]];
249 default:
250 nRet = *pM;
251 }
252 }
253 }
254 else
255 nRet = nWhich;
256 return nRet;
257}
258
259/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
SwAttrSetChg(const SwAttrSet &rTheSet, SwAttrSet &rSet)
Definition: hints.cxx:99
SwAttrSet * m_pChgSet
what has changed
Definition: hints.hxx:339
void ClearItem(sal_uInt16 nWhichL)
Definition: hints.cxx:122
bool m_bDelSet
Definition: hints.hxx:338
virtual ~SwAttrSetChg() override
Definition: hints.cxx:115
SwAutoFormatGetDocNode(const SwNodes *pNds)
Definition: hints.cxx:94
const SwNode * m_pFound
Definition: hints.hxx:381
const SwNode * m_pNode
Definition: hints.hxx:381
void CheckNode(const SwNode &rNd)
Definition: hints.cxx:172
SwFindNearestNode(const SwNode &rNd)
Definition: hints.cxx:167
SwFormatChg(SwFormat *pFormat)
Definition: hints.cxx:30
Base class for various Writer styles.
Definition: format.hxx:47
virtual bool operator==(const SfxPoolItem &) const override
Definition: hints.cxx:134
virtual SwMsgPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: hints.cxx:140
SwMsgPoolItem(sal_uInt16 nWhich)
Definition: hints.cxx:129
Base class of the Writer document model elements.
Definition: node.hxx:98
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:706
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:163
A page of the document layout.
Definition: pagefrm.hxx:60
union SwTableFormulaUpdate::@23 m_aData
const SwTable * m_pTable
Pointer to the current table.
Definition: hints.hxx:310
SwTableFormulaUpdate(const SwTable *)
Is sent if a table should be recalculated.
Definition: hints.cxx:84
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
SwUpdateAttr(sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW)
Definition: hints.cxx:74
SwVirtPageNumInfo(const SwPageFrame *pPg)
Multiple attributes can be attached to a single paragraph / table The frame, in the end,...
Definition: hints.cxx:162
DeleteChar(const sal_Int32 nPos)
Definition: hints.cxx:57
DeleteText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:52
InsertText(sal_Int32 nP, sal_Int32 nL, bool isInFMCommand, bool isInFMResult)
Definition: hints.cxx:44
MoveText(SwTextNode *pD, sal_Int32 nD, sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:39
RedlineDelText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:62
RedlineUnDelText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:67
size_t m_nPos
SfxHintId
constexpr TypedWhichId< SwVirtPageNumInfo > RES_VIRTPAGENUM_INFO(180)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr sal_uInt16 POOLATTR_BEGIN(HINT_BEGIN)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
constexpr TypedWhichId< SwFindNearestNode > RES_FINDNEARESTNODE(184)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_WEIGHT(15)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CJK_FONTSIZE(23)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CTL_WEIGHT(31)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(169)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CTL_POSTURE(30)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
SwDfltAttrTab aAttrTab
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CJK_WEIGHT(26)
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SwUpdateAttr > RES_UPDATE_ATTR(170)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CJK_POSTURE(25)
constexpr TypedWhichId< SwAutoFormatGetDocNode > RES_AUTOFMT_DOCNODE(176)
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(168)
const SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
Definition: hints.cxx:147
sal_uInt16 GetWhichOfScript(sal_uInt16 nWhich, sal_uInt16 nScript)
Definition: hints.cxx:184
@ TBL_CALC
Definition: hints.hxx:300
LanguageType GetAppLanguage()
Definition: init.cxx:741
sal_uInt16 nPos
sal_Int16 GetI18NScriptTypeOfLanguage(LanguageType nLang)
Dialog to specify the properties of date form field.
static SfxItemSet & rSet