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 .
21 #include "unmovss.hxx"
22 #include "DrawDocShell.hxx"
23 #include "drawdoc.hxx"
24 #include "stlsheet.hxx"
25 #include "stlpool.hxx"
27 SdMoveStyleSheetsUndoAction::SdMoveStyleSheetsUndoAction( SdDrawDocument
* pTheDoc
, SdStyleSheetVector
& rTheStyles
, bool bInserted
)
28 : SdUndoAction(pTheDoc
)
29 , mbMySheets( !bInserted
)
31 maStyles
.swap( rTheStyles
);
33 maListOfChildLists
.resize( maStyles
.size() );
34 // create list with lists of style sheet children
36 for(SdStyleSheetVector::iterator iter
= maStyles
.begin(); iter
!= maStyles
.end(); ++iter
)
38 maListOfChildLists
[i
++] = SdStyleSheetPool::CreateChildList( (*iter
).get() );
42 void SdMoveStyleSheetsUndoAction::Undo()
44 SfxStyleSheetBasePool
* pPool
= mpDoc
->GetStyleSheetPool();
48 // the styles have to be inserted in the pool
50 // first insert all styles to the pool
51 for(SdStyleSheetVector::iterator iter
= maStyles
.begin(); iter
!= maStyles
.end(); ++iter
)
53 pPool
->Insert((*iter
).get());
56 // now assign the children again
57 std::vector
< SdStyleSheetVector
>::iterator
childlistiter( maListOfChildLists
.begin() );
58 for(SdStyleSheetVector::iterator iter
= maStyles
.begin(); iter
!= maStyles
.end(); ++iter
, ++childlistiter
)
60 String
aParent((*iter
)->GetName());
61 for( SdStyleSheetVector::iterator childiter
= (*childlistiter
).begin(); childiter
!= (*childlistiter
).end(); ++childiter
)
63 (*childiter
)->SetParent(aParent
);
69 // remove the styles again from the pool
70 for(SdStyleSheetVector::iterator iter
= maStyles
.begin(); iter
!= maStyles
.end(); ++iter
)
72 pPool
->Remove((*iter
).get());
75 mbMySheets
= !mbMySheets
;
78 void SdMoveStyleSheetsUndoAction::Redo()
83 SdMoveStyleSheetsUndoAction::~SdMoveStyleSheetsUndoAction()
87 OUString
SdMoveStyleSheetsUndoAction::GetComment() const
93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */