InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ITableModel.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Joe Shankar
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 #ifndef __ITableModel__
25 #define __ITableModel__
26 
27 #include "TableTypes.h"
28 #include "TablesID.h"
29 #include "PMReal.h"
30 #include "CellIterator.h"
31 #include "K2SmartPtr.h"
32 #include "IScaleObject.h"
33 
34 //---- Forward declarations.
35 class IParcelList;
36 class ICellContent;
37 class ITextModel;
38 class ICellContentMgr;
39 
40 class AttributeBossList;
41 class TableMemento;
42 class TableMementoPiece;
44 
45 //===================================================================================
71 //===================================================================================
72 
73 class ITableModel : public IPMUnknown {
74 
75 public:
77  enum { kDefaultIID = IID_ITABLEMODEL };
78 
79  //-------------------------------------------------------------------------------
81 
82 
85  virtual RowRange GetHeaderRows() const = 0;
86 
90  virtual GridArea GetHeaderArea() const = 0;
91 
95  virtual RowRange GetBodyRows() const = 0;
96 
100  virtual GridArea GetBodyArea() const = 0;
101 
105  virtual RowRange GetFooterRows() const = 0;
106 
110  virtual GridArea GetFooterArea() const = 0;
111 
116  virtual RowRange GetTotalRows() const = 0;
117 
121  virtual ColRange GetTotalCols() const = 0;
122 
126  virtual GridArea GetTotalArea() const = 0;
128 
129  //-------------------------------------------------------------------------------
131 
132 
136  virtual bool16 IsAnchor(const GridAddress& element) const = 0;
137 
143  virtual GridSpan GetCellSpan(const GridAddress& anchor) const = 0;
144 
149  virtual GridArea GetCellArea(const GridAddress& anchor) const = 0;
150 
154  virtual GridAddress FindCellAnchor(const GridAddress& element) const = 0;
156 
157  //-------------------------------------------------------------------------------
159 
160 
165  virtual bool16 IsValid(const GridAddress& element) const = 0;
166 
169  virtual bool16 IsValidRow(int32 row) const = 0;
170 
174  virtual bool16 IsValidColumn(int32 col) const = 0;
175 
182  virtual bool16 ContainsCompleteCells(const GridArea& cells) const = 0;
184 
185  //-------------------------------------------------------------------------------
190 
191 
197  virtual GridID GetGridID (const GridAddress& element) const = 0;
198 
203  virtual GridAddress GetGridAddress(GridID gridID) const = 0;
205 
206  //-------------------------------------------------------------------------------
208 
209 
225  virtual void InsertRows(const RowRange& rows, const Tables::ERelativePosition pos, const PMReal& height, const Tables::EContinuation continuation = Tables::eStructureAllAttrs) = 0;
226 
239  virtual void InsertRowsButNotAnchors(const RowRange& rows, const Tables::ERelativePosition pos, const PMReal& height, const Tables::EContinuation continuation = Tables::eStructureAllAttrs) = 0;
240 
258  virtual void InsertColumns(const ColRange& cols, const Tables::ERelativePosition pos, const PMReal& width, const Tables::EContinuation continuation = Tables::eStructureAllAttrs) = 0;
259 
263  virtual void DeleteRows(const RowRange& rows) = 0;
264 
273  virtual void DeleteRowsButNotAnchors(const RowRange& rows) = 0;
274 
278  virtual void DeleteColumns(const ColRange& cols) = 0;
279 
287  virtual void MergeCells (const GridArea& area) = 0;
288 
293  virtual bool16 CanMergeCells(const GridArea& area) const = 0;
294 
298  virtual void UnmergeCell(const GridAddress& anchor) = 0;
299 
300  enum ESplitDirection { eVerticalSplit, eHorizontalSplit };
301 
306 // virtual void SplitCell(const GridAddress& anchor, ESplitDirection direction) = 0;
307 
311  virtual void SplitCells(const GridArea& cells, ESplitDirection direction) = 0;
312 
323 // virtual bool16 CanSplitCell(const GridAddress& anchor, ESplitDirection direction) const = 0;
324 
332  virtual bool16 CanSplitCells(const GridArea& cells, ESplitDirection direction) const = 0;
333 
336  enum EDeleteState { eNotDeleting, eTableInitiatedDelete, eTextInitiatedDelete };
337 
341  virtual EDeleteState DeleteState() const = 0;
342 
345  enum EInsertState { eNotInserting, eTableInitiatedInsert, eTextInitiatedInsert };
346 
350  virtual EInsertState InsertState() const = 0;
351 
353 
354  //-------------------------------------------------------------------------------
356 
357 
372  virtual boost::shared_ptr<ContentBossAccessor> CreateContentBossAccessor(void) const = 0;
373 
378  virtual ICellContent* QueryCellContentBoss(const GridAddress& anchor) const = 0;
379 
384  virtual ICellContentMgr* QueryContentMgr(CellType type) const = 0;
386 
387  //-------------------------------------------------------------------------------
389 
390 
402 
405  virtual const_iterator begin() const = 0;
406 
410  virtual const_iterator begin(const GridArea& area) const = 0;
411 
415  virtual const_iterator end() const = 0;
416 
422  virtual const_iterator end(const GridArea& area) const = 0;
423 
424 
428  virtual const_iterator make_iterator(const GridAddress& gridRef) const = 0;
429 
434  virtual const_reverse_iterator rbegin() const = 0;
435 
440  virtual const_reverse_iterator rbegin(const GridArea& area) const = 0;
441 
446  virtual const_reverse_iterator rend() const = 0;
447 
451  virtual const_reverse_iterator rend(const GridArea& area) const = 0;
452 
456  virtual const_reverse_iterator rmake_iterator(const GridAddress& gridRef) const = 0;
458 
459  //-------------------------------------------------------------------------------
461 
462 
469  virtual bool16 CanCopy(const GridArea& cells) const = 0;
470 
481  virtual TableMemento* Copy(const GridArea& cells) const = 0;
482 
483 
488  virtual bool16 CanClear(const GridArea& cells) const = 0;
489 
495  virtual void Clear (const GridArea& cells) = 0;
496 
502  {
503  // Table attributes and style.
504  eTableAttrsStyle = 0x01,
505 
506  // Row attributes.
507  eRowAttrs = 0x02,
508 
509  // Column attributes.
510  eColAttrs = 0x04,
511 
512  // Cell attributes.
513  eCellAttrs = 0x08,
514 
515  // Cell content.
516  eCellContent = 0x10,
517 
518 
520  eCells = 0x18,
521 
523  eAll = 0x1f
524 
525  };
526 
538  virtual void Paste(const GridAddress& atAnchor, EWhatState what, TableMemento* toAdopt) = 0;
539  virtual void Paste(const GridAddress& atAnchor, EWhatState what, TableMemento* toAdopt, bool16 clearRedundantRows) = 0;
540 
547  virtual bool16 CanPaste(const GridAddress& atAnchor, const GridSpan& mementoSpan, const ITableModel* sourceTable, const GridAddress& fromAnchor) const = 0;
548 
549  //-------------------------------------------------------------------------------
551 
552  #ifdef DEBUG
553 
557  virtual bool16 LockModel(bool16 lock) = 0;
558 
562  virtual bool16 IsModelLocked(void) const = 0;
563 
565  virtual void TraceStructureAsHtml(void) const = 0;
566 
568  virtual bool16 IsHeaderOrFooterPresent(void) const = 0;
569 #endif
570 
571 
572  //-------------------------------------------------------------------------------
574 
575 
579  virtual void CreateRowSegment(const PMReal& distanceFromTableTopEdge, const ColRange& segmentCols) = 0;
580 
585  virtual void CreateRowSegment(const PMReal& distanceFromTableTopEdge, const K2Vector<ColRange>& segmentCols) = 0;
586 
591  virtual void CreateColSegment(const PMReal& distanceFromTableLeftEdge, const RowRange& segmentRows) = 0;
593 
594  //-------------------------------------------------------------------------------
596 
597 
603  virtual void ConvertToHeaderRows(const RowRange& rows) = 0;
604 
610  virtual bool16 CanConvertToHeaderRows(const RowRange& rows) const = 0;
611 
617  virtual void ConvertToFooterRows(const RowRange& rows) = 0;
618 
624  virtual bool16 CanConvertToFooterRows(const RowRange& rows) const = 0;
625 
633  virtual void ConvertToBodyRows(const RowRange& rows) = 0;
634 
643  virtual bool16 CanConvertToBodyRows(const RowRange& rows) const = 0;
644 
645 
647  virtual void ConvertToHeaderRowsButNoAnchors(const RowRange& rows) = 0;
649  virtual void ConvertToFooterRowsButNoAnchors(const RowRange& rows) = 0;
650 
655  virtual Tables::EDirection GetTableDirection() const = 0;
656 
661  virtual void ChangeTableDirection (const Tables::EDirection directionRTL) = 0;
662 
668  virtual void ConvertCellsType(const GridArea& cells, const CellType destType, bool16 tryToPreserveData = kFalse) = 0;
669 
674  virtual bool16 CanConvertCellsType(const GridArea& cells, const CellType destType) const = 0;
675 
679  virtual CellType GetCellType(const GridAddress& cell) const = 0;
680 };
681 
686 {
687  ASSERT(first > 0 && first <= ITableModel::eAll );
688  ASSERT(second > 0 && second <= ITableModel::eAll );
689 
690  ITableModel::EWhatState result = (ITableModel::EWhatState)((uint32)first | (uint32)second);
691 
692  ASSERT(result > 0 && result <= ITableModel::eAll);
693  return result;
694 };
695 
699 const CellType kTextContentType = kTextCellContentMgrBoss;
700 const CellType kPageItemContentType = kPageItemCellContentMgrBoss;
701 
702 #endif // __ITableModel__