diff --git a/SLNKDWF.sln b/SLNKDWF.sln index 9b28c61..73c21ea 100644 --- a/SLNKDWF.sln +++ b/SLNKDWF.sln @@ -42,6 +42,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RemoveAbout", "RemoveAbout\RemoveAbout.vcproj", "{89BE476D-6C02-4514-BFCE-256106D98713}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CxImage", "SlnkDWFImpl\CxImage\CxImage\cximage.vcproj", "{C8E16319-530C-47D5-BED8-B18AB41FC01F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jpeg", "SlnkDWFImpl\CxImage\jpeg\Jpeg.vcproj", "{95E4E28A-C7FB-4764-BA53-48E3394511EF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "png", "SlnkDWFImpl\CxImage\png\png.vcproj", "{6C1E65C3-D0FA-488F-8B5A-4790B905117D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -53,25 +59,15 @@ Global {B2601E72-4FF4-4B9C-A89F-C2E7DACF36FD}.Release|Win32.ActiveCfg = Release|Win32 {B2601E72-4FF4-4B9C-A89F-C2E7DACF36FD}.Release|Win32.Build.0 = Release|Win32 {6DFC9788-904C-4724-A734-06634061EF00}.Debug|Win32.ActiveCfg = Debug|Win32 - {6DFC9788-904C-4724-A734-06634061EF00}.Debug|Win32.Build.0 = Debug|Win32 {6DFC9788-904C-4724-A734-06634061EF00}.Release|Win32.ActiveCfg = Release|Win32 - {6DFC9788-904C-4724-A734-06634061EF00}.Release|Win32.Build.0 = Release|Win32 {92F5EB69-069C-43EA-97E7-2F6507AA5873}.Debug|Win32.ActiveCfg = Debug|Win32 - {92F5EB69-069C-43EA-97E7-2F6507AA5873}.Debug|Win32.Build.0 = Debug|Win32 {92F5EB69-069C-43EA-97E7-2F6507AA5873}.Release|Win32.ActiveCfg = Release|Win32 - {92F5EB69-069C-43EA-97E7-2F6507AA5873}.Release|Win32.Build.0 = Release|Win32 {2F492A95-A23D-45C9-BBD9-E5B9325B22C1}.Debug|Win32.ActiveCfg = Debug|Win32 - {2F492A95-A23D-45C9-BBD9-E5B9325B22C1}.Debug|Win32.Build.0 = Debug|Win32 {2F492A95-A23D-45C9-BBD9-E5B9325B22C1}.Release|Win32.ActiveCfg = Release|Win32 - {2F492A95-A23D-45C9-BBD9-E5B9325B22C1}.Release|Win32.Build.0 = Release|Win32 {18EC7157-E263-458C-A41C-52E9538A642F}.Debug|Win32.ActiveCfg = Debug|Win32 - {18EC7157-E263-458C-A41C-52E9538A642F}.Debug|Win32.Build.0 = Debug|Win32 {18EC7157-E263-458C-A41C-52E9538A642F}.Release|Win32.ActiveCfg = Release|Win32 - {18EC7157-E263-458C-A41C-52E9538A642F}.Release|Win32.Build.0 = Release|Win32 {CF524F70-4DDD-4040-803B-41B5DE7B1CF9}.Debug|Win32.ActiveCfg = Debug|Win32 - {CF524F70-4DDD-4040-803B-41B5DE7B1CF9}.Debug|Win32.Build.0 = Debug|Win32 {CF524F70-4DDD-4040-803B-41B5DE7B1CF9}.Release|Win32.ActiveCfg = Release|Win32 - {CF524F70-4DDD-4040-803B-41B5DE7B1CF9}.Release|Win32.Build.0 = Release|Win32 {7F9F1060-C14D-4DD5-91D3-FA7263FECF5E}.Debug|Win32.ActiveCfg = Debug|Win32 {7F9F1060-C14D-4DD5-91D3-FA7263FECF5E}.Debug|Win32.Build.0 = Debug|Win32 {7F9F1060-C14D-4DD5-91D3-FA7263FECF5E}.Release|Win32.ActiveCfg = Release|Win32 @@ -88,6 +84,18 @@ Global {89BE476D-6C02-4514-BFCE-256106D98713}.Debug|Win32.Build.0 = Debug|Win32 {89BE476D-6C02-4514-BFCE-256106D98713}.Release|Win32.ActiveCfg = Release|Win32 {89BE476D-6C02-4514-BFCE-256106D98713}.Release|Win32.Build.0 = Release|Win32 + {C8E16319-530C-47D5-BED8-B18AB41FC01F}.Debug|Win32.ActiveCfg = Debug|Win32 + {C8E16319-530C-47D5-BED8-B18AB41FC01F}.Debug|Win32.Build.0 = Debug|Win32 + {C8E16319-530C-47D5-BED8-B18AB41FC01F}.Release|Win32.ActiveCfg = Release|Win32 + {C8E16319-530C-47D5-BED8-B18AB41FC01F}.Release|Win32.Build.0 = Release|Win32 + {95E4E28A-C7FB-4764-BA53-48E3394511EF}.Debug|Win32.ActiveCfg = Debug|Win32 + {95E4E28A-C7FB-4764-BA53-48E3394511EF}.Debug|Win32.Build.0 = Debug|Win32 + {95E4E28A-C7FB-4764-BA53-48E3394511EF}.Release|Win32.ActiveCfg = Release|Win32 + {95E4E28A-C7FB-4764-BA53-48E3394511EF}.Release|Win32.Build.0 = Release|Win32 + {6C1E65C3-D0FA-488F-8B5A-4790B905117D}.Debug|Win32.ActiveCfg = Debug|Win32 + {6C1E65C3-D0FA-488F-8B5A-4790B905117D}.Debug|Win32.Build.0 = Debug|Win32 + {6C1E65C3-D0FA-488F-8B5A-4790B905117D}.Release|Win32.ActiveCfg = Release|Win32 + {6C1E65C3-D0FA-488F-8B5A-4790B905117D}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SlnkDWFCom/DWFFile.cpp b/SlnkDWFCom/DWFFile.cpp index 330c4bf..74c3ae0 100644 --- a/SlnkDWFCom/DWFFile.cpp +++ b/SlnkDWFCom/DWFFile.cpp @@ -60,6 +60,106 @@ STDMETHODIMP CDWFFile::Open(BSTR DWFPath) } +STDMETHODIMP CDWFFile::Create(BSTR DWFPath, VARIANT EPlotStream) +{ + if (EPlotStream.vt==VT_ERROR) + { + if (EPlotStream.scode != DISP_E_PARAMNOTFOUND) + return E_INVALIDARG; + } + else + { + VARIANT *var2 = &EPlotStream; + if (var2->vt==(VT_VARIANT|VT_BYREF)) // ByRef + var2 = (VARIANT *)var2->pvarVal; + + if (var2->vt!=VT_DISPATCH) + return E_INVALIDARG; + + CComQIPtr DWFFile; + DWFFile = var2->pdispVal; + if (!DWFFile) + return E_INVALIDARG; + } + + try + { + { +//TODO CDWFFileImpl *epli; +// DWFFile->get_DWFFileImpl((BYTE **)&epli); + + if (CDWFFileImpl::Create(CString(DWFPath), /*epli*/NULL)) + { + return S_OK; + } + else + return E_FAIL; + } + } + catch (CString& e) + { + return myAtlReportError (GetObjectCLSID(), e); + } + + return S_OK; +} +// W2DPath bron W2D bestand +// EPlotStream: template waarvan paper settings en zo worden overgenomen +// (in de praktijk zal het bestand onder W2DPath afgeleid zijn van EPlotStream +// in een eerder proces) + +STDMETHODIMP CDWFFile::CreateEPlotSection(BSTR W2DPath, VARIANT EPlotStream, LONG *nItem) +{ + try + { + if (EPlotStream.vt!=VT_ERROR) + { + VARIANT *var2 = &EPlotStream; + if (var2->vt==(VT_VARIANT|VT_BYREF)) // ByRef + var2 = (VARIANT *)var2->pvarVal; + + if (var2->vt==VT_DISPATCH) + { + CComQIPtr EPlotSection; + EPlotSection = var2->pdispVal; + if (!EPlotSection) + return E_INVALIDARG; + else + { + CEPlotSectionImpl *epli; + EPlotSection->get_EPlotSectionImpl((BYTE **)&epli); + *nItem = CDWFFileImpl::CreateEPlotSection(CString(W2DPath), epli); + if (*nItem >=0) + return S_OK; + else + return E_FAIL; + } + } + else + return E_INVALIDARG; + } + } + catch (CString& e) + { + return myAtlReportError (GetObjectCLSID(), e); + } + return S_OK; +} + +STDMETHODIMP CDWFFile::Save() +{ + myDoTRACE("\nCDWFFile::Save()"); + + try + { + CDWFFileImpl::Save(); + } + catch (CString& e) + { + return myAtlReportError (GetObjectCLSID(), e); + } + return S_OK; +} STDMETHODIMP CDWFFile::get_PropertiesXML(BSTR* pVal) { CString s; diff --git a/SlnkDWFCom/DWFFile.h b/SlnkDWFCom/DWFFile.h index f37d368..07cbdbe 100644 --- a/SlnkDWFCom/DWFFile.h +++ b/SlnkDWFCom/DWFFile.h @@ -48,6 +48,9 @@ protected: public: STDMETHOD(Open)(BSTR DWFPath); + STDMETHOD(Create)(BSTR DWFPath, VARIANT EPlotStream); + STDMETHOD(CreateEPlotSection)(BSTR W2DPath, VARIANT EPlotStream, LONG *pVal); + STDMETHOD(Save)(); STDMETHOD(get_PropertiesXML)(BSTR* pVal); STDMETHOD(get_EPlotSections)(IEPlotSections **ppEPlotSections); }; diff --git a/SlnkDWFCom/EPlotSections.h b/SlnkDWFCom/EPlotSections.h index 9f9cc67..dc31078 100644 --- a/SlnkDWFCom/EPlotSections.h +++ b/SlnkDWFCom/EPlotSections.h @@ -55,5 +55,5 @@ public: STDMETHODIMP get_Parent(IDWFFile **ppParent); STDMETHOD(get_Count)(LONG* pVal); - STDMETHOD(get_Item)(LONG i, IDispatch** pVal); + STDMETHOD(get_Item)(LONG i, IEPlotSection** pVal); }; diff --git a/SlnkDWFCom/SLNKDWF.idl b/SlnkDWFCom/SLNKDWF.idl index a0e0c7f..09bb095 100644 --- a/SlnkDWFCom/SLNKDWF.idl +++ b/SlnkDWFCom/SLNKDWF.idl @@ -14,6 +14,8 @@ interface IEPlotSections; interface ISLNKEvent; interface IBoundingBox; interface IDWGPoint; +interface ISLNKSymbol; +interface ISLNKContour; //interface IChild; //interface ISubChild; @@ -27,8 +29,11 @@ interface IDWGPoint; ] interface IDWFFile : IDispatch{ [id(1), helpstring("method Open")] HRESULT Open(BSTR DWFPath); + [id(2), helpstring("method Create")] HRESULT Create(BSTR DWFPath, [in, optional] VARIANT DWFFile); + [id(3), helpstring("method CreateEPlotSection")] HRESULT CreateEPlotSection(BSTR W2DPath, [in] VARIANT EPlotStreamTemplate, [out, retval] LONG *pVal); + [id(4), helpstring("method Save")] HRESULT Save(); [propget, id(9), helpstring("property PropertiesXML")] HRESULT PropertiesXML([out, retval] BSTR* pVal); - [propget, id(10), helpstring("property EPlotSections")] HRESULT EPlotSections([out,retval] IEPlotSections **ppEPlotSections); + [propget, id(10), helpstring("property EPlotSections")] HRESULT EPlotSections([out, retval] IEPlotSections **ppEPlotSections); }; [ object, @@ -48,10 +53,10 @@ interface IWhipFile : IDispatch{ [id(9), helpstring("method SetLabelPosition")] HRESULT SetLabelPosition([in, defaultvalue(1)] BYTE LabelPos); [propget, id(10), helpstring("method ContoursXML")] HRESULT ContoursXML([out, retval] BSTR* pVal); [id(12), helpstring("method SetLayers")] HRESULT SetLayers([in] BSTR reContouren, [in] BSTR reLabels); - [propget, id(14), helpstring("property AddSymbol")] HRESULT AddSymbol([in] DOUBLE dwgX, [in] DOUBLE dwgY, BSTR symbolName, [out, retval] IUnknown** pVal); + [propget, id(14), helpstring("property AddSymbol")] HRESULT AddSymbol([in] DOUBLE dwgX, [in] DOUBLE dwgY, BSTR symbolName, [out, retval] ISLNKSymbol** pVal); [id(15), helpstring("method DefineSymbol")] HRESULT DefineSymbol([in] BSTR symbolName, [in] VARIANT EPlotStream); [id(16), helpstring("method DefineBitmapSymbol")] HRESULT DefineBitmapSymbol([in] BSTR symbolName, [in] BSTR symbolPath, [in] DOUBLE height); - [propget, id(17), helpstring("property Contour")] HRESULT Contour([in] BSTR IdentLabel, [out, retval] IUnknown** pVal); + [propget, id(17), helpstring("property Contour")] HRESULT Contour([in] BSTR IdentLabel, [out, retval] ISLNKContour** pVal); [id(18), helpstring("method SetFilterLayers")] HRESULT SetFilterLayers([in] BSTR reLayers); [propget, id(19), helpstring("property hintScale")] HRESULT hintScale([out, retval] DOUBLE* pVal); [propput, id(19), helpstring("property hintScale")] HRESULT hintScale([in] DOUBLE newVal); @@ -124,6 +129,7 @@ interface IEPlotSection : IDispatch{ [propget, helpstring("My Parent")] HRESULT Parent([out, retval] IEPlotSections **ppParent); [propget, id(3), helpstring("property Name")] HRESULT Name([out, retval] BSTR* pVal); [propget, id(4), helpstring("property Title")] HRESULT Title([out, retval] BSTR* pVal); + [id(5), helpstring("Add Property")] HRESULT AddProperty(BSTR pCategory, BSTR pName, BSTR pVal); [local] [id(6), helpstring("method Read")] HRESULT Read([out, size_is(cb), length_is(*pcbRead)]void *pv, [in]ULONG cb, [out]ULONG *pcbRead); @@ -150,7 +156,7 @@ interface IEPlotSection : IDispatch{ interface IEPlotSections : IDispatch{ [propget, helpstring("My Parent")] HRESULT Parent([out, retval] IDWFFile **ppParent); [propget, id(1), helpstring("property Count")] HRESULT Count([out, retval] LONG* pVal); - [propget, id(2), helpstring("property Item")] HRESULT Item([in] LONG i, [out, retval] IDispatch** pVal); + [propget, id(2), helpstring("property Item")] HRESULT Item([in] LONG i, [out, retval] IEPlotSection** pVal); }; [ object, @@ -237,7 +243,7 @@ interface ISLNKSymbol : IDispatch{ [propput, id(2), helpstring("property Scale")] HRESULT Scale([in] DOUBLE newVal); [propget, id(3), helpstring("property Rotation")] HRESULT Rotation([out, retval] LONG* pVal); [propput, id(3), helpstring("property Rotation")] HRESULT Rotation([in] LONG newVal); - [propget, id(4), helpstring("property Contour")] HRESULT Contour([out, retval] IUnknown** pVal); + [propget, id(4), helpstring("property Contour")] HRESULT Contour([out, retval] ISLNKContour** pVal); }; [ object, diff --git a/SlnkDWFCom/SLNKDWFVersion.h b/SlnkDWFCom/SLNKDWFVersion.h index 9b7bed7..fe5e906 100644 --- a/SlnkDWFCom/SLNKDWFVersion.h +++ b/SlnkDWFCom/SLNKDWFVersion.h @@ -1,7 +1,7 @@ // Zorg dat versies alfabetisch altijd op elkaar volgen! #define SLNK_MAJOR_VERSION 2 -#define SLNK_MINOR_VERSION 0 -#define SLNK_BUILD_VERSION 1 +#define SLNK_MINOR_VERSION 10 +#define SLNK_BUILD_VERSION 0 // Define resource strings #define ECHO(a) #a diff --git a/SlnkDWFCom/SLNKSymbol.cpp b/SlnkDWFCom/SLNKSymbol.cpp index 49ab0e5..e0edfe2 100644 --- a/SlnkDWFCom/SLNKSymbol.cpp +++ b/SlnkDWFCom/SLNKSymbol.cpp @@ -55,7 +55,7 @@ STDMETHODIMP CSLNKSymbol::put_Rotation(LONG newVal) return S_OK; } -STDMETHODIMP CSLNKSymbol::get_Contour(IUnknown** pVal) +STDMETHODIMP CSLNKSymbol::get_Contour(ISLNKContour** pVal) { CSLNKContourImpl *contour= &m_SLNKSymbol->m_SLNKContour; diff --git a/SlnkDWFCom/WhipFile.cpp b/SlnkDWFCom/WhipFile.cpp index 3b3ca2f..aedcfe3 100644 --- a/SlnkDWFCom/WhipFile.cpp +++ b/SlnkDWFCom/WhipFile.cpp @@ -442,9 +442,7 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do { switch(my_plan_file.current_object()->object_type()) { - case WT_Object::Origin_ID: - break; - case WT_Object::Drawable: + case WT_Object::Drawable: if (firstDrawable) GenerateContouren(my_plan_file, my_file, scale, true); // Alle 'solid' kleuren firstDrawable = false; @@ -462,43 +460,48 @@ HRESULT CWhipFile::SerializePlan(WT_File & my_plan_file, myWT_File & my_file, do case WT_Object::Attribute: { const WT_Attribute *obj = (WT_Attribute *)my_plan_file.current_object(); - if (obj->object_id() == WT_Object::Layer_ID) - { // Sla de oorspronkelijke contour lagen over - // En ook de lagen die we niet willen - CurrentLayerOn = TRUE; - WT_Layer *layer = (WT_Layer *)obj; - WT_Integer32 layer_num = layer->layer_num(); - if (layer_num==0) - { // ARKEY heeft lagen met nummer 0. Dat mag niet volgens de - // Whip-spec en gaat ook mis (alleen) bij binaire DWF's - if (my_file.heuristics().allow_binary_data()) - { - myDoTRACE("\nSkipping layer with invalid number 0"); - break; - } - } - WT_Layer *ll = my_plan_file.layer_list().find_layer_from_index(layer_num); - if (ll&& - ll->layer_name().ascii()&& - (m_State.labelMatch(ll->layer_name().ascii()) || - m_State.contMatch(ll->layer_name().ascii()) || - !m_State.layerMatch(ll->layer_name().ascii())) - ) - CurrentLayerOn = FALSE; // Layer object hoeft ook niet meer geserialized - else - layer->serialize(my_file); - } - else + switch(obj->object_id()) { -#ifdef _DEBUG - CString s(my_plan_file.file_stats()->descriptions()); - // myTRACE("Attribute '%s'\n", s); -#endif - // Hoewel een Attibute gaat hij toch niet via desired_rendition - // Omdat we weten dat we net uit uit een DWF komen kunnen we best - // wel rechtstreeks serializen - // Let wel: desired_rendition is dan niet meer te vertrouwen. Zie @@@ - obj->serialize(my_file); + case WT_Object::URL_ID: // Strippen omdat ze in de weg kunnen zitten met onze eigen URL's + break; + case WT_Object::Layer_ID: + { // Sla de oorspronkelijke contour lagen over + // En ook de lagen die we niet willen + CurrentLayerOn = TRUE; + WT_Layer *layer = (WT_Layer *)obj; + WT_Integer32 layer_num = layer->layer_num(); + if (layer_num==0) + { // ARKEY heeft lagen met nummer 0. Dat mag niet volgens de + // Whip-spec en gaat ook mis (alleen) bij binaire DWF's + if (my_file.heuristics().allow_binary_data()) + { + myDoTRACE("\nSkipping layer with invalid number 0"); + break; + } + } + WT_Layer *ll = my_plan_file.layer_list().find_layer_from_index(layer_num); + if (ll&& + ll->layer_name().ascii()&& + (m_State.labelMatch(ll->layer_name().ascii()) || + m_State.contMatch(ll->layer_name().ascii()) || + !m_State.layerMatch(ll->layer_name().ascii())) + ) + CurrentLayerOn = FALSE; // Layer object hoeft ook niet meer geserialized + else + layer->serialize(my_file); + } + default: + { + #ifdef _DEBUG + CString s(my_plan_file.file_stats()->descriptions()); + // myTRACE("Attribute '%s'\n", s); + #endif + // Hoewel een Attibute gaat hij toch niet via desired_rendition + // Omdat we weten dat we net uit uit een DWF komen kunnen we best + // wel rechtstreeks serializen + // Let wel: desired_rendition is dan niet meer te vertrouwen. Zie @@@ + obj->serialize(my_file); + } } } break; @@ -915,7 +918,7 @@ STDMETHODIMP CWhipFile::get_ContoursXML(BSTR* pVal) return bstrString.CopyTo(pVal); } -STDMETHODIMP CWhipFile::get_AddSymbol(DOUBLE dwgX, DOUBLE dwgY, BSTR symbolName, IUnknown** pVal) +STDMETHODIMP CWhipFile::get_AddSymbol(DOUBLE dwgX, DOUBLE dwgY, BSTR symbolName, ISLNKSymbol** pVal) { CString name(symbolName); @@ -996,7 +999,7 @@ STDMETHODIMP CWhipFile::DefineBitmapSymbol(BSTR symbolName, BSTR symbolPath, dou // Merk op: als iemand twee keer dezelfde contour opvraagt maken we twee onafhankelijke // SLNKContour objecten aan die beide naar dezelfde CSLNKContourImpl wijzen // Het maakt verder weinig uit en is wel gemakkelijker (toch?) -STDMETHODIMP CWhipFile::get_Contour(BSTR IdentLabel, IUnknown** pVal) +STDMETHODIMP CWhipFile::get_Contour(BSTR IdentLabel, ISLNKContour** pVal) { try { for (size_t i=0; i=(LONG)m_pSectionsImpl->get_Count()) return E_INVALIDARG; diff --git a/SlnkDWFCom/myEPlotSection.cpp b/SlnkDWFCom/myEPlotSection.cpp index 51d4048..7b05a59 100644 --- a/SlnkDWFCom/myEPlotSection.cpp +++ b/SlnkDWFCom/myEPlotSection.cpp @@ -51,6 +51,12 @@ STDMETHODIMP CEPlotSection::get_Title(BSTR* pVal) return bstrString.CopyTo(pVal); } +STDMETHODIMP CEPlotSection::AddProperty(BSTR pCategory, BSTR pName, BSTR pVal) +{ + m_pSectionImpl->addProperty(pCategory, pName, pVal); + return S_OK; +} + STDMETHODIMP CEPlotSection::get_PaperColor(ULONG* pVal) { (*pVal) = m_pSectionImpl->get_PaperColor(); diff --git a/SlnkDWFCom/myEPlotSection.h b/SlnkDWFCom/myEPlotSection.h index ddab093..f7a29c8 100644 --- a/SlnkDWFCom/myEPlotSection.h +++ b/SlnkDWFCom/myEPlotSection.h @@ -54,7 +54,7 @@ public: STDMETHODIMP get_Parent(IEPlotSections **ppParent); STDMETHOD(get_Name)(BSTR* pVal); STDMETHOD(get_Title)(BSTR* pVal); - + STDMETHOD(AddProperty)(BSTR pCategory, BSTR pName, BSTR pVal); void InitImpl(CEPlotSectionImpl *epl); // IWhipSequentialStream Methods diff --git a/SlnkDWFCom/slnksymbol.h b/SlnkDWFCom/slnksymbol.h index 65ab515..d19436a 100644 --- a/SlnkDWFCom/slnksymbol.h +++ b/SlnkDWFCom/slnksymbol.h @@ -68,7 +68,7 @@ public: STDMETHOD(put_Scale)(DOUBLE newVal); STDMETHOD(get_Rotation)(LONG* pVal); STDMETHOD(put_Rotation)(LONG newVal); - STDMETHOD(get_Contour)(IUnknown** pVal); + STDMETHOD(get_Contour)(ISLNKContour** pVal); }; //REMOVED OBJECT_ENTRY_AUTO(__uuidof(SLNKSymbol), CSLNKSymbol) diff --git a/SlnkDWFImpl/DWFFileImpl.cpp b/SlnkDWFImpl/DWFFileImpl.cpp index 95f4bfc..716e19b 100644 --- a/SlnkDWFImpl/DWFFileImpl.cpp +++ b/SlnkDWFImpl/DWFFileImpl.cpp @@ -5,6 +5,8 @@ #include "DWFFileImpl.h" #include "myEPlotSectionImpl.h" +#include "dwfcore/mime.h" +#include "../SLNKDwfCom/SLNKDwfVersion.h" // CDWFFile @@ -18,10 +20,175 @@ CDWFFileImpl::~CDWFFileImpl() if (m_oReader!=NULL) delete m_oReader; +#ifndef DWFTK_READ_ONLY + if (m_oWriter!=NULL) + delete m_oWriter; +#endif + if (m_DWF!=NULL) delete m_DWF; } +#ifndef DWFTK_READ_ONLY +bool CDWFFileImpl::Create(const CString &DWFPath, CDWFFileImpl *DWFFileTemplate) +{ + DWFCore::DWFFile oDWF( DWFPath ); + m_oWriter = new DWFToolkit::DWFPackageWriter ( oDWF ); + + return true; +} + +// Returns index of created item. -1 is error +// W2DPath wijst naar de W2D die we inlezen +// ePlotTemplate nemen we papier van over +LONG CDWFFileImpl::CreateEPlotSection(const CString &W2DPath, + CEPlotSectionImpl *ePlotTemplate) +{ + if (!m_oWriter) + throw CString("DWFFile package must be created first"); + + // Neem zo veel mogelijk van onze originele EPlotSection over + DWFToolkit::DWFEPlotSection* oldSection = ePlotTemplate->get_Section(); + // Maak een nieuwe DWFEPlotSection aan + DWFToolkit::DWFEPlotSection* pPage = + DWFCORE_ALLOC_OBJECT( DWFToolkit::DWFEPlotSection( + oldSection->title(), + oldSection->objectID(), oldSection->order(), + oldSection->source(), oldSection->color(), + oldSection->paper()) ); + + pPage->addProperty( DWFCORE_ALLOC_OBJECT(DWFToolkit::DWFProperty(L"Version", SLNK_BUILDVERSION, L"SLNKDWF", L"", L"")), true ); + + // Zoek de originele graphicsResource voor de units e.d. + DWFResourceContainer::ResourceIterator* piResources = + oldSection->findResourcesByRole( DWFXML::kzRole_Graphics2d ); + + if ((piResources == NULL) || (piResources->valid() == false)) + { + if (piResources) + { + DWFCORE_FREE_OBJECT( piResources ); + } + + myTRACE("%ls", "Illegal EPlot section - no graphics"); + return false; + } + + // + // get the w2d resource + // + //Since we know it's a Graphics2D role, we should be able to cast + //into an EPlotGraphicResource, otherwise the authoring tool didn't + //read the spec. + DWFToolkit::DWFGraphicResource* pW2D = dynamic_cast(piResources->get()); + + // + // define the resource - this must be allocated on the heap + // + DWFToolkit::DWFGraphicResource* p2Dgfx = + DWFCORE_ALLOC_OBJECT( DWFGraphicResource(L"SLNKDWF" , // title + DWFXML::kzRole_Graphics2d, // role + DWFMIME::kzMIMEType_W2D, // MIME type + L"Autodesk, Inc.", // author + L"SLNKDWF modfied", // description + L"", // creation time + L"") ); // modification time + + if (p2Dgfx == NULL) + { + _DWFCORE_THROW( DWFMemoryException, L"Failed to allocate resource" ); + } + + // + // configure the resource + // + + p2Dgfx->configureGraphic( pW2D->transform(), + NULL, + pW2D->clip() ); + + + // + // most importantly - bind a stream to the resource + // in this case, we have a file on disk so we open the + // file with a streaming descriptor. we will also + // create everything on the heap since the package writer + // will not use the stream immediately, he will need to own + // these resources. + // + DWFCore::DWFFile oW2DFilename( W2DPath ); + DWFCore::DWFStreamFileDescriptor* pW2DFile = DWFCORE_ALLOC_OBJECT( DWFStreamFileDescriptor(oW2DFilename, L"rb") ); + + if (pW2DFile == NULL) + { + DWFCORE_FREE_OBJECT( p2Dgfx ); + + _DWFCORE_THROW( DWFMemoryException, L"Failed to allocate file descriptor" ); + } + + DWFCore::DWFFileInputStream* pW2DFilestream = DWFCORE_ALLOC_OBJECT( DWFFileInputStream ); + + if (pW2DFilestream == NULL) + { + DWFCORE_FREE_OBJECT( p2Dgfx ); + DWFCORE_FREE_OBJECT( pW2DFile ); + + _DWFCORE_THROW( DWFMemoryException, L"Failed to allocate file stream" ); + } + + // + // open the file and bind it to the stream + // + pW2DFile->open(); + pW2DFilestream->attach( pW2DFile, true ); + + // + // hand the stream off to the resource + // NOTE: since we don't already know the filesize (in the application space - of course we can look on disk...) + // leave the second parameter (nBytes) default as zero, this will tell the package writer + // to use the number of bytes it processed through the stream as the size attribute in the descriptor. + // + p2Dgfx->setInputStream( pW2DFilestream ); + + // + // finally, drop the resource into the page + // + pPage->addResource( p2Dgfx, true ); + + /// + /// + + CEPlotSectionImpl *mySection = new CEPlotSectionImpl; + CString s;s.Format("%s (page %d)", "sourceDescription", m_EPlotSections.get_Count()); + mySection->Init(pPage, s, true); + m_EPlotSections.Add(mySection); + + m_oWriter->addSection( pPage ); + + // Aan het einde van de packagewriter gebeurt wel een flush...DWFCORE_FREE_OBJECT( pW2DFilestream ); + + return m_EPlotSections.get_Count()-1; +} + +bool CDWFFileImpl::Save() +{ + if (!m_oWriter) + throw CString("DWFFile package must be created first"); + + try + { + m_oWriter->write( L"Dijkoraad IT", L"SLNKDWF", SLNK_BUILDVERSION, // <== Wij + L"Autodesk, Inc", _DWFTK_VERSION_STRING ); // <== Zij + } + catch (DWFException& ex) + { + CString err; + err.Format("%ls\n%ls\n%s\n%ls(%d)",ex.type(),ex.message(),ex.function(),ex.file(),ex.line()); + throw myCString ("\nCDWFFileImpl::Save()\n%s", err); + } + return true; +} + bool CDWFFileImpl::Open(const CString &DWFPath) { if (m_isOpen) @@ -80,6 +247,7 @@ bool CDWFFileImpl::Open(const CString &DWFPath) throw myCString ("\nCDWFFileImpl::Open('%s')\n%s", DWFPath, err); } } +#endif #if DESIRED_CODE(WHIP_OUTPUT) bool CDWFFileImpl::get_PropertiesXML(CString & pVal) diff --git a/SlnkDWFImpl/EplotSectionsImpl.cpp b/SlnkDWFImpl/EplotSectionsImpl.cpp index 71df91e..370a436 100644 --- a/SlnkDWFImpl/EplotSectionsImpl.cpp +++ b/SlnkDWFImpl/EplotSectionsImpl.cpp @@ -11,6 +11,12 @@ CEPlotSectionsImpl::~CEPlotSectionsImpl() delete m_EPlotSections[i]; } +BOOL CEPlotSectionsImpl::Add(CEPlotSectionImpl *pSection) +{ + m_EPlotSections.Add(pSection); + return true; +} + // Actually process the EPlotSections and add them to our collection BOOL CEPlotSectionsImpl::ProcessManifest(DWFManifest& rManifest, CString sourceDescription) { diff --git a/SlnkDWFImpl/dwffileimpl.h b/SlnkDWFImpl/dwffileimpl.h index f5e22f2..d33203d 100644 --- a/SlnkDWFImpl/dwffileimpl.h +++ b/SlnkDWFImpl/dwffileimpl.h @@ -15,7 +15,10 @@ class CDWFFileImpl { public: CDWFFileImpl() - : m_DWF(NULL),m_oReader(NULL), m_isOpen(FALSE) + : m_DWF(NULL),m_oReader(NULL), m_isOpen(FALSE) +#ifndef DWFTK_READ_ONLY + ,m_oWriter(NULL) +#endif { } ~CDWFFileImpl(); @@ -23,6 +26,11 @@ public: public: bool get_PropertiesXML(CString & pVal); CEPlotSectionsImpl *get_EPlotSections(); +#ifndef DWFTK_READ_ONLY + bool Create(const CString &DWFPath, CDWFFileImpl *DWFFileTemplate ); + LONG CreateEPlotSection(const CString &W2DPath, CEPlotSectionImpl *ePlotTemplate); + bool Save(); +#endif bool Open(const CString &DWFPath); public: @@ -31,6 +39,9 @@ public: private: DWFCore::DWFFile *m_DWF; +#ifndef DWFTK_READ_ONLY + DWFToolkit::DWFPackageWriter* m_oWriter; +#endif DWFToolkit::DWFPackageReader* m_oReader; WT_File m_DWFFile; diff --git a/SlnkDWFImpl/eplotsectionsimpl.h b/SlnkDWFImpl/eplotsectionsimpl.h index d22500b..e62dc19 100644 --- a/SlnkDWFImpl/eplotsectionsimpl.h +++ b/SlnkDWFImpl/eplotsectionsimpl.h @@ -24,6 +24,7 @@ protected: public: BOOL ProcessManifest(DWFToolkit::DWFManifest& rManifest, CString sourceDescription); + BOOL Add(CEPlotSectionImpl *pSection); long get_Count(); CEPlotSectionImpl *get_Item(LONG i); diff --git a/SlnkDWFImpl/myEPlotSectionImpl.cpp b/SlnkDWFImpl/myEPlotSectionImpl.cpp index 1a19f63..866c73a 100644 --- a/SlnkDWFImpl/myEPlotSectionImpl.cpp +++ b/SlnkDWFImpl/myEPlotSectionImpl.cpp @@ -154,6 +154,12 @@ STDMETHODIMP CEPlotSectionImpl::Open(BOOL bForWrite) // DWFCORE_FREE_OBJECT( piResources ); + if (pW2D == NULL) + { + myTRACE("%ls", L"Type mismatch - not a W2D resource"); + return E_FAIL; + } + if (pW2D->mime() != DWFCore::DWFMIME::kzMIMEType_W2D) { myDoTRACE("\nMime: %ls", (const wchar_t*)pW2D->mime()); @@ -161,12 +167,6 @@ STDMETHODIMP CEPlotSectionImpl::Open(BOOL bForWrite) "\nMeasurement/Print disabled?", (const wchar_t*)pW2D->mime()); } - if (pW2D == NULL) - { - myTRACE("%ls", L"Type mismatch - not a W2D resource"); - return E_FAIL; - } - // // get the data stream // @@ -202,6 +202,13 @@ const DWFProperty* const CEPlotSectionImpl::findProperty( const DWFString& zName return m_pSection->findProperty( zName, zCategory); } +void const CEPlotSectionImpl::addProperty( const DWFString& zCategory, + const DWFString& zName, + const DWFString& zValue ) +{ + m_pSection->addProperty( DWFCORE_ALLOC_OBJECT(DWFToolkit::DWFProperty(zName, zValue, zCategory, L"", L"")), true ); +} + HRESULT CEPlotSectionImpl::Read( void *pv, ULONG cb, ULONG *pcbRead) { diff --git a/SlnkDWFImpl/myeplotsectionimpl.h b/SlnkDWFImpl/myeplotsectionimpl.h index a2f76b5..99fd515 100644 --- a/SlnkDWFImpl/myeplotsectionimpl.h +++ b/SlnkDWFImpl/myeplotsectionimpl.h @@ -45,11 +45,15 @@ public: const CString get_Name(); const CString get_Title(); + STDMETHOD(Open)(BOOL bForWrite); STDMETHOD(Read) ( void *pv, ULONG cb, ULONG *pcbRead); STDMETHOD(Seek) ( ULONG cb, ULONG *pcbRead); const DWFProperty* const findProperty( const DWFString& zName, const DWFString& zCategory = L"" ); + void const addProperty( const DWFString& zCategory, + const DWFString& zName, + const DWFString& zValue ); #ifndef DWFTK_READ_ONLY bool SaveAs(const CString &destpath); static bool SaveAsAscii(const CString &srcpath, const CString &destpath); @@ -58,6 +62,7 @@ public: #endif STDMETHOD(Close)(void); ULONG get_PaperColor(); + DWFToolkit::DWFEPlotSection* const get_Section() { return m_pSection; }; STDMETHOD(get_SourceDescription)(CString &pVal); #ifndef DWFTK_READ_ONLY STDMETHOD(get_PropertiesXML)(CString & pVal); diff --git a/Standalone/SLNKDWFViewer.aps b/Standalone/SLNKDWFViewer.aps index 81f0dc5..727fac9 100644 Binary files a/Standalone/SLNKDWFViewer.aps and b/Standalone/SLNKDWFViewer.aps differ diff --git a/Standalone/SLNKDWFViewer.vcproj b/Standalone/SLNKDWFViewer.vcproj index 5a2fb72..903ff74 100644 --- a/Standalone/SLNKDWFViewer.vcproj +++ b/Standalone/SLNKDWFViewer.vcproj @@ -66,7 +66,7 @@ Name="VCResourceCompilerTool" PreprocessorDefinitions="_DEBUG" Culture="1033" - AdditionalIncludeDirectories="$(IntDir);C:\Library\Wtl80\include" + AdditionalIncludeDirectories="$(IntDir);D:\Library\Wtl80\include" />