Hello!

I would like to mass import draw files into gallery - but somehow it does not work. I saw issue related (import to gallery via UI) this problem here:
http://qa.openoffice.org/issues/show_bug.cgi?id=29819
http://qa.openoffice.org/issues/show_bug.cgi?id=58870

Also we are working on another project where we have to mass import odg files - so one of us created a macro for it. We sadly experied that odg import might have problem on UI level. Can you confirm it and fix it? Or what did we wrong?

Here is a snippet from our lettering:

"

My guess is that this is a bug, so I will probably open a bug report.

I did check the code, but there are a few things that require a much deeper understanding of the code than I have. Well, it would likely take hours to understand even though it is also likely very simple.

See svx/source/unogallery/unogaltheme.cxx

::sal_Int32 SAL_CALL GalleryTheme::insertDrawingByIndex(
const uno::Reference< lang::XComponent >& Drawing, sal_Int32 nIndex )
      throw (lang::WrappedTargetException, uno::RuntimeException)
{
      const ::vos::OGuard aGuard( Application::GetSolarMutex() );
      sal_Int32                       nRet = -1;

      if( mpTheme )
      {
GalleryDrawingModel* pModel = GalleryDrawingModel::getImplementation( Drawing );

if( pModel && pModel->GetDoc() && pModel->GetDoc()->ISA( FmFormModel ) )
              {
nIndex = ::std::max( ::std::min( nIndex, getCount() ), sal_Int32( 0 ) );

if( mpTheme->InsertModel( *static_cast< FmFormModel* >( pModel->GetDoc() ), nIndex ) )
                              nRet = nIndex;
              }
      }

      return nRet;
}



Kálmán Szalai wrote:
Andrew Douglas Pitonyak <[EMAIL PROTECTED]> 07/18/07 1:59 du. >>>
Worst case:

I will see if I can read the SVG and then export it as a different graphic type and then add that to the gallery. If we can run a different command line to convert all SVG files to something else, however, that might be easier.

---
We can convert it to ODG easily. This method is very same as SVG filter extension in OOo. So we can convert SVG->ODG -- the quality of conversion is not perfect but good enough, so it produces usable output.
--
The API looks like it claims to support a Draw document. If I do not receive an answer here, I will see if I can download the latest copy of the code, check the code and then based on what I see there, I might open a bug report. the wording sounds like it might want something other than the document (because it uses the word MODEL, but it also indicates that it wants an XComponent interface).

---
Interesting thing -- gallery - itself does not support sxd and odg files. So you can't add it to the gallery via UI. it is might caused because OOo does not support self format in gallery internally... I do not know, we mighe have to ask ka@ about this. We have an issue about non importable sxd, odg files into gallery but no progression here...


KAMI

Kálmán Szalai wrote:
Hello Andrew and Developers!

I checked the stability of SVG filter and some files not converted that
simple command line java application does. This application produce odg
files from svg, so I would like to know how we can import odg files. The
UI of gallery does not support to add odg and sxd files (interesting? -
the gallery supports many formats but not the default OpenOffice.org
formats)... Are there any way to import odg files via API?

Best regards,
KAMI

Andrew Douglas Pitonyak <[EMAIL PROTECTED]> 07/18/07 5:57 de.

OOo has very little clipart. I was asked to write a macro that will create OOo clipart galleries from existing folders of clipart.

I figured out how to insert links from a URL

oTheme.insertURLByIndex(sURL, 0)

I figured out how to insert the object as a graphic

    Dim oProvider  'GraphicProvider service.
    oProvider =
createUnoService("com.sun.star.graphic.GraphicProvider")

    Dim oProps(0) as new com.sun.star.beans.PropertyValue
    oProps(0).Name  = "URL"
    oProps(0).Value = sURL

    REM Returns a graphic object from the URL to the graphic.
    oTheme.(oProvider.queryGraphic(oProps()), 0)

Apparently, a large collection of available clipart exists in SVG
format.
I installed the SVG importer from here:
http://www.ipd.uni-karlsruhe.de/~hauma/svg-import/
I looked at the API, and it looks like I can insert a draw document directly: http://api.openoffice.org/docs/common/ref/com/sun/star/gallery/XGalleryTheme.html

I tried it using this code:

    Dim oDoc
    Dim ImportArgs(0) As New com.sun.star.beans.PropertyValue
    ImportArgs(0).Name  = "FilterName"
    ImportArgs(0).Value = "draw_svg_import"
    oDoc = StarDesktop.LoadComponentFromURL(sURL, "_blank", 0,
ImportArgs())
    If NOT IsNull(oDoc) AND NOT IsEmpty(oDoc) Then
      oTheme.insertDrawingByIndex(oDoc, 0)
      oDoc.close(True)
    End If

A -1 is returned, which means that the image was not added (I can also

see that the image is not added).

If you want to run the entire macro, it will be here until I resolve this problem (at which point, I will likely move it someplace on my macros page).

http://www.pitonyak.org/OOoGalleryImport.odt



"


Thank you in advance!
KAMI

Reply via email to