Bundle-PBib

 view release on metacpan or  search on metacpan

lib/PBibTk/RefDialog.pm  view on Meta::CPAN

	my $text = $conv->itemStyle()->formatWith($paper->{'CiteKey'});
#	$text = $conv->outDoc()->replace_xchars($text);
	$self->textWidget()->insert("end", "$text\n\n");
	$self->textWidget()->mark(qw/set insert end/);
	#  $self->textWidget()->yview(-pickplace, "end"); # or use "see"
	$self->textWidget()->see("end");
}



#
#
# BP
#
#

sub importText {
	my ($self, $format) = @_;
	print STDERR "importText\n";
	my $text = $self->textWidget()->get("0.0", "end");
	$text =~ s/^\s*>+\s*(\w+).*\n//;
	$format = $1 unless $format;
	unless( $format ) {
		$format = 'bibtex' if $text =~ /^\s*@/;
		$format = 'endnote' if $text =~ /^\s*%/;
		$format = 'rfc1807' if $text =~ /\w::\s/;
	}
	unless( $format ) {
		print STDERR "cannot identify format!\n";
		return;
	}
	print STDERR "import using format $format\n";
	print STDERR $text;
	
	Biblio::BP::format($format, 'canon:8859-1');
	%bp_util::glb_keyreg = (); # clear key registry
print "tocanon - explode\n";
	my %rec = Biblio::BP::tocanon(Biblio::BP::explode($text));
print "--> ", Dumper(\%rec);
print "canon_to_pbib\n";
	%rec = Biblio::BP::canon_to_pbib(%rec);
print "--> ", Dumper(\%rec);
	$self->biblio()->storePaper(\%rec)
}

sub exportAsText {
	my ($self, $format) = @_;
	print STDERR "export as $format\n";
	
	Biblio::BP::format('canon:8859-1', $format);
	%bp_util::glb_keyreg = (); # clear key registry
	my %rec = Biblio::BP::pbib_to_canon(%{$self->paper()});
	my $text = Biblio::BP::implode(Biblio::BP::fromcanon(%rec));
	
	#  print "delete:\n";
	$self->textWidget()->delete("0.0", "end");
	#  print "insert:\n";
	$self->textWidget()->insert("end", "\n> $format\n\n$text\n\n");
	#  print "mark:\n";
	$self->textWidget()->mark(qw/set insert end/);
	$self->textWidget()->see("0.0"); # move cursor to beginning
	#  $self->textWidget()->tagAdd('sel', "0.0", 'end'); # set selection??
}


#
#
# access to PBib
#
#

sub conv {
	my $self = shift;
	return $self->pBibTkUI()->{'conv'};
}


#myline runter --------------------------------------------------------
sub formatRefInfos {
	my $self = shift;
	my $paper = shift;
	my $conv = shift;

	my $head = $self->defaultTitle($paper);
	my $ref = $self->formattedRefIEEETR($paper, $conv);
	return ($head, $ref);
}

sub formattedRefIEEETR {
	my ($self, $paper) = @_;
	my $back = $self->formattedRef($paper,
		'itemStyle'	=> new PBib::BibItemStyle::IEEETR
	);
	return $back;
}
sub formattedRef {
	my $self = shift;
	my $paper = shift;
	my %args = @_;
	my $text = $self->conv()->itemStyle()->formatWith($paper->{'CiteKey'});
	return $text;
}
#myline hoch --------------------------------------------------------


1;

#
# $Log: LitUIRefDialog.pm,v $
# Revision 1.21  2004/03/30 19:19:39  krugar
# refactored: 
# 	LitUIRefDialog -> LitUI::RefDialog 
#	LitUISearchDialog -> LitUI::SearchDialog 
#

# Revision 1.20  2004/03/29 13:12:34  tandler
# box to see refs
#
# Revision 1.19  2003/12/22 21:59:41  tandler
# toni's changes: include explaination field in UI
#



( run in 2.269 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )