2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
#include "doc.hxx"
|
2012-05-30 15:27:46 +02:00
|
|
|
#include "swundo.hxx"
|
2000-09-18 23:08:29 +00:00
|
|
|
#include "pam.hxx"
|
|
|
|
#include "ndtxt.hxx"
|
2010-12-15 09:14:14 +01:00
|
|
|
#include <UndoCore.hxx>
|
2000-09-18 23:08:29 +00:00
|
|
|
#include "rolbck.hxx"
|
2012-06-20 16:36:51 +02:00
|
|
|
#include "docary.hxx"
|
2000-09-18 23:08:29 +00:00
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
|
2008-06-13 09:28:41 +00:00
|
|
|
SwUndoFmtColl::SwUndoFmtColl( const SwPaM& rRange,
|
|
|
|
SwFmtColl* pColl,
|
|
|
|
const bool bReset,
|
|
|
|
const bool bResetListAttrs )
|
|
|
|
: SwUndo( UNDO_SETFMTCOLL ),
|
|
|
|
SwUndRng( rRange ),
|
|
|
|
pHistory( new SwHistory ),
|
|
|
|
pFmtColl( pColl ),
|
|
|
|
mbReset( bReset ),
|
|
|
|
mbResetListAttrs( bResetListAttrs )
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i31191#
|
2004-09-20 14:15:28 +00:00
|
|
|
if ( pColl )
|
|
|
|
aFmtName = pColl->GetName();
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwUndoFmtColl::~SwUndoFmtColl()
|
|
|
|
{
|
|
|
|
delete pHistory;
|
|
|
|
}
|
|
|
|
|
2010-12-15 09:14:11 +01:00
|
|
|
void SwUndoFmtColl::UndoImpl(::sw::UndoRedoContext & rContext)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-12-15 09:14:11 +01:00
|
|
|
// restore old values
|
|
|
|
pHistory->TmpRollback(& rContext.GetDoc(), 0);
|
2000-09-18 23:08:29 +00:00
|
|
|
pHistory->SetTmpEnd( pHistory->Count() );
|
|
|
|
|
2010-12-15 09:14:11 +01:00
|
|
|
// create cursor for undo range
|
|
|
|
AddUndoRedoPaM(rContext);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-15 09:14:11 +01:00
|
|
|
void SwUndoFmtColl::RedoImpl(::sw::UndoRedoContext & rContext)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-12-15 09:14:11 +01:00
|
|
|
SwPaM & rPam = AddUndoRedoPaM(rContext);
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2010-12-15 09:14:11 +01:00
|
|
|
DoSetFmtColl(rContext.GetDoc(), rPam);
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2010-12-15 09:14:11 +01:00
|
|
|
void SwUndoFmtColl::RepeatImpl(::sw::RepeatContext & rContext)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2010-12-15 09:14:11 +01:00
|
|
|
DoSetFmtColl(rContext.GetDoc(), rContext.GetRepeatPaM());
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
|
2010-12-15 09:14:11 +01:00
|
|
|
void SwUndoFmtColl::DoSetFmtColl(SwDoc & rDoc, SwPaM & rPaM)
|
2000-09-18 23:08:29 +00:00
|
|
|
{
|
2012-05-30 15:27:46 +02:00
|
|
|
// Only one TextFrmColl can be applied to a section, thus request only in
|
|
|
|
// this array.
|
2011-02-07 13:06:08 +01:00
|
|
|
sal_uInt16 const nPos = rDoc.GetTxtFmtColls()->GetPos(
|
2000-09-18 23:08:29 +00:00
|
|
|
(SwTxtFmtColl*)pFmtColl );
|
2010-12-15 09:14:11 +01:00
|
|
|
// does the format still exist?
|
2000-09-18 23:08:29 +00:00
|
|
|
if( USHRT_MAX != nPos )
|
2008-06-13 09:28:41 +00:00
|
|
|
{
|
2010-12-15 09:14:11 +01:00
|
|
|
rDoc.SetTxtFmtColl(rPaM,
|
2008-06-13 09:28:41 +00:00
|
|
|
(SwTxtFmtColl*)pFmtColl,
|
|
|
|
mbReset,
|
|
|
|
mbResetListAttrs );
|
|
|
|
}
|
2000-09-18 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2004-05-18 13:08:21 +00:00
|
|
|
SwRewriter SwUndoFmtColl::GetRewriter() const
|
|
|
|
{
|
|
|
|
SwRewriter aResult;
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i31191# Use stored format name instead of
|
2004-09-20 14:15:28 +00:00
|
|
|
// pFmtColl->GetName(), because pFmtColl does not have to be available
|
|
|
|
// anymore.
|
2012-04-02 09:34:41 +01:00
|
|
|
aResult.AddRule(UndoArg1, aFmtName );
|
2004-05-18 13:08:21 +00:00
|
|
|
|
|
|
|
return aResult;
|
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|