1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <unmovss.hxx>
21 #include <DrawDocShell.hxx>
22 #include <drawdoc.hxx>
23 #include <stlsheet.hxx>
24 #include <stlpool.hxx>
26 SdMoveStyleSheetsUndoAction::SdMoveStyleSheetsUndoAction( SdDrawDocument
* pTheDoc
, SdStyleSheetVector
& rTheStyles
, bool bInserted
)
27 : SdUndoAction(pTheDoc
)
28 , mbMySheets( !bInserted
)
30 maStyles
.swap( rTheStyles
);
32 maListOfChildLists
.resize( maStyles
.size() );
33 // create list with lists of style sheet children
35 for(SdStyleSheetVector::iterator iter
= maStyles
.begin(); iter
!= maStyles
.end(); ++iter
)
37 maListOfChildLists
[i
++] = SdStyleSheetPool::CreateChildList( (*iter
).get() );
41 void SdMoveStyleSheetsUndoAction::Undo()
43 SfxStyleSheetBasePool
* pPool
= mpDoc
->GetStyleSheetPool();
47 // the styles have to be inserted in the pool
49 // first insert all styles to the pool
50 for(SdStyleSheetVector::iterator iter
= maStyles
.begin(); iter
!= maStyles
.end(); ++iter
)
52 pPool
->Insert((*iter
).get());
55 // now assign the children again
56 std::vector
< SdStyleSheetVector
>::iterator
childlistiter( maListOfChildLists
.begin() );
57 for(SdStyleSheetVector::iterator iter
= maStyles
.begin(); iter
!= maStyles
.end(); ++iter
, ++childlistiter
)
59 OUString
aParent((*iter
)->GetName());
60 for( SdStyleSheetVector::iterator childiter
= (*childlistiter
).begin(); childiter
!= (*childlistiter
).end(); ++childiter
)
62 (*childiter
)->SetParent(aParent
);
68 // remove the styles again from the pool
69 for(SdStyleSheetVector::iterator iter
= maStyles
.begin(); iter
!= maStyles
.end(); ++iter
)
71 pPool
->Remove((*iter
).get());
74 mbMySheets
= !mbMySheets
;
77 void SdMoveStyleSheetsUndoAction::Redo()
82 SdMoveStyleSheetsUndoAction::~SdMoveStyleSheetsUndoAction()
86 OUString
SdMoveStyleSheetsUndoAction::GetComment() const
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */