Esempio n. 1
0
        private void AddHeaderLine(string text, List <Request> requests, int header, bool newline = true)
        {
            if (newline)
            {
                AddTextLine(text, requests);
            }
            else
            {
                AddText(text, requests);
            }

            Request request = new Request();
            UpdateParagraphStyleRequest updateParagraphStyleRequest = new UpdateParagraphStyleRequest();

            Google.Apis.Docs.v1.Data.Range range = new Google.Apis.Docs.v1.Data.Range();

            if (newline)
            {
                range.StartIndex = CurrentIndex - 1 - text.Length;
            }
            else
            {
                range.StartIndex = CurrentIndex - text.Length;
            }
            range.EndIndex = CurrentIndex;
            ParagraphStyle paragraphStyle = new ParagraphStyle();

            switch (header)
            {
            case 1:
                paragraphStyle.NamedStyleType = "HEADING_1";
                break;

            case 2:
                paragraphStyle.NamedStyleType = "HEADING_2";
                break;

            case 3:
                paragraphStyle.NamedStyleType = "HEADING_3";
                break;

            default:
                throw new Exception("Invalid header");
            }

            updateParagraphStyleRequest.Range          = range;
            updateParagraphStyleRequest.ParagraphStyle = paragraphStyle;
            updateParagraphStyleRequest.Fields         = "*";
            request.UpdateParagraphStyle = updateParagraphStyleRequest;

            requests.Add(request);
        }
Esempio n. 2
0
        private void AddParagraph(string text, List <Request> requests)
        {
            AddTextLine(text, requests);

            Request request = new Request();
            UpdateParagraphStyleRequest updateParagraphStyleRequest = new UpdateParagraphStyleRequest();

            Google.Apis.Docs.v1.Data.Range range = new Google.Apis.Docs.v1.Data.Range();
            range.StartIndex = CurrentIndex - 1 - text.Length;
            range.EndIndex   = CurrentIndex;
            ParagraphStyle paragraphStyle = new ParagraphStyle();

            paragraphStyle.NamedStyleType = "NORMAL_TEXT";

            updateParagraphStyleRequest.Range          = range;
            updateParagraphStyleRequest.ParagraphStyle = paragraphStyle;
            updateParagraphStyleRequest.Fields         = "*";
            request.UpdateParagraphStyle = updateParagraphStyleRequest;

            requests.Add(request);
        }