android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / core / attr / hints.cxx
blob20190d81e642f76e5d4830b7011f096e88b6b4de
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 <utility>
27 #include <vcl/outdev.hxx>
28 #include <osl/diagnose.h>
30 SwFormatChg::SwFormatChg( SwFormat* pFormat )
31 : SwMsgPoolItem( RES_FMT_CHG ), pChangedFormat( pFormat )
37 namespace sw {
39 MoveText::MoveText(SwTextNode *const pD, sal_Int32 const nD, sal_Int32 const nS, sal_Int32 const nL)
40 : pDestNode(pD), nDestStart(nD), nSourceStart(nS), nLen(nL)
44 InsertText::InsertText(const sal_Int32 nP, const sal_Int32 nL, const bool isInFMCommand, const bool isInFMResult)
45 : SfxHint( SfxHintId::SwInsertText )
46 , nPos( nP ), nLen( nL )
47 , isInsideFieldmarkCommand(isInFMCommand)
48 , isInsideFieldmarkResult(isInFMResult)
52 DeleteText::DeleteText( const sal_Int32 nS, const sal_Int32 nL )
53 : SfxHint( SfxHintId::SwDeleteText ), nStart( nS ), nLen( nL )
57 DeleteChar::DeleteChar( const sal_Int32 nPos )
58 : SfxHint( SfxHintId::SwDeleteChar ), m_nPos( nPos )
62 RedlineDelText::RedlineDelText(sal_Int32 const nS, sal_Int32 const nL)
63 : nStart(nS), nLen(nL)
67 RedlineUnDelText::RedlineUnDelText(sal_Int32 const nS, sal_Int32 const nL)
68 : nStart(nS), nLen(nL)
72 } // namespace sw
74 SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW )
75 : SwMsgPoolItem( RES_UPDATE_ATTR ), m_nStart( nS ), m_nEnd( nE ), m_nWhichAttr( nW )
79 SwUpdateAttr::SwUpdateAttr( sal_Int32 nS, sal_Int32 nE, sal_uInt16 nW, std::vector<sal_uInt16> aW )
80 : SwMsgPoolItem( RES_UPDATE_ATTR ), m_nStart( nS ), m_nEnd( nE ), m_nWhichAttr( nW ), m_aWhichFmtAttrs(std::move( aW ))
84 SwTableFormulaUpdate::SwTableFormulaUpdate(const SwTable* pNewTable)
85 : m_pTable(pNewTable)
86 , m_nSplitLine(USHRT_MAX)
87 , m_eFlags(TBL_CALC)
89 m_aData.pDelTable = nullptr;
90 m_bModified = m_bBehindSplitLine = false;
91 OSL_ENSURE( m_pTable, "No Table pointer" );
94 SwAutoFormatGetDocNode::SwAutoFormatGetDocNode( const SwNodes* pNds )
95 : SwMsgPoolItem( RES_AUTOFMT_DOCNODE ), pNodes( pNds )
99 SwAttrSetChg::SwAttrSetChg( const SwAttrSet& rTheSet, SwAttrSet& rSet )
100 : SwMsgPoolItem( RES_ATTRSET_CHG ),
101 m_bDelSet( false ),
102 m_pChgSet( &rSet ),
103 m_pTheChgdSet( &rTheSet )
107 SwAttrSetChg::SwAttrSetChg( const SwAttrSetChg& rChgSet )
108 : SwMsgPoolItem( RES_ATTRSET_CHG ),
109 m_bDelSet( true ),
110 m_pTheChgdSet( rChgSet.m_pTheChgdSet )
112 m_pChgSet = new SwAttrSet( *rChgSet.m_pChgSet );
115 SwAttrSetChg::~SwAttrSetChg()
117 if( m_bDelSet )
118 delete m_pChgSet;
121 #ifdef DBG_UTIL
122 void SwAttrSetChg::ClearItem( sal_uInt16 nWhch )
124 OSL_ENSURE( m_bDelSet, "The Set may not be changed!" );
125 m_pChgSet->ClearItem( nWhch );
127 #endif
129 SwMsgPoolItem::SwMsgPoolItem( sal_uInt16 nWhch )
130 : SfxPoolItem( nWhch )
134 bool SwMsgPoolItem::operator==( const SfxPoolItem& ) const
136 assert( false && "SwMsgPoolItem knows no ==" );
137 return false;
140 SwMsgPoolItem* SwMsgPoolItem::Clone( SfxItemPool* ) const
142 OSL_FAIL( "SwMsgPoolItem knows no Clone" );
143 return nullptr;
146 #if OSL_DEBUG_LEVEL > 0
147 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
149 OSL_ASSERT( nWhich < POOLATTR_END && nWhich >= POOLATTR_BEGIN );
151 SfxPoolItem *pHt = aAttrTab[ nWhich - POOLATTR_BEGIN ];
152 OSL_ENSURE( pHt, "GetDfltFormatAttr(): Dflt == 0" );
153 return pHt;
155 #else
156 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
158 return aAttrTab[ nWhich - POOLATTR_BEGIN ];
160 #endif
162 SwVirtPageNumInfo::SwVirtPageNumInfo( const SwPageFrame *pPg ) :
163 SwMsgPoolItem( RES_VIRTPAGENUM_INFO ), m_pPage( nullptr ), m_pOrigPage( pPg ), m_pFrame( nullptr )
167 SwFindNearestNode::SwFindNearestNode( const SwNode& rNd )
168 : SwMsgPoolItem( RES_FINDNEARESTNODE ), m_pNode( &rNd ), m_pFound( nullptr )
172 void SwFindNearestNode::CheckNode( const SwNode& rNd )
174 if( &m_pNode->GetNodes() == &rNd.GetNodes() )
176 SwNodeOffset nIdx = rNd.GetIndex();
177 if( nIdx < m_pNode->GetIndex() &&
178 ( !m_pFound || nIdx > m_pFound->GetIndex() ) &&
179 nIdx > rNd.GetNodes().GetEndOfExtras().GetIndex() )
180 m_pFound = &rNd;
184 sal_uInt16 GetWhichOfScript( sal_uInt16 nWhich, sal_uInt16 nScript )
186 static const sal_uInt16 aLangMap[3] =
187 { RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE };
188 static const sal_uInt16 aFontMap[3] =
189 { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT};
190 static const sal_uInt16 aFontSizeMap[3] =
191 { RES_CHRATR_FONTSIZE, RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CTL_FONTSIZE };
192 static const sal_uInt16 aWeightMap[3] =
193 { RES_CHRATR_WEIGHT, RES_CHRATR_CJK_WEIGHT, RES_CHRATR_CTL_WEIGHT};
194 static const sal_uInt16 aPostureMap[3] =
195 { RES_CHRATR_POSTURE, RES_CHRATR_CJK_POSTURE, RES_CHRATR_CTL_POSTURE};
197 const sal_uInt16* pM;
198 switch( nWhich )
200 case RES_CHRATR_LANGUAGE:
201 case RES_CHRATR_CJK_LANGUAGE:
202 case RES_CHRATR_CTL_LANGUAGE:
203 pM = aLangMap;
204 break;
206 case RES_CHRATR_FONT:
207 case RES_CHRATR_CJK_FONT:
208 case RES_CHRATR_CTL_FONT:
209 pM = aFontMap;
210 break;
212 case RES_CHRATR_FONTSIZE:
213 case RES_CHRATR_CJK_FONTSIZE:
214 case RES_CHRATR_CTL_FONTSIZE:
215 pM = aFontSizeMap;
216 break;
218 case RES_CHRATR_WEIGHT:
219 case RES_CHRATR_CJK_WEIGHT:
220 case RES_CHRATR_CTL_WEIGHT:
221 pM = aWeightMap;
222 break;
224 case RES_CHRATR_POSTURE:
225 case RES_CHRATR_CJK_POSTURE:
226 case RES_CHRATR_CTL_POSTURE:
227 pM = aPostureMap;
228 break;
230 default:
231 pM = nullptr;
234 sal_uInt16 nRet;
235 if( pM )
237 using namespace ::com::sun::star;
239 if( i18n::ScriptType::WEAK == nScript )
240 nScript = SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() );
241 switch( nScript)
243 case i18n::ScriptType::COMPLEX:
244 ++pM;
245 [[fallthrough]];
246 case i18n::ScriptType::ASIAN:
247 ++pM;
248 [[fallthrough]];
249 default:
250 nRet = *pM;
254 else
255 nRet = nWhich;
256 return nRet;
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */