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_VIRTPAGENUM_INFO ), m_pPage( nullptr ), m_pOrigPage( pPg ), m_pFrame( nullptr )
170 {
171 }
172 
174  : SwMsgPoolItem( RES_FINDNEARESTNODE ), m_pNode( &rNd ), m_pFound( nullptr )
175 {
176 }
177 
179 {
180  if( &m_pNode->GetNodes() == &rNd.GetNodes() )
181  {
182  sal_uLong nIdx = rNd.GetIndex();
183  if( nIdx < m_pNode->GetIndex() &&
184  ( !m_pFound || nIdx > m_pFound->GetIndex() ) &&
185  nIdx > rNd.GetNodes().GetEndOfExtras().GetIndex() )
186  m_pFound = &rNd;
187  }
188 }
189 
190 sal_uInt16 GetWhichOfScript( sal_uInt16 nWhich, sal_uInt16 nScript )
191 {
192  static const sal_uInt16 aLangMap[3] =
194  static const sal_uInt16 aFontMap[3] =
196  static const sal_uInt16 aFontSizeMap[3] =
198  static const sal_uInt16 aWeightMap[3] =
200  static const sal_uInt16 aPostureMap[3] =
202 
203  const sal_uInt16* pM;
204  switch( nWhich )
205  {
206  case RES_CHRATR_LANGUAGE:
209  pM = aLangMap;
210  break;
211 
212  case RES_CHRATR_FONT:
213  case RES_CHRATR_CJK_FONT:
214  case RES_CHRATR_CTL_FONT:
215  pM = aFontMap;
216  break;
217 
218  case RES_CHRATR_FONTSIZE:
221  pM = aFontSizeMap;
222  break;
223 
224  case RES_CHRATR_WEIGHT:
227  pM = aWeightMap;
228  break;
229 
230  case RES_CHRATR_POSTURE:
233  pM = aPostureMap;
234  break;
235 
236  default:
237  pM = nullptr;
238  }
239 
240  sal_uInt16 nRet;
241  if( pM )
242  {
243  using namespace ::com::sun::star;
244  {
245  if( i18n::ScriptType::WEAK == nScript )
247  switch( nScript)
248  {
249  case i18n::ScriptType::COMPLEX:
250  ++pM;
251  [[fallthrough]];
252  case i18n::ScriptType::ASIAN:
253  ++pM;
254  [[fallthrough]];
255  default:
256  nRet = *pM;
257  }
258  }
259  }
260  else
261  nRet = nWhich;
262  return nRet;
263 }
264 
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uLong GetIndex() const
Definition: node.hxx:291
constexpr TypedWhichId< SwTableFormulaUpdate > RES_TABLEFML_UPDATE(170)
VclPtr< OutputDevice > pOut
pointer to the current output device
Definition: hints.hxx:213
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
union SwTableFormulaUpdate::@26 m_aData
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
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(162)
virtual ~SwAttrSetChg() override
Definition: hints.cxx:121
sal_uIntPtr sal_uLong
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
RedlineDelText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:56
constexpr TypedWhichId< SwInsText > RES_INS_TXT(164)
SwUpdateAttr(sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW)
Definition: hints.cxx:68
Dialog to specify the properties of date form field.
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CJK_POSTURE(25)
SwRefMarkFieldUpdate(OutputDevice *)
Is sent if reference marks should be updated.
Definition: hints.cxx:78
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SwDocPosUpdate > RES_DOCPOS_UPDATE(169)
SwAutoFormatGetDocNode(const SwNodes *pNds)
Definition: hints.cxx:100
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
const SwTable * m_pTable
Pointer to the current table.
Definition: hints.hxx:243
constexpr sal_uInt16 POOLATTR_BEGIN(HINT_BEGIN)
oslFileHandle & pOut
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
constexpr TypedWhichId< SwFindNearestNode > RES_FINDNEARESTNODE(184)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_WEIGHT(15)
Base class for various Writer styles.
Definition: format.hxx:46
const SwNode * m_pFound
Definition: hints.hxx:315
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
constexpr TypedWhichId< SwUpdateAttr > RES_UPDATE_ATTR(167)
SwDocPosUpdate(const SwTwips nDocPos)
Definition: hints.cxx:85
SwDelText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:44
constexpr TypedWhichId< SwVirtPageNumInfo > RES_VIRTPAGENUM_INFO(180)
SwFindNearestNode(const SwNode &rNd)
Definition: hints.cxx:173
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
static sal_Int16 GetI18NScriptTypeOfLanguage(LanguageType nLang)
sal_uInt16 GetWhichOfScript(sal_uInt16 nWhich, sal_uInt16 nScript)
Definition: hints.cxx:190
constexpr TypedWhichId< SwAutoFormatGetDocNode > RES_AUTOFMT_DOCNODE(173)
void CheckNode(const SwNode &rNd)
Definition: hints.cxx:178
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:697
constexpr TypedWhichId< SwRefMarkFieldUpdate > RES_REFMARKFLD_UPDATE(168)
A page of the document layout.
Definition: pagefrm.hxx:41
tools::Long SwTwips
Definition: swtypes.hxx:49
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:111
SwMsgPoolItem(sal_uInt16 nWhich)
Definition: hints.cxx:135
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CJK_WEIGHT(26)
constexpr TypedWhichId< SvxWeightItem > RES_CHRATR_CTL_WEIGHT(31)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
SwDfltAttrTab aAttrTab
const SwNode * m_pNode
Definition: hints.hxx:315
LanguageType GetAppLanguage()
Definition: init.cxx:732
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CTL_POSTURE(30)
bool m_bDelSet
Definition: hints.hxx:272
SwTableFormulaUpdate(const SwTable *)
Is sent if a table should be recalculated.
Definition: hints.cxx:90
virtual SwMsgPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: hints.cxx:146
SwVirtPageNumInfo(const SwPageFrame *pPg)
Multiple attributes can be attached to a single paragraph / table The frame, in the end...
Definition: hints.cxx:168
void ClearItem(sal_uInt16 nWhichL)
Definition: hints.cxx:128
SwInsText(sal_Int32 nP, sal_Int32 nL)
Definition: hints.cxx:34
constexpr TypedWhichId< SwDelChr > RES_DEL_CHR(165)
SwDelChr(sal_Int32 nP)
Definition: hints.cxx:39
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:161
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CTL_FONTSIZE(28)
constexpr TypedWhichId< SwDelText > RES_DEL_TXT(166)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_CJK_FONTSIZE(23)
SwFormatChg(SwFormat *pFormat)
Definition: hints.cxx:29
SwAttrSet * m_pChgSet
what has changed
Definition: hints.hxx:273
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_POSTURE(11)
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CJK_LANGUAGE(24)
sal_uInt16 nPos
virtual bool operator==(const SfxPoolItem &) const override
Definition: hints.cxx:140
Base class of the Writer document model elements.
Definition: node.hxx:80