home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 9.3 KB | 365 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Part.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "Table.hpp"
-
- // ----- TablePart Includes -----
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef PROXY_H
- #include "Proxy.h"
- #endif
-
- #ifndef SELECTION_H
- #include "Selection.h"
- #endif
-
- #ifndef SOM_ODFExamples_ODFTableEmbeddedFramesIterator_xh
- #include "SOMIter.xh"
- #endif
-
- #ifndef LINKING_H
- #include "Linking.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWFRAME_H
- #include "FWFrame.h"
- #endif
-
- #ifndef FWABOUT_H
- #include "FWAbout.h"
- #endif
-
- #ifndef FWFCTCLP_H
- #include "FWFctClp.h"
- #endif
-
- #ifndef FWPRTITE_H
- #include "FWPrtIte.h"
- #endif
-
- #ifndef FWDRCMD_H
- #include "FWDrCmd.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWMENU_H
- #include "FWMenu.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWBARRAY_H
- #include "FWBArray.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- // ----- Foundation Layer -----
-
- #ifndef FWSTRING_H
- #include "FWString.h"
- #endif
-
- #ifndef FWEXCDEF_H
- #include "FWExcDef.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef FWODTYPS_H
- #include "FWODTyps.h"
- #endif
-
- #ifndef SOM_ODArbitrator_xh
- #include <Arbitrat.xh>
- #endif
-
- #ifndef SOM_ODMenuBar_xh
- #include <MenuBar.xh>
- #endif
-
- #ifndef SOM_ODShape_xh
- #include <Shape.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #ifndef SOM_Module_OpenDoc_StdTypes_defined
- #include <StdTypes.xh>
- #endif
-
- #ifndef SOM_ODStorageUnit_xh
- #include <StorageU.xh>
- #endif
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfTable
- #endif
-
- FW_DEFINE_AUTO(CTablePart)
-
- //========================================================================================
- // class CTablePart
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CTablePart::CTablePart
- //----------------------------------------------------------------------------------------
-
- CTablePart::CTablePart(ODPart* odPart) :
- FW_CEmbeddingPart(odPart, FW_gInstance, kPartInfoID),
- fTableLinkManager(NULL),
- fPostCreated(false)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::~CTablePart
- //----------------------------------------------------------------------------------------
-
- CTablePart::~CTablePart()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::Initialize
- //----------------------------------------------------------------------------------------
-
- void CTablePart::Initialize(Environment* ev, ODStorageUnit* storageUnit, FW_Boolean fromStorage)
- {
- // ----- Call Inherited Initialize -----
- FW_CEmbeddingPart::Initialize(ev, storageUnit, fromStorage);
-
- // ----- Register Presentation -----
- fTablePresentation = RegisterPresentation(ev,
- kTablePresentation,
- true,
- kTableView, kTableView,
- FW_NEW(CTableSelection, (ev, this, fTableContent)));
-
- // ----- Build Table menu -----
- #ifdef FW_BUILD_WIN
- // [HLX] Temporary embed menu for windows
- WinAddEmbedMenu(ev, GetMenuBar(ev));
- #endif
-
- FW_DO_NOT_DEAD_STRIP(FW_CToggleItem);
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::NewFrame
- //----------------------------------------------------------------------------------------
-
- FW_CFrame* CTablePart::NewFrame(Environment* ev,
- ODFrame* odFrame,
- FW_CPresentation* presentation,
- FW_Boolean fromStorage)
- {
- FW_UNUSED(fromStorage);
-
- return FW_NEW(CTableFrame, (ev, odFrame, presentation, this, fTableContent));
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::NewPartContent
- //----------------------------------------------------------------------------------------
-
- FW_CContent* CTablePart::NewPartContent(Environment* ev)
- {
- fTableContent = FW_NEW(CTablePartContent, (ev, this));
- return fTableContent;
- }
-
- //========================================================
- // ADDITIONS FOR LINKING SUPPORT
- //========================================================
-
- //----------------------------------------------------------------------------------------
- // CTablePart::PartChanged
- //----------------------------------------------------------------------------------------
- void CTablePart::PartChanged(Environment* ev)
- {
- fTablePresentation->ContentUpdated(ev);
-
- //--- Update affected link sources ---
- fTableLinkManager->UpdateLinkSource(ev, kODUnknownUpdate);
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::DoAbout
- //----------------------------------------------------------------------------------------
-
- FW_Handled CTablePart::DoAbout(Environment* ev)
- {
- ::FW_About(ev, this, kAbout);
-
- return FW_kHandled;
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::ChangeFrameStatus
- //----------------------------------------------------------------------------------------
-
- void CTablePart::ChangeFrameStatus(Environment* ev, const CCell& cell, ODLinkStatus newStatus)
- {
- CTableProxy* proxy = fTableContent->CellToProxy(cell);
- if (proxy)
- proxy->ChangeLinkStatus(ev, newStatus);
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::AboutToClearCell
- //----------------------------------------------------------------------------------------
- void CTablePart::AboutToClearCell(Environment* ev, const CCell& cell)
- {
- //-- Break affected links --
- fTableLinkManager->BreakExistingLinks(ev, cell);
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::ProxyMoved
- //----------------------------------------------------------------------------------------
- void CTablePart::ProxyMoved(Environment* ev,
- const CCell& fromCell,
- const CCell& toCell)
- {
- //-- Adjust affected links --
- fTableLinkManager->MoveExistingLinks(ev, fromCell, toCell);
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::GetTableSelection
- //----------------------------------------------------------------------------------------
- CTableSelection* CTablePart::GetTableSelection(Environment* ev)
- {
- return (CTableSelection*) fTablePresentation->GetSelection(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::NewLinkManager
- //----------------------------------------------------------------------------------------
-
- FW_CLinkManager* CTablePart::NewLinkManager(Environment* ev) // Override
- {
- CTableLinkManager* linkMgr = FW_NEW (CTableLinkManager, (ev, this, fTableContent));
- fTableLinkManager = linkMgr;
- return linkMgr;
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::DoPostCreate
- //----------------------------------------------------------------------------------------
- void CTablePart::DoPostCreate(Environment* ev)
- {
- // Perform "DoPostCreate"-type initialization:
- // 1. Set the initial selection
- // 2. Make sure that any subscribers that were just internalized get registered for automatic updates.
-
- if (!fPostCreated) // do this only once!
- {
- // Register any link destinations that were just internalized.
- fTableLinkManager->RegisterLinks(ev);
-
- fPostCreated = true;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::FindValidTableFrame
- //----------------------------------------------------------------------------------------
- CTableFrame* CTablePart::FindValidTableFrame(Environment* ev, CTableFrame* frame1, CTableFrame* frame2)
- {
- if (IsFrameValid(ev, frame1))
- return frame1;
- if (IsFrameValid(ev, frame2))
- return frame2;
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::IsFrameValid
- //----------------------------------------------------------------------------------------
- FW_Boolean CTablePart::IsFrameValid(Environment* ev, FW_CFrame* frame)
- {
- FW_CPresentationFrameIterator it(ev, fTablePresentation);
- for (FW_CFrame* aFrame = it.First(ev); it.IsNotComplete(ev); aFrame = it.Next(ev))
- {
- if (aFrame == frame) // frame is valid
- return true;
- }
- return false;
- }
-