InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IDynDocsPublicUtils.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Yeming Liu
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 
25 // ----- Interface files -----
26 #include "IGraphicsPort.h"
27 #include "IXPAttributeSuite.h"
28 
29 // ----- Include files -----
30 #include "DynamicDocumentsTypes.h"
31 #include "Utils.h"
32 
33 // ----- ID files -----
34 #include "DynamicDocumentsID.h"
35 
36 class IDocument;
37 class IShape;
38 
45 {
46 public:
47  enum { kDefaultIID = IID_IDYNDOCSPUBLICUTILS };
48 
57  virtual bool BeginHyperlink(IGraphicsPort *port, UIDRef const &item) = 0;
58 
68  virtual bool BeginHyperlink(IGraphicsPort *port, UIDRef const &item, PMRect const &bounds, PMMatrix const &matrix) = 0;
69 
74  virtual void EndHyperlink(IGraphicsPort *port) = 0;
75 
83  virtual bool CanAddHyperlink(IGraphicsPort const *port, UIDRef const &item) = 0;
84 
92  virtual void CalculateSelectedBounds(UIDList const &items, PMReal &width, PMReal &height) const = 0;
93 
103  virtual void CalculateTotalBounds(UIDList const &items, bool readersSpreads, PMReal &width, PMReal &height) const = 0;
104 
119  PMReal const &sourceWidth, PMReal const &sourceHeight,
120  flash_export::SizeAndFitSettings const &settings,
121  uint32 &destWidth, uint32 &destHeight
122  ) const = 0;
123 
138  virtual bool IterateDocForExport(ICommand* pCmdExport, const UIDList& items, IDocument* pDoc, UIFlags uiFlags, bool* bValidationFailure = nil) const = 0;
139 
147  virtual AString GetResourceDirectoryNameFromDDExportFile(const IDFile& ddExportFile) const = 0;
148 
158 };
159 
163 class DynDocsHyperlinkHelper : boost::noncopyable
164 {
165  Utils<IDynDocsPublicUtils> fDynDocsUtils;
166  InterfacePtr<IGraphicsPort> fGraphicsPort;
167  bool fPushHyperlink;
168 
169 public:
177  fGraphicsPort(port, UseDefaultIID()),
178  fPushHyperlink(false)
179  {
180  if (fDynDocsUtils.Exists() && fDynDocsUtils->CanAddHyperlink(port, item))
181  fPushHyperlink = fDynDocsUtils->BeginHyperlink(port, item);
182  }
183 
192  DynDocsHyperlinkHelper(IGraphicsPort *port, UIDRef const &item, PMRect const &bounds, PMMatrix const &matrix) :
193  fGraphicsPort(port, UseDefaultIID()),
194  fPushHyperlink(false)
195  {
196  if (fDynDocsUtils.Exists() && fDynDocsUtils->CanAddHyperlink(port, item))
197  fPushHyperlink = fDynDocsUtils->BeginHyperlink(port, item, bounds, matrix);
198  }
199 
204  {
205  if (fPushHyperlink)
206  {
207  ASSERT(fDynDocsUtils.Exists());
208  fDynDocsUtils->EndHyperlink(fGraphicsPort);
209  }
210  }
211 };
212