[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

Re: [XaraXtreme-dev] Open file, get standard colours



Here are a number of points.

Let's suppose there is a means by which a filter plugin can communicate
it's need for a default document. It is possible for a plugin to state
that it does not need a default document, and yet not output any named
colours. In order to directly fix this problem it would need to be
understood by plugin writers (and documented) that if you do not request
a default document, then you must provide at least one named colour.
Additionally, a robust implementation of Xara should still check to see
if there are any named colours after loading the document, and either
cancel the load or do something else reasonable.

My second point is that maybe the problem is not directly with loading a
document with no colours, but with the rest of the system in assuming
that all documents have colours. If you open the colour gallery while
working on a document with no colours and click on "New...", Xara
crashes. Clearly this should not happen.

Thirdly, I noticed that after opening an SVG (SVGs do not load a default
document), the bitmap gallery shows the Xara default standard bitmap. So
this is an inconsistency. If no default document is loaded, and no
colours are created, then I would also expect no bitmaps either. Since
this is not the case, it would seem to validate my proposed solution of
creating default colours for documents that have none. Although maybe
the implementation should be different, since I do not see the default
bitmap being created in the same function as I am creating the colours.

Gerry Iles wrote:
> Yes, it sounds like your change is fine, at least for the time being.
> 
> As for the SVG filter, it sounds like the "plugin" filter mechanism
> could do with a way for the filter to specify if it needs a default
> document to import into when opening files.  This should probably be
> specified in the XML file that defines the filter, the PluginOILFilter
> class tweaked to read the setting from the XML and the
> PluginNativeFilter class override the IsDefaultDocRequired function to
> return the relevant setting.  This could easily default to the current
> FALSE value when the setting isn't present in the XML so existing
> filters would only need to change if they need a default document...
> 
> Gerry
> 
> -----Original Message-----
> From: owner-dev@xxxxxxxxxxxxxxxx [mailto:owner-dev@xxxxxxxxxxxxxxxx] On
> Behalf Of JLM
> Sent: 27 June 2007 02:05
> To: dev@xxxxxxxxxxxxxx
> Subject: Re: [XaraXtreme-dev] Open file, get standard colours
> 
> I simply commented out the EXCLUDE_FROM_XARALX preprocessor directives,
> recompiled, and it appears to work. It loads a default document for gif,
> png, and jpg, but not for svg or xar. Also, I tried saving a file that I
> opened (originally a png), and Xara did not automatically save it as
> filename.xar, but prompted for a name.
> 
> The only problem I still see is when loading an SVG file. An SVG does
> not have to define any colours, and hence when opening one a document
> with no colours is still created. I think my code submission is still
> valid for this filter as well as any others that answer no to
> IsDefaultDocRequired, but may not define any colours.
> 
> Gerry Iles wrote:
>> The #ifndef EXCLUDE_FROM_XARALX in CCamDoc::DefaultDocumentRequired is
>> causing the important lines at the end of the function to be skipped
> as
>> the #else clause is simply returning.
>>
>> This code should really be asking the relevant filter if it is
> required
>> as loading a Xar document should not require the default document.
>> Loading all bitmap formats will generally require the default document
>> as they have no document structure of their own.
>>
>> The comments in the function imply that the person doing the porting
> was
>> trying to make it always load the default document but, in fact, it
>> never does so.  This function should really be called
>> LoadDefaultDocumentIfRequired so it is clear what it is supposed to
> do.
>> Once the function is correctly loading the default document when
>> required it may also be necessary to set a member variable to indicate
>> that the document was created from a template so that "Save as" can be
>> used when the user tries to save the document.  This will ensures that
>> another file is not overwritten without warning the user (e.g. if you
>> load fred.jpg and hit save it will probably try to automatically save
>> fred.xar without prompting if it already exists).
>>
>> Gerry
>>
>> -----Original Message-----
>> From: owner-dev@xxxxxxxxxxxxxxxx [mailto:owner-dev@xxxxxxxxxxxxxxxx]
> On
>> Behalf Of Gerry Iles
>> Sent: 25 June 2007 09:43
>> To: dev@xxxxxxxxxxxxxx
>> Subject: RE: [XaraXtreme-dev] Open file, get standard colours
>>
>> Hi Guys,
>>
>> I did do some (though not all) of the code in this area and I think
> you
>> are right that at the time it was done there weren't any template
>> documents to load...
>>
>> I think the code concerned is in CCamDoc::DefaultDocumentRequired
>> (wxOil\camdoc.cpp).  It appears that this function simply determines
> if
>> the template is required but I believe it should also be loading the
>> template if it is.
>>
>> Gerry
>>
>> -----Original Message-----
>> From: owner-dev@xxxxxxxxxxxxxxxx [mailto:owner-dev@xxxxxxxxxxxxxxxx]
> On
>> Behalf Of Alex Bligh
>> Sent: 24 June 2007 11:14
>> To: dev@xxxxxxxxxxxxxx
>> Cc: Alex Bligh
>> Subject: Re: [XaraXtreme-dev] Open file, get standard colours
>>
>> JLM,
>>
>> --On 23 June 2007 18:26 -0400 JLM <jsado_sc5@xxxxxxxxxxxxx> wrote:
>>
>>> When you open an image or SVG file, a new document is created
>> (complete
>>> with new tab) but it does not appear that a default template is
> loaded
>>> prior to reading in the file.
>>>
>>> So if I understand correctly, you believe that opening a file should
>> do
>>> the same thing as creating a new document and then importing that
>> file?
>>> I can change the program to work that way.
>> Yes I believe so. I am more interested though in /why/ (given we're
>> using a codebase similar to the Windows version) it doesn't "just
> work".
>> Gerry converted this stuff (hi Gerry!) and I'm hoping he's going to
>> chime
>> in and say something like "oh yes just uncomment the following line
> from
>> this file which was commented out as we didn't have default document
>> loading
>> working then". I suspect what is happening is that it is using the
> wrong
>> document template (I think there's a very basic internal code
> generated
>> one) which is potentially dangerous for lots of reasons.
>>
>> Alex
>>
>