l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
July 21: Defensive computing: Information security for individuals
Next Installfest:
TBD
Latest News:
Jul. 4: July, August and September: Security, Photography and Programming for Kids
Page last updated:
2002 Oct 29 21:01

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Dia & Visio
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Dia & Visio



You did a lot of work!  Thanks!

On Tue, 2002-10-29 at 19:16, Charles Polisher wrote:
> Ryan wrote:
> > I should think visio can export to some sane format. I'll check at work 
> > tomorrow
> 
> I seem to remember that Visio will export in Adobe Illustrator
> format, which is actually PostScript under the hood. It
> might be possible to walk Visio's internal data structures in 
> Ivfhny Onfvp and home-brew your own exporter. Or in Perl,
> maybe something like:
> 
> 
> 
> 
> 
> 
> #
> # -*- Perl -*-
> # $Id: olevisio.pl,v 0.01 2002/02/25 21:00:00 Y.Fujiyama Exp $
> #                  v 0.10 2002/03/30 12:00:00 Y.Fujiyama BugFix
> #                  v 0.10 2002/04/05 12:00:00 Y.Fujiyama Bigin Block Test
> 
> package olevisio;
> #use strict;
> require 'util.pl';
> require 'gfilter.pl';
> use Win32::OLE;
> use Win32::OLE::Enum;
> use Win32::OLE::Const;
> 
> 
> #BEGIN {
> #
> #    my $vsd;
> #    eval {$vsd = Win32::OLE->GetActiveObject('Visio.Application')};
> #    die "Visio not installed" if $@;
> #    unless (defined $vsd) {
> #        $vsd = Win32::OLE->new('Visio.Application', sub {$_[0]->Quit;})
> #            or die "Oops, cannot start Visio";
> #    }
> #
> #    #Visible VisioWindow
> #
> #    $Win32::OLE::Warn = 0;
> #    $vsd->{Visible} = 0;    #After Visio2000 Use Only
> #    $vsd->{AlertResponse} = 2;
> #
> #    #Dumy ioNewDocument
> #    $vsd->Documents->Add("");
> #}
> 
> END {
> #    eval {$vsd = Win32::OLE->GetActiveObject('Visio.Application')};
> #    die "Visio not installed" if $@;
> #    unless (defined $vsd) {
> #        $vsd = Win32::OLE->new('Visio.Application', sub {$_[0]->Quit;})
> #            or die "Oops, cannot start Visio";
> #    }
>     if (defined $vsd) {
>         util::vprint("Visio->Quit\n");
>         $vsd->Quit;
>         undef $vsd;
>     }
> }
> 
> sub mediatype() {
>     return ('application/visio');
> }
> 
> sub status() {
>     open (SAVEERR,">&STDERR");
>     open (STDERR,">nul");
>     my $const;
>     $const = Win32::OLE::Const->Load("Visio 2000 Type Library*");
> #    $const = Win32::OLE::Const->Load("Visio 5.0 Type Library*") unless $const;
> #    $const = Win32::OLE::Const->Load("Visio 4.1 Type Library*") unless $const;
>     open (STDERR,">&SAVEERR");
>     return 'yes' if (defined $const);
>     return 'no';
> }
> 
> sub recursive() {
>     return 0;
> }
> 
> sub pre_codeconv() {
>     return 0;
> }
> 
> sub post_codeconv () {
>     return 1;
> }
> 
> sub add_magic ($) {
>     my ($magic) = @_;
> 
>     $magic->addFileExts('\\.vsd$', 'application/visio');
>     return;
> }
> 
> sub filter ($$$$$) {
>     my ($orig_cfile, $cont, $weighted_str, $headings, $fields) = @_;
> 
>     my $cfile = defined $orig_cfile ? $$orig_cfile : '';
> 
>     util::vprint("Processing visio file ... (using  'Win32::OLE->new Visio.Application')\n");
> 
>     $cfile =~ s/\//\\/g;
>     $$cont = "";
>     ReadVSD::ReadVSD($cfile, $cont, $fields);
>     $cfile = defined $orig_cfile ? $$orig_cfile : '';
> 
>     gfilter::line_adjust_filter($cont);
> #    gfilter::line_adjust_filter($weighted_str);
>     gfilter::white_space_adjust_filter($cont);
>     $fields->{'title'} = gfilter::filename_to_title($cfile, $weighted_str)
>         unless $fields->{'title'};
>     gfilter::show_filter_debug_info($cont, $weighted_str, $fields, $headings);
> 
>     return undef;
> }
> 
> 
> sub enum ($$$) {
>     my ($enum_objs, $func, $cont) = @_;
> 
>     die "No Objects or No Function" unless ($enum_objs and $func );
> 
>     my $e = Win32::OLE::Enum->new($enum_objs);
>     while(($obj = $e->Next)) {
>         return 0 if (!&$func($obj, $cont));
>     }
>     return 1;
> }
> 
> sub getProperties ($$) {
>     my ($cfile, $fields) = @_;
> 
> 
>     my $title = $cfile->Title;
>     util::vprint("Title .. $title\n");
>     $title = $cfile->Subject
>         unless (defined $title);
>     util::vprint("SubjectTitle .. $title\n");
>     $fields->{'title'} = codeconv::shiftjis_to_eucjp($title)
>         if (defined $title);
> 
>     my $author = $cfile->Creator;
>     util::vprint("Creator .. $author\n");
>     $author = $cfile->Application->{UserName}
>         unless (defined $author);
>     $fields->{'author'} = codeconv::shiftjis_to_eucjp($author)
>         if (defined $author);
> 
> 
>     return undef;
> }
> 
> package ReadVSD;
> 
> sub ReadVSD ($$$) {
>     my ($cfile, $cont, $fields) = @_;
> 
>     my $vsd;
>     eval {$vsd = Win32::OLE->GetActiveObject('Visio.Application')};
>     die "Visio not installed" if $@;
>     unless (defined $vsd) {
>         $vsd = Win32::OLE->new('Visio.Application', sub {$_[0]->Quit;})
>             or die "Oops, cannot start Visio";
>     }
> 
>     #Visible VisioWindow
> 
>     $Win32::OLE::Warn = 0;
>     $vsd->{Visible} = 0;    #After Visio2000 Use Only
>     $vsd->{AlertResponse} = 2;
> 
>     # Redirect stderr to null device, to ignore Error and Exception message.
>     open (SAVEERR,">&STDERR");
>     open (STDERR,">nul");
> 
>     # Load Office 97/98/2000 Constant
>     my $office_consts;
>     $office_consts = Win32::OLE::Const->Load("Visio 2000 Type Library*");
> #    $const = Win32::OLE::Const->Load("Visio 5.0 Type Library*") unless $const;
> #    $const = Win32::OLE::Const->Load("Visio 4.1 Type Library*") unless $const;
> 
>     open (STDERR,">&SAVEERR");
> 
>     my $vdoc = $vsd->Documents->OpenEx({
>         'FileName' => $cfile,
>         'Flags'=> 11        #OpenEx Flags ( 1:OpenCopy + 2:ReadOnly + 8:DontList      + 16:OpenMinimized???  )
>         });
>     die "Cannot open File $cfile" unless (defined $vdoc);
> 
>     olevisio::getProperties($vdoc, $fields);
> 
>     my $vpage = $vdoc->Pages;
>     my $vpagcnt = $vpage->{Count};
> 
>     for ( my $vpageno = 1; $vpageno <= $vpagcnt; $vpageno++ ){
>         my $pagename = $vpage->Item($vpageno)->{Name};
>         util::vprint("Page .. $pagename\n");
>         chomp($pagename);
>         $$cont .= "$pagename\n" if (defined $pagename);
>         my $vshapecnt = $vpage->Item($vpageno)->Shapes->{Count};
>         for (my $vshapeno = 1; $vshapeno <= $vshapecnt; $vshapeno++ ){
>             if ($vpage->Item($vpageno)->Shapes->Item($vshapeno)->{CharCount} > 0 ){
>                 my $shapetext = $vpage->Item($vpageno)->Shapes->Item($vshapeno)->Characters->{TextAsString};
>                 chomp($shapetext);
>                 $$cont .= "$shapetext\n" if (defined $shapetext);
>             }
>         }
>         undef $vshapeno;
>     }
>     undef $vpageno;
>     undef $vpagcnt;
> 
>     $vdoc->close();
>     undef $vdoc;
> 
> #    When You Use BIGIN Block , Comment Out 3 Line.
>     util::vprint("Visio->Quit\n");
>     $vsd->Quit;
>     undef $vsd;
> 
>     return undef;
> }
> 
> ...but hey, that's just a guess ;^)
> 
> ( npghnyyl gung pbzrf evtug bss gur jro ng 
> http://216.239.37.100/search?q=cache:hgE6ki7L5p8C:search.namazu.org/ml
>        /namazu-win32-users-ja/msg01347.html+Visio+Perl&hl=en&ie=UTF-8 
> )
> 
> 
> Also have a look at: http://public.logica.com/~redferni/emf/,
> and http://www.lysator.liu.se/~alla/dia/links.html
> 
> HTH, HAND
> 
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech
> 


_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.