InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ITableUtils.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Jesse Jones (jejones)
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 // Purpose: Table related utility functions.
24 //
25 //========================================================================================
26 
27 #ifndef __ITABLEUTILS__
28 #define __ITABLEUTILS__
29 
30 #include "IPMUnknown.h"
31 #include "TablesID.h"
32 #include "UIDRef.h"
33 #include "ScriptData.h"
34 #include "TableTypes.h"
35 #include "PMTextUtils.h"
36 #include "K2Vector.h"
37 #include "PMPoint.h"
38 #include "TextChar.h"
39 
40 //-----------------------------------
41 // Forward References
42 //
43 class ITableFrame;
44 class ITableModel;
45 class ITextModel;
46 class ITableTarget;
47 class PMReal;
49 class ICellContent;
50 class IPlaceBehavior;
51 
52 
53 // ===================================================================================
54 // class ITableUtils
55 // ===================================================================================
59 class ITableUtils : public IPMUnknown {
60 
61 //-----------------------------------
62 // API
63 //
64 public:
65  // ----- Constants -----
66  enum {kDefaultIID = IID_ITABLEUTILS};
67 
71  class CellChunk
72  {
73  public:
74  typedef base_type data_type;
75 
80  CellChunk(GridArea chunk, UIDRef tableFrame) : chunkArea(chunk), tableFrameContainingChunck(tableFrame) {}
81  GridArea chunkArea;
82  UIDRef tableFrameContainingChunck;
83  };
84 
85  // ----- Table Creation -----
98  virtual UIDRef ConvertTextToTable(ITextModel* textModel, const Text::StoryRange& textRange, const PMString colSeparator="\t", const PMString rowSeparator="\r", const int32 userNumCols=1, const UID& tableStyleUID = kInvalidUID) const = 0;
103  virtual UIDRef ConvertTextToTable(ITextModel* textModel, const Text::StoryRange& textRange, const K2Vector<PMString>& colSeparators,
104  const K2Vector<PMString>& rowSeparators, const int32 userNumCols=1,
105  const UID& tableStyleUID = kInvalidUID) const = 0;
106  // $$$ Use a specifier here: should not require a selection.
107  // $$$ This is probably true for most of these functions.
108 
112  enum ESetTextSelection { eNoSelection, eSetSelectionInFirstCell };
113 
139  virtual void InsertTable(ITextModel* textModel,
140  TextIndex index, int32 len,
141  int32 numRows, int32 numCols,
142  const PMReal& rowHeight,
143  const PMReal& colWidth,
144  CellType cellType,
145  const ESetTextSelection setSelection,
146  const UID& tableStyle = kInvalidUID) const = 0;
147 
155  virtual void InsertTable(ITextModel* textModel,
156  TextIndex index, int32 len,
157  int32 numRows, int32 numCols,
158  int32 numHeaderRows, int32 numFooterRows,
159  const PMReal& rowHeight,
160  const PMReal& colWidth,
161  CellType cellType,
162  const ESetTextSelection setSelection,
163  const UID& tableStyle = kInvalidUID,
164  Tables::EDirection direction = Tables::eLTR) const = 0;
165 
166  // ----- Misc -----
186  virtual UIDRef GetTableModel(ITextModel* text, TextIndex index) const = 0;
187 
192  virtual UID GetRootTableStyle(IDataBase* db) const = 0;
193 
199  virtual K2Vector<CellChunk> * GetCellChunks(const GridArea selection, const ITableModel* tableModel) const = 0;
200 
201  // ----- Misc shared by UI and scripting -----
213  virtual void CalculateDefaultCellBounds(const ITextModel* textModel,
214  TextIndex insertLocation,
215  int32 numRows, int32 numCols,
216  PMReal& rowHeight, PMReal& colWidth) const = 0;
217 
218  // ----- Misc shared by UI and Model -----
227  virtual Tables::ESelectionSides CalculateSides(const ITableTarget* tableTarget) const = 0;
228 
229  // ----- Scripting -----
239  virtual ErrorCode CreateCellScriptObject( const RequestContext& context, const GridArea& area, const ITableModel* tableModel, ScriptList* objectList ) = 0 ;
241  virtual ErrorCode CreateCellScriptObject( const RequestContext& context, const GridArea& area, const ITableModel* tableModel, ScriptList* objectList, IScript* parent ) = 0 ;
243  virtual ErrorCode CreateRowScriptObject( const RequestContext& context, GridCoord row, const ITableModel* tableModel, ScriptList* objectList, IScript* parent ) = 0 ;
245  virtual ErrorCode CreateColumnScriptObject( const RequestContext& context, GridCoord col, const ITableModel* tableModel, ScriptList* objectList, IScript* parent ) = 0 ;
247  virtual ErrorCode CreateTableScriptObject( const RequestContext& context, const ITableModel* tableModel, ScriptList* objectList ) = 0;
249  virtual IScript* CreateTableScriptObject( const RequestContext& context, const ITableModel* tableModel) = 0;
250 
257  virtual ErrorCode ProcessCreateTableStyle(const PMString& styleName, const AttributeBossList* styleAttributes, IDataBase* dbOfStyleNameTable, UID& outNewStyleUID) const = 0;
258 
265  virtual bool16 IsStyleNamePresent(const PMString& styleName, IDataBase* dbOfStyleNameTable) const = 0;
266 
267 #ifdef DEBUG
268 
271  virtual bool16 AreTableAttributes(const AttributeBossList* attrs) const = 0;
272 #endif
273 
282  virtual PMPoint ConvertToLocalPoint(const ITableFrame *tableFrame, const PBPMPoint& pt) const = 0;
283 
289  virtual bool16 InsideTable(const ITextModel* textModel, TextIndex at) const = 0;
290 
297  virtual TextIndex TableToPrimaryTextIndex(const ITextModel* textModel, TextIndex withinTableTextIndex) const = 0;
298 
305  virtual RangeData TableToPrimaryTextRange(const ITextModel* textModel, RangeData tableRange) const = 0;
306 
310  virtual bool16 DictGetIsComposable(const ITextStoryThreadDict* dict,
311  uint32 dictKey) const = 0;
312  virtual ParcelKey DictGetParcelKeyOfControllingAnchor(const ITextStoryThreadDict* dict, uint32 dictKey, ParcelKey keyInChildThread) const = 0;
313 
320  virtual GridArea FixUpTableSelection(const GridArea selection, const ITableModel *model) const = 0;
321 
329  virtual bool16 CanInsertTableAt(const ITextModel* textModel,
330  TextIndex at) const = 0;
331 
337  virtual ParcelKey GetHFProxyParcelKey(const ICellContent* cell,
338  ParcelKey key) const = 0;
339 
350  virtual bool16 GetHFTextRangeContext(const ITextModel* textModel,
351  TextIndex at,
352  RangeData* pFrameBodyRange,
353  RangeData* pTableBodyRange) const = 0;
354 
363  virtual IPlaceBehavior* QueryPageItemCellPlaceBehavior(const ITableModel* tableModel,
364  GridAddress cellAddress) = 0;
365 
375  GridAddress cellAddress) = 0;
376 
383  virtual bool16 IsTableCellContent(const UIDRef& item, UID& pageItemAdapter) const = 0;
384 
391  virtual bool16 IsTableCellContent(const UIDRef& item, UID* pageItemAdapter = nil) = 0;
392 
393 
400  virtual void ValidateContent(UIDList& items) const = 0;
401 
408  virtual CellType GetCellContentType(UIDRef tableModel, GridAddress cellAddress) const = 0;
409 
415  virtual ICellContent* QueryCellContentfromPlacedItem(UIDRef placedItem) const = 0;
416 
422  virtual bool16 CanConvertToGraphicCell(UIDRef tableModel, const GridAddress &cellAddress) const = 0;
423 
429  virtual bool16 CanConvertInlineCellToImageCell(const ITableModel* table, const GridAddress& cell) const = 0;
430 
436  virtual bool16 HasAnyTextCell(ITableModel* tableModel, const GridArea& area) const = 0;
437 
443  virtual bool16 HasAnyGraphicCell(ITableModel* tableModel, const GridArea& area) const = 0;
444 
445  virtual bool16 CanPlaceInGraphicCell(UIDRef item, ErrorCode* err = NULL) const = 0;
446 
447  virtual ErrorCode ResizeTableFrame(ITableFrame *tableFrame, const PMReal& horizonProp, const PMReal& verticalProp) = 0;
448 
449  virtual ErrorCode ResizeTableFrame(ITableFrame *tableFrame, PMRect tableArea, const int32 numRowsInFrame,
450  const int32 numColumnsInFrame, ColRange columnsInFrame, const PMReal& horizonProp, const PMReal& verticalProp) = 0;
451 
452  virtual void SetMinRowHeight(ITableModel* table, int32 row, int32 howMany, const PMReal& height) = 0;
453 };
454 
455 
456 #endif // __ITABLEUTILS__