// get information about a current floating object public static string GetInformationAboutCurrentFloatingObject(FloatingObjectAnchorBox currentObjectAnchor, DocumentLayout currentLayout) { LayoutFloatingObject currentFloatingObject = currentObjectAnchor.FloatingObjectBox; string returnedInformation = ""; if (currentFloatingObject.Type == LayoutType.FloatingPicture) { returnedInformation = "!A FLOATING PICTURE IS SELECTED!\r\n"; } else if (currentFloatingObject.Type == LayoutType.TextBox) { returnedInformation = "!A TEXT BOX IS SELECTED!\r\n"; } returnedInformation += String.Format("Anchor location: {0}\r\n", currentObjectAnchor.Bounds.Location); returnedInformation += String.Format("Object bounds: {0}\r\n", currentFloatingObject.Bounds); returnedInformation += String.Format("Rotation: {0}\r\n", currentFloatingObject.RotationAngle); if (currentFloatingObject.Type == LayoutType.TextBox) { LayoutTextBox currentTextBox = currentFloatingObject as LayoutTextBox; returnedInformation += String.Format("\r\n!!Content information:\r\n"); returnedInformation += TextBoxLayoutHelper.GetInformationAboutCurrentTextBoxContent(currentTextBox, currentLayout); } else if (currentFloatingObject.Type == LayoutType.FloatingPicture) { LayoutFloatingPicture currentFloatingPicture = currentFloatingObject as LayoutFloatingPicture; returnedInformation += String.Format("\r\n!!Image properties:\r\n"); returnedInformation += GetInformationAboutOfficeImage(currentFloatingPicture.Image); } return(returnedInformation); }
public static string GetInformationAboutCurrentDocumentElement(Document currentDocument, DocumentLayout currentDocumentLayout, SubDocument currentSubDocument, DocumentPosition docPosition) { if (currentSubDocument.GetSubDocumentType() == SubDocumentType.TextBox) { return(TextBoxLayoutHelper.GetInformationAboutCurrentTextBox(currentSubDocument, currentDocumentLayout, docPosition)); } if (currentSubDocument.GetSubDocumentType() == SubDocumentType.Main) { RangedLayoutElement tableCell = currentDocumentLayout.GetElement(docPosition, LayoutType.TableCell); if (tableCell != null) { // collect information about TABLE CELL return(DocumentElementLayoutHelper.GetInformationAboutCurrentTableCell(currentDocument, tableCell as LayoutTableCell)); } RangedLayoutElement imageinline = currentDocumentLayout.GetElement(docPosition, LayoutType.InlinePictureBox); if (imageinline != null) { // collect information about INLINE PICTURE return(DocumentElementLayoutHelper.GetInformationAboutCurrentInlinePicture(imageinline as InlinePictureBox)); } RangedLayoutElement floatingObjectAnchor = currentDocumentLayout.GetElement(docPosition, LayoutType.FloatingObjectAnchorBox); if (floatingObjectAnchor != null) { // collect information about FLOATING OBJECT return(DocumentElementLayoutHelper.GetInformationAboutCurrentFloatingObject(floatingObjectAnchor as FloatingObjectAnchorBox, currentDocumentLayout)); } RangedLayoutElement regularTextBlock = currentDocumentLayout.GetElement(docPosition, LayoutType.PlainTextBox); if (regularTextBlock != null) { // collect information about REGULAR TEXT BLOCK return(DocumentElementLayoutHelper.GetInformationAboutRegularTextBlock(regularTextBlock as PlainTextBox, currentDocument)); } } return(""); }