API: Improve handling of compound shapes

This commit is contained in:
Jon Evans
2024-11-28 17:58:23 -05:00
parent 7a9cb919dc
commit 0d7588bdfb
3 changed files with 25 additions and 18 deletions
+14 -3
View File
@@ -125,11 +125,21 @@ HANDLER_RESULT<GetTextAsShapesResponse> API_HANDLER_COMMON::handleGetTextAsShape
{
GetTextAsShapesResponse reply;
for( const Text& textMsg : aMsg.text() )
for( const TextOrTextBox& textMsg : aMsg.text() )
{
Text dummyText;
const Text* textPtr = &textMsg.text();
if( textMsg.has_textbox() )
{
dummyText.set_text( textMsg.textbox().text() );
dummyText.mutable_attributes()->CopyFrom( textMsg.textbox().attributes() );
textPtr = &dummyText;
}
EDA_TEXT text( pcbIUScale );
google::protobuf::Any any;
any.PackFrom( textMsg );
any.PackFrom( *textPtr );
if( !text.Deserialize( any ) )
{
@@ -148,7 +158,8 @@ HANDLER_RESULT<GetTextAsShapesResponse> API_HANDLER_COMMON::handleGetTextAsShape
{
EDA_SHAPE proxy( *subshape );
proxy.Serialize( any );
any.UnpackTo( entry->mutable_shapes() );
GraphicShape* shapeMsg = entry->mutable_shapes()->add_shapes();
any.UnpackTo( shapeMsg );
}
}