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 const nP, sal_Int32 const nL, bool const isInFMCommand, bool const isInFMResult)
36  , nPos( nP ), nLen( nL )
37  , isInsideFieldmarkCommand(isInFMCommand)
38  , isInsideFieldmarkResult(isInFMResult)
39 {
40 }
41 
42 SwDelChr::SwDelChr( sal_Int32 nP )
43  : SwMsgPoolItem( RES_DEL_CHR ), nPos( nP )
44 {
45 }
46 
47 SwDelText::SwDelText( sal_Int32 nS, sal_Int32 nL )
48  : SwMsgPoolItem( RES_DEL_TXT ), nStart( nS ), nLen( nL )
49 {
50 }
51 
52 namespace sw {
53 
54 MoveText::MoveText(SwTextNode *const pD, sal_Int32 const nD, sal_Int32 const nS, sal_Int32 const nL)
55  : pDestNode(pD), nDestStart(nD), nSourceStart(nS), nLen(nL)
56 {
57 }
58 
59 RedlineDelText::RedlineDelText(sal_Int32 const nS, sal_Int32 const nL)
60  : nStart(nS), nLen(nL)
61 {
62 }
63 
64 RedlineUnDelText::RedlineUnDelText(sal_Int32 const nS, sal_Int32 const nL)
65  : nStart(nS), nLen(nL)
66 {
67 }
68 
69 } // namespace sw
70 
71 SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW )
72  : SwMsgPoolItem( RES_UPDATE_ATTR ), m_nStart( nS ), m_nEnd( nE ), m_nWhichAttr( nW )
73 {
74 }
75 
76 SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW, std::vector<sal_uInt16> aW )
77  : SwMsgPoolItem( RES_UPDATE_ATTR ), m_nStart( nS ), m_nEnd( nE ), m_nWhichAttr( nW ), m_aWhichFmtAttrs( aW )
78 {
79 }
80 
83  pOut( pOutput )
84 {
85  OSL_ENSURE( pOut, "No OutputDevice pointer" );
86 }
87 
89  : SwMsgPoolItem( RES_DOCPOS_UPDATE ), nDocPos(nDcPos)
90 {
91 }
92 
95  m_pTable( pNewTable ), m_pHistory( nullptr ), m_nSplitLine( USHRT_MAX ),
96  m_eFlags( TBL_CALC )
97 {
98  m_aData.pDelTable = nullptr;
100  OSL_ENSURE( m_pTable, "No Table pointer" );
101 }
102 
104  : SwMsgPoolItem( RES_AUTOFMT_DOCNODE ), pNodes( pNds )
105 {
106 }
107 
110  m_bDelSet( false ),
111  m_pChgSet( &rSet ),
112  m_pTheChgdSet( &rTheSet )
113 {
114 }
115 
118  m_bDelSet( true ),
119  m_pTheChgdSet( rChgSet.m_pTheChgdSet )
120 {
121  m_pChgSet = new SwAttrSet( *rChgSet.m_pChgSet );
122 }
123 
125 {
126  if( m_bDelSet )
127  delete m_pChgSet;
128 }
129 
130 #ifdef DBG_UTIL
131 void SwAttrSetChg::ClearItem( sal_uInt16 nWhch )
132 {
133  OSL_ENSURE( m_bDelSet, "The Set may not be changed!" );
134  m_pChgSet->ClearItem( nWhch );
135 }
136 #endif
137 
138 SwMsgPoolItem::SwMsgPoolItem( sal_uInt16 nWhch )
139  : SfxPoolItem( nWhch )
140 {
141 }
142 
144 {
145  assert( false && "SwMsgPoolItem knows no ==" );
146  return false;
147 }
148 
150 {
151  OSL_FAIL( "SwMsgPoolItem knows no Clone" );
152  return nullptr;
153 }
154 
155 #if OSL_DEBUG_LEVEL > 0
156 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
157 {
158  OSL_ASSERT( nWhich < POOLATTR_END && nWhich >= POOLATTR_BEGIN );
159 
160  SfxPoolItem *pHt = aAttrTab[ nWhich - POOLATTR_BEGIN ];
161  OSL_ENSURE( pHt, "GetDfltFormatAttr(): Dflt == 0" );
162  return pHt;
163 }
164 #else
165 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
166 {
167  return aAttrTab[ nWhich - POOLATTR_BEGIN ];
168 }
169 #endif
170 
172  SwMsgPoolItem( RES_VIRTPAGENUM_INFO ), m_pPage( nullptr ), m_pOrigPage( pPg ), m_pFrame( nullptr )
173 {
174 }
175 
177  : SwMsgPoolItem( RES_FINDNEARESTNODE ), m_pNode( &rNd ), m_pFound( nullptr )
178 {
179 }
180 
182 {
183  if( &m_pNode->GetNodes() == &rNd.GetNodes() )
184  {
185  SwNodeOffset nIdx = rNd.GetIndex();
186  if( nIdx < m_pNode->GetIndex() &&
187  ( !m_pFound || nIdx > m_pFound->GetIndex() ) &&
188  nIdx > rNd.GetNodes().GetEndOfExtras().GetIndex() )
189  m_pFound = &rNd;
190  }
191 }
192 
193 sal_uInt16 GetWhichOfScript( sal_uInt16 nWhich, sal_uInt16 nScript )
194 {
195  static const sal_uInt16 aLangMap[3] =
197  static const sal_uInt16 aFontMap[3] =
199  static const sal_uInt16 aFontSizeMap[3] =
201  static const sal_uInt16 aWeightMap[3] =
203  static const sal_uInt16 aPostureMap[3] =
205 
206  const sal_uInt16* pM;
207  switch( nWhich )
208  {
209  case RES_CHRATR_LANGUAGE:
212  pM = aLangMap;
213  break;
214 
215  case RES_CHRATR_FONT:
216  case RES_CHRATR_CJK_FONT:
217  case RES_CHRATR_CTL_FONT:
218  pM = aFontMap;
219  break;
220 
221  case RES_CHRATR_FONTSIZE:
224  pM = aFontSizeMap;
225  break;
226 
227  case RES_CHRATR_WEIGHT:
230  pM = aWeightMap;
231  break;
232 
233  case RES_CHRATR_POSTURE:
236  pM = aPostureMap;
237  break;
238 
239  default:
240  pM = nullptr;
241  }
242 
243  sal_uInt16 nRet;
244  if( pM )
245  {
246  using namespace ::com::sun::star;
247  {
248  if( i18n::ScriptType::WEAK == nScript )
250  switch( nScript)
251  {
252  case i18n::ScriptType::COMPLEX:
253  ++pM;
254  [[fallthrough]];
255  case i18n::ScriptType::ASIAN:
256  ++pM;
257  [[fallthrough]];
258  default:
259  nRet = *pM;
260  }
261  }
262  }
263  else
264  nRet = nWhich;
265  return nRet;
266 }
267 
268 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< SwTableFormulaUpdate > RES_TABLEFML_UPDATE(170)
VclPtr< OutputDevice > pOut
pointer to the current output device
Definition: hints.hxx:233
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CTL_FONT(27)
union SwTableFormulaUpdate::@26 m_aData
SwAttrSetChg(const SwAttrSet &rTheSet, SwAttrSet &rSet)
Definition: hints.cxx:108
MoveText(SwTextNode *pD, sal_Int32 nD, sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:54
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(162)
virtual ~SwAttrSetChg() override
Definition: hints.cxx:124
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_LANGUAGE(10)
constexpr TypedWhichId< SvxFontHeightItem > RES_CHRATR_FONTSIZE(8)
RedlineDelText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:59
constexpr TypedWhichId< SwInsText > RES_INS_TXT(164)
SwUpdateAttr(sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW)
Definition: hints.cxx:71
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:81
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_FONT(7)
constexpr TypedWhichId< SwDocPosUpdate > RES_DOCPOS_UPDATE(169)
SwAutoFormatGetDocNode(const SwNodes *pNds)
Definition: hints.cxx:103
constexpr TypedWhichId< SvxLanguageItem > RES_CHRATR_CTL_LANGUAGE(29)
const SwTable * m_pTable
Pointer to the current table.
Definition: hints.hxx:263
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:156
RedlineUnDelText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:64
sal_Int16 GetI18NScriptTypeOfLanguage(LanguageType nLang)
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:335
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
constexpr TypedWhichId< SwUpdateAttr > RES_UPDATE_ATTR(167)
SwDocPosUpdate(const SwTwips nDocPos)
Definition: hints.cxx:88
SwDelText(sal_Int32 nS, sal_Int32 nL)
Definition: hints.cxx:47
SwNodeOffset GetIndex() const
Definition: node.hxx:292
constexpr TypedWhichId< SwVirtPageNumInfo > RES_VIRTPAGENUM_INFO(180)
SwFindNearestNode(const SwNode &rNd)
Definition: hints.cxx:176
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
sal_uInt16 GetWhichOfScript(sal_uInt16 nWhich, sal_uInt16 nScript)
Definition: hints.cxx:193
constexpr TypedWhichId< SwAutoFormatGetDocNode > RES_AUTOFMT_DOCNODE(173)
void CheckNode(const SwNode &rNd)
Definition: hints.cxx:181
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:703
constexpr TypedWhichId< SwRefMarkFieldUpdate > RES_REFMARKFLD_UPDATE(168)
A page of the document layout.
Definition: pagefrm.hxx:57
tools::Long SwTwips
Definition: swtypes.hxx:51
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:112
SwMsgPoolItem(sal_uInt16 nWhich)
Definition: hints.cxx:138
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)
SwDfltAttrTab aAttrTab
const SwNode * m_pNode
Definition: hints.hxx:335
LanguageType GetAppLanguage()
Definition: init.cxx:725
constexpr TypedWhichId< SvxFontItem > RES_CHRATR_CJK_FONT(22)
constexpr TypedWhichId< SvxPostureItem > RES_CHRATR_CTL_POSTURE(30)
bool m_bDelSet
Definition: hints.hxx:292
SwTableFormulaUpdate(const SwTable *)
Is sent if a table should be recalculated.
Definition: hints.cxx:93
virtual SwMsgPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: hints.cxx:149
SwVirtPageNumInfo(const SwPageFrame *pPg)
Multiple attributes can be attached to a single paragraph / table The frame, in the end...
Definition: hints.cxx:171
void ClearItem(sal_uInt16 nWhichL)
Definition: hints.cxx:131
constexpr TypedWhichId< SwDelChr > RES_DEL_CHR(165)
SwDelChr(sal_Int32 nP)
Definition: hints.cxx:42
SwInsText(sal_Int32 nP, sal_Int32 nL, bool isInFMCommand, bool isInFMResult)
Definition: hints.cxx:34
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:160
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:293
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:143
bool m_bDetectedRangeSegmentation false
Base class of the Writer document model elements.
Definition: node.hxx:81