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