Index: trunk/src/buffer.c =================================================================== --- trunk/src/buffer.c (revision 15621) +++ trunk/src/buffer.c (revision 15622) @@ -182,7 +182,7 @@ if (!name) PCB_ACT_FAIL(LoadFootprint); - if (!pcb_element_load_to_buffer(PCB_PASTEBUFFER, name, NULL)) + if (!pcb_buffer_load_footprint(PCB_PASTEBUFFER, name, NULL)) return 1; len = pcb_subclist_length(&PCB_PASTEBUFFER->Data->subc); @@ -658,7 +658,34 @@ } } +/* loads footprint data from file/library into buffer (as subcircuit) + * returns pcb_false on error + * if successful, update some other stuff and reposition the pastebuffer */ +pcb_bool pcb_buffer_load_footprint(pcb_buffer_t *Buffer, const char *Name, const char *fmt) +{ + pcb_buffer_clear(PCB, Buffer); + if (!pcb_parse_element(Buffer->Data, Name, fmt)) { + if (conf_core.editor.show_solder_side) + pcb_buffer_flip_side(PCB, Buffer); + pcb_set_buffer_bbox(Buffer); + Buffer->X = 0; + Buffer->Y = 0; + Buffer->from_outside = 1; + + if (pcb_subclist_length(&Buffer->Data->subc)) { + pcb_subc_t *subc = pcb_subclist_first(&Buffer->Data->subc); + pcb_subc_get_origin(subc, &Buffer->X, &Buffer->Y); + } + return pcb_true; + } + + /* release memory which might have been acquired */ + pcb_buffer_clear(PCB, Buffer); + return pcb_false; +} + + /* ---------------------------------------------------------------------- */ static const char pcb_acts_PasteBuffer[] = Index: trunk/src/buffer.h =================================================================== --- trunk/src/buffer.h (revision 15621) +++ trunk/src/buffer.h (revision 15622) @@ -93,6 +93,8 @@ /* change the side of all objects in the buffer */ void pcb_buffer_flip_side(pcb_board_t *pcb, pcb_buffer_t *Buffer); +/* Load a footprint by name into a buffer; fmt is optional (may be NULL). */ +pcb_bool pcb_buffer_load_footprint(pcb_buffer_t *Buffer, const char *Name, const char *fmt); /* sets currently active buffer */ void pcb_buffer_set_number(int Number); Index: trunk/src/file_act.c =================================================================== --- trunk/src/file_act.c (revision 15621) +++ trunk/src/file_act.c (revision 15622) @@ -36,6 +36,7 @@ #include "build_run.h" #include "conf_core.h" #include "data.h" +#include "buffer.h" #include "action_helper.h" #include "plug_io.h" @@ -128,7 +129,7 @@ if (pcb_strcasecmp(function, "ElementToBuffer") == 0) { pcb_notify_crosshair_change(pcb_false); - if (pcb_element_load_to_buffer(PCB_PASTEBUFFER, name, format)) + if (pcb_buffer_load_footprint(PCB_PASTEBUFFER, name, format)) pcb_crosshair_set_mode(PCB_MODE_PASTE_BUFFER); pcb_notify_crosshair_change(pcb_true); } Index: trunk/src/obj_elem.c =================================================================== --- trunk/src/obj_elem.c (revision 15621) +++ trunk/src/obj_elem.c (revision 15622) @@ -58,35 +58,6 @@ /*** utility ***/ -#warning subc TODO: move this to obj_subc.c -/* loads footprint data from file/library into buffer (as subcircuit) - * returns pcb_false on error - * if successful, update some other stuff and reposition the pastebuffer */ -pcb_bool pcb_element_load_to_buffer(pcb_buffer_t *Buffer, const char *Name, const char *fmt) -{ - pcb_buffer_clear(PCB, Buffer); - if (!pcb_parse_element(Buffer->Data, Name, fmt)) { - if (conf_core.editor.show_solder_side) - pcb_buffer_flip_side(PCB, Buffer); - pcb_set_buffer_bbox(Buffer); - - Buffer->X = 0; - Buffer->Y = 0; - Buffer->from_outside = 1; - - if (pcb_subclist_length(&Buffer->Data->subc)) { - pcb_subc_t *subc = pcb_subclist_first(&Buffer->Data->subc); - pcb_subc_get_origin(subc, &Buffer->X, &Buffer->Y); - } - return pcb_true; - } - - /* release memory which might have been acquired */ - pcb_buffer_clear(PCB, Buffer); - return pcb_false; -} - - void *pcb_element_remove(pcb_element_t *Element) { void *res;