Class Selection

Zaznaczenie

Wybór użytkownika w aktywnej prezentacji.

var selection = SlidesApp.getActivePresentation().getSelection();
var currentPage = selection.getCurrentPage();
var selectionType = selection.getSelectionType();
}

Metody

MetodaZwracany typKrótki opis
getCurrentPage()PageZwraca obecnie aktywną właściwość Page lub null, jeśli nie ma aktywnej strony.
getPageElementRange()PageElementRangeZwraca kolekcję PageElementRange wybranych instancji PageElement lub null, jeśli nie wybrano żadnych instancji PageElement.
getPageRange()PageRangeZwraca PageRange kolekcję Page instancji, która jest wybrana we flamingu, lub null, jeśli wybór nie jest typu SelectionType.PAGE.
getSelectionType()SelectionTypeZwraca wartość SelectionType.
getTableCellRange()TableCellRangeZwraca kolekcję TableCellRange wybranych instancji TableCell lub null, jeśli nie wybrano żadnych instancji TableCell.
getTextRange()TextRangeZwraca TextRange (wybrany) lub null, jeśli wybór nie jest SelectionType.TEXT.

Szczegółowa dokumentacja

getCurrentPage()

Zwraca obecnie aktywną właściwość Page lub null, jeśli nie ma aktywnej strony.

var selection = SlidesApp.getActivePresentation().getSelection();
var currentPage = selection.getCurrentPage();
if (currentPage != null) {
  Logger.log('Selected current active page ID: ' + currentPage.getObjectId());
}

Zwróć

Page

Autoryzacja

Skrypty korzystające z tej metody wymagają autoryzacji przy użyciu co najmniej jednego z tych zakresów:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPageElementRange()

Zwraca kolekcję PageElementRange wybranych instancji PageElement lub null, jeśli nie wybrano żadnych instancji PageElement.

var selection = SlidesApp.getActivePresentation().getSelection();
var selectionType = selection.getSelectionType();
if (selectionType == SlidesApp.SelectionType.PAGE_ELEMENT) {
  var currentPage = selection.getCurrentPage();
  var pageElements = selection.getPageElementRange().getPageElements();
  Logger.log('Number of page elements selected: ' + pageElements.length);
}

Zwróć

PageElementRange

Autoryzacja

Skrypty korzystające z tej metody wymagają autoryzacji przy użyciu co najmniej jednego z tych zakresów:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPageRange()

Zwraca PageRange kolekcję Page instancji, która jest wybrana we flamingu, lub null, jeśli wybór nie jest typu SelectionType.PAGE.

var selection = SlidesApp.getActivePresentation().getSelection();
var selectionType = selection.getSelectionType();
if (selectionType == SlidesApp.SelectionType.PAGE) {
  var pageRange = selection.getPageRange();
  Logger.log('Number of pages in the flimstrip selected: ' + pageRange.getPages().length);
}
}

Zwróć

PageRange

Autoryzacja

Skrypty korzystające z tej metody wymagają autoryzacji przy użyciu co najmniej jednego z tych zakresów:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getSelectionType()

Zwraca wartość SelectionType.

var selection = SlidesApp.getActivePresentation().getSelection();
var selectionType = selection.getSelectionType();
if (selectionType == SlidesApp.SelectionType.CURRENT_PAGE) {
  var currentPage = selection.getCurrentPage();
  Logger.log('Selected current active page ID: ' + currentPage.getObjectId());
}

Zwróć

SelectionType

Autoryzacja

Skrypty korzystające z tej metody wymagają autoryzacji przy użyciu co najmniej jednego z tych zakresów:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getTableCellRange()

Zwraca kolekcję TableCellRange wybranych instancji TableCell lub null, jeśli nie wybrano żadnych instancji TableCell.

var selection = SlidesApp.getActivePresentation().getSelection();
var selectionType = selection.getSelectionType();
if (selectionType == SlidesApp.SelectionType.TABLE_CELL) {
  var currentPage = selection.getCurrentPage();
  var tableCells = selection.getTableCellRange().getTableCells();
  var table = tableCells[0].getParentTable();
  Logger.log('Number of table cells selected: ' + tableCells.length);
}

Zwróć

TableCellRange

Autoryzacja

Skrypty korzystające z tej metody wymagają autoryzacji przy użyciu co najmniej jednego z tych zakresów:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getTextRange()

Zwraca TextRange (wybrany) lub null, jeśli wybór nie jest SelectionType.TEXT.

TextRange oznacza 2 sytuacje:

1. Wybrano zakres tekstu. Na przykład jeśli kształt zawiera tekst "Cześć", &&tt;He" zwracany jest zakres TextRange.getStartIndex() = 0, a TextRange.getEndIndex() = 2.

2. Pozycja kursora. Na przykład jeśli kształt zawiera tekst "Cześć", a kursor znajduje się po &&tt;H", ("H|ello"), zwracany zakres ma TextRange.getStartIndex() = 1 i TextRange.getEndIndex() = 1.

var selection = SlidesApp.getActivePresentation().getSelection();
var selectionType = selection.getSelectionType();
if (selectionType == SlidesApp.SelectionType.TEXT) {
  var currentPage = selection.getCurrentPage();
  var pageElement = selection.getPageElementRange().getPageElements()[0];
  var textRange = selection.getTextRange();
  Logger.log('Text selected: ' + textRange.asString());
}

Zwróć

TextRange

Autoryzacja

Skrypty korzystające z tej metody wymagają autoryzacji przy użyciu co najmniej jednego z tych zakresów:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations