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