From a6e84552da5c7d18f676eae9cf7ea8332f777326 Mon Sep 17 00:00:00 2001 From: forbes-0023 Date: Thu, 5 Feb 2026 14:54:36 -0600 Subject: [PATCH] feat(gui): add cross-origin detection in StdCmdSaveAs (#17) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Detect document's origin vs current (target) origin - Route to appropriate workflow: - Same origin: standard SaveAs - Local → PLM: migration (handled by PLM origin) - PLM → Local: export (handled by local origin) - PLM → PLM: transfer (handled by target PLM origin) This provides the infrastructure for Issue #17: Mixed origin workflows. The actual migration/export dialogs will be implemented in the respective origin adapters (SiloOrigin, LocalFileOrigin). --- src/Gui/CommandDoc.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 21789ceb70..70af7c9a62 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -768,13 +768,40 @@ void StdCmdSaveAs::activated(int iMsg) return; } - // SaveAs uses current origin (allows saving to different origin) - FileOrigin* origin = OriginManager::instance()->currentOrigin(); - if (!origin) { + auto* mgr = OriginManager::instance(); + FileOrigin* currentOrigin = mgr->currentOrigin(); + FileOrigin* docOrigin = mgr->originForDocument(doc); + + if (!currentOrigin) { return; } - origin->saveDocumentAsInteractive(doc); + // Determine workflow based on document and target origins + OriginType currentType = currentOrigin->type(); + OriginType docType = docOrigin ? docOrigin->type() : OriginType::Local; + + if (docOrigin == currentOrigin || !docOrigin) { + // Same origin or new document - standard SaveAs + currentOrigin->saveDocumentAsInteractive(doc); + } + else if (currentType == OriginType::PLM && docType == OriginType::Local) { + // Local → PLM: Migration workflow + // The PLM origin's saveDocumentAsInteractive should handle this + currentOrigin->saveDocumentAsInteractive(doc); + } + else if (currentType == OriginType::Local && docType == OriginType::PLM) { + // PLM → Local: Export workflow + // Use local origin to save without PLM tracking + currentOrigin->saveDocumentAsInteractive(doc); + } + else if (currentType == OriginType::PLM && docType == OriginType::PLM) { + // PLM → Different PLM: Transfer workflow + currentOrigin->saveDocumentAsInteractive(doc); + } + else { + // Default: use current origin + currentOrigin->saveDocumentAsInteractive(doc); + } } bool StdCmdSaveAs::isActive()