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
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
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.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
23cdf0e10cSrcweir #include "precompiled_sw.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir #include <hintids.hxx>
26cdf0e10cSrcweir #include <svl/whiter.hxx>
27cdf0e10cSrcweir #include <editeng/colritem.hxx>
28cdf0e10cSrcweir #include <editeng/brshitem.hxx>
29cdf0e10cSrcweir #include <editeng/bolnitem.hxx>
30cdf0e10cSrcweir #include <editeng/boxitem.hxx>
31cdf0e10cSrcweir #include <svx/xtable.hxx>
32cdf0e10cSrcweir #include <fmtpdsc.hxx>
33cdf0e10cSrcweir #include <pagedesc.hxx>
34cdf0e10cSrcweir #include <charfmt.hxx>
35cdf0e10cSrcweir #include <doc.hxx>
36cdf0e10cSrcweir #include <node.hxx>
37cdf0e10cSrcweir #include <paratr.hxx> // fuer SetModifyAtAttr
38cdf0e10cSrcweir #include <cellatr.hxx> // fuer SetModifyAtAttr
39cdf0e10cSrcweir #ifndef _CMDID_H
40cdf0e10cSrcweir #include <cmdid.h>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include <istyleaccess.hxx>
43cdf0e10cSrcweir #include <numrule.hxx>
44cdf0e10cSrcweir #include <list.hxx>
4564b14621SArmin Le Grand #include <svx/svdpool.hxx>
4664b14621SArmin Le Grand #include <svx/sxenditm.hxx>
4764b14621SArmin Le Grand #include <svx/sdsxyitm.hxx>
483f09c2ceSJürgen Schmidt #include <editeng/editeng.hxx>
49cdf0e10cSrcweir
SwAttrPool(SwDoc * pD)50cdf0e10cSrcweir SwAttrPool::SwAttrPool( SwDoc* pD )
51cdf0e10cSrcweir : SfxItemPool( String::CreateFromAscii(
52cdf0e10cSrcweir RTL_CONSTASCII_STRINGPARAM( "SWG" )),
53cdf0e10cSrcweir POOLATTR_BEGIN, POOLATTR_END-1,
54cdf0e10cSrcweir aSlotTab, aAttrTab ),
55cdf0e10cSrcweir pDoc( pD )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir SetVersionMap( 1, 1, 60, pVersionMap1 );
58cdf0e10cSrcweir SetVersionMap( 2, 1, 75, pVersionMap2 );
59cdf0e10cSrcweir SetVersionMap( 3, 1, 86, pVersionMap3 );
60cdf0e10cSrcweir SetVersionMap( 4, 1,121, pVersionMap4 );
61cdf0e10cSrcweir // OD 2004-01-21 #i18732# - apply new version map
62cdf0e10cSrcweir SetVersionMap( 5, 1,130, pVersionMap5 );
63cdf0e10cSrcweir SetVersionMap( 6, 1,136, pVersionMap6 );
6464b14621SArmin Le Grand
6564b14621SArmin Le Grand //UUUU create secondary pools immediately
6664b14621SArmin Le Grand createAndAddSecondaryPools();
67cdf0e10cSrcweir }
68cdf0e10cSrcweir
~SwAttrPool()69cdf0e10cSrcweir SwAttrPool::~SwAttrPool()
70cdf0e10cSrcweir {
7164b14621SArmin Le Grand //UUUU cleanup secondary pools first
7264b14621SArmin Le Grand removeAndDeleteSecondaryPools();
7364b14621SArmin Le Grand }
7464b14621SArmin Le Grand
7564b14621SArmin Le Grand //UUUU
createAndAddSecondaryPools()7664b14621SArmin Le Grand void SwAttrPool::createAndAddSecondaryPools()
7764b14621SArmin Le Grand {
7864b14621SArmin Le Grand const SfxItemPool* pCheckAlreadySet = GetSecondaryPool();
7964b14621SArmin Le Grand
8064b14621SArmin Le Grand if(pCheckAlreadySet)
8164b14621SArmin Le Grand {
8264b14621SArmin Le Grand OSL_ENSURE(false, "SwAttrPool already has a secondary pool (!)");
8364b14621SArmin Le Grand return;
8464b14621SArmin Le Grand }
8564b14621SArmin Le Grand
8664b14621SArmin Le Grand // create SfxItemPool and EditEngine pool and add these in a chain. These
8764b14621SArmin Le Grand // belomg us and will be removed/destroyed in removeAndDeleteSecondaryPools() used from
8864b14621SArmin Le Grand // the destructor
8964b14621SArmin Le Grand SfxItemPool *pSdrPool = new SdrItemPool(this);
9064b14621SArmin Le Grand
9164b14621SArmin Le Grand // #75371# change DefaultItems for the SdrEdgeObj distance items
9264b14621SArmin Le Grand // to TWIPS.
9364b14621SArmin Le Grand if(pSdrPool)
9464b14621SArmin Le Grand {
9564b14621SArmin Le Grand // 1/100th mm in twips
9664b14621SArmin Le Grand const long nDefEdgeDist = ((500 * 72) / 127);
9764b14621SArmin Le Grand
9864b14621SArmin Le Grand pSdrPool->SetPoolDefaultItem(SdrEdgeNode1HorzDistItem(nDefEdgeDist));
9964b14621SArmin Le Grand pSdrPool->SetPoolDefaultItem(SdrEdgeNode1VertDistItem(nDefEdgeDist));
10064b14621SArmin Le Grand pSdrPool->SetPoolDefaultItem(SdrEdgeNode2HorzDistItem(nDefEdgeDist));
10164b14621SArmin Le Grand pSdrPool->SetPoolDefaultItem(SdrEdgeNode2VertDistItem(nDefEdgeDist));
10264b14621SArmin Le Grand
10364b14621SArmin Le Grand // #i33700# // Set shadow distance defaults as PoolDefaultItems
10464b14621SArmin Le Grand pSdrPool->SetPoolDefaultItem(SdrShadowXDistItem((300 * 72) / 127));
10564b14621SArmin Le Grand pSdrPool->SetPoolDefaultItem(SdrShadowYDistItem((300 * 72) / 127));
10664b14621SArmin Le Grand }
10764b14621SArmin Le Grand
10864b14621SArmin Le Grand SfxItemPool *pEEgPool = EditEngine::CreatePool(sal_False);
10964b14621SArmin Le Grand
11064b14621SArmin Le Grand pSdrPool->SetSecondaryPool(pEEgPool);
11164b14621SArmin Le Grand
11264b14621SArmin Le Grand if(!GetFrozenIdRanges())
11364b14621SArmin Le Grand {
11464b14621SArmin Le Grand FreezeIdRanges();
11564b14621SArmin Le Grand }
11664b14621SArmin Le Grand else
11764b14621SArmin Le Grand {
11864b14621SArmin Le Grand pSdrPool->FreezeIdRanges();
11964b14621SArmin Le Grand }
12064b14621SArmin Le Grand }
12164b14621SArmin Le Grand
12264b14621SArmin Le Grand //UUUU
removeAndDeleteSecondaryPools()12364b14621SArmin Le Grand void SwAttrPool::removeAndDeleteSecondaryPools()
12464b14621SArmin Le Grand {
12564b14621SArmin Le Grand SfxItemPool *pSdrPool = GetSecondaryPool();
12664b14621SArmin Le Grand
12764b14621SArmin Le Grand if(!pSdrPool)
12864b14621SArmin Le Grand {
12964b14621SArmin Le Grand OSL_ENSURE(false, "SwAttrPool has no secondary pool, it's missing (!)");
13064b14621SArmin Le Grand return;
13164b14621SArmin Le Grand }
13264b14621SArmin Le Grand
13364b14621SArmin Le Grand SfxItemPool *pEEgPool = pSdrPool->GetSecondaryPool();
13464b14621SArmin Le Grand
13564b14621SArmin Le Grand if(!pEEgPool)
13664b14621SArmin Le Grand {
13764b14621SArmin Le Grand OSL_ENSURE(false, "i don't accept additional pools");
13864b14621SArmin Le Grand return;
13964b14621SArmin Le Grand }
14064b14621SArmin Le Grand
14164b14621SArmin Le Grand // first delete the items, then break the linking
14264b14621SArmin Le Grand pSdrPool->Delete();
14364b14621SArmin Le Grand
14464b14621SArmin Le Grand SetSecondaryPool(0);
14564b14621SArmin Le Grand pSdrPool->SetSecondaryPool(0);
14664b14621SArmin Le Grand
14764b14621SArmin Le Grand // final cleanup of secondary pool(s)
14864b14621SArmin Le Grand SfxItemPool::Free(pSdrPool);
14964b14621SArmin Le Grand SfxItemPool::Free(pEEgPool);
150cdf0e10cSrcweir }
151cdf0e10cSrcweir
SwAttrSet(SwAttrPool & rPool,sal_uInt16 nWh1,sal_uInt16 nWh2)152cdf0e10cSrcweir SwAttrSet::SwAttrSet( SwAttrPool& rPool, sal_uInt16 nWh1, sal_uInt16 nWh2 )
153cdf0e10cSrcweir : SfxItemSet( rPool, nWh1, nWh2 ), pOldSet( 0 ), pNewSet( 0 )
154cdf0e10cSrcweir {
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
157cdf0e10cSrcweir
SwAttrSet(SwAttrPool & rPool,const sal_uInt16 * nWhichPairTable)158cdf0e10cSrcweir SwAttrSet::SwAttrSet( SwAttrPool& rPool, const sal_uInt16* nWhichPairTable )
159cdf0e10cSrcweir : SfxItemSet( rPool, nWhichPairTable ), pOldSet( 0 ), pNewSet( 0 )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir
SwAttrSet(const SwAttrSet & rSet)164cdf0e10cSrcweir SwAttrSet::SwAttrSet( const SwAttrSet& rSet )
165cdf0e10cSrcweir : SfxItemSet( rSet ), pOldSet( 0 ), pNewSet( 0 )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
Clone(sal_Bool bItems,SfxItemPool * pToPool) const169cdf0e10cSrcweir SfxItemSet* SwAttrSet::Clone( sal_Bool bItems, SfxItemPool *pToPool ) const
170cdf0e10cSrcweir {
171cdf0e10cSrcweir if ( pToPool && pToPool != GetPool() )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir SwAttrPool* pAttrPool = dynamic_cast< SwAttrPool* >(pToPool);
174cdf0e10cSrcweir SfxItemSet* pTmpSet = 0;
175cdf0e10cSrcweir if ( !pAttrPool )
176cdf0e10cSrcweir pTmpSet = SfxItemSet::Clone( bItems, pToPool );
177cdf0e10cSrcweir else
178cdf0e10cSrcweir {
179cdf0e10cSrcweir pTmpSet = new SwAttrSet( *pAttrPool, GetRanges() );
180cdf0e10cSrcweir if ( bItems )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir SfxWhichIter aIter(*pTmpSet);
183cdf0e10cSrcweir sal_uInt16 nWhich = aIter.FirstWhich();
184cdf0e10cSrcweir while ( nWhich )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir const SfxPoolItem* pItem;
187cdf0e10cSrcweir if ( SFX_ITEM_SET == GetItemState( nWhich, sal_False, &pItem ) )
188cdf0e10cSrcweir pTmpSet->Put( *pItem, pItem->Which() );
189cdf0e10cSrcweir nWhich = aIter.NextWhich();
190cdf0e10cSrcweir }
191cdf0e10cSrcweir }
192cdf0e10cSrcweir }
193cdf0e10cSrcweir return pTmpSet;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir else
196cdf0e10cSrcweir return bItems
197cdf0e10cSrcweir ? new SwAttrSet( *this )
198cdf0e10cSrcweir : new SwAttrSet( *GetPool(), GetRanges() );
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
Put_BC(const SfxPoolItem & rAttr,SwAttrSet * pOld,SwAttrSet * pNew)201cdf0e10cSrcweir int SwAttrSet::Put_BC( const SfxPoolItem& rAttr,
202cdf0e10cSrcweir SwAttrSet* pOld, SwAttrSet* pNew )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir pNewSet = pNew;
205cdf0e10cSrcweir pOldSet = pOld;
206cdf0e10cSrcweir int nRet = 0 != SfxItemSet::Put( rAttr );
207cdf0e10cSrcweir pOldSet = pNewSet = 0;
208cdf0e10cSrcweir return nRet;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir
Put_BC(const SfxItemSet & rSet,SwAttrSet * pOld,SwAttrSet * pNew)212cdf0e10cSrcweir int SwAttrSet::Put_BC( const SfxItemSet& rSet,
213cdf0e10cSrcweir SwAttrSet* pOld, SwAttrSet* pNew )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir pNewSet = pNew;
216cdf0e10cSrcweir pOldSet = pOld;
217cdf0e10cSrcweir int nRet = 0 != SfxItemSet::Put( rSet );
218cdf0e10cSrcweir pOldSet = pNewSet = 0;
219cdf0e10cSrcweir return nRet;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222cdf0e10cSrcweir
223cdf0e10cSrcweir
ClearItem_BC(sal_uInt16 nWhich,SwAttrSet * pOld,SwAttrSet * pNew)224cdf0e10cSrcweir sal_uInt16 SwAttrSet::ClearItem_BC( sal_uInt16 nWhich,
225cdf0e10cSrcweir SwAttrSet* pOld, SwAttrSet* pNew )
226cdf0e10cSrcweir {
227cdf0e10cSrcweir pNewSet = pNew;
228cdf0e10cSrcweir pOldSet = pOld;
229cdf0e10cSrcweir sal_uInt16 nRet = SfxItemSet::ClearItem( nWhich );
230cdf0e10cSrcweir pOldSet = pNewSet = 0;
231cdf0e10cSrcweir return nRet;
232cdf0e10cSrcweir }
233cdf0e10cSrcweir
234cdf0e10cSrcweir
ClearItem_BC(sal_uInt16 nWhich1,sal_uInt16 nWhich2,SwAttrSet * pOld,SwAttrSet * pNew)235cdf0e10cSrcweir sal_uInt16 SwAttrSet::ClearItem_BC( sal_uInt16 nWhich1, sal_uInt16 nWhich2,
236cdf0e10cSrcweir SwAttrSet* pOld, SwAttrSet* pNew )
237cdf0e10cSrcweir {
238cdf0e10cSrcweir ASSERT( nWhich1 <= nWhich2, "kein gueltiger Bereich" );
239cdf0e10cSrcweir pNewSet = pNew;
240cdf0e10cSrcweir pOldSet = pOld;
241cdf0e10cSrcweir sal_uInt16 nRet = 0;
242cdf0e10cSrcweir for( ; nWhich1 <= nWhich2; ++nWhich1 )
243cdf0e10cSrcweir nRet = nRet + SfxItemSet::ClearItem( nWhich1 );
244cdf0e10cSrcweir pOldSet = pNewSet = 0;
245cdf0e10cSrcweir return nRet;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir
248cdf0e10cSrcweir
249cdf0e10cSrcweir
Intersect_BC(const SfxItemSet & rSet,SwAttrSet * pOld,SwAttrSet * pNew)250cdf0e10cSrcweir int SwAttrSet::Intersect_BC( const SfxItemSet& rSet,
251cdf0e10cSrcweir SwAttrSet* pOld, SwAttrSet* pNew )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir pNewSet = pNew;
254cdf0e10cSrcweir pOldSet = pOld;
255cdf0e10cSrcweir SfxItemSet::Intersect( rSet );
256cdf0e10cSrcweir pOldSet = pNewSet = 0;
257cdf0e10cSrcweir return pNew ? pNew->Count() : ( pOld ? pOld->Count() : 0 );
258cdf0e10cSrcweir }
259cdf0e10cSrcweir
260cdf0e10cSrcweir // Notification-Callback
Changed(const SfxPoolItem & rOld,const SfxPoolItem & rNew)261cdf0e10cSrcweir void SwAttrSet::Changed( const SfxPoolItem& rOld,
262cdf0e10cSrcweir const SfxPoolItem& rNew )
263cdf0e10cSrcweir {
264cdf0e10cSrcweir if( pOldSet )
265cdf0e10cSrcweir pOldSet->PutChgd( rOld );
266cdf0e10cSrcweir
267cdf0e10cSrcweir if( pNewSet )
268cdf0e10cSrcweir pNewSet->PutChgd( rNew );
269cdf0e10cSrcweir }
270cdf0e10cSrcweir
271cdf0e10cSrcweir
272cdf0e10cSrcweir // ----------------------------------------------------------------
273cdf0e10cSrcweir // Sonderbehandlung fuer einige Attribute
274cdf0e10cSrcweir // Setze den Modify-Pointer (alten pDefinedIn) bei folgenden Attributen:
275cdf0e10cSrcweir // - SwFmtDropCaps
276cdf0e10cSrcweir // - SwFmtPageDesc
277cdf0e10cSrcweir // (Wird beim Einfuegen in Formate/Nodes gerufen)
278cdf0e10cSrcweir // ----------------------------------------------------------------
279cdf0e10cSrcweir
SetModifyAtAttr(const SwModify * pModify)280cdf0e10cSrcweir bool SwAttrSet::SetModifyAtAttr( const SwModify* pModify )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir bool bSet = false;
283cdf0e10cSrcweir
284cdf0e10cSrcweir const SfxPoolItem* pItem;
285cdf0e10cSrcweir if( SFX_ITEM_SET == GetItemState( RES_PAGEDESC, sal_False, &pItem ) &&
286cdf0e10cSrcweir ((SwFmtPageDesc*)pItem)->GetDefinedIn() != pModify )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir ((SwFmtPageDesc*)pItem)->ChgDefinedIn( pModify );
289cdf0e10cSrcweir bSet = true;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir
292cdf0e10cSrcweir if( SFX_ITEM_SET == GetItemState( RES_PARATR_DROP, sal_False, &pItem ) &&
293cdf0e10cSrcweir ((SwFmtDrop*)pItem)->GetDefinedIn() != pModify )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir // CharFormat gesetzt und dann noch in unterschiedlichen
296cdf0e10cSrcweir // Attribut Pools, dann muss das CharFormat kopiert werden!
297cdf0e10cSrcweir SwCharFmt* pCharFmt;
298cdf0e10cSrcweir if( 0 != ( pCharFmt = ((SwFmtDrop*)pItem)->GetCharFmt() )
299cdf0e10cSrcweir && GetPool() != pCharFmt->GetAttrSet().GetPool() )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir pCharFmt = GetDoc()->CopyCharFmt( *pCharFmt );
302cdf0e10cSrcweir ((SwFmtDrop*)pItem)->SetCharFmt( pCharFmt );
303cdf0e10cSrcweir }
304cdf0e10cSrcweir ((SwFmtDrop*)pItem)->ChgDefinedIn( pModify );
305cdf0e10cSrcweir bSet = true;
306cdf0e10cSrcweir }
307cdf0e10cSrcweir
308cdf0e10cSrcweir if( SFX_ITEM_SET == GetItemState( RES_BOXATR_FORMULA, sal_False, &pItem ) &&
309cdf0e10cSrcweir ((SwTblBoxFormula*)pItem)->GetDefinedIn() != pModify )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir ((SwTblBoxFormula*)pItem)->ChgDefinedIn( pModify );
312cdf0e10cSrcweir bSet = true;
313cdf0e10cSrcweir }
314cdf0e10cSrcweir
315cdf0e10cSrcweir return bSet;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir
CopyToModify(SwModify & rMod) const318cdf0e10cSrcweir void SwAttrSet::CopyToModify( SwModify& rMod ) const
319cdf0e10cSrcweir {
320cdf0e10cSrcweir // kopiere die Attribute ggfs. ueber Dokumentgrenzen
321cdf0e10cSrcweir SwCntntNode* pCNd = PTR_CAST( SwCntntNode, &rMod );
322cdf0e10cSrcweir SwFmt* pFmt = PTR_CAST( SwFmt, &rMod );
323cdf0e10cSrcweir
324cdf0e10cSrcweir if( pCNd || pFmt )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir if( Count() )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir // --> OD 2008-08-15 #i92811#
329cdf0e10cSrcweir SfxStringItem* pNewListIdItem( 0 );
330cdf0e10cSrcweir // <--
331cdf0e10cSrcweir
332cdf0e10cSrcweir const SfxPoolItem* pItem;
333cdf0e10cSrcweir const SwDoc *pSrcDoc = GetDoc();
334cdf0e10cSrcweir SwDoc *pDstDoc = pCNd ? pCNd->GetDoc() : pFmt->GetDoc();
335cdf0e10cSrcweir
336cdf0e10cSrcweir // muss die NumRule kopiert werden?
337cdf0e10cSrcweir if( pSrcDoc != pDstDoc && SFX_ITEM_SET == GetItemState(
338cdf0e10cSrcweir RES_PARATR_NUMRULE, sal_False, &pItem ) )
339cdf0e10cSrcweir {
340cdf0e10cSrcweir const String& rNm = ((SwNumRuleItem*)pItem)->GetValue();
341cdf0e10cSrcweir if( rNm.Len() )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir SwNumRule* pDestRule = pDstDoc->FindNumRulePtr( rNm );
344cdf0e10cSrcweir if( pDestRule )
345cdf0e10cSrcweir pDestRule->SetInvalidRule( sal_True );
346cdf0e10cSrcweir else
347cdf0e10cSrcweir pDstDoc->MakeNumRule( rNm,
348cdf0e10cSrcweir pSrcDoc->FindNumRulePtr( rNm ) );
349cdf0e10cSrcweir }
350cdf0e10cSrcweir }
351cdf0e10cSrcweir
352cdf0e10cSrcweir // --> OD 2008-03-19 #refactorlists#
353cdf0e10cSrcweir // copy list and if needed also the corresponding list style
354cdf0e10cSrcweir // for text nodes
355cdf0e10cSrcweir if ( pSrcDoc != pDstDoc &&
356cdf0e10cSrcweir pCNd && pCNd->IsTxtNode() &&
357cdf0e10cSrcweir GetItemState( RES_PARATR_LIST_ID, sal_False, &pItem ) == SFX_ITEM_SET )
358cdf0e10cSrcweir {
359cdf0e10cSrcweir const String& sListId =
360cdf0e10cSrcweir dynamic_cast<const SfxStringItem*>(pItem)->GetValue();
361cdf0e10cSrcweir if ( sListId.Len() > 0 &&
362cdf0e10cSrcweir !pDstDoc->getListByName( sListId ) )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir const SwList* pList = pSrcDoc->getListByName( sListId );
365cdf0e10cSrcweir // copy list style, if needed
366cdf0e10cSrcweir const String sDefaultListStyleName =
367cdf0e10cSrcweir pList->GetDefaultListStyleName();
368cdf0e10cSrcweir // --> OD 2008-08-15 #i92811#
369cdf0e10cSrcweir const SwNumRule* pDstDocNumRule =
370cdf0e10cSrcweir pDstDoc->FindNumRulePtr( sDefaultListStyleName );
371cdf0e10cSrcweir if ( !pDstDocNumRule )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir pDstDoc->MakeNumRule( sDefaultListStyleName,
374cdf0e10cSrcweir pSrcDoc->FindNumRulePtr( sDefaultListStyleName ) );
375cdf0e10cSrcweir }
376cdf0e10cSrcweir else
377cdf0e10cSrcweir {
378cdf0e10cSrcweir const SwNumRule* pSrcDocNumRule =
379cdf0e10cSrcweir pSrcDoc->FindNumRulePtr( sDefaultListStyleName );
380cdf0e10cSrcweir // If list id of text node equals the list style's
381cdf0e10cSrcweir // default list id in the source document, the same
382cdf0e10cSrcweir // should be hold in the destination document.
383cdf0e10cSrcweir // Thus, create new list id item.
384cdf0e10cSrcweir if ( sListId == pSrcDocNumRule->GetDefaultListId() )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir pNewListIdItem = new SfxStringItem (
387cdf0e10cSrcweir RES_PARATR_LIST_ID,
388cdf0e10cSrcweir pDstDocNumRule->GetDefaultListId() );
389cdf0e10cSrcweir }
390cdf0e10cSrcweir }
391cdf0e10cSrcweir // check again, if list exist, because <SwDoc::MakeNumRule(..)>
392cdf0e10cSrcweir // could have also created it.
393cdf0e10cSrcweir if ( pNewListIdItem == 0 &&
394cdf0e10cSrcweir !pDstDoc->getListByName( sListId ) )
395cdf0e10cSrcweir {
396cdf0e10cSrcweir // copy list
397cdf0e10cSrcweir pDstDoc->createList( sListId, sDefaultListStyleName );
398cdf0e10cSrcweir }
399cdf0e10cSrcweir // <--
400cdf0e10cSrcweir }
401cdf0e10cSrcweir }
402cdf0e10cSrcweir // <--
403cdf0e10cSrcweir
404cdf0e10cSrcweir // JP 04.02.99: Task #61467# Seitenvorlagenwechsel mit kopieren
405cdf0e10cSrcweir // Gegenueber dem alten Verhalten, sie zu entfernen
406cdf0e10cSrcweir const SwPageDesc* pPgDesc;
407cdf0e10cSrcweir if( pSrcDoc != pDstDoc && SFX_ITEM_SET == GetItemState(
408cdf0e10cSrcweir RES_PAGEDESC, sal_False, &pItem ) &&
409cdf0e10cSrcweir 0 != ( pPgDesc = ((SwFmtPageDesc*)pItem)->GetPageDesc()) )
410cdf0e10cSrcweir {
411cdf0e10cSrcweir SfxItemSet aTmpSet( *this );
412cdf0e10cSrcweir
413cdf0e10cSrcweir SwPageDesc* pDstPgDesc = pDstDoc->FindPageDescByName(
414cdf0e10cSrcweir pPgDesc->GetName() );
415cdf0e10cSrcweir if( !pDstPgDesc )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir // dann kopieren, ansonsten den benutzen
418cdf0e10cSrcweir pDstPgDesc = &pDstDoc->_GetPageDesc( pDstDoc->MakePageDesc(
419cdf0e10cSrcweir pPgDesc->GetName() ));
420cdf0e10cSrcweir pDstDoc->CopyPageDesc( *pPgDesc, *pDstPgDesc );
421cdf0e10cSrcweir }
422cdf0e10cSrcweir SwFmtPageDesc aDesc( pDstPgDesc );
423cdf0e10cSrcweir aDesc.SetNumOffset( ((SwFmtPageDesc*)pItem)->GetNumOffset() );
424cdf0e10cSrcweir aTmpSet.Put( aDesc );
425cdf0e10cSrcweir
426cdf0e10cSrcweir if( pCNd )
427cdf0e10cSrcweir {
428cdf0e10cSrcweir // --> OD 2008-08-15 #i92811#
429cdf0e10cSrcweir if ( pNewListIdItem != 0 )
430cdf0e10cSrcweir {
431cdf0e10cSrcweir aTmpSet.Put( *pNewListIdItem );
432cdf0e10cSrcweir }
433cdf0e10cSrcweir // <--
434cdf0e10cSrcweir pCNd->SetAttr( aTmpSet );
435cdf0e10cSrcweir }
436cdf0e10cSrcweir else
437cdf0e10cSrcweir pFmt->SetFmtAttr( aTmpSet );
438cdf0e10cSrcweir }
439cdf0e10cSrcweir else if( pCNd )
440cdf0e10cSrcweir {
441cdf0e10cSrcweir // --> OD 2008-08-15 #i92811#
442cdf0e10cSrcweir if ( pNewListIdItem != 0 )
443cdf0e10cSrcweir {
444cdf0e10cSrcweir SfxItemSet aTmpSet( *this );
445cdf0e10cSrcweir aTmpSet.Put( *pNewListIdItem );
446cdf0e10cSrcweir pCNd->SetAttr( aTmpSet );
447cdf0e10cSrcweir }
448cdf0e10cSrcweir else
449cdf0e10cSrcweir {
450cdf0e10cSrcweir pCNd->SetAttr( *this );
451cdf0e10cSrcweir }
452cdf0e10cSrcweir // <--
453cdf0e10cSrcweir }
454cdf0e10cSrcweir else
455cdf0e10cSrcweir pFmt->SetFmtAttr( *this );
456cdf0e10cSrcweir
457cdf0e10cSrcweir // --> OD 2008-08-15 #i92811#
458cdf0e10cSrcweir delete pNewListIdItem;
459cdf0e10cSrcweir pNewListIdItem = 0;
460cdf0e10cSrcweir // <--
461cdf0e10cSrcweir }
462cdf0e10cSrcweir }
463cdf0e10cSrcweir #ifdef DBG_UTIL
464cdf0e10cSrcweir else
465*870262e3SDon Lewis ASSERT( sal_False, "neither format nor ContentNode - no attributes copied");
466cdf0e10cSrcweir #endif
467cdf0e10cSrcweir }
468cdf0e10cSrcweir
469cdf0e10cSrcweir // check if ID is InRange of AttrSet-Ids
IsInRange(const sal_uInt16 * pRange,const sal_uInt16 nId)470cdf0e10cSrcweir sal_Bool IsInRange( const sal_uInt16* pRange, const sal_uInt16 nId )
471cdf0e10cSrcweir {
472cdf0e10cSrcweir while( *pRange )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir if( *pRange <= nId && nId <= *(pRange+1) )
475cdf0e10cSrcweir return sal_True;
476cdf0e10cSrcweir pRange += 2;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir return sal_False;
479cdf0e10cSrcweir }
480cdf0e10cSrcweir
481