home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 10.7 KB | 352 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWAcquir.cpp
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- #ifndef SOM_ODStorageUnitView_xh
- #include <SUView.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitCursor_xh
- #include <SUCursor.xh>
- #endif
-
- #ifndef SOM_ODRefCntObject_xh
- #include <RefCtObj.xh>
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include "Window.xh"
- #endif
-
- #ifndef SOM_ODPart_xh
- #include "Part.xh"
- #endif
-
- #ifndef SOM_ODFrame_xh
- #include "Frame.xh"
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitView_xh
- #include <SUView.xh>
- #endif
-
- #ifndef SOM_ODStorageUnitCursor_xh
- #include <SUCursor.xh>
- #endif
-
- #ifndef SOM_ODMenuBar_xh
- #include <MenuBar.xh>
- #endif
-
- #ifndef SOM_ODDraft_xh
- #include <Draft.xh>
- #endif
-
- #ifndef SOM_ODContainer_xh
- #include <ODCtr.xh>
- #endif
-
- #ifndef SOM_ODDocument_xh
- #include <Document.xh>
- #endif
-
- #if defined(__MWERKS__) && GENERATING68K
- // A hack to work around a bug
- #pragma import list somGetGlobalEnvironment
- #endif
-
- //========================================================================================
- // Runtime Informations
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwodmisc
- #endif
-
- //========================================================================================
- // class FW_CAcquiredODRefCntObject
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CAcquiredODRefCntObject)
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquiredODRefCntObject::FW_CAcquiredODRefCntObject
- //----------------------------------------------------------------------------------------
-
- FW_CAcquiredODRefCntObject::FW_CAcquiredODRefCntObject() :
- fODObject(NULL)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquiredODRefCntObject::FW_CAcquiredODRefCntObject
- //----------------------------------------------------------------------------------------
-
- FW_CAcquiredODRefCntObject::FW_CAcquiredODRefCntObject(ODRefCntObject* odObject) :
- fODObject(odObject)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquiredODRefCntObject::FW_CAcquiredODRefCntObject
- //----------------------------------------------------------------------------------------
-
- FW_CAcquiredODRefCntObject::FW_CAcquiredODRefCntObject(const FW_CAcquiredODRefCntObject& other) :
- fODObject(other.fODObject)
- {
- #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
- fODObject->Acquire(somGetGlobalEnvironment());
- #endif
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquiredODRefCntObject::~FW_CAcquiredODRefCntObject
- //----------------------------------------------------------------------------------------
-
- FW_CAcquiredODRefCntObject::~FW_CAcquiredODRefCntObject()
- {
- FW_START_DESTRUCTOR
-
- #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
- if (fODObject)
- fODObject->Release(somGetGlobalEnvironment());
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquiredODRefCntObject::AcquireAndAssign
- //----------------------------------------------------------------------------------------
-
- FW_CAcquiredODRefCntObject* FW_CAcquiredODRefCntObject::AcquireAndAssign(ODRefCntObject* newObject)
- {
- #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
- if (fODObject != newObject)
- {
- Environment* ev = somGetGlobalEnvironment();
-
- if (fODObject != NULL)
- fODObject->Release(ev);
-
- if (newObject != NULL)
- newObject->Acquire(ev);
- }
- #endif
-
- fODObject = newObject;
-
- return this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquiredODRefCntObject::Assign
- //----------------------------------------------------------------------------------------
-
- FW_CAcquiredODRefCntObject* FW_CAcquiredODRefCntObject::Assign(ODRefCntObject* newObject)
- {
- #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
- if (fODObject != NULL && fODObject != newObject)
- fODObject->Release(somGetGlobalEnvironment());
- #endif
-
- fODObject = newObject;
-
- return this;
- }
-
- //========================================================================================
- // class FW_CAcquireODStorageUnitView
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CAcquireODStorageUnitView)
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireODStorageUnitView::FW_CAcquireODStorageUnitView
- //----------------------------------------------------------------------------------------
-
- FW_CAcquireODStorageUnitView::FW_CAcquireODStorageUnitView(Environment* ev, ODStorageUnit* su,
- ODPropertyName propertyName,
- ODPositionCode propertyPosCode,
- ODValueType valueType,
- ODValueIndex valueIndex,
- ODPositionCode valuePosCode) :
- fSUView(NULL)
- {
- su->Focus(ev, propertyName, propertyPosCode, valueType, valueIndex, valuePosCode);
- fSUView = su->CreateView(ev);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireODStorageUnitView::FW_CAcquireODStorageUnitView
- //----------------------------------------------------------------------------------------
-
- FW_CAcquireODStorageUnitView::FW_CAcquireODStorageUnitView(Environment* ev, ODStorageUnit* su) :
- fSUView(NULL)
- {
- fSUView = su->CreateView(ev);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireODStorageUnitView::~FW_CAcquireODStorageUnitView
- //----------------------------------------------------------------------------------------
-
- FW_CAcquireODStorageUnitView::~FW_CAcquireODStorageUnitView()
- {
- FW_START_DESTRUCTOR
- delete fSUView;
- }
-
- //========================================================================================
- // class FW_CAcquireODPropertyName
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CAcquireODPropertyName)
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireODPropertyName::FW_CAcquireODPropertyName
- //----------------------------------------------------------------------------------------
-
- FW_CAcquireODPropertyName::FW_CAcquireODPropertyName(Environment* ev, ODStorageUnit* su) :
- fPropName(NULL)
- {
- fPropName = su->GetProperty(ev);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireODPropertyName::FW_CAcquireODPropertyName
- //----------------------------------------------------------------------------------------
-
- FW_CAcquireODPropertyName::FW_CAcquireODPropertyName(Environment* ev, ODStorageUnitView* suView) :
- fPropName(NULL)
- {
- fPropName = suView->GetProperty(ev);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireODPropertyName::FW_CAcquireODPropertyName
- //----------------------------------------------------------------------------------------
-
- FW_CAcquireODPropertyName::FW_CAcquireODPropertyName(Environment* ev, ODStorageUnitCursor* suCursor) :
- fPropName(NULL)
- {
- suCursor->GetProperty(ev, &fPropName);
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireODPropertyName::~FW_CAcquireODPropertyName
- //----------------------------------------------------------------------------------------
-
- FW_CAcquireODPropertyName::~FW_CAcquireODPropertyName()
- {
- FW_START_DESTRUCTOR
- if (fPropName != NULL)
- FW_CMemoryManager::FreeBlock(fPropName);
- }
-
- //========================================================================================
- // class FW_CAcquireODType
- //========================================================================================
-
- FW_DEFINE_AUTO(FW_CAcquireODType)
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireODType::FW_CAcquireODType
- //----------------------------------------------------------------------------------------
-
- FW_CAcquireODType::FW_CAcquireODType(ODType type) :
- fODType(type)
- {
- FW_ASSERT(type);
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CAcquireODType::~FW_CAcquireODType
- //----------------------------------------------------------------------------------------
-
- FW_CAcquireODType::~FW_CAcquireODType()
- {
- FW_START_DESTRUCTOR
-
- FW_ASSERT(fODType);
- FW_CMemoryManager::FreeBlock(fODType);
- fODType = NULL;
- }
-
- //========================================================================================
- // FW_CopyAndRelease
- //========================================================================================
-
- //########################################################################################
- // SCpp Hack
- // Work around SCpp 8.0.3 bug - importing overloaded functions doesn't work.
- // Replace overloaded functions with normal functions with different names.
- // Use inline overloaded functions which turn around and call the renamed
- // functions so client code isn't affected.
- //########################################################################################
-
- //----------------------------------------------------------------------------------------
- // ODShape
- //----------------------------------------------------------------------------------------
-
- ODShape* FW_PrivCopyAndRelease_Shape(Environment* ev, ODShape* shapeToCopy)
- {
- FW_ASSERT(shapeToCopy != NULL);
- FW_ASSERT(shapeToCopy->GetRefCount(ev) >= 1);
-
- FW_CAcquiredODShape aqShapeToCopy(shapeToCopy);
- return aqShapeToCopy->Copy(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // ODTransform
- //----------------------------------------------------------------------------------------
-
- ODTransform* FW_PrivCopyAndRelease_Transform(Environment* ev, ODTransform* transformToCopy)
- {
- FW_ASSERT(transformToCopy != NULL);
- FW_ASSERT(transformToCopy->GetRefCount(ev) >= 1);
-
- FW_CAcquiredODTransform aqTransformToCopy(transformToCopy);
- return transformToCopy->Copy(ev);
- }
-