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
SwFormatChg(SwFormat * pFormat)29 SwFormatChg::SwFormatChg( SwFormat* pFormat )
30 : SwMsgPoolItem( RES_FMT_CHG ), pChangedFormat( pFormat )
31 {
32 }
33
SwInsText(sal_Int32 nP,sal_Int32 nL)34 SwInsText::SwInsText( sal_Int32 nP, sal_Int32 nL )
35 : SwMsgPoolItem( RES_INS_TXT ), nPos( nP ), nLen( nL )
36 {
37 }
38
SwDelChr(sal_Int32 nP)39 SwDelChr::SwDelChr( sal_Int32 nP )
40 : SwMsgPoolItem( RES_DEL_CHR ), nPos( nP )
41 {
42 }
43
SwDelText(sal_Int32 nS,sal_Int32 nL)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
MoveText(SwTextNode * const pD,sal_Int32 const nD,sal_Int32 const nS,sal_Int32 const nL)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
RedlineDelText(sal_Int32 const nS,sal_Int32 const nL)56 RedlineDelText::RedlineDelText(sal_Int32 const nS, sal_Int32 const nL)
57 : nStart(nS), nLen(nL)
58 {
59 }
60
RedlineUnDelText(sal_Int32 const nS,sal_Int32 const nL)61 RedlineUnDelText::RedlineUnDelText(sal_Int32 const nS, sal_Int32 const nL)
62 : nStart(nS), nLen(nL)
63 {
64 }
65
66 } // namespace sw
67
SwUpdateAttr(sal_Int32 nS,sal_Int32 nE,sal_uInt16 nW)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
SwUpdateAttr(sal_Int32 nS,sal_Int32 nE,sal_uInt16 nW,std::vector<sal_uInt16> aW)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
SwRefMarkFieldUpdate(OutputDevice * pOutput)78 SwRefMarkFieldUpdate::SwRefMarkFieldUpdate( OutputDevice* pOutput )
79 : SwMsgPoolItem( RES_REFMARKFLD_UPDATE ),
80 pOut( pOutput )
81 {
82 OSL_ENSURE( pOut, "No OutputDevice pointer" );
83 }
84
SwDocPosUpdate(const SwTwips nDcPos)85 SwDocPosUpdate::SwDocPosUpdate( const SwTwips nDcPos )
86 : SwMsgPoolItem( RES_DOCPOS_UPDATE ), nDocPos(nDcPos)
87 {
88 }
89
SwTableFormulaUpdate(const SwTable * pNewTable)90 SwTableFormulaUpdate::SwTableFormulaUpdate( const SwTable* pNewTable )
91 : SwMsgPoolItem( RES_TABLEFML_UPDATE ),
92 m_pTable( pNewTable ), m_pHistory( nullptr ), m_nSplitLine( USHRT_MAX ),
93 m_eFlags( TBL_CALC )
94 {
95 m_aData.pDelTable = nullptr;
96 m_bModified = m_bBehindSplitLine = false;
97 OSL_ENSURE( m_pTable, "No Table pointer" );
98 }
99
SwAutoFormatGetDocNode(const SwNodes * pNds)100 SwAutoFormatGetDocNode::SwAutoFormatGetDocNode( const SwNodes* pNds )
101 : SwMsgPoolItem( RES_AUTOFMT_DOCNODE ), pNodes( pNds )
102 {
103 }
104
SwAttrSetChg(const SwAttrSet & rTheSet,SwAttrSet & rSet)105 SwAttrSetChg::SwAttrSetChg( const SwAttrSet& rTheSet, SwAttrSet& rSet )
106 : SwMsgPoolItem( RES_ATTRSET_CHG ),
107 m_bDelSet( false ),
108 m_pChgSet( &rSet ),
109 m_pTheChgdSet( &rTheSet )
110 {
111 }
112
SwAttrSetChg(const SwAttrSetChg & rChgSet)113 SwAttrSetChg::SwAttrSetChg( const SwAttrSetChg& rChgSet )
114 : SwMsgPoolItem( RES_ATTRSET_CHG ),
115 m_bDelSet( true ),
116 m_pTheChgdSet( rChgSet.m_pTheChgdSet )
117 {
118 m_pChgSet = new SwAttrSet( *rChgSet.m_pChgSet );
119 }
120
~SwAttrSetChg()121 SwAttrSetChg::~SwAttrSetChg()
122 {
123 if( m_bDelSet )
124 delete m_pChgSet;
125 }
126
127 #ifdef DBG_UTIL
ClearItem(sal_uInt16 nWhch)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
SwMsgPoolItem(sal_uInt16 nWhch)135 SwMsgPoolItem::SwMsgPoolItem( sal_uInt16 nWhch )
136 : SfxPoolItem( nWhch )
137 {
138 }
139
operator ==(const SfxPoolItem &) const140 bool SwMsgPoolItem::operator==( const SfxPoolItem& ) const
141 {
142 assert( false && "SwMsgPoolItem knows no ==" );
143 return false;
144 }
145
Clone(SfxItemPool *) const146 SfxPoolItem* SwMsgPoolItem::Clone( SfxItemPool* ) const
147 {
148 OSL_FAIL( "SwMsgPoolItem knows no Clone" );
149 return nullptr;
150 }
151
152 #if OSL_DEBUG_LEVEL > 0
GetDfltAttr(sal_uInt16 nWhich)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
GetDfltAttr(sal_uInt16 nWhich)162 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
163 {
164 return aAttrTab[ nWhich - POOLATTR_BEGIN ];
165 }
166 #endif
167
SwCondCollCondChg(SwFormat * pFormat)168 SwCondCollCondChg::SwCondCollCondChg( SwFormat *pFormat )
169 : SwMsgPoolItem( RES_CONDCOLL_CONDCHG ), pChangedFormat( pFormat )
170 {
171 }
172
SwVirtPageNumInfo(const SwPageFrame * pPg)173 SwVirtPageNumInfo::SwVirtPageNumInfo( const SwPageFrame *pPg ) :
174 SwMsgPoolItem( RES_VIRTPAGENUM_INFO ), m_pPage( nullptr ), m_pOrigPage( pPg ), m_pFrame( nullptr )
175 {
176 }
177
SwFindNearestNode(const SwNode & rNd)178 SwFindNearestNode::SwFindNearestNode( const SwNode& rNd )
179 : SwMsgPoolItem( RES_FINDNEARESTNODE ), m_pNode( &rNd ), m_pFound( nullptr )
180 {
181 }
182
CheckNode(const SwNode & rNd)183 void SwFindNearestNode::CheckNode( const SwNode& rNd )
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
GetWhichOfScript(sal_uInt16 nWhich,sal_uInt16 nScript)195 sal_uInt16 GetWhichOfScript( sal_uInt16 nWhich, sal_uInt16 nScript )
196 {
197 static const sal_uInt16 aLangMap[3] =
198 { RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE };
199 static const sal_uInt16 aFontMap[3] =
200 { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT};
201 static const sal_uInt16 aFontSizeMap[3] =
202 { RES_CHRATR_FONTSIZE, RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CTL_FONTSIZE };
203 static const sal_uInt16 aWeightMap[3] =
204 { RES_CHRATR_WEIGHT, RES_CHRATR_CJK_WEIGHT, RES_CHRATR_CTL_WEIGHT};
205 static const sal_uInt16 aPostureMap[3] =
206 { RES_CHRATR_POSTURE, RES_CHRATR_CJK_POSTURE, RES_CHRATR_CTL_POSTURE};
207
208 const sal_uInt16* pM;
209 switch( nWhich )
210 {
211 case RES_CHRATR_LANGUAGE:
212 case RES_CHRATR_CJK_LANGUAGE:
213 case RES_CHRATR_CTL_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:
224 case RES_CHRATR_CJK_FONTSIZE:
225 case RES_CHRATR_CTL_FONTSIZE:
226 pM = aFontSizeMap;
227 break;
228
229 case RES_CHRATR_WEIGHT:
230 case RES_CHRATR_CJK_WEIGHT:
231 case RES_CHRATR_CTL_WEIGHT:
232 pM = aWeightMap;
233 break;
234
235 case RES_CHRATR_POSTURE:
236 case RES_CHRATR_CJK_POSTURE:
237 case RES_CHRATR_CTL_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 )
251 nScript = SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() );
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: */
271