xref: /aoo42x/main/sw/source/core/attr/hints.cxx (revision 56b35d86)
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(
68     xub_StrLen nS,
69     xub_StrLen nE,
70     sal_uInt16 nW)
71 :   SwMsgPoolItem(RES_UPDATE_ATTR),
72     nStart(nS),
73     nEnd(nE),
74     nWhichAttr(nW)
75 {
76 }
77 
78 
79 // SwRefMarkFldUpdate wird verschickt, wenn sich die ReferenzMarkierungen
80 // Updaten sollen. Um Seiten-/KapitelNummer feststellen zu koennen, muss
81 // der akt. Frame befragt werden. Dafuer wird das akt. OutputDevice benoetigt.
82 
83 
SwRefMarkFldUpdate(const OutputDevice * pOutput)84 SwRefMarkFldUpdate::SwRefMarkFldUpdate( const OutputDevice* pOutput )
85 	: SwMsgPoolItem( RES_REFMARKFLD_UPDATE ),
86 	pOut( pOutput )
87 {
88 	ASSERT( pOut, "es muss ein OutputDevice-Pointer gesetzt werden!" );
89 }
90 
91 
SwDocPosUpdate(const SwTwips nDcPos)92 SwDocPosUpdate::SwDocPosUpdate( const SwTwips nDcPos )
93 	: SwMsgPoolItem( RES_DOCPOS_UPDATE ),
94 	nDocPos(nDcPos)
95 {}
96 
97 
98 
99 // SwTableFmlUpdate wird verschickt, wenn sich die Tabelle neu berechnen soll
SwTableFmlUpdate(const SwTable * pNewTbl)100 SwTableFmlUpdate::SwTableFmlUpdate( const SwTable* pNewTbl )
101 	: SwMsgPoolItem( RES_TABLEFML_UPDATE ),
102 	pTbl( pNewTbl ), pHistory( 0 ), nSplitLine( USHRT_MAX ),
103 	eFlags( TBL_CALC )
104 {
105 	DATA.pDelTbl = 0;
106 	bModified = bBehindSplitLine = sal_False;
107 	ASSERT( pTbl, "es muss ein Table-Pointer gesetzt werden!" );
108 }
109 
110 
SwAutoFmtGetDocNode(const SwNodes * pNds)111 SwAutoFmtGetDocNode::SwAutoFmtGetDocNode( const SwNodes* pNds )
112 	: SwMsgPoolItem( RES_AUTOFMT_DOCNODE ),
113 	pCntntNode( 0 ), pNodes( pNds )
114 {}
115 
116 
SwAttrSetChg(const SwAttrSet & rTheSet,SwAttrSet & rSet)117 SwAttrSetChg::SwAttrSetChg( const SwAttrSet& rTheSet, SwAttrSet& rSet )
118 	: SwMsgPoolItem( RES_ATTRSET_CHG ),
119 	bDelSet( sal_False ),
120 	pChgSet( &rSet ),
121 	pTheChgdSet( &rTheSet )
122 {}
123 
124 
SwAttrSetChg(const SwAttrSetChg & rChgSet)125 SwAttrSetChg::SwAttrSetChg( const SwAttrSetChg& rChgSet )
126 	: SwMsgPoolItem( RES_ATTRSET_CHG ),
127 	bDelSet( sal_True ),
128 	pTheChgdSet( rChgSet.pTheChgdSet )
129 {
130 	pChgSet = new SwAttrSet( *rChgSet.pChgSet );
131 }
132 
133 
~SwAttrSetChg()134 SwAttrSetChg::~SwAttrSetChg()
135 {
136 	if( bDelSet )
137 		delete pChgSet;
138 }
139 
140 
141 #ifdef DBG_UTIL
142 
ClearItem(sal_uInt16 nWhch)143 void SwAttrSetChg::ClearItem( sal_uInt16 nWhch )
144 {
145 	ASSERT( bDelSet, "der Set darf nicht veraendert werden!" );
146 	pChgSet->ClearItem( nWhch );
147 }
148 
149 #endif
150 
151 
SwMsgPoolItem(sal_uInt16 nWhch)152 SwMsgPoolItem::SwMsgPoolItem( sal_uInt16 nWhch )
153 	: SfxPoolItem( nWhch )
154 {}
155 
156 
157 // "Overhead" vom SfxPoolItem
operator ==(const SfxPoolItem &) const158 int SwMsgPoolItem::operator==( const SfxPoolItem& ) const
159 {
160 	ASSERT( sal_False, "SwMsgPoolItem kennt kein ==" );
161 	return 0;
162 }
163 
164 
Clone(SfxItemPool *) const165 SfxPoolItem* SwMsgPoolItem::Clone( SfxItemPool* ) const
166 {
167 	ASSERT( sal_False, "SwMsgPoolItem kennt kein Clone" );
168 	return 0;
169 }
170 
171 /******************************************************************************
172  * hole aus der Default-Attribut Tabelle ueber den Which-Wert
173  * das entsprechende default Attribut.
174  * Ist keines vorhanden, returnt ein 0-Pointer !!!
175  * Used to be inlined (hintids.hxx) in PRODUCT.
176  ******************************************************************************/
177 #ifndef DBG_UTIL
GetDfltAttr(sal_uInt16 nWhich)178 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
179 {
180 	return aAttrTab[ nWhich - POOLATTR_BEGIN ];
181 }
182 #else
GetDfltAttr(sal_uInt16 nWhich)183 const SfxPoolItem* GetDfltAttr( sal_uInt16 nWhich )
184 {
185 	ASSERT_ID( nWhich < POOLATTR_END && nWhich >= POOLATTR_BEGIN,
186 			   ERR_OUTOFSCOPE );
187 
188 	SfxPoolItem *pHt = aAttrTab[ nWhich - POOLATTR_BEGIN ];
189 	ASSERT( pHt, "GetDfltFmtAttr(): Dflt == 0" );
190 	return pHt;
191 }
192 #endif
193 
194 
195 
SwCondCollCondChg(SwFmt * pFmt)196 SwCondCollCondChg::SwCondCollCondChg( SwFmt *pFmt )
197 	: SwMsgPoolItem( RES_CONDCOLL_CONDCHG ), pChangedFmt( pFmt )
198 {
199 }
200 
201 
SwVirtPageNumInfo(const SwPageFrm * pPg)202 SwVirtPageNumInfo::SwVirtPageNumInfo( const SwPageFrm *pPg ) :
203 	SwMsgPoolItem( RES_VIRTPAGENUM_INFO ),
204 	pPage( 0 ),
205 	pOrigPage( pPg ),
206 	pFrm( 0 )
207 {
208 }
209 
210 // --> OD 2008-02-19 #refactorlists#
211 //SwNumRuleInfo::SwNumRuleInfo( const String& rRuleName )
212 //    : SwMsgPoolItem( RES_GETNUMNODES ), rName( rRuleName )
213 //{
214 //}
215 
216 //void SwNumRuleInfo::AddNode( SwTxtNode& rNd )
217 //{
218 //    aList.Insert(rNd.GetIndex(), &rNd);
219 //}
220 
221 
SwFindNearestNode(const SwNode & rNd)222 SwFindNearestNode::SwFindNearestNode( const SwNode& rNd )
223 	: SwMsgPoolItem( RES_FINDNEARESTNODE ), pNd( &rNd ), pFnd( 0 )
224 {
225 }
226 
CheckNode(const SwNode & rNd)227 void SwFindNearestNode::CheckNode( const SwNode& rNd )
228 {
229 	if( &pNd->GetNodes() == &rNd.GetNodes() )
230 	{
231 		sal_uLong nIdx = rNd.GetIndex();
232 		if( nIdx < pNd->GetIndex() &&
233 			( !pFnd || nIdx > pFnd->GetIndex() ) &&
234 			nIdx > rNd.GetNodes().GetEndOfExtras().GetIndex() )
235 			pFnd = &rNd;
236 	}
237 }
238 
239 
240 
GetWhichOfScript(sal_uInt16 nWhich,sal_uInt16 nScript)241 sal_uInt16 GetWhichOfScript( sal_uInt16 nWhich, sal_uInt16 nScript )
242 {
243 	static const sal_uInt16 aLangMap[3] =
244 		{ RES_CHRATR_LANGUAGE, RES_CHRATR_CJK_LANGUAGE, RES_CHRATR_CTL_LANGUAGE };
245 	static const sal_uInt16 aFontMap[3] =
246 		{ RES_CHRATR_FONT, RES_CHRATR_CJK_FONT,  RES_CHRATR_CTL_FONT};
247 	static const sal_uInt16 aFontSizeMap[3] =
248 		{ RES_CHRATR_FONTSIZE, RES_CHRATR_CJK_FONTSIZE,  RES_CHRATR_CTL_FONTSIZE };
249 	static const sal_uInt16 aWeightMap[3] =
250 		{ RES_CHRATR_WEIGHT, RES_CHRATR_CJK_WEIGHT,  RES_CHRATR_CTL_WEIGHT};
251 	static const sal_uInt16 aPostureMap[3] =
252 		{ RES_CHRATR_POSTURE, RES_CHRATR_CJK_POSTURE,  RES_CHRATR_CTL_POSTURE};
253 
254 	const sal_uInt16* pM;
255 	switch( nWhich )
256 	{
257 	case RES_CHRATR_LANGUAGE:
258 	case RES_CHRATR_CJK_LANGUAGE:
259 	case RES_CHRATR_CTL_LANGUAGE:
260 		pM = aLangMap;
261 		break;
262 
263 	case RES_CHRATR_FONT:
264 	case RES_CHRATR_CJK_FONT:
265 	case RES_CHRATR_CTL_FONT:
266 		pM = aFontMap;
267 		break;
268 
269 	case RES_CHRATR_FONTSIZE:
270 	case RES_CHRATR_CJK_FONTSIZE:
271 	case RES_CHRATR_CTL_FONTSIZE:
272 		pM = aFontSizeMap;
273 		break;
274 
275 	case  RES_CHRATR_WEIGHT:
276 	case  RES_CHRATR_CJK_WEIGHT:
277 	case  RES_CHRATR_CTL_WEIGHT:
278 		pM = aWeightMap;
279 		break;
280 	case RES_CHRATR_POSTURE:
281 	case RES_CHRATR_CJK_POSTURE:
282 	case RES_CHRATR_CTL_POSTURE:
283 		pM = aPostureMap;
284 		break;
285 
286 	default:
287 		pM = 0;
288 	}
289 
290 	sal_uInt16 nRet;
291 	if( pM )
292 	{
293         using namespace ::com::sun::star::i18n;
294 		{
295 			if( ScriptType::WEAK == nScript )
296                 nScript = GetI18NScriptTypeOfLanguage( (sal_uInt16)GetAppLanguage() );
297 			switch( nScript)
298 			{
299 			case ScriptType::COMPLEX:	++pM;  // no break;
300 			case ScriptType::ASIAN:		++pM;  // no break;
301 			default:					nRet = *pM;
302 			}
303 		}
304 	}
305 	else
306 		nRet = nWhich;
307 	return nRet;
308 }
309