xref: /trunk/main/sd/source/ui/func/unmovss.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 #include "unmovss.hxx"
28 #include "DrawDocShell.hxx"
29 #include "drawdoc.hxx"
30 #include "stlsheet.hxx"
31 #include "stlpool.hxx"
32 
SdMoveStyleSheetsUndoAction(SdDrawDocument * pTheDoc,SdStyleSheetVector & rTheStyles,bool bInserted)33 SdMoveStyleSheetsUndoAction::SdMoveStyleSheetsUndoAction( SdDrawDocument* pTheDoc, SdStyleSheetVector& rTheStyles, bool bInserted)
34 : SdUndoAction(pTheDoc)
35 , mbMySheets( !bInserted )
36 {
37 	maStyles.swap( rTheStyles );
38 
39 	maListOfChildLists.resize( maStyles.size() );
40 	// Liste mit den Listen der StyleSheet-Kinder erstellen
41 	std::size_t i = 0;
42 	for(SdStyleSheetVector::iterator iter = maStyles.begin(); iter != maStyles.end(); iter++ )
43 	{
44 		maListOfChildLists[i++] = SdStyleSheetPool::CreateChildList( (*iter).get() );
45 	}
46 }
47 
48 /*************************************************************************
49 |*
50 |* Undo()
51 |*
52 \************************************************************************/
53 
Undo()54 void SdMoveStyleSheetsUndoAction::Undo()
55 {
56 	SfxStyleSheetBasePool* pPool  = mpDoc->GetStyleSheetPool();
57 
58 	if (mbMySheets)
59 	{
60 		// the styles have to be inserted in the pool
61 
62 		// first insert all styles to the pool
63 		for(SdStyleSheetVector::iterator iter = maStyles.begin(); iter != maStyles.end(); iter++ )
64 		{
65 			pPool->Insert((*iter).get());
66 		}
67 
68 		// now assign the childs again
69 		std::vector< SdStyleSheetVector >::iterator childlistiter( maListOfChildLists.begin() );
70 		for(SdStyleSheetVector::iterator iter = maStyles.begin(); iter != maStyles.end(); iter++, childlistiter++ )
71 		{
72 			String aParent((*iter)->GetName());
73 			for( SdStyleSheetVector::iterator childiter = (*childlistiter).begin(); childiter != (*childlistiter).end(); childiter++ )
74 			{
75 				(*childiter)->SetParent(aParent);
76 			}
77 		}
78 	}
79 	else
80 	{
81 		// remove the styles again from the pool
82 		for(SdStyleSheetVector::iterator iter = maStyles.begin(); iter != maStyles.end(); iter++ )
83 		{
84 			pPool->Remove((*iter).get());
85 		}
86 	}
87 	mbMySheets = !mbMySheets;
88 }
89 
Redo()90 void SdMoveStyleSheetsUndoAction::Redo()
91 {
92 	Undo();
93 }
94 
~SdMoveStyleSheetsUndoAction()95 SdMoveStyleSheetsUndoAction::~SdMoveStyleSheetsUndoAction()
96 {
97 }
98 
GetComment() const99 String SdMoveStyleSheetsUndoAction::GetComment() const
100 {
101 	return String();
102 }
103 
104 
105