xref: /aoo41x/main/sw/source/core/attr/hints.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 #include <hints.hxx>
27 
28 #ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_
29 #include <com/sun/star/i18n/ScriptType.hdl>
30 #endif
31 #include <editeng/scripttypeitem.hxx>
32 #include <hintids.hxx>
33 #include <swtypes.hxx>
34 #include <ndtxt.hxx>
35 #include <errhdl.hxx>
36 
SwFmtChg(SwFmt * pFmt)37 SwFmtChg::SwFmtChg( SwFmt *pFmt )
38 	: SwMsgPoolItem( RES_FMT_CHG ),
39 	pChangedFmt( pFmt )
40 {}
41 
42 
43 
SwInsTxt(xub_StrLen nP,xub_StrLen nL)44 SwInsTxt::SwInsTxt( xub_StrLen nP, xub_StrLen nL )
45 	: SwMsgPoolItem( RES_INS_TXT ),
46 	nPos( nP ),
47 	nLen( nL )
48 {}
49 
50 
51 
SwDelChr(xub_StrLen nP)52 SwDelChr::SwDelChr( xub_StrLen nP )
53 	: SwMsgPoolItem( RES_DEL_CHR ),
54 	nPos( nP )
55 {}
56 
57 
58 
SwDelTxt(xub_StrLen nS,xub_StrLen nL)59 SwDelTxt::SwDelTxt( xub_StrLen nS, xub_StrLen nL )
60 	: SwMsgPoolItem( RES_DEL_TXT ),
61 	nStart( nS ),
62 	nLen( nL )
63 {}
64 
65 
66 
SwUpdateAttr(xub_StrLen nS,xub_StrLen nE,sal_uInt16 nW)67 SwUpdateAttr::SwUpdateAttr( xub_StrLen nS, xub_StrLen nE, sal_uInt16 nW )
68 	: SwMsgPoolItem( RES_UPDATE_ATTR ),
69 	nStart( nS ),
70 	nEnd( nE ),
71 	nWhichAttr( nW )
72 {}
73 
74 
75 // SwRefMarkFldUpdate wird verschickt, wenn sich die ReferenzMarkierungen
76 // Updaten sollen. Um Seiten-/KapitelNummer feststellen zu koennen, muss
77 // der akt. Frame befragt werden. Dafuer wird das akt. OutputDevice benoetigt.
78 
79 
SwRefMarkFldUpdate(const OutputDevice * pOutput)80 SwRefMarkFldUpdate::SwRefMarkFldUpdate( const OutputDevice* pOutput )
81 	: SwMsgPoolItem( RES_REFMARKFLD_UPDATE ),
82 	pOut( pOutput )
83 {
84 	ASSERT( pOut, "es muss ein OutputDevice-Pointer gesetzt werden!" );
85 }
86 
87 
SwDocPosUpdate(const SwTwips nDcPos)88 SwDocPosUpdate::SwDocPosUpdate( const SwTwips nDcPos )
89 	: SwMsgPoolItem( RES_DOCPOS_UPDATE ),
90 	nDocPos(nDcPos)
91 {}
92 
93 
94 
95 // SwTableFmlUpdate wird verschickt, wenn sich die Tabelle neu berechnen soll
SwTableFmlUpdate(const SwTable * pNewTbl)96 SwTableFmlUpdate::SwTableFmlUpdate( const SwTable* pNewTbl )
97 	: SwMsgPoolItem( RES_TABLEFML_UPDATE ),
98 	pTbl( pNewTbl ), pHistory( 0 ), nSplitLine( USHRT_MAX ),
99 	eFlags( TBL_CALC )
100 {
101 	DATA.pDelTbl = 0;
102 	bModified = bBehindSplitLine = sal_False;
103 	ASSERT( pTbl, "es muss ein Table-Pointer gesetzt werden!" );
104 }
105 
106 
SwAutoFmtGetDocNode(const SwNodes * pNds)107 SwAutoFmtGetDocNode::SwAutoFmtGetDocNode( const SwNodes* pNds )
108 	: SwMsgPoolItem( RES_AUTOFMT_DOCNODE ),
109 	pCntntNode( 0 ), pNodes( pNds )
110 {}
111 
112 
SwAttrSetChg(const SwAttrSet & rTheSet,SwAttrSet & rSet)113 SwAttrSetChg::SwAttrSetChg( const SwAttrSet& rTheSet, SwAttrSet& rSet )
114 	: SwMsgPoolItem( RES_ATTRSET_CHG ),
115 	bDelSet( sal_False ),
116 	pChgSet( &rSet ),
117 	pTheChgdSet( &rTheSet )
118 {}
119 
120 
SwAttrSetChg(const SwAttrSetChg & rChgSet)121 SwAttrSetChg::SwAttrSetChg( const SwAttrSetChg& rChgSet )
122 	: SwMsgPoolItem( RES_ATTRSET_CHG ),
123 	bDelSet( sal_True ),
124 	pTheChgdSet( rChgSet.pTheChgdSet )
125 {
126 	pChgSet = new SwAttrSet( *rChgSet.pChgSet );
127 }
128 
129 
~SwAttrSetChg()130 SwAttrSetChg::~SwAttrSetChg()
131 {
132 	if( bDelSet )
133 		delete pChgSet;
134 }
135 
136 
137 #ifdef DBG_UTIL
138 
ClearItem(sal_uInt16 nWhch)139 void SwAttrSetChg::ClearItem( sal_uInt16 nWhch )
140 {
141 	ASSERT( bDelSet, "der Set darf nicht veraendert werden!" );
142 	pChgSet->ClearItem( nWhch );
143 }
144 
145 #endif
146 
147 
SwMsgPoolItem(sal_uInt16 nWhch)148 SwMsgPoolItem::SwMsgPoolItem( sal_uInt16 nWhch )
149 	: SfxPoolItem( nWhch )
150 {}
151 
152 
153 // "Overhead" vom SfxPoolItem
operator ==(const SfxPoolItem &) const154 int SwMsgPoolItem::operator==( const SfxPoolItem& ) const
155 {
156 	ASSERT( sal_False, "SwMsgPoolItem kennt kein ==" );
157 	return 0;
158 }
159 
160 
Clone(SfxItemPool *) const161 SfxPoolItem* SwMsgPoolItem::Clone( SfxItemPool* ) const
162 {
163 	ASSERT( sal_False, "SwMsgPoolItem kennt kein Clone" );
164 	return 0;
165 }
166 
167 /******************************************************************************
168  * hole aus der Default-Attribut Tabelle ueber den Which-Wert
169  * das entsprechende default Attribut.
170  * Ist keines vorhanden, returnt ein 0-Pointer !!!
171  * Used to be inlined (hintids.hxx) in PRODUCT.
172  ******************************************************************************/
173 #ifndef DBG_UTIL
GetDfltAttr(sal_uInt16 nWhich)174 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
175 {
176 	return aAttrTab[ nWhich - POOLATTR_BEGIN ];
177 }
178 #else
GetDfltAttr(sal_uInt16 nWhich)179 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
180 {
181 	ASSERT_ID( nWhich < POOLATTR_END && nWhich >= POOLATTR_BEGIN,
182 			   ERR_OUTOFSCOPE );
183 
184 	SfxPoolItem *pHt = aAttrTab[ nWhich - POOLATTR_BEGIN ];
185 	ASSERT( pHt, "GetDfltFmtAttr(): Dflt == 0" );
186 	return pHt;
187 }
188 #endif
189 
190 
191 
SwCondCollCondChg(SwFmt * pFmt)192 SwCondCollCondChg::SwCondCollCondChg( SwFmt *pFmt )
193 	: SwMsgPoolItem( RES_CONDCOLL_CONDCHG ), pChangedFmt( pFmt )
194 {
195 }
196 
197 
SwVirtPageNumInfo(const SwPageFrm * pPg)198 SwVirtPageNumInfo::SwVirtPageNumInfo( const SwPageFrm *pPg ) :
199 	SwMsgPoolItem( RES_VIRTPAGENUM_INFO ),
200 	pPage( 0 ),
201 	pOrigPage( pPg ),
202 	pFrm( 0 )
203 {
204 }
205 
206 // --> OD 2008-02-19 #refactorlists#
207 //SwNumRuleInfo::SwNumRuleInfo( const String& rRuleName )
208 //    : SwMsgPoolItem( RES_GETNUMNODES ), rName( rRuleName )
209 //{
210 //}
211 
212 //void SwNumRuleInfo::AddNode( SwTxtNode& rNd )
213 //{
214 //    aList.Insert(rNd.GetIndex(), &rNd);
215 //}
216 
217 
SwFindNearestNode(const SwNode & rNd)218 SwFindNearestNode::SwFindNearestNode( const SwNode& rNd )
219 	: SwMsgPoolItem( RES_FINDNEARESTNODE ), pNd( &rNd ), pFnd( 0 )
220 {
221 }
222 
CheckNode(const SwNode & rNd)223 void SwFindNearestNode::CheckNode( const SwNode& rNd )
224 {
225 	if( &pNd->GetNodes() == &rNd.GetNodes() )
226 	{
227 		sal_uLong nIdx = rNd.GetIndex();
228 		if( nIdx < pNd->GetIndex() &&
229 			( !pFnd || nIdx > pFnd->GetIndex() ) &&
230 			nIdx > rNd.GetNodes().GetEndOfExtras().GetIndex() )
231 			pFnd = &rNd;
232 	}
233 }
234 
235 
236 
GetWhichOfScript(sal_uInt16 nWhich,sal_uInt16 nScript)237 sal_uInt16 GetWhichOfScript( sal_uInt16 nWhich, sal_uInt16 nScript )
238 {
239 	static const sal_uInt16 aLangMap[3] =
240 		{ RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE };
241 	static const sal_uInt16 aFontMap[3] =
242 		{ RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,  RES_CHRATR_CTL_FONT};
243 	static const sal_uInt16 aFontSizeMap[3] =
244 		{ RES_CHRATR_FONTSIZE, RES_CHRATR_CJK_FONTSIZE,  RES_CHRATR_CTL_FONTSIZE };
245 	static const sal_uInt16 aWeightMap[3] =
246 		{ RES_CHRATR_WEIGHT, RES_CHRATR_CJK_WEIGHT,  RES_CHRATR_CTL_WEIGHT};
247 	static const sal_uInt16 aPostureMap[3] =
248 		{ RES_CHRATR_POSTURE, RES_CHRATR_CJK_POSTURE,  RES_CHRATR_CTL_POSTURE};
249 
250 	const sal_uInt16* pM;
251 	switch( nWhich )
252 	{
253 	case RES_CHRATR_LANGUAGE:
254 	case RES_CHRATR_CJK_LANGUAGE:
255 	case RES_CHRATR_CTL_LANGUAGE:
256 		pM = aLangMap;
257 		break;
258 
259 	case RES_CHRATR_FONT:
260 	case RES_CHRATR_CJK_FONT:
261 	case RES_CHRATR_CTL_FONT:
262 		pM = aFontMap;
263 		break;
264 
265 	case RES_CHRATR_FONTSIZE:
266 	case RES_CHRATR_CJK_FONTSIZE:
267 	case RES_CHRATR_CTL_FONTSIZE:
268 		pM = aFontSizeMap;
269 		break;
270 
271 	case  RES_CHRATR_WEIGHT:
272 	case  RES_CHRATR_CJK_WEIGHT:
273 	case  RES_CHRATR_CTL_WEIGHT:
274 		pM = aWeightMap;
275 		break;
276 	case RES_CHRATR_POSTURE:
277 	case RES_CHRATR_CJK_POSTURE:
278 	case RES_CHRATR_CTL_POSTURE:
279 		pM = aPostureMap;
280 		break;
281 
282 	default:
283 		pM = 0;
284 	}
285 
286 	sal_uInt16 nRet;
287 	if( pM )
288 	{
289         using namespace ::com::sun::star::i18n;
290 		{
291 			if( ScriptType::WEAK == nScript )
292                 nScript = GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() );
293 			switch( nScript)
294 			{
295 			case ScriptType::COMPLEX:	++pM;  // no break;
296 			case ScriptType::ASIAN:		++pM;  // no break;
297 			default:					nRet = *pM;
298 			}
299 		}
300 	}
301 	else
302 		nRet = nWhich;
303 	return nRet;
304 }
305