Update ooo320-m1
[ooovba.git] / sw / source / core / attr / hints.cxx
bloba1725667feb397fed1aa7ce90650addfc51779e6
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hints.cxx,v $
10 * $Revision: 1.16 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <hints.hxx>
35 #ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_
36 #include <com/sun/star/i18n/ScriptType.hdl>
37 #endif
38 #include <svx/scripttypeitem.hxx>
39 #include <hintids.hxx>
40 #include <swtypes.hxx>
41 #include <ndtxt.hxx>
42 #include <errhdl.hxx>
44 SwFmtChg::SwFmtChg( SwFmt *pFmt )
45 : SwMsgPoolItem( RES_FMT_CHG ),
46 pChangedFmt( pFmt )
50 SwInsChr::SwInsChr( xub_StrLen nP )
51 : SwMsgPoolItem( RES_INS_CHR ),
52 nPos( nP )
57 SwInsTxt::SwInsTxt( xub_StrLen nP, xub_StrLen nL )
58 : SwMsgPoolItem( RES_INS_TXT ),
59 nPos( nP ),
60 nLen( nL )
65 SwDelChr::SwDelChr( xub_StrLen nP )
66 : SwMsgPoolItem( RES_DEL_CHR ),
67 nPos( nP )
72 SwDelTxt::SwDelTxt( xub_StrLen nS, xub_StrLen nL )
73 : SwMsgPoolItem( RES_DEL_TXT ),
74 nStart( nS ),
75 nLen( nL )
80 SwUpdateAttr::SwUpdateAttr( xub_StrLen nS, xub_StrLen nE, USHORT nW )
81 : SwMsgPoolItem( RES_UPDATE_ATTR ),
82 nStart( nS ),
83 nEnd( nE ),
84 nWhichAttr( nW )
88 // SwRefMarkFldUpdate wird verschickt, wenn sich die ReferenzMarkierungen
89 // Updaten sollen. Um Seiten-/KapitelNummer feststellen zu koennen, muss
90 // der akt. Frame befragt werden. Dafuer wird das akt. OutputDevice benoetigt.
93 SwRefMarkFldUpdate::SwRefMarkFldUpdate( const OutputDevice* pOutput )
94 : SwMsgPoolItem( RES_REFMARKFLD_UPDATE ),
95 pOut( pOutput )
97 ASSERT( pOut, "es muss ein OutputDevice-Pointer gesetzt werden!" );
101 SwDocPosUpdate::SwDocPosUpdate( const SwTwips nDcPos )
102 : SwMsgPoolItem( RES_DOCPOS_UPDATE ),
103 nDocPos(nDcPos)
108 // SwTableFmlUpdate wird verschickt, wenn sich die Tabelle neu berechnen soll
109 SwTableFmlUpdate::SwTableFmlUpdate( const SwTable* pNewTbl )
110 : SwMsgPoolItem( RES_TABLEFML_UPDATE ),
111 pTbl( pNewTbl ), pHistory( 0 ), nSplitLine( USHRT_MAX ),
112 eFlags( TBL_CALC )
114 DATA.pDelTbl = 0;
115 bModified = bBehindSplitLine = FALSE;
116 ASSERT( pTbl, "es muss ein Table-Pointer gesetzt werden!" );
120 SwAutoFmtGetDocNode::SwAutoFmtGetDocNode( const SwNodes* pNds )
121 : SwMsgPoolItem( RES_AUTOFMT_DOCNODE ),
122 pCntntNode( 0 ), pNodes( pNds )
126 SwAttrSetChg::SwAttrSetChg( const SwAttrSet& rTheSet, SwAttrSet& rSet )
127 : SwMsgPoolItem( RES_ATTRSET_CHG ),
128 bDelSet( FALSE ),
129 pChgSet( &rSet ),
130 pTheChgdSet( &rTheSet )
134 SwAttrSetChg::SwAttrSetChg( const SwAttrSetChg& rChgSet )
135 : SwMsgPoolItem( RES_ATTRSET_CHG ),
136 bDelSet( TRUE ),
137 pTheChgdSet( rChgSet.pTheChgdSet )
139 pChgSet = new SwAttrSet( *rChgSet.pChgSet );
143 SwAttrSetChg::~SwAttrSetChg()
145 if( bDelSet )
146 delete pChgSet;
150 #ifndef PRODUCT
152 void SwAttrSetChg::ClearItem( USHORT nWhch )
154 ASSERT( bDelSet, "der Set darf nicht veraendert werden!" );
155 pChgSet->ClearItem( nWhch );
158 #endif
161 SwMsgPoolItem::SwMsgPoolItem( USHORT nWhch )
162 : SfxPoolItem( nWhch )
166 // "Overhead" vom SfxPoolItem
167 int SwMsgPoolItem::operator==( const SfxPoolItem& ) const
169 ASSERT( FALSE, "SwMsgPoolItem kennt kein ==" );
170 return 0;
174 SfxPoolItem* SwMsgPoolItem::Clone( SfxItemPool* ) const
176 ASSERT( FALSE, "SwMsgPoolItem kennt kein Clone" );
177 return 0;
180 /******************************************************************************
181 * hole aus der Default-Attribut Tabelle ueber den Which-Wert
182 * das entsprechende default Attribut.
183 * Ist keines vorhanden, returnt ein 0-Pointer !!!
184 * Used to be inlined (hintids.hxx) in PRODUCT.
185 ******************************************************************************/
186 #ifdef PRODUCT
187 const SfxPoolItem* GetDfltAttr( USHORT nWhich )
189 return aAttrTab[ nWhich - POOLATTR_BEGIN ];
191 #else
192 const SfxPoolItem* GetDfltAttr( USHORT nWhich )
194 ASSERT_ID( nWhich < POOLATTR_END && nWhich >= POOLATTR_BEGIN,
195 ERR_OUTOFSCOPE );
197 SfxPoolItem *pHt = aAttrTab[ nWhich - POOLATTR_BEGIN ];
198 ASSERT( pHt, "GetDfltFmtAttr(): Dflt == 0" );
199 return pHt;
201 #endif
205 SwCondCollCondChg::SwCondCollCondChg( SwFmt *pFmt )
206 : SwMsgPoolItem( RES_CONDCOLL_CONDCHG ), pChangedFmt( pFmt )
211 SwVirtPageNumInfo::SwVirtPageNumInfo( const SwPageFrm *pPg ) :
212 SwMsgPoolItem( RES_VIRTPAGENUM_INFO ),
213 pPage( 0 ),
214 pOrigPage( pPg ),
215 pFrm( 0 )
219 // --> OD 2008-02-19 #refactorlists#
220 //SwNumRuleInfo::SwNumRuleInfo( const String& rRuleName )
221 // : SwMsgPoolItem( RES_GETNUMNODES ), rName( rRuleName )
225 //void SwNumRuleInfo::AddNode( SwTxtNode& rNd )
227 // aList.Insert(rNd.GetIndex(), &rNd);
230 SwNRuleLowerLevel::SwNRuleLowerLevel( const String& rRuleName, BYTE nSrchLvl )
231 : SwMsgPoolItem( RES_GETLOWERNUMLEVEL ), rName( rRuleName ),
232 nLvl(nSrchLvl)
237 SwFindNearestNode::SwFindNearestNode( const SwNode& rNd )
238 : SwMsgPoolItem( RES_FINDNEARESTNODE ), pNd( &rNd ), pFnd( 0 )
242 void SwFindNearestNode::CheckNode( const SwNode& rNd )
244 if( &pNd->GetNodes() == &rNd.GetNodes() )
246 ULONG nIdx = rNd.GetIndex();
247 if( nIdx < pNd->GetIndex() &&
248 ( !pFnd || nIdx > pFnd->GetIndex() ) &&
249 nIdx > rNd.GetNodes().GetEndOfExtras().GetIndex() )
250 pFnd = &rNd;
256 USHORT GetWhichOfScript( USHORT nWhich, USHORT nScript )
258 static const USHORT aLangMap[3] =
259 { RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE };
260 static const USHORT aFontMap[3] =
261 { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT};
262 static const USHORT aFontSizeMap[3] =
263 { RES_CHRATR_FONTSIZE, RES_CHRATR_CJK_FONTSIZE, RES_CHRATR_CTL_FONTSIZE };
264 static const USHORT aWeightMap[3] =
265 { RES_CHRATR_WEIGHT, RES_CHRATR_CJK_WEIGHT, RES_CHRATR_CTL_WEIGHT};
266 static const USHORT aPostureMap[3] =
267 { RES_CHRATR_POSTURE, RES_CHRATR_CJK_POSTURE, RES_CHRATR_CTL_POSTURE};
269 const USHORT* pM;
270 switch( nWhich )
272 case RES_CHRATR_LANGUAGE:
273 case RES_CHRATR_CJK_LANGUAGE:
274 case RES_CHRATR_CTL_LANGUAGE:
275 pM = aLangMap;
276 break;
278 case RES_CHRATR_FONT:
279 case RES_CHRATR_CJK_FONT:
280 case RES_CHRATR_CTL_FONT:
281 pM = aFontMap;
282 break;
284 case RES_CHRATR_FONTSIZE:
285 case RES_CHRATR_CJK_FONTSIZE:
286 case RES_CHRATR_CTL_FONTSIZE:
287 pM = aFontSizeMap;
288 break;
290 case RES_CHRATR_WEIGHT:
291 case RES_CHRATR_CJK_WEIGHT:
292 case RES_CHRATR_CTL_WEIGHT:
293 pM = aWeightMap;
294 break;
295 case RES_CHRATR_POSTURE:
296 case RES_CHRATR_CJK_POSTURE:
297 case RES_CHRATR_CTL_POSTURE:
298 pM = aPostureMap;
299 break;
301 default:
302 pM = 0;
305 USHORT nRet;
306 if( pM )
308 using namespace ::com::sun::star::i18n;
310 if( ScriptType::WEAK == nScript )
311 nScript = GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() );
312 switch( nScript)
314 case ScriptType::COMPLEX: ++pM; // no break;
315 case ScriptType::ASIAN: ++pM; // no break;
316 default: nRet = *pM;
320 else
321 nRet = nWhich;
322 return nRet;