merge the formfield patch from ooo-build
[ooovba.git] / sw / source / ui / uiview / formatclipboard.cxx
blobcce491f67750b6a0623f78fb6e1df2b59e174010
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: formatclipboard.cxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #include "formatclipboard.hxx"
37 #include <hintids.hxx>
38 #ifndef _SVX_SVXIDS_HRC
39 #include <svx/svxids.hrc>
40 #endif
41 #ifndef _CMDID_H
42 #include <cmdid.h>
43 #endif
44 #include <format.hxx>
45 #include <charfmt.hxx>
46 #include <fmtcol.hxx>
47 #include <frmfmt.hxx>
48 #include <docstyle.hxx>
49 #include <fchrfmt.hxx>
50 #include <pam.hxx>
51 // header for class SdrView
52 #include <svx/svdview.hxx>
53 //SvxBrushItem
54 #include <svx/brshitem.hxx>
55 #include <svx/shaditem.hxx>
56 #include <frmatr.hxx>
57 // header for class SvxBoxInfoItem
58 #include <svx/boxitem.hxx>
59 // header for class SvxFmtBreakItem
60 #include <svx/brkitem.hxx>
61 // header for class SwFmtLayoutSplit
62 #include <fmtlsplt.hxx>
63 // header for class SvxFmtKeepItem
64 #include <svx/keepitem.hxx>
65 // header for class SvxFrameDirectionItem
66 #include <svx/frmdiritem.hxx>
67 #include <paratr.hxx>
68 #include <fmtpdsc.hxx>
69 #include <fmtrowsplt.hxx>
70 #include <swundo.hxx> // fuer die UndoIds
71 #include <boost/shared_ptr.hpp>
73 //#define FORMAT_PAINTBRUSH_ALSO_COPY_NUMBERFORMAT_FOR_TABLES 1
75 #ifdef FORMAT_PAINTBRUSH_ALSO_COPY_NUMBERFORMAT_FOR_TABLES
76 #include <cellatr.hxx>
77 #endif
79 /*--------------------------------------------------------------------
80 --------------------------------------------------------------------*/
82 namespace
84 #define FORMAT_PAINTBRUSH_FRAME_IDS \
85 RES_FRMATR_BEGIN, RES_FILL_ORDER, \
86 /* no RES_FRM_SIZE */ \
87 RES_PAPER_BIN, RES_SURROUND, \
88 /* no RES_VERT_ORIENT */ \
89 /* no RES_HORI_ORIENT */ \
90 /* no RES_ANCHOR */ \
91 RES_BACKGROUND, RES_SHADOW, \
92 /* no RES_FRMMACRO */ \
93 RES_COL, RES_KEEP, \
94 /* no RES_URL */ \
95 RES_EDIT_IN_READONLY, RES_LAYOUT_SPLIT, \
96 /* no RES_CHAIN */ \
97 RES_TEXTGRID, RES_FRMATR_END-1,
99 #define FORMAT_PAINTBRUSH_PARAGRAPH_IDS \
100 RES_PARATR_BEGIN, RES_PARATR_END -1, \
101 RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END -1, \
102 FORMAT_PAINTBRUSH_FRAME_IDS \
103 FN_NUMBER_NEWSTART, FN_NUMBER_NEWSTART, \
104 FN_NUMBER_NEWSTART_AT, FN_NUMBER_NEWSTART_AT,
106 SfxItemSet* lcl_CreateEmptyItemSet( int nSelectionType, SfxItemPool& rPool
107 , bool bNoCharacterFormats = false, bool bNoParagraphFormats = false )
109 SfxItemSet* pItemSet = 0;
110 if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
112 pItemSet = new SfxItemSet(rPool,
113 FORMAT_PAINTBRUSH_FRAME_IDS
116 else if( nSelectionType & nsSelectionType::SEL_DRW )
118 //is handled different
120 else if( nSelectionType == nsSelectionType::SEL_TBL )
122 pItemSet = new SfxItemSet(rPool,
123 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW, //SID_ATTR_BORDER_OUTER is inbetween
124 RES_BACKGROUND, RES_SHADOW, //RES_BOX is inbetween
125 SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE,
126 RES_BREAK, RES_BREAK,
127 RES_PAGEDESC, RES_PAGEDESC,
128 RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
129 RES_ROW_SPLIT, RES_ROW_SPLIT,
130 RES_KEEP, RES_KEEP,
131 RES_FRAMEDIR, RES_FRAMEDIR,
132 FN_PARAM_TABLE_HEADLINE, FN_PARAM_TABLE_HEADLINE,
133 FN_TABLE_BOX_TEXTDIRECTION, FN_TABLE_BOX_TEXTDIRECTION,
134 FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN,
135 #ifdef FORMAT_PAINTBRUSH_ALSO_COPY_NUMBERFORMAT_FOR_TABLES
136 RES_BOXATR_FORMAT, RES_BOXATR_FORMAT,
137 #endif
140 else if( nSelectionType & nsSelectionType::SEL_TXT )
142 if( bNoCharacterFormats )
143 pItemSet = new SfxItemSet(rPool,
144 FORMAT_PAINTBRUSH_PARAGRAPH_IDS
146 else if( bNoParagraphFormats )
147 pItemSet = new SfxItemSet(rPool,
148 RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
150 else
151 pItemSet = new SfxItemSet(rPool,
152 RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
153 FORMAT_PAINTBRUSH_PARAGRAPH_IDS
156 return pItemSet;
159 void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh )
161 SvxBrushItem aBrush( RES_BACKGROUND );
162 rSh.GetBoxBackground(aBrush);
163 rSet.Put( aBrush );
164 if(rSh.GetRowBackground(aBrush))
165 rSet.Put( aBrush, SID_ATTR_BRUSH_ROW );
166 else
167 rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
168 rSh.GetTabBackground(aBrush);
169 rSet.Put( aBrush, SID_ATTR_BRUSH_TABLE );
171 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
172 rSet.Put(aBoxInfo);
173 rSh.GetTabBorders( rSet );
175 SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
176 if(rSh.GetBoxDirection( aBoxDirection ))
177 rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTDIRECTION);
179 rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign()));
181 rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) );
183 SwFrmFmt *pFrmFmt = rSh.GetTableFmt();
184 if(pFrmFmt)
186 rSet.Put( pFrmFmt->GetShadow() );
187 rSet.Put( pFrmFmt->GetBreak() );
188 rSet.Put( pFrmFmt->GetPageDesc() );
189 rSet.Put( pFrmFmt->GetLayoutSplit() );
190 rSet.Put( pFrmFmt->GetKeep() );
191 rSet.Put( pFrmFmt->GetFrmDir() );
194 SwFmtRowSplit* pSplit = 0;
195 rSh.GetRowSplit(pSplit);
196 if(pSplit)
197 rSet.Put(*pSplit);
199 //-- numberformat in cells
200 #ifdef FORMAT_PAINTBRUSH_ALSO_COPY_NUMBERFORMAT_FOR_TABLES
201 rSh.GetTblBoxFormulaAttrs( rSet ); //RES_BOXATR_FORMAT
202 #endif
205 void lcl_setTableAttributes( const SfxItemSet& rSet, SwWrtShell &rSh )
207 const SfxPoolItem* pItem = 0;
208 BOOL bBorder = ( SFX_ITEM_SET == rSet.GetItemState( RES_BOX ) ||
209 SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
210 pItem = 0;
211 BOOL bBackground = SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, FALSE, &pItem );
212 const SfxPoolItem* pRowItem = 0, *pTableItem = 0;
213 bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_ROW, FALSE, &pRowItem );
214 bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_TABLE, FALSE, &pTableItem );
216 if(bBackground)
218 if(pItem)
219 rSh.SetBoxBackground( *(const SvxBrushItem*)pItem );
220 if(pRowItem)
222 SvxBrushItem aBrush(*(const SvxBrushItem*)pRowItem);
223 aBrush.SetWhich(RES_BACKGROUND);
224 rSh.SetRowBackground(aBrush);
226 if(pTableItem)
228 SvxBrushItem aBrush(*(const SvxBrushItem*)pTableItem);
229 aBrush.SetWhich(RES_BACKGROUND);
230 rSh.SetTabBackground( aBrush );
233 if(bBorder)
234 rSh.SetTabBorders( rSet );
236 if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, FALSE, &pItem) )
237 rSh.SetRowsToRepeat( ((SfxUInt16Item*)pItem)->GetValue() );
239 SwFrmFmt* pFrmFmt = rSh.GetTableFmt();
240 if(pFrmFmt)
242 //RES_SHADOW
243 pItem=0;
244 rSet.GetItemState(rSet.GetPool()->GetWhich(RES_SHADOW), FALSE, &pItem);
245 if(pItem)
246 pFrmFmt->SetFmtAttr( *pItem );
248 //RES_BREAK
249 pItem=0;
250 rSet.GetItemState(rSet.GetPool()->GetWhich(RES_BREAK), FALSE, &pItem);
251 if(pItem)
252 pFrmFmt->SetFmtAttr( *pItem );
254 //RES_PAGEDESC
255 pItem=0;
256 rSet.GetItemState(rSet.GetPool()->GetWhich(RES_PAGEDESC), FALSE, &pItem);
257 if(pItem)
258 pFrmFmt->SetFmtAttr( *pItem );
260 //RES_LAYOUT_SPLIT
261 pItem=0;
262 rSet.GetItemState(rSet.GetPool()->GetWhich(RES_LAYOUT_SPLIT), FALSE, &pItem);
263 if(pItem)
264 pFrmFmt->SetFmtAttr( *pItem );
266 //RES_KEEP
267 pItem=0;
268 rSet.GetItemState(rSet.GetPool()->GetWhich(RES_KEEP), FALSE, &pItem);
269 if(pItem)
270 pFrmFmt->SetFmtAttr( *pItem );
272 //RES_FRAMEDIR
273 pItem=0;
274 rSet.GetItemState(rSet.GetPool()->GetWhich(RES_FRAMEDIR), FALSE, &pItem);
275 if(pItem)
276 pFrmFmt->SetFmtAttr( *pItem );
279 if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTDIRECTION, FALSE, &pItem) )
281 SvxFrameDirectionItem aDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
282 aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pItem)->GetValue());
283 rSh.SetBoxDirection(aDirection);
286 if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_SET_VERT_ALIGN, FALSE, &pItem))
287 rSh.SetBoxAlign(((SfxUInt16Item*)(pItem))->GetValue());
289 if( SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, FALSE, &pItem) )
290 rSh.SetRowSplit(*static_cast<const SwFmtRowSplit*>(pItem));
292 //-- numberformat in cells
293 #ifdef FORMAT_PAINTBRUSH_ALSO_COPY_NUMBERFORMAT_FOR_TABLES
294 if( SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_FORMAT, FALSE, &pItem ))
296 SfxItemSet aBoxSet( *rSet.GetPool(), RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
297 aBoxSet.Put( SwTblBoxNumFormat( ((SfxUInt32Item*)pItem)->GetValue() ));
298 rSh.SetTblBoxFormulaAttrs( aBoxSet );
301 #endif
303 }//end anonymous namespace
305 SwFormatClipboard::SwFormatClipboard()
306 : m_nSelectionType(0)
307 , m_pItemSet(0)
308 , m_pTableItemSet(0)
309 , m_bPersistentCopy(false)
312 SwFormatClipboard::~SwFormatClipboard()
314 if(m_pItemSet)
315 delete m_pItemSet;
316 if(m_pTableItemSet)
317 delete m_pTableItemSet;
320 bool SwFormatClipboard::HasContent() const
322 return m_pItemSet!=0
323 || m_pTableItemSet != 0
324 || m_aCharStyle.Len()
325 || m_aParaStyle.Len()
328 bool SwFormatClipboard::HasContentForThisType( int nSelectionType ) const
330 if( !HasContent() )
331 return false;
333 if( m_nSelectionType == nSelectionType )
334 return true;
336 if( ( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
338 ( m_nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
340 return true;
342 if( nSelectionType & nsSelectionType::SEL_TXT && m_nSelectionType & nsSelectionType::SEL_TXT )
343 return true;
345 return false;
348 bool SwFormatClipboard::CanCopyThisType( int nSelectionType ) const
350 if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF
351 | nsSelectionType::SEL_TXT | nsSelectionType::SEL_DRW | nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS ) )
352 return true;
353 return false;
356 void SwFormatClipboard::Copy( SwWrtShell& rWrtShell, SfxItemPool& rPool, bool bPersistentCopy )
358 this->Erase();
359 m_bPersistentCopy = bPersistentCopy;
361 int nSelectionType = rWrtShell.GetSelectionType();
362 SfxItemSet* pItemSet = lcl_CreateEmptyItemSet( nSelectionType, rPool );
364 rWrtShell.StartAction();
365 rWrtShell.Push();
366 if( nSelectionType == nsSelectionType::SEL_TXT )
368 SwPaM* pCrsr = rWrtShell.GetCrsr();
369 //select one character only to get the attributes of this single character only
370 BOOL bHasSelection = pCrsr->HasMark();
371 BOOL bForwardSelection = FALSE;
373 if(!bHasSelection) //check for and handle multiselections
375 if( pCrsr->GetPrev() != pCrsr && pCrsr->GetPrev() != 0)
377 pCrsr = (SwPaM*)pCrsr->GetPrev();
378 bForwardSelection = (*pCrsr->GetPoint()) > (*pCrsr->GetMark());
379 bHasSelection = true;
380 pCrsr->DeleteMark();
381 pCrsr->SetMark();
382 rWrtShell.KillPams();
383 pCrsr = rWrtShell.GetCrsr();
386 else
387 bForwardSelection = (*pCrsr->GetPoint()) > (*pCrsr->GetMark());
388 pCrsr->DeleteMark();
389 pCrsr->SetMark();
391 if( !bHasSelection && rWrtShell.IsInRightToLeftText() )
392 bForwardSelection = !bForwardSelection;
394 if( !( !bHasSelection && rWrtShell.IsEndPara() ) )
395 pCrsr->Move( bForwardSelection ? fnMoveBackward : fnMoveForward );
398 if(pItemSet)
400 if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
401 rWrtShell.GetFlyFrmAttr(*pItemSet);
402 else
404 rWrtShell.GetCurAttr(*pItemSet);
406 // additional numbering properties for paragraph styles
407 if( nSelectionType & nsSelectionType::SEL_TXT && rWrtShell.GetCurNumRule() )
409 SfxBoolItem aStart(FN_NUMBER_NEWSTART, rWrtShell.IsNumRuleStart());
410 pItemSet->Put(aStart);
411 SfxUInt16Item aStartAt(FN_NUMBER_NEWSTART_AT, rWrtShell.GetNodeNumStart());
412 pItemSet->Put(aStartAt);
416 else if ( nSelectionType & nsSelectionType::SEL_DRW )
418 SdrView* pDrawView = rWrtShell.GetDrawView();
419 if(pDrawView)
421 BOOL bOnlyHardAttr = TRUE;
422 if( pDrawView->AreObjectsMarked() )
424 pItemSet = new SfxItemSet( pDrawView->GetAttrFromMarked(bOnlyHardAttr) );
425 //remove attributes defining the type/data of custom shapes
426 pItemSet->ClearItem(SDRATTR_CUSTOMSHAPE_ENGINE);
427 pItemSet->ClearItem(SDRATTR_CUSTOMSHAPE_DATA);
428 pItemSet->ClearItem(SDRATTR_CUSTOMSHAPE_GEOMETRY);
429 pItemSet->ClearItem(SDRATTR_CUSTOMSHAPE_REPLACEMENT_URL);
433 if( nSelectionType & nsSelectionType::SEL_TBL_CELLS )//only copy table attributes if really cells are selected (not only text in tables)
435 m_pTableItemSet = lcl_CreateEmptyItemSet( nsSelectionType::SEL_TBL, rPool );
436 lcl_getTableAttributes( *m_pTableItemSet, rWrtShell );
439 m_nSelectionType = nSelectionType;
440 m_pItemSet = pItemSet;
442 if( nSelectionType & nsSelectionType::SEL_TXT )
444 SwFmt* pFmt = rWrtShell.GetCurCharFmt();
445 if( pFmt )
446 m_aCharStyle = pFmt->GetName();
448 pFmt = rWrtShell.GetCurTxtFmtColl();
449 if( pFmt )
450 m_aParaStyle = pFmt->GetName();
452 rWrtShell.Pop(FALSE);
453 rWrtShell.EndAction();
455 typedef boost::shared_ptr< SfxPoolItem > SfxPoolItemSharedPtr;
456 typedef std::vector< SfxPoolItemSharedPtr > ItemVector;
457 // #144857# collect all PoolItems from the applied styles
458 void lcl_AppendSetItems( ItemVector& rItemVector, const SfxItemSet& rStyleAttrSet )
460 const USHORT* pRanges = rStyleAttrSet.GetRanges();
461 while( *pRanges )
463 for ( USHORT nWhich = *pRanges; nWhich <= *(pRanges+1); ++nWhich )
465 const SfxPoolItem* pItem;
466 if( SFX_ITEM_SET == rStyleAttrSet.GetItemState( nWhich, sal_False, &pItem ) )
468 rItemVector.push_back( SfxPoolItemSharedPtr( pItem->Clone() ) );
471 pRanges += 2;
474 // #144857# remove all items that are inherited from the styles
475 void lcl_RemoveEqualItems( SfxItemSet& rTemplateItemSet, ItemVector& rItemVector )
477 ItemVector::iterator aEnd = rItemVector.end();
478 ItemVector::iterator aIter = rItemVector.begin();
479 while( aIter != aEnd )
481 const SfxPoolItem* pItem;
482 if( SFX_ITEM_SET == rTemplateItemSet.GetItemState( (*aIter)->Which(), sal_True, &pItem ) &&
483 *pItem == *(*aIter) )
485 rTemplateItemSet.ClearItem( (*aIter)->Which() );
487 ++aIter;
491 void SwFormatClipboard::Paste( SwWrtShell& rWrtShell, SfxStyleSheetBasePool* pPool
492 , bool bNoCharacterFormats, bool bNoParagraphFormats )
494 int nSelectionType = rWrtShell.GetSelectionType();
495 if( !this->HasContentForThisType(nSelectionType) )
497 if(!m_bPersistentCopy)
498 this->Erase();
499 return;
502 rWrtShell.StartAction();
503 rWrtShell.StartUndo(UNDO_INSATTR);
505 ItemVector aItemVector;
506 if(pPool) //to find the styles we need the pool
508 if( nSelectionType & nsSelectionType::SEL_TXT )
510 if(m_aCharStyle.Len() && !bNoCharacterFormats )
512 SwDocStyleSheet* pStyle = (SwDocStyleSheet*)pPool->Find(m_aCharStyle, SFX_STYLE_FAMILY_CHAR);
513 if( pStyle )
515 SwFmtCharFmt aFmt(pStyle->GetCharFmt());
516 // #144857# collect items from character style
517 lcl_AppendSetItems( aItemVector, aFmt.GetCharFmt()->GetAttrSet());
518 USHORT nFlags=0; //(nMode & KEY_SHIFT) ? SETATTR_DONTREPLACE : SETATTR_DEFAULT;
519 rWrtShell.SetAttr( aFmt, nFlags );
522 if(m_aParaStyle.Len() && !bNoParagraphFormats )
524 SwDocStyleSheet* pStyle = (SwDocStyleSheet*)pPool->Find(m_aParaStyle, SFX_STYLE_FAMILY_PARA);
525 if( pStyle )
527 // #144857# collect items from paragraph style
528 lcl_AppendSetItems( aItemVector, pStyle->GetCollection()->GetAttrSet());
529 rWrtShell.SetTxtFmtColl( pStyle->GetCollection() );
534 if(m_pItemSet)
536 if( nSelectionType & nsSelectionType::SEL_DRW )
538 SdrView* pDrawView = rWrtShell.GetDrawView();
539 if(pDrawView)
541 BOOL bReplaceAll = TRUE;
542 pDrawView->SetAttrToMarked(*m_pItemSet, bReplaceAll);
545 else
547 SfxItemSet* pTemplateItemSet = lcl_CreateEmptyItemSet(
548 nSelectionType, *m_pItemSet->GetPool()
549 , bNoCharacterFormats, bNoParagraphFormats );
550 if(pTemplateItemSet)
552 pTemplateItemSet->Put( *m_pItemSet );
553 // #144857# only _set_ attributes that differ from style attributes should be applied - the style is applied anyway
554 lcl_RemoveEqualItems( *pTemplateItemSet, aItemVector );
556 if( nSelectionType & (nsSelectionType::SEL_FRM | nsSelectionType::SEL_OLE | nsSelectionType::SEL_GRF) )
557 rWrtShell.SetFlyFrmAttr(*pTemplateItemSet);
558 else
560 rWrtShell.SetAttr(*pTemplateItemSet);
562 // additional numbering properties for paragraph styles
563 if( nSelectionType & nsSelectionType::SEL_TXT && rWrtShell.GetCurNumRule() )
565 if( SFX_ITEM_SET == pTemplateItemSet->GetItemState(FN_NUMBER_NEWSTART) )
567 BOOL bStart = ((SfxBoolItem&)pTemplateItemSet->Get(FN_NUMBER_NEWSTART)).GetValue();
568 USHORT nNumStart = USHRT_MAX;
569 if( SFX_ITEM_SET == pTemplateItemSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
571 nNumStart = ((SfxUInt16Item&)pTemplateItemSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
572 if(USHRT_MAX != nNumStart)
573 bStart = FALSE;
575 rWrtShell.SetNumRuleStart(bStart);
576 rWrtShell.SetNodeNumStart(nNumStart);
578 else if( SFX_ITEM_SET == pTemplateItemSet->GetItemState(FN_NUMBER_NEWSTART_AT) )
580 USHORT nNumStart = ((SfxUInt16Item&)pTemplateItemSet->Get(FN_NUMBER_NEWSTART_AT)).GetValue();
581 rWrtShell.SetNodeNumStart(nNumStart);
582 rWrtShell.SetNumRuleStart(FALSE);
586 delete pTemplateItemSet;
591 if( m_pTableItemSet && nSelectionType & (nsSelectionType::SEL_TBL | nsSelectionType::SEL_TBL_CELLS) )
592 lcl_setTableAttributes( *m_pTableItemSet, rWrtShell );
594 rWrtShell.EndUndo(UNDO_INSATTR);
595 rWrtShell.EndAction();
597 if(!m_bPersistentCopy)
598 this->Erase();
601 void SwFormatClipboard::Erase()
603 m_nSelectionType = 0;
604 if(m_pItemSet)
606 delete m_pItemSet;
607 m_pItemSet = 0;
609 if(m_pTableItemSet)
611 delete m_pTableItemSet;
612 m_pTableItemSet = 0;
614 if( m_aCharStyle.Len() )
615 m_aCharStyle.Erase();
616 if( m_aParaStyle.Len() )
617 m_aParaStyle.Erase();
619 m_bPersistentCopy = false;