office-gobmx/sd/source/ui/func/unmovss.cxx

109 lines
3.4 KiB
C++
Raw Normal View History

2000-09-18 11:07:07 -05:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 11:07:07 -05:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 11:07:07 -05:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 11:07:07 -05:00
*
* This file is part of OpenOffice.org.
2000-09-18 11:07:07 -05:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 11:07:07 -05:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 11:07:07 -05:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 11:07:07 -05:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
2000-09-18 11:07:07 -05:00
#include "unmovss.hxx"
#include "DrawDocShell.hxx"
2000-09-18 11:07:07 -05:00
#include "drawdoc.hxx"
#include "stlsheet.hxx"
#include "stlpool.hxx"
2000-09-18 11:07:07 -05:00
SdMoveStyleSheetsUndoAction::SdMoveStyleSheetsUndoAction( SdDrawDocument* pTheDoc, SdStyleSheetVector& rTheStyles, bool bInserted)
: SdUndoAction(pTheDoc)
, mbMySheets( !bInserted )
2000-09-18 11:07:07 -05:00
{
maStyles.swap( rTheStyles );
2000-09-18 11:07:07 -05:00
maListOfChildLists.resize( maStyles.size() );
2000-09-18 11:07:07 -05:00
// Liste mit den Listen der StyleSheet-Kinder erstellen
std::size_t i = 0;
for(SdStyleSheetVector::iterator iter = maStyles.begin(); iter != maStyles.end(); iter++ )
2000-09-18 11:07:07 -05:00
{
maListOfChildLists[i++] = SdStyleSheetPool::CreateChildList( (*iter).get() );
2000-09-18 11:07:07 -05:00
}
}
/*************************************************************************
|*
|* Undo()
|*
\************************************************************************/
void SdMoveStyleSheetsUndoAction::Undo()
2000-09-18 11:07:07 -05:00
{
SfxStyleSheetBasePool* pPool = mpDoc->GetStyleSheetPool();
2000-09-18 11:07:07 -05:00
if (mbMySheets)
2000-09-18 11:07:07 -05:00
{
// the styles have to be inserted in the pool
// first insert all styles to the pool
for(SdStyleSheetVector::iterator iter = maStyles.begin(); iter != maStyles.end(); iter++ )
2000-09-18 11:07:07 -05:00
{
pPool->Insert((*iter).get());
2000-09-18 11:07:07 -05:00
}
// now assign the childs again
std::vector< SdStyleSheetVector >::iterator childlistiter( maListOfChildLists.begin() );
for(SdStyleSheetVector::iterator iter = maStyles.begin(); iter != maStyles.end(); iter++, childlistiter++ )
2000-09-18 11:07:07 -05:00
{
String aParent((*iter)->GetName());
for( SdStyleSheetVector::iterator childiter = (*childlistiter).begin(); childiter != (*childlistiter).end(); childiter++ )
2000-09-18 11:07:07 -05:00
{
(*childiter)->SetParent(aParent);
2000-09-18 11:07:07 -05:00
}
}
}
else
{
// remove the styles again from the pool
for(SdStyleSheetVector::iterator iter = maStyles.begin(); iter != maStyles.end(); iter++ )
2000-09-18 11:07:07 -05:00
{
pPool->Remove((*iter).get());
2000-09-18 11:07:07 -05:00
}
}
mbMySheets = !mbMySheets;
2000-09-18 11:07:07 -05:00
}
void SdMoveStyleSheetsUndoAction::Redo()
2000-09-18 11:07:07 -05:00
{
Undo();
}
SdMoveStyleSheetsUndoAction::~SdMoveStyleSheetsUndoAction()
2000-09-18 11:07:07 -05:00
{
}
String SdMoveStyleSheetsUndoAction::GetComment() const
2000-09-18 11:07:07 -05:00
{
return String();
}