nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / attr / hints.cxx
blob56288c840bbe07e2fc23a64d4b3d65f77f48ccd2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
29 SwFormatChg::SwFormatChg( SwFormat* pFormat )
30 : SwMsgPoolItem( RES_FMT_CHG ), pChangedFormat( pFormat )
34 SwInsText::SwInsText( sal_Int32 nP, sal_Int32 nL )
35 : SwMsgPoolItem( RES_INS_TXT ), nPos( nP ), nLen( nL )
39 SwDelChr::SwDelChr( sal_Int32 nP )
40 : SwMsgPoolItem( RES_DEL_CHR ), nPos( nP )
44 SwDelText::SwDelText( sal_Int32 nS, sal_Int32 nL )
45 : SwMsgPoolItem( RES_DEL_TXT ), nStart( nS ), nLen( nL )
49 namespace sw {
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)
56 RedlineDelText::RedlineDelText(sal_Int32 const nS, sal_Int32 const nL)
57 : nStart(nS), nLen(nL)
61 RedlineUnDelText::RedlineUnDelText(sal_Int32 const nS, sal_Int32 const nL)
62 : nStart(nS), nLen(nL)
66 } // namespace sw
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 )
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 )
78 SwRefMarkFieldUpdate::SwRefMarkFieldUpdate( OutputDevice* pOutput )
79 : SwMsgPoolItem( RES_REFMARKFLD_UPDATE ),
80 pOut( pOutput )
82 OSL_ENSURE( pOut, "No OutputDevice pointer" );
85 SwDocPosUpdate::SwDocPosUpdate( const SwTwips nDcPos )
86 : SwMsgPoolItem( RES_DOCPOS_UPDATE ), nDocPos(nDcPos)
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 )
95 m_aData.pDelTable = nullptr;
96 m_bModified = m_bBehindSplitLine = false;
97 OSL_ENSURE( m_pTable, "No Table pointer" );
100 SwAutoFormatGetDocNode::SwAutoFormatGetDocNode( const SwNodes* pNds )
101 : SwMsgPoolItem( RES_AUTOFMT_DOCNODE ), pNodes( pNds )
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 )
113 SwAttrSetChg::SwAttrSetChg( const SwAttrSetChg& rChgSet )
114 : SwMsgPoolItem( RES_ATTRSET_CHG ),
115 m_bDelSet( true ),
116 m_pTheChgdSet( rChgSet.m_pTheChgdSet )
118 m_pChgSet = new SwAttrSet( *rChgSet.m_pChgSet );
121 SwAttrSetChg::~SwAttrSetChg()
123 if( m_bDelSet )
124 delete m_pChgSet;
127 #ifdef DBG_UTIL
128 void SwAttrSetChg::ClearItem( sal_uInt16 nWhch )
130 OSL_ENSURE( m_bDelSet, "The Set may not be changed!" );
131 m_pChgSet->ClearItem( nWhch );
133 #endif
135 SwMsgPoolItem::SwMsgPoolItem( sal_uInt16 nWhch )
136 : SfxPoolItem( nWhch )
140 bool SwMsgPoolItem::operator==( const SfxPoolItem& ) const
142 assert( false && "SwMsgPoolItem knows no ==" );
143 return false;
146 SwMsgPoolItem* SwMsgPoolItem::Clone( SfxItemPool* ) const
148 OSL_FAIL( "SwMsgPoolItem knows no Clone" );
149 return nullptr;
152 #if OSL_DEBUG_LEVEL > 0
153 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
155 OSL_ASSERT( nWhich < POOLATTR_END && nWhich >= POOLATTR_BEGIN );
157 SfxPoolItem *pHt = aAttrTab[ nWhich - POOLATTR_BEGIN ];
158 OSL_ENSURE( pHt, "GetDfltFormatAttr(): Dflt == 0" );
159 return pHt;
161 #else
162 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
164 return aAttrTab[ nWhich - POOLATTR_BEGIN ];
166 #endif
168 SwVirtPageNumInfo::SwVirtPageNumInfo( const SwPageFrame *pPg ) :
169 SwMsgPoolItem( RES_VIRTPAGENUM_INFO ), m_pPage( nullptr ), m_pOrigPage( pPg ), m_pFrame( nullptr )
173 SwFindNearestNode::SwFindNearestNode( const SwNode& rNd )
174 : SwMsgPoolItem( RES_FINDNEARESTNODE ), m_pNode( &rNd ), m_pFound( nullptr )
178 void SwFindNearestNode::CheckNode( const SwNode& rNd )
180 if( &m_pNode->GetNodes() == &rNd.GetNodes() )
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;
190 sal_uInt16 GetWhichOfScript( sal_uInt16 nWhich, sal_uInt16 nScript )
192 static const sal_uInt16 aLangMap[3] =
193 { RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE };
194 static const sal_uInt16 aFontMap[3] =
195 { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT};
196 static const sal_uInt16 aFontSizeMap[3] =
197 { RES_CHRATR_FONTSIZE, RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CTL_FONTSIZE };
198 static const sal_uInt16 aWeightMap[3] =
199 { RES_CHRATR_WEIGHT, RES_CHRATR_CJK_WEIGHT, RES_CHRATR_CTL_WEIGHT};
200 static const sal_uInt16 aPostureMap[3] =
201 { RES_CHRATR_POSTURE, RES_CHRATR_CJK_POSTURE, RES_CHRATR_CTL_POSTURE};
203 const sal_uInt16* pM;
204 switch( nWhich )
206 case RES_CHRATR_LANGUAGE:
207 case RES_CHRATR_CJK_LANGUAGE:
208 case RES_CHRATR_CTL_LANGUAGE:
209 pM = aLangMap;
210 break;
212 case RES_CHRATR_FONT:
213 case RES_CHRATR_CJK_FONT:
214 case RES_CHRATR_CTL_FONT:
215 pM = aFontMap;
216 break;
218 case RES_CHRATR_FONTSIZE:
219 case RES_CHRATR_CJK_FONTSIZE:
220 case RES_CHRATR_CTL_FONTSIZE:
221 pM = aFontSizeMap;
222 break;
224 case RES_CHRATR_WEIGHT:
225 case RES_CHRATR_CJK_WEIGHT:
226 case RES_CHRATR_CTL_WEIGHT:
227 pM = aWeightMap;
228 break;
230 case RES_CHRATR_POSTURE:
231 case RES_CHRATR_CJK_POSTURE:
232 case RES_CHRATR_CTL_POSTURE:
233 pM = aPostureMap;
234 break;
236 default:
237 pM = nullptr;
240 sal_uInt16 nRet;
241 if( pM )
243 using namespace ::com::sun::star;
245 if( i18n::ScriptType::WEAK == nScript )
246 nScript = SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() );
247 switch( nScript)
249 case i18n::ScriptType::COMPLEX:
250 ++pM;
251 [[fallthrough]];
252 case i18n::ScriptType::ASIAN:
253 ++pM;
254 [[fallthrough]];
255 default:
256 nRet = *pM;
260 else
261 nRet = nWhich;
262 return nRet;
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */