home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 9.6 KB | 374 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: Part.cpp
- // Release Version: $ ODF 1 $
- //
- // 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
-
- // ----- 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),
- fLinksRegistered(false)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::~CTablePart
- //----------------------------------------------------------------------------------------
-
- CTablePart::~CTablePart()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::Initialize
- //----------------------------------------------------------------------------------------
-
- void CTablePart::Initialize(Environment* ev)
- {
- // ----- Call Inherited Initialize -----
- FW_CEmbeddingPart::Initialize(ev);
-
- // ----- Register Presentation -----
- fTablePresentation = RegisterPresentation(ev, "Apple:Presentation:ODFTable", true, 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);
- GetMenuBar(ev)->InitializeFromResource(ev, kMenuBar);
- }
-
- //----------------------------------------------------------------------------------------
- // 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(CTableContent, (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::RegisterSubscribers
- //----------------------------------------------------------------------------------------
-
- void CTablePart::RegisterSubscribers(Environment* ev)
- {
- //--- Check for links that need to be registered for automatic updates
- if (!fLinksRegistered) // only want to do this once!
- {
- fTableLinkManager->RegisterLinks(ev);
- fLinksRegistered = true;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::ShowLinkInfo
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTablePart::ShowLinkInfo(Environment* ev, FW_CFrame* frame)
- {
- return fTableLinkManager->ShowLinkInfo(ev, frame->GetActiveFacet(ev));
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::IsLinkSelected
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTablePart::IsLinkSelected(Environment* ev)
- {
- /* for now, return TRUE if a link's cell is selected */
- if (fTableLinkManager->GetSelectedLinkSource(ev) != NULL)
- return true;
- else if (fTableLinkManager->GetSelectedLinkDest(ev) != NULL)
- return true;
-
- return false;
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::DoMenu
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTablePart::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent) // Override
- {
- FW_Boolean menuHandled = true;
- if (theMenuEvent.GetCommandID(ev) == kODCommandAbout)
- ::FW_About(ev, this, kAbout);
- else
- menuHandled = false;
-
- return menuHandled;
- }
- //----------------------------------------------------------------------------------------
- // 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::DoAdjustMenus
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CTablePart::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus, FW_Boolean isRoot)
- {
- FW_UNUSED(isRoot);
-
- if (hasMenuFocus)
- {
- //--- Set up the Part Info menu item ---
- if (this->IsLinkSelected(ev))
- {
- menuBar->SetItemString(ev, kODCommandGetPartInfo, FW_CString32("Link Info"));
- menuBar->EnableCommand(ev, kODCommandGetPartInfo, true);
- }
- }
-
- return false;
- }
-
- //----------------------------------------------------------------------------------------
- // CTablePart::NewLinkManager
- //----------------------------------------------------------------------------------------
-
- FW_CLinkManager* CTablePart::NewLinkManager(Environment* ev) // Override
- {
- CTableLinkManager* linkMgr = FW_NEW (CTableLinkManager, (ev, this, fTableContent));
- fTableLinkManager = linkMgr;
- return linkMgr;
- }
-