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>
25 #include <svl/languageoptions.hxx>
26 #include <vcl/outdev.hxx>
27 #include <osl/diagnose.h>
28 
30  : SwMsgPoolItem( RES_FMT_CHG ), pChangedFormat( pFormat )
31 {
32 }
33 
34 SwInsText::SwInsText( sal_Int32 nP, sal_Int32 nL )
35  : SwMsgPoolItem( RES_INS_TXT ), nPos( nP ), nLen( nL )
36 {
37 }
38 
39 SwDelChr::SwDelChr( sal_Int32 nP )
40  : SwMsgPoolItem( RES_DEL_CHR ), nPos( nP )
41 {
42 }
43 
44 SwDelText::SwDelText( sal_Int32 nS, sal_Int32 nL )
45  : SwMsgPoolItem( RES_DEL_TXT ), nStart( nS ), nLen( nL )
46 {
47 }
48 
49 namespace sw {
50 
51 MoveText::MoveText(SwTextNode *const pD, sal_Int32 const nD, sal_Int32 const nS, sal_Int32 const nL)
52  : pDestNode(pD), nDestStart(nD), nSourceStart(nS), nLen(nL)
53 {
54 }
55 
56 RedlineDelText::RedlineDelText(sal_Int32 const nS, sal_Int32 const nL)
57  : nStart(nS), nLen(nL)
58 {
59 }
60 
61 RedlineUnDelText::RedlineUnDelText(sal_Int32 const nS, sal_Int32 const nL)
62  : nStart(nS), nLen(nL)
63 {
64 }
65 
66 } // namespace sw
67 
68 SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW )
69  : SwMsgPoolItem( RES_UPDATE_ATTR ), m_nStart( nS ), m_nEnd( nE ), m_nWhichAttr( nW )
70 {
71 }
72 
73 SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW, std::vector<sal_uInt16> aW )
74  : SwMsgPoolItem( RES_UPDATE_ATTR ), m_nStart( nS ), m_nEnd( nE ), m_nWhichAttr( nW ), m_aWhichFmtAttrs( aW )
75 {
76 }
77 
80  pOut( pOutput )
81 {
82  OSL_ENSURE( pOut, "No OutputDevice pointer" );
83 }
84 
86  : SwMsgPoolItem( RES_DOCPOS_UPDATE ), nDocPos(nDcPos)
87 {
88 }
89 
92  m_pTable( pNewTable ), m_pHistory( nullptr ), m_nSplitLine( USHRT_MAX ),
93  m_eFlags( TBL_CALC )
94 {
95  m_aData.pDelTable = nullptr;
97  OSL_ENSURE( m_pTable, "No Table pointer" );
98 }
99 
101  : SwMsgPoolItem( RES_AUTOFMT_DOCNODE ), pNodes( pNds )
102 {
103 }
104 
107  m_bDelSet( false ),
108  m_pChgSet( &rSet ),
109  m_pTheChgdSet( &rTheSet )
110 {
111 }
112 
115  m_bDelSet( true ),
116  m_pTheChgdSet( rChgSet.m_pTheChgdSet )
117 {
118  m_pChgSet = new SwAttrSet( *rChgSet.m_pChgSet );
119 }
120 
122 {
123  if( m_bDelSet )
124  delete m_pChgSet;
125 }
126 
127 #ifdef DBG_UTIL
128 void SwAttrSetChg::ClearItem( sal_uInt16 nWhch )
129 {
130  OSL_ENSURE( m_bDelSet, "The Set may not be changed!" );
131  m_pChgSet->ClearItem( nWhch );
132 }
133 #endif
134 
135 SwMsgPoolItem::SwMsgPoolItem( sal_uInt16 nWhch )
136  : SfxPoolItem( nWhch )
137 {
138 }
139 
141 {
142  assert( false && "SwMsgPoolItem knows no ==" );
143  return false;
144 }
145 
147 {
148  OSL_FAIL( "SwMsgPoolItem knows no Clone" );
149  return nullptr;
150 }
151 
152 #if OSL_DEBUG_LEVEL > 0
153 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
154 {
155  OSL_ASSERT( nWhich < POOLATTR_END && nWhich >= POOLATTR_BEGIN );
156 
157  SfxPoolItem *pHt = aAttrTab[ nWhich - POOLATTR_BEGIN ];
158  OSL_ENSURE( pHt, "GetDfltFormatAttr(): Dflt == 0" );
159  return pHt;
160 }
161 #else
162 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
163 {
164  return aAttrTab[ nWhich - POOLATTR_BEGIN ];
165 }
166 #endif
167 
169  : SwMsgPoolItem( RES_CONDCOLL_CONDCHG ), pChangedFormat( pFormat )
170 {
171 }
172 
174  SwMsgPoolItem( RES_VIRTPAGENUM_INFO ), m_pPage( nullptr ), m_pOrigPage( pPg ), m_pFrame( nullptr )
175 {
176 }
177 
179  : SwMsgPoolItem( RES_FINDNEARESTNODE ), m_pNode( &rNd ), m_pFound( nullptr )
180 {
181 }
182 
184 {
185  if( &m_pNode->GetNodes() == &rNd.GetNodes() )
186  {
187  sal_uLong nIdx = rNd.GetIndex();
188  if( nIdx < m_pNode->GetIndex() &&
189  ( !m_pFound || nIdx > m_pFound->GetIndex() ) &&
190  nIdx > rNd.GetNodes().GetEndOfExtras().GetIndex() )
191  m_pFound = &rNd;
192  }
193 }
194 
195 sal_uInt16 GetWhichOfScript( sal_uInt16 nWhich, sal_uInt16 nScript )
196 {
197  static const sal_uInt16 aLangMap[3] =
199  static const sal_uInt16 aFontMap[3] =
201  static const sal_uInt16 aFontSizeMap[3] =
203  static const sal_uInt16 aWeightMap[3] =
205  static const sal_uInt16 aPostureMap[3] =
207 
208  const sal_uInt16* pM;
209  switch( nWhich )
210  {
211  case RES_CHRATR_LANGUAGE:
214  pM = aLangMap;
215  break;
216 
217  case RES_CHRATR_FONT:
218  case RES_CHRATR_CJK_FONT:
219  case RES_CHRATR_CTL_FONT:
220  pM = aFontMap;
221  break;
222 
223  case RES_CHRATR_FONTSIZE:
226  pM = aFontSizeMap;
227  break;
228 
229  case RES_CHRATR_WEIGHT:
232  pM = aWeightMap;
233  break;
234 
235  case RES_CHRATR_POSTURE:
238  pM = aPostureMap;
239  break;
240 
241  default:
242  pM = nullptr;
243  }
244 
245  sal_uInt16 nRet;
246  if( pM )
247  {
248  using namespace ::com::sun::star;
249  {
250  if( i18n::ScriptType::WEAK == nScript )
252  switch( nScript)
253  {
254  case i18n::ScriptType::COMPLEX:
255  ++pM;
256  [[fallthrough]];
257  case i18n::ScriptType::ASIAN:
258  ++pM;
259  [[fallthrough]];
260  default:
261  nRet = *pM;
262  }
263  }
264  }
265  else
266  nRet = nWhich;
267  return nRet;
268 }
269 
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define RES_CHRATR_WEIGHT
Definition: hintids.hxx:84
sal_uLong GetIndex() const
Definition: node.hxx:282
VclPtr< OutputDevice > pOut
pointer to the current output device
Definition: hints.hxx:171
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:93
#define RES_CHRATR_FONTSIZE
Definition: hintids.hxx:77
#define RES_AUTOFMT_DOCNODE
Definition: hintids.hxx:297
#define RES_ATTRSET_CHG
Definition: hintids.hxx:287
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:79
SwAttrSetChg(const SwAttrSet &rTheSet, SwAttrSet &rSet)
Definition: hints.cxx:105
MoveText(SwTextNode *pD, sal_Int32 nD, sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:51
#define RES_INS_TXT
Definition: hintids.hxx:288
virtual ~SwAttrSetChg() override
Definition: hints.cxx:121
#define RES_DEL_CHR
Definition: hintids.hxx:289
#define RES_CHRATR_CJK_POSTURE
Definition: hintids.hxx:94
sal_uIntPtr sal_uLong
RedlineDelText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:56
#define RES_CHRATR_CJK_WEIGHT
Definition: hintids.hxx:95
#define RES_CHRATR_FONT
Definition: hintids.hxx:76
long SwTwips
Definition: swtypes.hxx:49
SwUpdateAttr(sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW)
Definition: hints.cxx:68
Dialog to specify the properties of date form field.
#define RES_CHRATR_CJK_FONT
Definition: hintids.hxx:91
#define RES_CHRATR_CJK_FONTSIZE
Definition: hintids.hxx:92
#define RES_DOCPOS_UPDATE
Definition: hintids.hxx:293
SwRefMarkFieldUpdate(OutputDevice *)
Is sent if reference marks should be updated.
Definition: hints.cxx:78
#define RES_UPDATE_ATTR
Definition: hintids.hxx:291
#define RES_TABLEFML_UPDATE
Definition: hintids.hxx:294
SwAutoFormatGetDocNode(const SwNodes *pNds)
Definition: hints.cxx:100
#define RES_CHRATR_CTL_FONTSIZE
Definition: hintids.hxx:97
#define RES_CONDCOLL_CONDCHG
Definition: hintids.hxx:303
const SwTable * m_pTable
Pointer to the current table.
Definition: hints.hxx:201
const SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
Definition: hints.cxx:153
RedlineUnDelText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:61
Base class for various Writer styles.
Definition: format.hxx:43
#define POOLATTR_BEGIN
Definition: hintids.hxx:64
const SwNode * m_pFound
Definition: hints.hxx:280
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: hints.cxx:146
SwDocPosUpdate(const SwTwips nDocPos)
Definition: hints.cxx:85
#define RES_CHRATR_CTL_FONT
Definition: hintids.hxx:96
SwDelText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:44
#define RES_DEL_TXT
Definition: hintids.hxx:290
bool const m_bDelSet
Definition: hints.hxx:230
SwFindNearestNode(const SwNode &rNd)
Definition: hints.cxx:178
static sal_Int16 GetI18NScriptTypeOfLanguage(LanguageType nLang)
sal_uInt16 GetWhichOfScript(sal_uInt16 nWhich, sal_uInt16 nScript)
Definition: hints.cxx:195
void CheckNode(const SwNode &rNd)
Definition: hints.cxx:183
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
#define RES_FINDNEARESTNODE
Definition: hintids.hxx:308
#define RES_FMT_CHG
Definition: hintids.hxx:286
A page of the document layout.
Definition: pagefrm.hxx:40
#define RES_REFMARKFLD_UPDATE
Definition: hintids.hxx:292
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
SwMsgPoolItem(sal_uInt16 nWhich)
Definition: hints.cxx:135
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
#define RES_VIRTPAGENUM_INFO
Definition: hintids.hxx:304
#define RES_CHRATR_CTL_LANGUAGE
Definition: hintids.hxx:98
#define RES_CHRATR_POSTURE
Definition: hintids.hxx:80
#define RES_CHRATR_CTL_WEIGHT
Definition: hintids.hxx:100
#define RES_CHRATR_CTL_POSTURE
Definition: hintids.hxx:99
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
SwDfltAttrTab aAttrTab
const SwNode * m_pNode
Definition: hints.hxx:280
LanguageType GetAppLanguage()
Definition: init.cxx:729
SwCondCollCondChg(SwFormat *pFormat)
Definition: hints.cxx:168
SwTableFormulaUpdate(const SwTable *)
Is sent if a table should be recalculated.
Definition: hints.cxx:90
SwVirtPageNumInfo(const SwPageFrame *pPg)
Multiple attributes can be attached to a single paragraph / table The frame, in the end...
Definition: hints.cxx:173
void ClearItem(sal_uInt16 nWhichL)
Definition: hints.cxx:128
SwInsText(sal_Int32 nP, sal_Int32 nL)
Definition: hints.cxx:34
SwDelChr(sal_Int32 nP)
Definition: hints.cxx:39
union SwTableFormulaUpdate::@27 m_aData
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:162
sal_Int32 nPos
SwFormatChg(SwFormat *pFormat)
Definition: hints.cxx:29
SwAttrSet * m_pChgSet
what has changed
Definition: hints.hxx:231
virtual bool operator==(const SfxPoolItem &) const override
Definition: hints.cxx:140
Base class of the Writer document model elements.
Definition: node.hxx:79