MCPcopy Create free account
hub / github.com/openclaw/gogcli / buildParagraphStyleRequest

Function buildParagraphStyleRequest

internal/docsformat/format.go:278–387  ·  view source on GitHub ↗
(options Options, start, end int64, tabID string)

Source from the content-addressed store, hash-verified

276}
277
278func buildParagraphStyleRequest(options Options, start, end int64, tabID string) (*docs.Request, bool, error) {
279 style := &docs.ParagraphStyle{}
280 var fields []string
281
282 if align := strings.TrimSpace(options.Alignment); align != "" {
283 resolved, err := formatAlignment(align)
284 if err != nil {
285 return nil, false, err
286 }
287 style.Alignment = resolved
288
289 fields = append(fields, "alignment")
290 }
291
292 if options.LineSpacing < 0 {
293 return nil, false, ValidationError("--line-spacing must be positive")
294 }
295
296 if options.LineSpacing > 0 {
297 style.LineSpacing = options.LineSpacing
298
299 fields = append(fields, "lineSpacing")
300 }
301
302 if spacingMode := strings.TrimSpace(options.SpacingMode); spacingMode != "" {
303 resolved, err := formatSpacingMode(spacingMode)
304 if err != nil {
305 return nil, false, err
306 }
307 style.SpacingMode = resolved
308
309 fields = append(fields, "spacingMode")
310 }
311
312 namedStyle, err := formatNamedStyle(options.HeadingLevel, options.NamedStyle)
313 if err != nil {
314 return nil, false, err
315 }
316
317 if namedStyle != "" {
318 style.NamedStyleType = namedStyle
319
320 fields = append(fields, "namedStyleType")
321 }
322
323 addDimension := func(value *float64, flag, field string, apply func(*docs.Dimension)) error {
324 if value == nil {
325 return nil
326 }
327
328 if *value < 0 {
329 return invalidf("--%s must be non-negative", flag)
330 }
331
332 dimension := &docs.Dimension{Magnitude: *value, Unit: "PT"}
333 if *value == 0 {
334 dimension.ForceSendFields = append(dimension.ForceSendFields, "Magnitude")
335 }

Callers 1

BuildRequestsFunction · 0.85

Calls 5

formatAlignmentFunction · 0.85
formatSpacingModeFunction · 0.85
formatNamedStyleFunction · 0.85
ValidationErrorTypeAlias · 0.70
invalidfFunction · 0.70

Tested by

no test coverage detected