InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AutoStyleMapping.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Gaurav Bhargava
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // ADOBE CONFIDENTIAL
16 //
17 // Copyright 2010 Adobe Systems Incorporated
18 // All Rights Reserved.
19 //
20 // NOTICE: All information contained herein is, and remains
21 // the property of Adobe Systems Incorporated and its suppliers,
22 // if any. The intellectual and technical concepts contained
23 // herein are proprietary to Adobe Systems Incorporated and its
24 // suppliers and are protected by trade secret or copyright law.
25 // Dissemination of this information or reproduction of this material
26 // is strictly forbidden unless prior written permission is obtained
27 // from Adobe Systems Incorporated.
28 //
29 //========================================================================================
30 
31 #ifndef __AutoStyleMapping__
32 #define __AutoStyleMapping__
33 
34 #include "IBoolData.h"
35 #include "IStyleMappings.h"
36 #include "IMappingSession.h"
37 
49 {
50 public:
51 
54  explicit AutoStyleMapping(bool16 map, const IPMUnknown* styleMappingItem, IDataBase *srcDB, IDataBase *destDB):
55  fMap(map)
56  {
57  InterfacePtr<IMappingSession> mappingSession(GetExecutionContextSession(), UseDefaultIID());
58  if(mappingSession && map)
59  {
60  mappingSession->BeginMappingSession(srcDB, destDB);
61 
62  InterfacePtr<IStyleMappings> styleMappings(styleMappingItem, UseDefaultIID());
63  if( styleMappings )
64  {
65  InterfacePtr<IStyleMappings> sessionStyleMappings(mappingSession,UseDefaultIID());
66  ASSERT(sessionStyleMappings);
67  sessionStyleMappings->ClearMappings();
68  sessionStyleMappings->CopyFrom(styleMappings);
69  }
70  }
71  }
72 
76  {
77  InterfacePtr<IMappingSession> mappingSession(GetExecutionContextSession(), UseDefaultIID());
78  if(mappingSession && fMap)
79  {
80  mappingSession->EndMappingSession();
81 
82  InterfacePtr<IStyleMappings> sessionStyleMappings(mappingSession,UseDefaultIID());
83  ASSERT(sessionStyleMappings);
84  sessionStyleMappings->ClearMappings();
85  }
86 
87  }
88 private:
89  bool16 fMap;
90 };
91 
92 
93 #endif //__AutoStyleMapping__