Skip to main content
Known Participant
October 31, 2023
Question

Can't include SnpManipulateTextFrame.cpp snippet into my plugin

  • October 31, 2023
  • 1 reply
  • 393 views

Simple goal:

To get all text from active TextFrame, iterate over it, add "-" (dash) at the end of each word, apply it back to the TextFrame

 

Current state: Can't even fetch a text from TextFrame

 

After hours of reading unintuitive SDK docs, I found out that there is a class SnpManipulateTextFrame, which has a method that gets text from TextFrame:

WideString GetWideStringFromTextFrame(IMultiColumnTextFrame* mcf)

 

So, I've copied `SnpManipulateTextFrame.cpp` file into my plugin directory, and created its header file for importing it into my `WFPDialogController.cpp`. Inside the header file, I copied only the class definition part with all #include lines from cpp file.

 

Inside my controller cpp, I did include the header file and tried to initialize the class and get the text from TextFrame:

#include "SnpManipulateTextFrame.h"

...

void WFPDialogController::ApplyDialogFields(IActiveContext* myContext, const WidgetID& widgetId) {

    ...

    InterfacePtr<IMultiColumnTextFrame> mcTextFrame(myContext->GetContextSelection(), UseDefaultIID());
    WideString textContent;

    SnpManipulateTextFrame manTextFrame = SnpManipulateTextFrame();
    textContent = manTextFrame.GetWideStringFromTextFrame(mcTextFrame);

}

Include directories: 

[Project > Properties > Configuration Properties > VC++ Directories > Include Directories]

(I wonder if there is any option to include whole SDK folder and let VS automatically detect all .h files, instead of manually including its subdirectories where .h file reside. Or maybe I'm doing something wrong)

 

Also, If you know a better and simpler solution towards achieving the goal, please suggest!

 

Here is the build error log:

 

Build started...
1>------ Build started: Project: WriteFishPrice, Configuration: Release x64 ------
1>WFPDialogController.cpp
1>SnpManipulateTextFrame.cpp
1>Performing Custom Build Tools
1>ODFRC deleting old resources...
1>merge_res.cmd - calling ConcatRes
1>        1 file(s) copied.
1>ConcatRes skipped since ".\objRx64\WriteFishPrice"\WFP.fres is an empty file.
1>merge_res.cmd done.
1>Deleting old resources...
1>14 File(s) copied
1>   Creating library ..\..\..\build\win\objRx64\WriteFishPrice/WriteFishPrice.lib and object ..\..\..\build\win\objRx64\WriteFishPrice/WriteFishPrice.exp
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: __cdecl SDKLayoutHelper::SDKLayoutHelper(void)" (??0SDKLayoutHelper@@QEAA@XZ) referenced in function "public: class UIDRef __cdecl SnpManipulateTextFrame::CreateAndThreadTextFrame(class UIDRef const &)" (?CreateAndThreadTextFrame@SnpManipulateTextFrame@@QEAA?AVUIDRef@@AEBV2@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl SDKLayoutHelper::~SDKLayoutHelper(void)" (??1SDKLayoutHelper@@UEAA@XZ) referenced in function "public: class UIDRef __cdecl SnpManipulateTextFrame::CreateAndThreadTextFrame(class UIDRef const &)" (?CreateAndThreadTextFrame@SnpManipulateTextFrame@@QEAA?AVUIDRef@@AEBV2@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: class UIDRef __cdecl SDKLayoutHelper::CreateDocument(enum K2::UIFlags,class PMReal const &,class PMReal const &,long,long,long)" (?CreateDocument@SDKLayoutHelper@@QEAA?AVUIDRef@@W4UIFlags@K2@@AEBVPMReal@@1JJJ@Z) referenced in function "public: long __cdecl SnpManipulateTextFrame::CreateLinkedStory(class UIDRef const &)" (?CreateLinkedStory@SnpManipulateTextFrame@@QEAAJAEBVUIDRef@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: long __cdecl SDKLayoutHelper::OpenLayoutWindow(class UIDRef const &)" (?OpenLayoutWindow@SDKLayoutHelper@@QEAAJAEBVUIDRef@@@Z) referenced in function "public: long __cdecl SnpManipulateTextFrame::CreateLinkedStory(class UIDRef const &)" (?CreateLinkedStory@SnpManipulateTextFrame@@QEAAJAEBVUIDRef@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: class UIDRef __cdecl SDKLayoutHelper::GetActiveSpreadLayerRef(class UIDRef const &,short)" (?GetActiveSpreadLayerRef@SDKLayoutHelper@@QEAA?AVUIDRef@@AEBV2@F@Z) referenced in function "public: long __cdecl SnpManipulateTextFrame::CreateLinkedStory(class UIDRef const &)" (?CreateLinkedStory@SnpManipulateTextFrame@@QEAAJAEBVUIDRef@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: class UIDRef __cdecl SDKLayoutHelper::CreateTextFrame(class UIDRef const &,class PMRect const &,long,short,class UIDRef *,short)" (?CreateTextFrame@SDKLayoutHelper@@QEAA?AVUIDRef@@AEBV2@AEBVPMRect@@JFPEAV2@F@Z) referenced in function "public: class UIDRef __cdecl SnpManipulateTextFrame::CreateAndThreadTextFrame(class UIDRef const &)" (?CreateAndThreadTextFrame@SnpManipulateTextFrame@@QEAA?AVUIDRef@@AEBV2@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: class UIDRef __cdecl SDKLayoutHelper::GetTextModelRef(class InterfacePtr<class IGraphicFrameData> const &)" (?GetTextModelRef@SDKLayoutHelper@@QEAA?AVUIDRef@@AEBV?$InterfacePtr@VIGraphicFrameData@@@@@Z) referenced in function "public: long __cdecl SnpManipulateTextFrame::SelectFrameDisplayingTextIndex(class UIDRef const &,class ISelectionManager *)" (?SelectFrameDisplayingTextIndex@SnpManipulateTextFrame@@QEAAJAEBVUIDRef@@PEAVISelectionManager@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: __cdecl SnpRunnable::SnpRunnable(char const *)" (??0SnpRunnable@@QEAA@PEBD@Z) referenced in function "public: __cdecl _SnpRunnerManipulateTextFrame::_SnpRunnerManipulateTextFrame(void)" (??0_SnpRunnerManipulateTextFrame@@QEAA@XZ)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl SnpRunnable::~SnpRunnable(void)" (??1SnpRunnable@@UEAA@XZ) referenced in function "public: virtual __cdecl _SnpRunnerManipulateTextFrame::~_SnpRunnerManipulateTextFrame(void)" (??1_SnpRunnerManipulateTextFrame@@UEAA@XZ)
1>SnpManipulateTextFrame.obj : error LNK2001: unresolved external symbol "public: virtual long __cdecl SnpRunnable::RunUnitTest(class ISnpRunnableContext *)" (?RunUnitTest@SnpRunnable@@UEAAJPEAVISnpRunnableContext@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2001: unresolved external symbol "public: virtual long __cdecl SnpRunnable::SetupContext(class ISnpRunnableContext *)" (?SetupContext@SnpRunnable@@UEAAJPEAVISnpRunnableContext@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "void __cdecl SNIPLOG(char const *,...)" (?SNIPLOG@@YAXPEBDZZ) referenced in function "public: long __cdecl SnpManipulateTextFrame::CreateLinkedStory(class UIDRef const &)" (?CreateLinkedStory@SnpManipulateTextFrame@@QEAAJAEBVUIDRef@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: __cdecl SnpTextModelHelper::SnpTextModelHelper(void)" (??0SnpTextModelHelper@@QEAA@XZ) referenced in function "public: class WideString __cdecl SnpManipulateTextFrame::GetWideStringFromTextFrame(class IMultiColumnTextFrame *)" (?GetWideStringFromTextFrame@SnpManipulateTextFrame@@QEAA?AVWideString@@PEAVIMultiColumnTextFrame@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl SnpTextModelHelper::~SnpTextModelHelper(void)" (??1SnpTextModelHelper@@UEAA@XZ) referenced in function "public: class WideString __cdecl SnpManipulateTextFrame::GetWideStringFromTextFrame(class IMultiColumnTextFrame *)" (?GetWideStringFromTextFrame@SnpManipulateTextFrame@@QEAA?AVWideString@@PEAVIMultiColumnTextFrame@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: class IParcel * __cdecl SnpTextModelHelper::QueryParcelContaining(class ITextModel *,long)" (?QueryParcelContaining@SnpTextModelHelper@@QEAAPEAVIParcel@@PEAVITextModel@@J@Z) referenced in function "public: class ITextFrameColumn * __cdecl SnpManipulateTextFrame::QueryTextFrameContaining(class ITextModel *,long)" (?QueryTextFrameContaining@SnpManipulateTextFrame@@QEAAPEAVITextFrameColumn@@PEAVITextModel@@J@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: class WideString __cdecl SnpTextModelHelper::GetWideStringFromTextRange(class InDesign::TextRange const &)" (?GetWideStringFromTextRange@SnpTextModelHelper@@QEAA?AVWideString@@AEBVTextRange@InDesign@@@Z) referenced in function "public: class WideString __cdecl SnpManipulateTextFrame::GetWideStringFromTextFrame(class IMultiColumnTextFrame *)" (?GetWideStringFromTextFrame@SnpManipulateTextFrame@@QEAA?AVWideString@@PEAVIMultiColumnTextFrame@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: void __cdecl K2Internals::K2VectorBase<struct KeyValuePair<long,class PMString>,class K2Allocator<struct KeyValuePair<long,class PMString> > >::push_back(struct KeyValuePair<long,class PMString> const &)" (?push_back@?$K2VectorBase@U?$KeyValuePair@JVPMString@@@@V?$K2Allocator@U?$KeyValuePair@JVPMString@@@@@@@K2Internals@@QEAAXAEBU?$KeyValuePair@JVPMString@@@@@Z) referenced in function "private: class PMString __cdecl SnpManipulateTextFrame::ResolveClass(class IDType<struct ClassID_tag> const &)" (?ResolveClass@SnpManipulateTextFrame@@AEAA?AVPMString@@AEBV?$IDType@UClassID_tag@@@@@Z)
1>SnpManipulateTextFrame.obj : error LNK2019: unresolved external symbol "public: void __cdecl K2Internals::K2VectorBase<struct KeyValuePair<long,class PMString>,class K2Allocator<struct KeyValuePair<long,class PMString> > >::DoCleanup(void)" (?DoCleanup@?$K2VectorBase@U?$KeyValuePair@JVPMString@@@@V?$K2Allocator@U?$KeyValuePair@JVPMString@@@@@@@K2Internals@@QEAAXXZ) referenced in function "void __cdecl `private: class PMString __cdecl SnpManipulateTextFrame::ResolveClass(class IDType<struct ClassID_tag> const &)'::`2'::`dynamic atexit destructor for 'gClassNameDict''(void)" (??__FgClassNameDict@?1??ResolveClass@SnpManipulateTextFrame@@AEAA?AVPMString@@AEBV?$IDType@UClassID_tag@@@@@Z@YAXXZ)
1>.\releasex64\sdk\WriteFishPrice.sdk.pln : fatal error LNK1120: 18 unresolved externals
1>Done building project "WriteFishPrice.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 11:20 PM and took 06.815 seconds ==========

 

This topic has been closed for replies.

1 reply

Community Expert
November 1, 2023

The errors describe the issue quite well.

  • You havc unresolved symbols for SDKLayoutHelper, so that needs to be included in your project and compiled to get rid of the errors related to it. The file is located at <SDK_Root>/source/sdksamples/common/SDKLayoutHelper.cpp
  • Then you have some errors related to classes probably from the SnippetRunner project. See that you copied over the definition of these classes as well. And if you just copied the code and not the classes then you need to rename the class references according to your porject structure.
  • The you have errors related to K2Vector. Probably you don't have the proper libs included which has the defintion for it. The libs are situated in buiuld directory of the SDK. Check the libs included in the SnippetRunner project and add the missing ones to your project. Hopefully this will get resolved.

-Manan

-Manan
Known Participant
November 1, 2023

1) I included the path "<SDK_Root>/source/sdksamples/common/", 

but still getting SDKLayoutHelper related errors:

Full log: Build Error - Pastebin.com

 

2) "snippetrunner" directory is also included in "Include Directories", I've tried renaming the copied .cpp to "SnpManipulateTextFrame2.cpp" along with its header file to "SnpManipulateTextFrame2.h", and changed class name to "SnpManipulateTextFrame2", thinking it might be conflicting with already existing .cpp file in "snippetrunner" folder, since that folder is also included, but no effect

How they look:

 

3) I've included lib directory, but still getting the same error

 

 

Community Expert
November 1, 2023
  1. It not about adding the path to SDKLayoutHelper but it is about compiling it so that it can be linked to your code. So add the SDKLayoutHelper.cpp file into your project for compiliation that should resolve those errors.
  2. You renamed the class so what error do you get now. Does it still reference the original one or your renamed 2 one?
  3.  You don't need to just add the library path but give it the specific librarie's path. Check the linker tab in your setting and compare it with the Snippet runner project. There would be specific reference to .lib files.

-Manan

 

-Manan