+sub render_pasted_text_block {
+ my ($self, $text_block, %params) = @_;
+
+ if ($self->current_text_block_output_position == $text_block->output_position) {
+ my $html = $self->render('requirement_spec_text_block/_text_block', { output => 0 }, text_block => $text_block);
+ $self->js
+ ->appendTo($html, '#text-block-list')
+ ->hide('#text-block-list-empty');
+ }
+
+ my $node = $self->presenter->requirement_spec_text_block_jstree_data($text_block);
+ my $front_back = $text_block->output_position == 0 ? 'front' : 'back';
+ $self->js
+ ->jstree->create_node('#tree', "#tb-${front_back}", 'last', $node)
+ ->jstree->open_node( '#tree', "#tb-${front_back}");
+}
+
+sub render_pasted_section {
+ my ($self, $item, $parent_id) = @_;
+
+ my $node = $self->presenter->requirement_spec_item_jstree_data($item);
+ $self->js
+ ->jstree->create_node('#tree', $parent_id ? "#fb-${parent_id}" : '#sections', 'last', $node)
+ ->jstree->open_node( '#tree', $parent_id ? "#fb-${parent_id}" : '#sections');
+
+ $self->render_pasted_section($_, $item->id) for @{ $item->children_sorted };
+}
+
+sub render_first_pasted_section_as_list {
+ my ($self, $section, %params) = @_;
+
+ my $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $section);
+ $self->js
+ ->html('#column-content', $html)
+ ->val( '#current_content_type', $section->item_type)
+ ->val( '#current_content_id', $section->id)
+ ->jstree->select_node('#tree', '#fb-' . $section->id);
+}
+
+sub prepare_pictures_for_printing {
+ my ($self) = @_;
+
+ my @files;
+ my $userspath = File::Spec->rel2abs($::lx_office_conf{paths}->{userspath});
+ my $target = "${userspath}/kivitendo-print-requirement-spec-picture-" . Common::unique_id() . '-';
+
+ foreach my $picture (map { @{ $_->pictures } } @{ $self->requirement_spec->text_blocks }) {
+ my $output_file_name = $target . $picture->id . '.' . $picture->get_default_file_name_extension;
+ $picture->{print_file_name} = File::Spec->abs2rel($output_file_name, $userspath);
+ my $out = IO::File->new($output_file_name, 'w') || die("Could not create file " . $output_file_name);
+ $out->binmode;
+ $out->print($picture->picture_content);
+ $out->close;
+
+ push @files, $output_file_name;
+ }
+
+ return @files;
+}