Re: how Get Bitmap file from SVG module?

2012-06-04 Thread Armin Le Grand
Hi jianlizhao,

jianlizhao jianlizh...@hotmail.com wrote:
 Hi Armin:
 
 I send an Email to Texmaths's author ,  asked he some questions, communicate
 with each other as follows:
 
 My question:
 LaTeX will equations can be inserted as images (SVG or PNG formats) and
  the LaTeX, code is saved into the image attribute for further editing.
 
 His reply:
 Image attributes are not stored directly in the png file but in LibreOffice
 data that are attached to the image.
 
 
  attached the image attribute in openOffice data  below:( basic code)
 ,,,
 Sub SetAttributes( oShape as Variant, iEqSize as Integer, sEqType as String,
 sCode as String) 
  'Add the Latex attribute to the image.
  Dim oAttributes as Variant, oLatexAttribute as Variant
  oAttributes = oShape.UserDefinedAttributes
  oLatexAttribute = createUnoStruct(
 ;com.sun.star.xml.AttributeDataquot; )
  oLatexAttribute.Type =  
  oLatexAttribute.Value = 
  oAttributes.insertByName( ) 
  oShape.UserDefinedAttributes = oAttributes
 End Sub
 ,,,
 
 My question is:
 When the image attribute very long, example 10M bytes, if it  will  wrong.

I cannot tell you, I never used this. You will have to just try it out. I
would guess that it will work, I see no reason someone should have added a
size limitation to it.

 The image attribute can  as a zip file saved in the odf?

I do not know about internals, but saving image attributes with the image
is done internally at save/export time from the AOO code. I see no way to
do it yourself whithout changing this (e.g. implement callbacks which may
be used in an external module if needed). I think it is also not necessary.
Just try out if it works when you add that data and if it will be there
again after reading it.

  Look forward to your reply.
  Best Regards!

HTH!
Sincerely,
Armin
-- 
ALG



Re: how Get Bitmap file from SVG module?

2012-06-03 Thread RGB ES
2012/6/3 jianlizhao jianlizh...@hotmail.com:
 Hi Armin:

 I send an Email to Texmaths's author ,  asked he some questions, communicate
 with each other as follows:

 My question:
 LaTeX will equations can be inserted as images (SVG or PNG formats) and
  the LaTeX, code is saved into the image attribute for further editing.

 His reply:
 Image attributes are not stored directly in the png file but in LibreOffice
 data that are attached to the image.


 But he did not tell me how to attached the image in openOffice data,could
 you tell me?


KLatexFormula(1) works pretty well on AOO 3.4. You can also install an
extension that makes easy to later edit the equation. It also offer an
openoffice compatible image format that gives good results when
exporting to PDF. This program is a completely different beast than
the extension you mention: it can be used as stand alone program to
generate images, provide a library of formulas... etc.

(1) http://klatexformula.sourceforge.net/

Regards
Ricardo


Re: how Get Bitmap file from SVG module?

2012-06-01 Thread Armin Le Grand

Hi jianlizhao,

On 01.06.2012 06:22, jianlizhao wrote:

Hi Armin:
You say this I understanding.
I would  insert original image aoo's write and display, I do not how to do it 
with zip file?


I am not sure I understand what you need to know. The method described 
is just a possibility to check the file content of ODF files.


If you insert the reduced Bitmap as GraphicObject in a ODF document and 
save it, it will be contained.


I understood from your last comments that including the raw data 
directly to ODF is not needed. Instead it is set as kind of comment to 
the inserted GraphicObject and thus evtl. indirectly saved and included 
in the ODF. How this may happen I have no idea, sorry.


HTH!


Look forward to your reply.
  Best Regards!


-邮件原件-
发件人: Armin Le Grand [mailto:armin.le.gr...@me.com]
发送时间: 2012年5月31日 22:28
收件人: ooo-dev@incubator.apache.org
主题: Re: how Get Bitmap file from SVG module?

Hi jianlizhao,

much more simple, only a trick to look at the contents of a ODF file.

Example: Save the file (e.g. foo.odf), extend filename (e.g. in explorer
on windows) by *.ziz (-  foo.odf.zip). You can the open the odf file as
zip archive and inspect/check it's contents.

HTH!


[..]

Sincerely,
Armin
--
ALG



Re: how Get Bitmap file from SVG module?

2012-05-31 Thread Armin Le Grand

Hi jianlizhao,

much more simple, only a trick to look at the contents of a ODF file.

Example: Save the file (e.g. foo.odf), extend filename (e.g. in explorer 
on windows) by *.ziz (- foo.odf.zip). You can the open the odf file as 
zip archive and inspect/check it's contents.


HTH!

On 31.05.2012 13:54, jianlizhao wrote:

Hi Armin:
You reply said  Another way is to add a '.zip' to
the AOO file name and to open it as archive.
how to do it?

Can you give a simple and complete example, Programming languages ​​using C++ 
,runtime environment for Microsoft Windows.

Look forward to your reply.
Best Regards!

-邮件原件-
发件人: Armin Le Grand [mailto:armin.le.gr...@me.com]
发送时间: 2012年5月30日 23:46
收件人: ooo-dev@incubator.apache.org
主题: Re: how Get Bitmap file from SVG module?

Hi jianlizhao,


[..]

Sincerely,
Armin
--
ALG



Re: how Get Bitmap file from SVG module?

2012-05-30 Thread Armin Le Grand

Hi jianlizhao,

On 30.05.2012 16:29, jianlizhao wrote:

Hi Armin:

I find  TexMaths extension is very like my needs. Described as follows:

TexMaths is an extension designed to provide LaTeX support into LibreOffice.
LaTeX equations can be inserted as images (SVG or PNG formats) and the LaTeX
code is saved into the image attribute for further editing.

My question as follows:
The new type picture can be inserted as images (PNG formats) and the
Original picture is saved into the image attribute for further used.
the image attribute can be saved with a file?


I have no idea, I never used something like this. If the example 
extension does it currently and it is allowed to save any binary data at 
the PNG then you can do the same (probably).


To find out if it is saved with the file I would check if it is saved 
currently with the TexMaths extension. Another way is to add a '.zip' to 
the AOO file name and to open it as archive. There you can check for the 
contained single files and data, your binary data should be there somewhere.



The difference between them is
LaTeX equations is small and short, The new type picture is large.
can  This method rigth?


If it serves your needs and works it is right. You need to check if the 
files you create are loadable by a standard office (the AOO3.4 release 
version for example). It should load and show the PNG. I cannot say if 
it will strip your binary data when saving changed, you have to find out 
yourself.


The only possible drawback is when you or other people using your 
extension would spread files generated this way and these files are very 
big. This may cause high eMail loads and similar effects. People may ask 
'why is this file so big, there is only one picture in it'. I would 
suggest to not spread such files with extra data in them too much, maybe 
you only need to use them inhouse or privately anyways. It is a very 
specialized usage of ODF files.



The benefits of the treatment is:
do not have to program  a import filter,
without considering the compatibility of the file ,
Only insert a  picture into openoffice's write.


Yes, looks reasonable.


Look forward to your reply.
Best Regards!


Thanks, same to You. And good luck with it!


  Hi Armin:

Receipt of your reply, I modified my needs.


[..]

Sincerely,
Armin
--
ALG



Re: how Get Bitmap file from SVG module?

2012-05-29 Thread Armin Le Grand
Hi jianlizhao,

I still have to guess what you want to do, but it sounds like:
- Insert raw data file to draw/Impress
- A special extension uses that data to proccess something and outputs a
text file
- That extension creates a Bitmap/BitmapEx AOO can display

If this is correct I see no real reason to implement/embed this
internally in AOO. If you only need the raw data in your extension, why
use AOO for it and create a file format which is potentially very big?
Why not load the raw data from an app which needs it and processes it
(the extension itself)? It seems so specialized that I would think about
a specialized solution. When you already put a *.txt file with results
next to the ODF, why not also let the raw data be aside the ODF file?
Why do you need Draw/Impress at all?

Maybe I'm wrong, still guessing your needs and plan.

On 25.05.2012 03:27, jianlizhao wrote:
 Hi Armin:
 Receipt of your reply, I modified my needs.
 
 The original picture I do not need to display and modify,only to provide
 data to the extension,used for data analysis and processing. This process
 does not need to show only need end result, the end result is saved to a TXT
 file.
 
 All requirements are summarized as follows:
 1)On screen Display bmp or png file, the bmp or png converted from the
 original pictures.

Yes. Who converts this? Which instance?

 2) In the save file include two files, one is the original file.
 In order to achieve compatibility.

Only useful when the extension is installed, no extra use for the
standard user, but much bigger files?

 3)on screen when the user delete the BMP file,in the save file, the file
 related to this BMP files do not save,that is also deleted.
 
 4)In the extension, the original file for data analysis and processing, and
 processing the results are saved to txt file.
 It should be based on the screen select the BMP file,access to the
 corresponding original file.
 
 Do you have any good suggestions.

See above!

 Thanks...
 Best Regards!
 
 
[..]

Sincerely,
Armin
--
ALG



Re: how Get Bitmap file from SVG module?

2012-05-24 Thread Armin Le Grand

Hi Eric,

On 24.05.2012 03:43, Yong Lin Ma wrote:

Let me try to translate the message below.


Thanks, that helped. Ansering below...


Hi Armin,
I see two interfaces XSVGPrinter and XSVGWriter in svg mdoule

Could they be used for graphic in Bitmap format?


No.


For function extractFromGraphic in svgimagenode

void extractFromGraphic (
 const Graphic  rGraphic
 drawinglayer :: primitive2d :: Primitive2DSequence  rEmbedded,
 basegfx :: B2DRange  rViewBox,
 BitmapEx  rBitmapEx)

What is parameter rBitmapEx work for?


This is a helper method in module svxio. It is not exported from the 
svgio module to make that clear. It should not be called directly and 
may change in the future.


Instead, use the classes Graphic and GraphicObject and work with the 
SvgData class used there if you want to do something in the environment 
of the office core code.


From outside you may use the service XSvgParser to convert from 
io::XInputStream to uno::Sequence uno::Reference 
::graphic::XPrimitive2D   (the imported primitive representation of 
the SVG). Then use the service XPrimitive2DRenderer to convert such a 
primitive to a rendering::XBitmap. Grep the code to find usage examples.


HTH!


On Wed, May 23, 2012 at 5:06 PM, jianlizhaojianlizh...@hotmail.com  wrote:

Hi Armin:
I ask you some question as below:
In  module svg, have two Interfaces, one is  XSVGPrinter, the other is
XSVGWriter.

1) Can I use these interfaces, output Bitmap file?

2) under the module svg, in the file of svgimagenode.cxx,

void extractFromGraphic (
const Graphic  rGraphic
drawinglayer :: primitive2d :: Primitive2DSequence  rEmbedded,
basegfx :: B2DRange  rViewBox,
BitmapEx  rBitmapEx)

is the  parameters rBitmapEx get Bitmap file?

Thanks...
Best Regards!








Re: how Get Bitmap file from SVG module?

2012-05-24 Thread Armin Le Grand
Hi jianlizhao,

On 24.05.2012 10:57, jianlizhao wrote:
 Hi Armin:
 Read your letter, I know my idea is stupid.
 
 I would like to achieve an ADDON expansion in openoffice's write,
 The extension function is plug a new type of picture into openoffice's
 write, need following requirements
 
 1) There were also ODF-compatible File Format adaptions needed.That is to
 say,
 That is not installed the extended  on the openoffice's write  can open
 the saved file.
 2) If the extension is installed, can use the extended functionality to deal
 with the inserted picture.
 
 This function is very similar to  your SVGIO, so I need to look deeper
 SVGIO.

Sorry, it is not similar and I would not suggest svgio as an example to
extend for picture formats. The way to extend picture formats is to look
at how e.g. png, jpeg and others are handled in the office and to extend
these by a filter. Be warned, this is a complex (and fragile) system
which will need a lot of care.

Your raw format is pixel data, so this will fit much better than svgio.
Svgio needed an exception to be hold at Graphic/GraphicObject at all,
this will not be needed for another pixel-based format and thus is a
very bad example for your case.

All this would need to be done in the core, there are deep vcl- and
tools-based mechanisms behind this, including the GraphicManager who
will automatically buffer the picture data and import/export it on
demand to rduce mem footprint. I think it cannot be done as an extension.

What you could do in an extension is to implement the loader (raw data
to Bitmap/BitmapEx) and insert that pixel data using API to the writer
somehow. It will then not be embedded as the original raw bitmap data,
but it will be in the system in a compatible way.

HTH!

 Then modeled this idea, realization my needs.
 
 I have installed openoffice's SDK.Debugging through a simple C++ example of
 the addon.
 Do you have any good suggestions.
 
 Thanks...
 Best Regards!
 
 
 
 -邮件原件-
 发件人: Armin Le Grand [mailto:armin.le.gr...@me.com]
 发送时间: 2012年5月23日 20:51
 收件人: ooo-dev@incubator.apache.org
 主题: Re: how Get Bitmap file from SVG module?
 
   Hi jianlizhao,
 
 On 23.05.2012 11:06, jianlizhao wrote:
 Hi Armin:
 I ask you some question as below:
 In  module svg, have two Interfaces, one is  XSVGPrinter, the other is
 XSVGWriter.
 
 Both are interfaces, XSVGPrinter is not used at all and XSVGWriter is
 the current SVG export which has nothing to do with the new import.
 There also is no module svg, the module I added for the new SVG import
 is svgio.
 
 1) Can I use these interfaces, output Bitmap file?
 
 No.
 
 2) under the module svg, in the file of svgimagenode.cxx,

 void extractFromGraphic (
   const Graphic   rGraphic
   drawinglayer :: primitive2d :: Primitive2DSequence
 rEmbedded,
   basegfx :: B2DRange   rViewBox,
   BitmapEx   rBitmapEx)

 is the  parameters rBitmapEx get Bitmap file?
 
 I am not sure what you want to do. To work with imported SVGs you need a
 Graphic (see vcl and GraphicObject, too) where it is loaded. From
 Graphic you may try
 
   const SvgDataPtr  getSvgData() const;
 
 If getSvgData().is() there is a SVG graphic. At the contained SvgData
 you can use
 
   const BitmapEx  getReplacement() const;
 
 to get the BitmapEx of the SVG. There is no need to work with stuff from
 svgio directly. All usages work with it are using the service XSvgParser
 and do the work for you, where XSvgParser is implemented in svgio.
 
 I still do not understand what you want to do, please explain this, else
 I cannot really help you.
 
 Thanks...
 Best Regards!


 
 Sincerely,
   Armin
 --
 ALG
 
 
 




Re: how Get Bitmap file from SVG module?

2012-05-24 Thread Armin Le Grand
Hi jianlizhao,

On 24.05.2012 16:07, jianlizhao wrote:
 Hi Armin:
 I am very glad to receipt your letter,
 
 I see the following content in your blog:
 There were also ODF-compatible File Format adaptions needed, more concrete
 the in ODF already contained and described multi-image support. In ODF, the
 original SVG is now embedded to the 'Pictures' folder inside the ODF file as
 one would expect from such a feature and can be easily extracted (unzip the
 ODF file and there you are). There is also a Png file written as replacement
 image. The draw:frame is now multi-image capable (as the spec allows). In
 the case of a SVG it writes a good quality Png and the original SVG as
 draw:image elements. Since older (and other) office versions are only
 capable of loading a single (and thus the first) image, the Png is written
 first. This allows file exchange with other and older offices without
 breaking backward compatibility and/or ODF file exchange.
 
 I have two questions :
 1) I would also like to use this method to insert the picture, so that in
 document will retain the original file, the original file  is there are
 other useful.

To achieve this you have to add the needed code to the core (similar as
jpeg and png are added). This includes import code to get the data into
a Bitmap/BitmapEx. This is uniquely held (using a unique ID calculated
based on the bitmap data, there is one calculation defined for each
format) at the GraphicManager and can be accessed using
Graphic/GraphicObject.
AFAIK it is also possible to hold the original raw data at the entry in
the GraphicManager (to be able to write the original again in unchanged
form without needing to export it to it's format).
The feature you mentioned above is needed for file formats which differ
in content, in Your case this is not needed since a e.g. reduced data
BitmapEx can be recreated without data loss from your raw data. It makes
no sense to write both, so no need for this feature.

 2) How do I access the original file.

The Graphic holding it (and the contact with the GraphicManager) may
have it as raw data, but also has a link to a temporary storage (using
the temp on your system) where it is swapped out.
To Access, use Graphic/GraphicObject. I repeat here: It is no easy task
to add a graphic format to the core. I'm also not the specialist for
that, maybe someone else knows in more details about exactly what steps
have to be done to implement it.

HTH!

 Thanks...
 Best Regards!
 
 
 -邮件原件-
 发件人: Armin Le Grand [mailto:armin.le.gr...@me.com]
 发送时间: 2012年5月24日 18:10
 收件人: ooo-dev@incubator.apache.org
 主题: Re: how Get Bitmap file from SVG module?
 
   Hi jianlizhao,
 
[..]

Sincerely,
Armin
--
ALG



Re: how Get Bitmap file from SVG module?

2012-05-23 Thread Regina Henschel

Hi jianlizhao,

it is still not clear to me, what you want to do:

Do you want to write macros or extensions and need help to use the API?

or

Do you want to work on the core itself. If it is this, what do you want 
to do? What feature do you want to implement or what bug do you want to fix?


jianlizhao schrieb:

Hi Armin:
I ask you some question as below:
In  module svg, have two Interfaces, one is  XSVGPrinter, the other is
XSVGWriter.

1) Can I use these interfaces, output Bitmap file?


If you will use the API the interface XGraphicRasterizer seems to be the 
correct one.




2) under the module svg, in the file of svgimagenode.cxx,

void extractFromGraphic (
 const Graphic  rGraphic
 drawinglayer :: primitive2d :: Primitive2DSequence  rEmbedded,
 basegfx :: B2DRange  rViewBox,
 BitmapEx  rBitmapEx)

is the  parameters rBitmapEx get Bitmap file?


As far as I understand it, you have to use methode getDecomposition from 
XSvgParser and then method rasterize from XPrimitve2DRenderer. But Armin 
can surely tell it, he had implemented it ;)


Kind regards
Regina


Re: how Get Bitmap file from SVG module?

2012-05-23 Thread Armin Le Grand

Hi jianlizhao,

On 23.05.2012 11:06, jianlizhao wrote:

Hi Armin:
I ask you some question as below:
In  module svg, have two Interfaces, one is  XSVGPrinter, the other is
XSVGWriter.


Both are interfaces, XSVGPrinter is not used at all and XSVGWriter is 
the current SVG export which has nothing to do with the new import. 
There also is no module svg, the module I added for the new SVG import 
is svgio.



1) Can I use these interfaces, output Bitmap file?


No.


2) under the module svg, in the file of svgimagenode.cxx,

void extractFromGraphic (
 const Graphic  rGraphic
 drawinglayer :: primitive2d :: Primitive2DSequence  rEmbedded,
 basegfx :: B2DRange  rViewBox,
 BitmapEx  rBitmapEx)

is the  parameters rBitmapEx get Bitmap file?


I am not sure what you want to do. To work with imported SVGs you need a 
Graphic (see vcl and GraphicObject, too) where it is loaded. From 
Graphic you may try


const SvgDataPtr getSvgData() const;

If getSvgData().is() there is a SVG graphic. At the contained SvgData 
you can use


const BitmapEx getReplacement() const;

to get the BitmapEx of the SVG. There is no need to work with stuff from 
svgio directly. All usages work with it are using the service XSvgParser 
and do the work for you, where XSvgParser is implemented in svgio.


I still do not understand what you want to do, please explain this, else 
I cannot really help you.



Thanks...
Best Regards!




Sincerely,
Armin
--
ALG



Re: how Get Bitmap file from SVG module?

2012-05-23 Thread Yong Lin Ma
Let me try to translate the message below.

Hi Armin,
I see two interfaces XSVGPrinter and XSVGWriter in svg mdoule

Could they be used for graphic in Bitmap format?

For function extractFromGraphic in svgimagenode

void extractFromGraphic (
const Graphic  rGraphic
drawinglayer :: primitive2d :: Primitive2DSequence  rEmbedded,
basegfx :: B2DRange  rViewBox,
BitmapEx  rBitmapEx)

What is parameter rBitmapEx work for?

On Wed, May 23, 2012 at 5:06 PM, jianlizhao jianlizh...@hotmail.com wrote:
 Hi Armin:
 I ask you some question as below:
 In  module svg, have two Interfaces, one is  XSVGPrinter, the other is
 XSVGWriter.

 1) Can I use these interfaces, output Bitmap file?

 2) under the module svg, in the file of svgimagenode.cxx,

 void extractFromGraphic (
            const Graphic  rGraphic
            drawinglayer :: primitive2d :: Primitive2DSequence  rEmbedded,
            basegfx :: B2DRange  rViewBox,
            BitmapEx  rBitmapEx)

 is the  parameters rBitmapEx get Bitmap file?

 Thanks...
 Best Regards!