bump product version to 6.3.0.0.beta1
[LibreOffice.git] / sd / source / ui / func / unmovss.cxx
blobeaa37a73a69563be1872b9d81996e58ca3f90539
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <drawdoc.hxx>
22 #include <stlsheet.hxx>
23 #include <stlpool.hxx>
25 SdMoveStyleSheetsUndoAction::SdMoveStyleSheetsUndoAction( SdDrawDocument* pTheDoc, StyleSheetCopyResultVector& rTheStyles, bool bInserted)
26 : SdUndoAction(pTheDoc)
27 , mbMySheets( !bInserted )
29 maStyles.swap( rTheStyles );
31 maListOfChildLists.resize( maStyles.size() );
32 // create list with lists of style sheet children
33 std::size_t i = 0;
34 for (auto& a : maStyles)
36 maListOfChildLists[i++] = SdStyleSheetPool::CreateChildList(a.m_xStyleSheet.get());
40 void SdMoveStyleSheetsUndoAction::Undo()
42 SfxStyleSheetBasePool* pPool = mpDoc->GetStyleSheetPool();
44 if (mbMySheets)
46 // the styles have to be inserted in the pool
48 // first insert all styles to the pool
49 for (auto& a : maStyles)
51 if (!a.m_bCreatedByCopy) // tdf#119259, existed before this action, so leave it alone
52 continue;
53 pPool->Insert(a.m_xStyleSheet.get());
56 // now assign the children again
57 std::vector< SdStyleSheetVector >::iterator childlistiter( maListOfChildLists.begin() );
58 for (auto& a : maStyles)
60 OUString aParent(a.m_xStyleSheet->GetName());
61 for( auto& rxChild : *childlistiter )
63 rxChild->SetParent(aParent);
65 ++childlistiter;
68 else
70 // remove the styles again from the pool
71 for (auto& a : maStyles)
73 if (!a.m_bCreatedByCopy) // tdf#119259, existed before this action, so leave it alone
74 continue;
75 pPool->Remove(a.m_xStyleSheet.get());
78 mbMySheets = !mbMySheets;
81 void SdMoveStyleSheetsUndoAction::Redo()
83 Undo();
86 SdMoveStyleSheetsUndoAction::~SdMoveStyleSheetsUndoAction()
90 OUString SdMoveStyleSheetsUndoAction::GetComment() const
92 return OUString();
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */