diff --git a/MPOLnchActionComponent.cpp b/MPOLnchActionComponent.cpp index 26cce39..a980843 100644 --- a/MPOLnchActionComponent.cpp +++ b/MPOLnchActionComponent.cpp @@ -47,9 +47,8 @@ #include "FileUtils.h" #include "CoreFileUtils.h" #include "StreamUtil.h" -#include -#include -#include + +#include "MPOLnchHelper.h" /** MPOLnchActionComponent @@ -228,67 +227,37 @@ void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget) { // building the scripts - const int MAXITEMS = 12; - - - PMString newscriptfiles[MAXITEMS] = { - "newscriptfile01.jsx", - "newscriptfile02.jsx", - "newscriptfile03.jsx", - "newscriptfile04.jsx", - "newscriptfile05.jsx", - "newscriptfile06.jsx", - "newscriptfile07.jsx", - "newscriptfile08.jsx", - "newscriptfile09.jsx", - "newscriptfile10.jsx", - "newscriptfile11.jsx", - "newscriptfile12.jsx"}; - - - PMString helpfiles[MAXITEMS] = { - "help_newscriptfile01.jsx", - "help_newscriptfile02.jsx", - "help_newscriptfile03.jsx", - "help_newscriptfile04.jsx", - "help_newscriptfile05.jsx", - "help_newscriptfile06.jsx", - "help_newscriptfile07.jsx", - "help_newscriptfile08.jsx", - "help_newscriptfile09.jsx", - "help_newscriptfile10.jsx", - "help_newscriptfile11.jsx", - "help_newscriptfile12.jsx"}; - + MPOLnchHelper helper; + - for (int i = 0; i < MAXITEMS ; i++) { + for (int i = 0; i < helper.MAXITEMS ; i++) { - IDFile theSource;//scriptfiles[i]; + IDFile theSource = helper.GetInternalResourceFolder();//scriptfiles[i]; - FileUtils::GetAppInstallationFolder(&theSource); - FileUtils::AppendPath(&theSource, PMString("Plug-Ins")); - FileUtils::AppendPath(&theSource, PMString("tmn")); - FileUtils::AppendPath(&theSource, PMString("MPOLauncher.InDesignPlugin")); -// - FileUtils::AppendPath(&theSource, PMString("Versions")); - FileUtils::AppendPath(&theSource, PMString("A")); - FileUtils::AppendPath(&theSource, PMString("Resources")); - - IDFile theHelpSource;//scriptfiles[i]; + //FileUtils::GetAppInstallationFolder(&theSource); +// FileUtils::AppendPath(&theSource, PMString("Plug-Ins")); +// FileUtils::AppendPath(&theSource, PMString("tmn")); +// FileUtils::AppendPath(&theSource, PMString("MPOLauncher.InDesignPlugin")); +//// +// FileUtils::AppendPath(&theSource, PMString("Versions")); +// FileUtils::AppendPath(&theSource, PMString("A")); +// FileUtils::AppendPath(&theSource, PMString("Resources")); + + IDFile theHelpSource = helper.GetInternalResourceFolder();//scriptfiles[i]; - FileUtils::GetAppInstallationFolder(&theHelpSource); - FileUtils::AppendPath(&theHelpSource, PMString("Plug-Ins")); - FileUtils::AppendPath(&theHelpSource, PMString("tmn")); - FileUtils::AppendPath(&theHelpSource, PMString("MPOLauncher.InDesignPlugin")); - // - FileUtils::AppendPath(&theHelpSource, PMString("Versions")); - FileUtils::AppendPath(&theHelpSource, PMString("A")); - FileUtils::AppendPath(&theHelpSource, PMString("Resources")); + //FileUtils::GetAppInstallationFolder(&theHelpSource); +// FileUtils::AppendPath(&theHelpSource, PMString("Plug-Ins")); +// FileUtils::AppendPath(&theHelpSource, PMString("tmn")); +// FileUtils::AppendPath(&theHelpSource, PMString("MPOLauncher.InDesignPlugin")); +// // +// FileUtils::AppendPath(&theHelpSource, PMString("Versions")); +// FileUtils::AppendPath(&theHelpSource, PMString("A")); +// FileUtils::AppendPath(&theHelpSource, PMString("Resources")); - FileUtils::AppendPath(&theSource, PMString(newscriptfiles[i])); - FileUtils::AppendPath(&theHelpSource, PMString(helpfiles[i])); + FileUtils::AppendPath(&theSource, PMString(helper.GetScriptFile(i))); + FileUtils::AppendPath(&theHelpSource, PMString(helper.GetHelpFile(i))); PMString sourceFileStringUrl = FileUtils::SysFileToFileURL(theSource); PMString sourceHelpFileStringUrl = FileUtils::SysFileToFileURL(theHelpSource); @@ -324,8 +293,8 @@ void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget) FileUtils::CreateFolderIfNeeded(theHelpTarget,kTrue); - PMString fn(newscriptfiles[i]); - PMString fnh(helpfiles[i]); + PMString fn(helper.GetScriptFile(i)); + PMString fnh(helper.GetHelpFile(i)); FileUtils::AppendPath(&theTarget, fn); FileUtils::AppendPath(&theHelpTarget, fnh); diff --git a/MPOLnchHelper.cpp b/MPOLnchHelper.cpp index fd115cf..0ffab23 100644 --- a/MPOLnchHelper.cpp +++ b/MPOLnchHelper.cpp @@ -16,6 +16,55 @@ MPOLnchHelper::MPOLnchHelper(); // Helpfile function +int MPOLnchHelper::MAXITEMS = 12; + +PMString MPOLnchHelper::GetScriptFile(int i){ + + PMString theFileName[12] = { + "newscriptfile01.jsx", + "newscriptfile02.jsx", + "newscriptfile03.jsx", + "newscriptfile04.jsx", + "newscriptfile05.jsx", + "newscriptfile06.jsx", + "newscriptfile07.jsx", + "newscriptfile08.jsx", + "newscriptfile09.jsx", + "newscriptfile10.jsx", + "newscriptfile11.jsx", + "newscriptfile12.jsx"}; + + + if (i > 12) { + i = 12; + } + return theFileName[i]; +} + +PMString MPOLnchHelper::GetHelpFile(int i){ + + PMString theFileName[12] = { + "help_newscriptfile01.jsx", + "help_newscriptfile02.jsx", + "help_newscriptfile03.jsx", + "help_newscriptfile04.jsx", + "help_newscriptfile05.jsx", + "help_newscriptfile06.jsx", + "help_newscriptfile07.jsx", + "help_newscriptfile08.jsx", + "help_newscriptfile09.jsx", + "help_newscriptfile10.jsx", + "help_newscriptfile11.jsx", + "help_newscriptfile12.jsx"}; + + + + if (i > 12) { + i = 12; + } + return theFileName[i]; +} + PMString MPOLnchHelper::ReadAllAsText(IPMStream *s) { PMString text; @@ -31,4 +80,19 @@ PMString MPOLnchHelper::ReadAllAsText(IPMStream *s) } // end while streamstategood return text; -} \ No newline at end of file +} + +IDFile MPOLnchHelper::GetInternalResourceFolder(){ + IDFile theSource; + + FileUtils::GetAppInstallationFolder(&theSource); + FileUtils::AppendPath(&theSource, PMString("Plug-Ins")); + FileUtils::AppendPath(&theSource, PMString("tmn")); + FileUtils::AppendPath(&theSource, PMString("MPOLauncher.InDesignPlugin")); + // + FileUtils::AppendPath(&theSource, PMString("Versions")); + FileUtils::AppendPath(&theSource, PMString("A")); + FileUtils::AppendPath(&theSource, PMString("Resources")); + + return theSource; +} diff --git a/MPOLnchHelper.h b/MPOLnchHelper.h index 8b2dfd9..7b89554 100644 --- a/MPOLnchHelper.h +++ b/MPOLnchHelper.h @@ -7,20 +7,29 @@ * */ -#ifndef DATE_H -#define DATE_H +#ifndef MPOLNCHHELPER_H +#define MPOLNCHHELPER_H + #include "IPMStream.h" +#include "FileUtils.h" + class MPOLnchHelper { public: - MPOLnchHelper() { } // default constructor + MPOLnchHelper() { }; // default constructor PMString ReadAllAsText(IPMStream *s); + PMString GetScriptFile(int i); + PMString GetHelpFile(int i); + IDFile GetInternalResourceFolder(); + + static int MAXITEMS; + }; #endif \ No newline at end of file diff --git a/MPOLnchPenObserver.cpp b/MPOLnchPenObserver.cpp index fdc02b7..f66108c 100644 --- a/MPOLnchPenObserver.cpp +++ b/MPOLnchPenObserver.cpp @@ -212,18 +212,11 @@ void MPOLnchPenObserver::Update + MPOLnchHelper helper; + + // look for the internal resource files + IDFile helpFile = helper.GetInternalResourceFolder(); - IDFile helpFile; - - FileUtils::GetAppInstallationFolder(&helpFile); // Application Folder Path - - FileUtils::AppendPath(&helpFile, PMString("Plug-Ins")); - FileUtils::AppendPath(&helpFile, PMString("tmn")); - FileUtils::AppendPath(&helpFile, PMString("MPOLauncher.InDesignPlugin")); - // - FileUtils::AppendPath(&helpFile, PMString("Versions")); - FileUtils::AppendPath(&helpFile, PMString("A")); - FileUtils::AppendPath(&helpFile, PMString("Resources")); PMString pre("help_"); PMString fn(nodeName); @@ -236,7 +229,6 @@ void MPOLnchPenObserver::Update if (FileUtils::DoesFileExist(helpFile)) { InterfacePtr s(StreamUtil::CreateFileStreamRead(helpFile)); - MPOLnchHelper helper; //CAlert::InformationAlert(helper.ReadAllAsText(s)); CAlert::ModalAlert(helper.ReadAllAsText(s), diff --git a/MPOLnchTreeViewAdapter.cpp b/MPOLnchTreeViewAdapter.cpp index a61570d..185ede6 100644 --- a/MPOLnchTreeViewAdapter.cpp +++ b/MPOLnchTreeViewAdapter.cpp @@ -27,6 +27,7 @@ #include "ListTreeViewAdapter.h" #include "MPOLnchNodeID.h" #include "MPOLnchID.h" +#include "MPOLnchHelper.h" /** * TreeViewAdapter. @@ -52,12 +53,20 @@ MPOLnchTreeViewAdapter::MPOLnchTreeViewAdapter(IPMUnknown* boss):ListTreeViewAda { //initialize the list with the default list string name K2Vector lists; - for (int32 i = 0; i< 12; i++) + MPOLnchHelper helper; + + for (int32 i = 0; i< helper.MAXITEMS; i++) { - PMString name(kMPOLnchItemBaseKey); - name.AppendNumber(i+1); - name.Translate(); - lists.push_back(name); + PMString nodeName = helper.GetScriptFile(i); + nodeName.Truncate(4); + + // this is from the original code + // if you need ranslateable names + //PMString name(kMPOLnchItemBaseKey); + //name.AppendNumber(i+1); + //name.Translate(); + + lists.push_back(nodeName); } InterfacePtr iListData(this, IID_ISTRINGLISTDATA); iListData->SetStringList(lists);