Adobe.com
Contents Suites Classes Class Index Member Index

IAIArtboards.hpp

Go to the documentation of this file.
00001 #pragma once
00002 #ifndef _IAI_ARTBOARDS_
00003 #define _IAI_ARTBOARDS_
00004 
00005 /*
00006 * Name: IAIArtboards.hpp
00007 * Author: Started by Pushp
00008 * Date: November, 2008
00009 * Purpose: Adobe Illustrator Artboard Interfaces
00010 *
00011 * ADOBE SYSTEMS INCORPORATED
00012 * Copyright 2009 Adobe Systems Incorporated.
00013 * All rights reserved.
00014 *
00015 * NOTICE:  Adobe permits you to use, modify, and distribute this file
00016 * in accordance with the terms of the Adobe license agreement
00017 * accompanying it. If you have received this file from a source other
00018 * than Adobe, then your use, modification, or distribution of it
00019 * requires the prior written permission of Adobe.
00020 *
00021 */
00022 #include "AITypes.h"
00023 #include "IAIUnicodeString.h"
00024 #if defined(ILLUSTRATOR_MINIMAL)
00025         #include "IAIUUID.h"
00026 #endif
00027 
00028 #include <vector>
00029 #ifdef AI_HAS_RVALUE_REFERENCES
00030 #include <utility>
00031 #endif //AI_HAS_RVALUE_REFERENCES
00032 
00033 class CAIArtboardProperties;
00034 class CAIArtboardList;
00035 
00038 #define kAICantDeleteLastArtboardErr            'CDLC'
00039 
00041 #define kAIExceededMaxArtboardLimitErr          'EMxL'
00042 
00047 #define kAIArtboardRulerOriginChangedNotifier "AI Artboard Ruler Origin Changed Notifier"
00048 
00049 #define kNotFoundErr            '!FND'
00050 
00051 #define kAIArtboardOutOfCanvasErr                       'AOoC'
00052 
00053 #define kActiveArtboard -1
00054 
00055 namespace ai
00056 {
00058         typedef ai::int32 ArtboardID;
00060         typedef CAIArtboardProperties* ArtboardRef;
00062         typedef CAIArtboardList* ArtboardListRef;
00063 #if defined(ILLUSTRATOR_MINIMAL)
00064     typedef ai::uuid ArtboardUUID;
00065 #endif
00066 
00071         class ArtboardProperties
00072         {
00073         public:
00075                 typedef enum
00076                 {
00077                         kNone = 0,
00078                         kCenter = 1,
00079                         kCrossHair = 1<<1,
00080                         kSafeAreas = 1<<2
00081                 } DisplayMarkType;
00082 
00084                 ArtboardProperties();
00085 
00087                 ArtboardProperties(const ArtboardProperties&);
00088 
00089 #ifdef AI_HAS_RVALUE_REFERENCES
00090 
00091                 ArtboardProperties(ArtboardProperties&& rhs) AINOEXCEPT : fImpl{rhs.fImpl}
00092                 {
00093                         rhs.fImpl = nullptr;
00094                 }
00095 #endif
00096 
00098                 ~ArtboardProperties();
00099 
00100                 void swap(ArtboardProperties& rhs) AINOEXCEPT
00101                 {
00102                         std::swap(fImpl, rhs.fImpl);
00103                 }
00104 
00106                 ArtboardProperties& operator=(const ArtboardProperties&);
00107 
00108 #ifdef AI_HAS_RVALUE_REFERENCES
00109 
00110                 ArtboardProperties& operator=(ArtboardProperties&& rhs) AINOEXCEPT
00111                 {
00112                         swap(rhs);
00113                         return *this;
00114                 }
00115 #endif
00116 
00120                 bool IsValid() const
00121                 {
00122                         return fImpl != NULL;
00123                 }
00124 
00128                 AIErr GetPosition(AIRealRect& value) const;
00129 
00134                 AIErr SetPosition(AIRealRect value);
00135 
00139                 AIErr GetPAR(AIReal& value) const;
00140 
00145                 AIErr SetPAR(AIReal value);
00146 
00151                 AIErr GetShowDisplayMark(DisplayMarkType mark, bool& show) const;
00152 
00157                 AIErr SetShowDisplayMark(DisplayMarkType mark,bool show);
00158 
00162                 AIErr GetName(ai::UnicodeString& name) const;
00163 
00167                 AIErr SetName(const ai::UnicodeString& name);
00168 
00172                 AIErr GetRulerOrigin(AIRealPoint& rulerOrigin) const;
00173 
00177                 AIErr SetRulerOrigin(const AIRealPoint& rulerOrigin);
00178 
00183                 AIErr IsDefaultName(AIBoolean& isDefault) const;
00184 
00186                 AIErr SetIsDefaultName(const AIBoolean& isDefault);
00187 
00188                 AIErr IsSelected(AIBoolean& isSelected) const;
00189 #if defined(ILLUSTRATOR_MINIMAL)
00190 
00193         AIErr GetUUID(ArtboardUUID& uuid) const;
00194         
00202         AIErr CloneWithUniqueUUID(const ArtboardProperties& source);
00203 #endif
00204 
00205         public: // internal use public interface
00206                 ArtboardProperties(const ArtboardRef ref);
00207                 void deleteImpl();
00208         private:
00209 #if defined(ILLUSTRATOR_MINIMAL)
00210         AIErr SetUUID(const ArtboardUUID& uuid);
00211 #endif
00212                 friend class ArtboardList;
00213                 ArtboardRef fImpl;
00214         };
00215 
00219         class ArtboardList
00220         {
00221         public:
00222 #ifdef AI_HAS_RVALUE_REFERENCES
00223                 class Artboard;
00224                 class iterator;
00225                 friend class iterator;
00226                 using value_type = Artboard;
00227 #endif
00228                 /* Constructs an ArtboardList object for the current document*/
00229                 ArtboardList();
00230 
00232                 ~ArtboardList();
00237                 bool IsValid() const
00238                 {
00239                         return fImpl != NULL;
00240                 }
00241 
00248                 AIErr AddNew(ArtboardProperties& newArtboard, ArtboardID& index);
00249 
00256                 AIErr Insert(ArtboardProperties& artboard, ArtboardID& index);
00257 
00262                 AIErr Delete(ArtboardID index);
00263 
00264                 // Delete multiple artboards
00265                 // It's more efficient to use this method, if multiple artboards are to be deleted simultaneously, 
00266                 // than looping for each artboard and calling Delete for that one
00267                 AIErr Delete(const std::vector<ai::ArtboardID>& artboardIDs);
00268 
00272                 AIErr GetCount(ArtboardID& count) const;
00273 
00279                 ArtboardProperties GetArtboardProperties(ArtboardID index);
00280 
00286                 AIErr Update(ArtboardID index, const ArtboardProperties& artboard);
00287 
00292                 AIErr GetActive(ArtboardID& index) const;
00293 
00297                 AIErr SetActive(ArtboardID index);
00298 
00299                 // TODO: documentation [dkhandel]
00300                 AIErr Select(ai::ArtboardID artboardID, bool exclusively);
00301 
00302                 // Set selection for multiple artboards
00303                 // It's more efficient to use this method, if multiple artboards are to be selected, 
00304                 // than looping for each artboard and calling SetSelection for that one
00305                 AIErr Select(const std::vector<ai::ArtboardID>& artboardIDs, bool exclusively);
00306 
00307                 // Select all artboards
00308                 AIErr SelectAll();
00309 
00310                 AIErr Deselect(ai::ArtboardID artboardID);
00311                 AIErr DeselectAll();
00312 
00313         public: // internal use public interface
00314                 ArtboardList(const ArtboardList&);
00315                 ArtboardList& operator=(const ArtboardList&);
00316                 ArtboardList(ArtboardListRef);
00317                 void deleteImpl();
00318 
00319                 void swap(ArtboardList& rhs) AINOEXCEPT
00320                 {
00321                         std::swap(fImpl, rhs.fImpl);
00322                 }
00323 
00324 #ifdef AI_HAS_RVALUE_REFERENCES
00325                 ArtboardList(ArtboardList&& rhs) AINOEXCEPT : fImpl{rhs.fImpl}
00326                 {
00327                         rhs.fImpl = nullptr;
00328                 }
00329 
00330                 ArtboardList& operator=(ArtboardList&& rhs) AINOEXCEPT
00331                 {
00332                         swap(rhs);
00333                         return *this;
00334                 }
00335 
00345                 iterator begin();
00346                 iterator end();
00347 
00364                 value_type at(ArtboardID artboardID);
00365 
00366                 ArtboardID size() const AINOEXCEPT;
00367 #endif
00368         private:
00369                 ArtboardListRef fImpl;
00370         };
00371 
00372 #ifdef AI_HAS_RVALUE_REFERENCES
00373         class ArtboardList::Artboard
00374         {
00375         public:
00376                 using container_type = ArtboardList*;
00377 
00381                 Artboard(ArtboardID artboardID, container_type artboardListPtr);
00382                 
00386                 Artboard(Artboard&& other) AINOEXCEPT :
00387                         mArtboardID(other.mArtboardID),
00388                         mProps(std::move(other.mProps)),
00389                         mArtboardListPtr(other.mArtboardListPtr)
00390                 {
00391                         other.mArtboardListPtr = nullptr;
00392                 }
00393 
00394                 Artboard& operator=(Artboard&& other) AINOEXCEPT
00395                 {
00396                         swap(other);
00397                         return (*this);
00398                 }
00399 
00400                 Artboard(const Artboard&) = delete;
00401                 Artboard& operator=(const Artboard&) = delete;
00402 
00403                 void swap(Artboard& other) AINOEXCEPT
00404                 {
00405                         std::swap(mArtboardID, other.mArtboardID);
00406                         mProps.swap(other.mProps);
00407                         std::swap(mArtboardListPtr, other.mArtboardListPtr);
00408                 }
00409 
00413                 AIErr Update();
00414 
00418                 ArtboardID GetID() const AINOEXCEPT { return mArtboardID; }
00419 
00423                 ArtboardProperties& GetProps() { return mProps; }
00424 
00428                 const ArtboardProperties& GetProps() const { return mProps; }
00429 
00430         private:
00431                 ArtboardID mArtboardID = 0;
00432                 ArtboardProperties mProps;
00433                 container_type mArtboardListPtr;
00434         };
00435 
00436         class ArtboardList::iterator
00437         {
00438         public:
00439                 using value_type = ArtboardList::Artboard;
00440                 using container_type = ArtboardList*;
00441                 using size_type = ArtboardID;
00442 
00443                 iterator(size_type index, container_type artboardListPtr);
00444 
00445                 iterator(iterator&& other) AINOEXCEPT : 
00446                         mValue(std::move(other.mValue)),
00447                         mArtboardListPtr(other.mArtboardListPtr),
00448                         mArtboardCount(other.mArtboardCount)
00449                 {
00450                         other.mArtboardListPtr = nullptr;
00451                 }
00452 
00453                 iterator& operator=(iterator&& other) AINOEXCEPT
00454                 {
00455                         swap(other);
00456                         return (*this);
00457                 }
00458 
00459                 iterator(const iterator&) = delete;
00460                 iterator& operator=(const iterator&) = delete;
00461 
00462                 void swap(iterator& other) AINOEXCEPT
00463                 {
00464                         mValue.swap(other.mValue);
00465                         std::swap(mArtboardCount, other.mArtboardCount);
00466                         std::swap(mArtboardListPtr, other.mArtboardListPtr);
00467                 }
00468 
00469                 iterator& operator++();
00470 
00471                 value_type& operator*() { return mValue; }
00472                 const value_type& operator*() const { return mValue; }
00473 
00474                 bool operator==(const iterator& rhs) const;
00475                 bool operator!=(const iterator& rhs) const { return !(*this == rhs); }
00476 
00477         private:
00478                 bool compatible(const iterator& rhs) const;
00479 
00480         private:
00481                 value_type mValue;
00482                 container_type mArtboardListPtr;
00483                 size_type mArtboardCount = 1;
00484         };
00485 #endif //AI_HAS_RVALUE_REFERENCES
00486 
00489         namespace ArtboardUtils
00490         {
00494                 inline AIErr GetCount(ArtboardID& count)
00495                 {
00496                         ArtboardList list;
00497                         return list.GetCount(count);
00498                 }
00499 
00504                 inline AIErr GetPosition(ArtboardID index,AIRealRect& rect)
00505                 {
00506                         ArtboardList list;
00507                         ArtboardProperties artboard(list.GetArtboardProperties(index));
00508                         if(!artboard.IsValid()) return kBadParameterErr;
00509                         return artboard.GetPosition(rect);
00510                 }
00514                 inline AIErr GetActiveArtboardPosition(AIRealRect& rect)
00515                 {
00516                         AIErr error = kNoErr;
00517                         ArtboardList list;
00518                         ArtboardID index;
00519                         error = list.GetActive(index);
00520                         GetPosition(index,rect);
00521                         return error;
00522                 }
00523 
00527                 inline AIErr GetActiveArtboardIndex(ArtboardID& index)
00528                 {
00529                         ArtboardList list;
00530                         return list.GetActive(index);
00531                 }
00532 
00533                 /* Selects all artboards..
00534                 */
00535                 inline AIErr SelectAllArtboards()
00536                 {
00537                         ArtboardList list;
00538                         return list.SelectAll();
00539                 }
00540 
00541                 inline AIErr IsSelected(ai::ArtboardID id, AIBoolean& isSelected)
00542                 {
00543                         ArtboardList list;
00544                         const auto properties = list.GetArtboardProperties(id);
00545                         return properties.IsSelected(isSelected);
00546                 }
00547 
00553                 AIErr GetArtboardName(ai::UnicodeString& name,bool& isDefault, ArtboardID index = kActiveArtboard);
00554 
00559                 AIErr GetArtboardIndexByName(const ai::UnicodeString& name, ai::ArtboardID& index);
00560 
00563                 AIErr AreAnyArtboardsOverlapping(ai::ArtboardList &artboardList, AIBoolean &isOverlapping);
00564         }
00565 }
00566 
00567 #endif //_IAI_ARTBOARDS_


Contents Suites Classes Class Index Member Index
Adobe Solutions Network
 
Copyright © 2014 Adobe Systems Incorporated. All rights reserved.
Terms of Use Online Privacy Policy Adobe and accessibility Avoid software piracy Permissions and Trademarks