コード例 #1
0
 def deleteCol(self):
     if not self.cellDispEle:
         return
     cellIndex = self.cellDispEle.cellIndex
     numrows = self.tableDispEle.rows.length
     for r in range(numrows):
         row = self.tableDispEle.rows[r]
         getDispElement(row).deleteCell(cellIndex)
コード例 #2
0
 def deleteCol(self):
     if not self.cellDispEle:
         return
     cellIndex = self.cellDispEle.cellIndex
     numrows = self.tableDispEle.rows.length
     for r in range(numrows):
         row = self.tableDispEle.rows[r]
         getDispElement(row).deleteCell(cellIndex)
コード例 #3
0
    def moveCol(self, where):
        if not self.canMoveCol(where):
            return

        cellIndex = self.cellDispEle.cellIndex
        newCellIndex = cellIndex + 1
        if ZMshtmlTableContext.LEFT == where:
            newCellIndex = cellIndex - 1
        numrows = self.tableDispEle.rows.length
        for r in range(numrows):
            row = self.tableDispEle.rows[r]
            getDispElement(row.cells[cellIndex]).swapNode(getDispElement(row.cells[newCellIndex]) )
コード例 #4
0
    def moveCol(self, where):
        if not self.canMoveCol(where):
            return

        cellIndex = self.cellDispEle.cellIndex
        newCellIndex = cellIndex + 1
        if ZMshtmlTableContext.LEFT == where:
            newCellIndex = cellIndex - 1
        numrows = self.tableDispEle.rows.length
        for r in range(numrows):
            row = self.tableDispEle.rows[r]
            getDispElement(row.cells[cellIndex]).swapNode(
                getDispElement(row.cells[newCellIndex]))
コード例 #5
0
 def _createTableContext(self, tableEle, rowEle, cellEle, parent):
     if not tableEle:
         return None
     table = None
     row = None
     cell = None
     if cellEle:
         cell = getDispElement(cellEle)
     if rowEle:
         row = getDispElement(rowEle)
     if tableEle:
         table = getDispElement(tableEle)
     return ZMshtmlTableContext(table, row, cell, parent)
コード例 #6
0
 def _createTableContext(self, tableEle, rowEle, cellEle, parent):
     if not tableEle:
         return None
     table = None
     row = None
     cell = None
     if cellEle:
         cell = getDispElement(cellEle)
     if rowEle:
         row = getDispElement(rowEle)
     if tableEle:
         table = getDispElement(tableEle)
     return ZMshtmlTableContext(table, row, cell, parent)
コード例 #7
0
ファイル: mshtmluiproxies.py プロジェクト: mpm2050/Raven
    def removeExtendedEntry(self, mshtmlElement): #@UnusedVariable
        u"""
        removeExtendedEntry(mshtmlElement) -> bool
        Removes Extended Entry marker and returns True on success.
        """ #$NON-NLS-1$

        # find body element
        while mshtmlElement.tagName != u"BODY" and mshtmlElement.parentElement: #$NON-NLS-1$
            mshtmlElement = mshtmlElement.parentElement
        if not mshtmlElement or mshtmlElement.tagName != u"BODY": #$NON-NLS-1$
            return False

        mshtmlDispElement = getDispElement(mshtmlElement)
        hrEleList = mshtmlDispElement.getElementsByTagName(u"HR")  #$NON-NLS-1$
        # remove all markers with special id
        for ele in hrEleList:
            id = ele.getAttribute(u"id")#$NON-NLS-1$
            if id == ZMshtmlExtendedEntryMarkerProxy.EXTENDED_ENTRY_MARKER_ID: #$NON-NLS-1$
                ele.removeNode(True)
        hrEleList = mshtmlDispElement.getElementsByTagName(u"IMG")  #$NON-NLS-1$
        # remove all markers with special id
        for ele in hrEleList:
            id = ele.getAttribute(u"id")#$NON-NLS-1$
            if id == ZMshtmlExtendedEntryMarkerProxy.EXTENDED_ENTRY_MARKER_ID: #$NON-NLS-1$
                ele.removeNode(True)
        return True
コード例 #8
0
 def insertCaption(self): #@UnusedVariable
     if not self.tableDispEle:
         return
     caption = self.tableDispEle.caption
     if not caption:
         caption = self.tableDispEle.createCaption()
     getDispElement(caption).innerText = u"table caption" #$NON-NLS-1$
コード例 #9
0
    def _visitBodyDispatchElement(self, mshtmlBodyElement):  #@UnusedVariable
        self.mshtmlBodyElement = mshtmlBodyElement
        eleList = self.mshtmlBodyElement.getElementsByTagName(u"OBJECT") #$NON-NLS-1$
        for ele in eleList:
            if getNoneString(ele.classid) is not None: #$NON-NLS-1$
                # Class ID already defined. Skip!
                continue
            # 1. Lookup <embed> child element
            # 2. If child <embed> element is application/x-shockwave-flash, then remove OBJECT elem wrapper
            # The problem is, IE does not parse <embed> as an element. Instead, it is represented as OBJECT nodes' text.
            # Work around is to do load the content into ZDOm and select embed elem.

            content = getNoneString(ele.outerHTML)
            if not content:
                continue
            xhtmlDoc = loadXhtmlDocumentFromString(content)
            dom = xhtmlDoc.getDom()
            embed = dom.selectSingleNode(u"//xhtml:embed") #$NON-NLS-1$ #$NON-NLS-1$
            if not embed:
                continue
            if embed.getAttribute(u"type") == u"application/x-shockwave-flash": #$NON-NLS-1$ #$NON-NLS-2$
                embedNode = self.mshtmlDoc.createElement(u"embed") #$NON-NLS-1$
                ele.insertAdjacentElement(u"AfterEnd",embedNode) #$NON-NLS-1$
                embedEle = getDispElement(embedNode)
                for attrNode in embed.getAttributes():
                    embedEle.setAttribute( attrNode.nodeName, attrNode.getText() )
                ele.parentNode.removeChild(ele)
                classes = getSafeString(ele.getAttribute(u"className")).split(u" ") #$NON-NLS-1$ #$NON-NLS-2$
                if not u"_Z_RAVEN_OBJECT_WRAPPER_" in classes: #$NON-NLS-1$
                    classes.append(u"_Z_RAVEN_OBJECT_WRAPPER_") #$NON-NLS-1$
                embedEle.setAttribute(u"className", u" ".join(classes).strip() ) #$NON-NLS-2$ #$NON-NLS-1$
        return False
コード例 #10
0
 def insertCaption(self):  #@UnusedVariable
     if not self.tableDispEle:
         return
     caption = self.tableDispEle.caption
     if not caption:
         caption = self.tableDispEle.createCaption()
     getDispElement(caption).innerText = u"table caption"  #$NON-NLS-1$
コード例 #11
0
 def moveRow(self, where):
     if not self.canMoveRow(where):
         return
     row = None
     if ZMshtmlTableContext.ABOVE == where:
         row = self.tableDispEle.rows[self.rowDispEle.rowIndex - 1]
     else:
         row = self.tableDispEle.rows[self.rowDispEle.rowIndex + 1]
     self.rowDispEle.swapNode(getDispElement(row))
コード例 #12
0
 def moveRow(self, where):
     if not self.canMoveRow(where):
         return
     row = None
     if ZMshtmlTableContext.ABOVE == where:
         row = self.tableDispEle.rows[self.rowDispEle.rowIndex - 1]
     else:
         row = self.tableDispEle.rows[self.rowDispEle.rowIndex + 1]
     self.rowDispEle.swapNode( getDispElement( row ) )
コード例 #13
0
 def visitDocument(self, document):  #@UnusedVariable
     self.mshtmlDoc = document.node
     try:
         if self.mshtmlDoc.body:
             mshtmlBodyElement = getDispElement(self.mshtmlDoc.body)
             self._visitBodyDispatchElement(mshtmlBodyElement)
     except:
         # FIXME (PJ) log error
         return False
コード例 #14
0
 def _visitBodyDispatchElement(self, mshtmlBodyElement):
     eleList = mshtmlBodyElement.getElementsByTagName(u"TABLE") #$NON-NLS-1$
     for ele in eleList:
         table = getDispElement(ele)
         if not table.border or unicode(table.border).lower() in [u"0", u"0px", u"0em", u"0%"]: #$NON-NLS-1$ #$NON-NLS-2$ #$NON-NLS-3$ #$NON-NLS-4$
             self._setRuntimeBorder(table, u"#bcbcbc") #$NON-NLS-1$
             #table.runtimeStyle.borderCollapse = u"separate" #$NON-NLS-1$
             for tdEle in table.getElementsByTagName(u"TD"): #$NON-NLS-1$
                 self._setRuntimeBorder( getDispElement(tdEle), u"#bcbcbc" ) #$NON-NLS-1$
             for tdEle in table.getElementsByTagName(u"TH"): #$NON-NLS-1$
                 self._setRuntimeBorder( getDispElement(tdEle), u"#bcbcbc" ) #$NON-NLS-1$
         else:
             # remove rt style if table has border.
             self._removeRuntimeBorder(table) #$NON-NLS-1$
             for tdEle in table.getElementsByTagName(u"TD"): #$NON-NLS-1$
                 self._removeRuntimeBorder( getDispElement(tdEle)) #$NON-NLS-1$
             for tdEle in table.getElementsByTagName(u"TH"): #$NON-NLS-1$
                 self._removeRuntimeBorder( getDispElement(tdEle) ) #$NON-NLS-1$
コード例 #15
0
 def canMoveRow(self, where):
     tbodyRows = 0
     if self.rowDispEle and self.rowDispEle.parentElement:
         tbodyDisp = getDispElement(self.rowDispEle.parentElement)
         tbodyRows = tbodyDisp.rows.length
     if self.rowDispEle and ZMshtmlTableContext.ABOVE == where and self.rowDispEle.sectionRowIndex > 0:
         return True
     elif self.rowDispEle and ZMshtmlTableContext.BELOW == where and self.rowDispEle.sectionRowIndex < (tbodyRows - 1):
         return True
     return False
コード例 #16
0
ファイル: mshtmlspellcheckctx.py プロジェクト: mpm2050/Raven
 def _initialize(self):
     doc = self.mshtmlEditControl._getMshtmlControl().getIHTMLDocument()
     mshtmlBodyDispElement = getDispElement(doc.body)
     self.startRange = mshtmlBodyDispElement.createTextRange()
     self.startRange.collapse(True)
     self.currRange = mshtmlBodyDispElement.createTextRange()
     self.currRange.collapse(True)
     self.endRange = mshtmlBodyDispElement.createTextRange()
     self.endRange.collapse(False)
     self._resetWordCount()
コード例 #17
0
 def canMoveRow(self, where):
     tbodyRows = 0
     if self.rowDispEle and self.rowDispEle.parentElement:
         tbodyDisp = getDispElement(self.rowDispEle.parentElement)
         tbodyRows = tbodyDisp.rows.length
     if self.rowDispEle and ZMshtmlTableContext.ABOVE == where and self.rowDispEle.sectionRowIndex > 0:
         return True
     elif self.rowDispEle and ZMshtmlTableContext.BELOW == where and self.rowDispEle.sectionRowIndex < (
             tbodyRows - 1):
         return True
     return False
コード例 #18
0
 def _checkImgUnicodePaths(self):
     eleList = self.mshtmlBodyElement.getElementsByTagName(u"IMG") #$NON-NLS-1$
     for ele in eleList:
         src = getNoneString(ele.getAttribute(u"src")) #$NON-NLS-1$
         if not src:
             continue
         localFilePath = getFilePathFromUri(src)
         if localFilePath and os.path.exists(localFilePath):
             # if local file path, then "set" image path - IE MSHTML quirk - to 'update' the image
             dispEle = getDispElement(ele) #@UnusedVariable
             dispEle.src = localFilePath
コード例 #19
0
    def insertFooter(self): #@UnusedVariable
        if not self.tableDispEle:
            return
        ncols = 2
        if self.tableDispEle.rows.length > 0:
            ncols = self.tableDispEle.rows[self.tableDispEle.rows.length-1].cells.length
        tFoot =  self.tableDispEle.tFoot
        if not tFoot:
            tFoot = self.tableDispEle.createTFoot()
        row = getDispElement( tFoot.insertRow(-1) )

        for idx in range(ncols): #@UnusedVariable
            cell = row.insertCell(-1)
            cell.innerText = u"FT" #$NON-NLS-1$
コード例 #20
0
    def insertHeader(self): #@UnusedVariable
        if not self.tableDispEle:
            return
        ncols = 2
        if self.tableDispEle.rows.length > 0:
            ncols = self.tableDispEle.rows[0].cells.length
        tHead =  self.tableDispEle.tHead
        if not tHead:
            tHead = self.tableDispEle.createTHead()
        row = getDispElement( tHead.insertRow(-1) )

        for idx in range(ncols): #@UnusedVariable
            th = row.ownerDocument.createElement(u"TH") #$NON-NLS-1$
            row.appendChild(th)
            th.innerText = u"TH" #$NON-NLS-1$
コード例 #21
0
    def insertHeader(self):  #@UnusedVariable
        if not self.tableDispEle:
            return
        ncols = 2
        if self.tableDispEle.rows.length > 0:
            ncols = self.tableDispEle.rows[0].cells.length
        tHead = self.tableDispEle.tHead
        if not tHead:
            tHead = self.tableDispEle.createTHead()
        row = getDispElement(tHead.insertRow(-1))

        for idx in range(ncols):  #@UnusedVariable
            th = row.ownerDocument.createElement(u"TH")  #$NON-NLS-1$
            row.appendChild(th)
            th.innerText = u"TH"  #$NON-NLS-1$
コード例 #22
0
    def insertFooter(self):  #@UnusedVariable
        if not self.tableDispEle:
            return
        ncols = 2
        if self.tableDispEle.rows.length > 0:
            ncols = self.tableDispEle.rows[self.tableDispEle.rows.length -
                                           1].cells.length
        tFoot = self.tableDispEle.tFoot
        if not tFoot:
            tFoot = self.tableDispEle.createTFoot()
        row = getDispElement(tFoot.insertRow(-1))

        for idx in range(ncols):  #@UnusedVariable
            cell = row.insertCell(-1)
            cell.innerText = u"FT"  #$NON-NLS-1$
コード例 #23
0
 def insertRow(self, where): #@UnusedVariable
     if self.rowDispEle is None:
         return
     # insert row from current tBody
     i = -1
     tbodyDisp = getDispElement(self.rowDispEle.parentElement)
     if ZMshtmlTableContext.ABOVE == where:
         i = self.rowDispEle.rowIndex - 1
         if i < 0:
             i = 0
     else:
         i = self.rowDispEle.rowIndex + 1
         if i >= tbodyDisp.rows.length:
             i = -1
     newRow = tbodyDisp.insertRow(i)
     numcols = self.rowDispEle.cells.length
     for i in range(numcols):
         newRow.insertCell(-1)
コード例 #24
0
 def insertRow(self, where):  #@UnusedVariable
     if self.rowDispEle is None:
         return
     # insert row from current tBody
     i = -1
     tbodyDisp = getDispElement(self.rowDispEle.parentElement)
     if ZMshtmlTableContext.ABOVE == where:
         i = self.rowDispEle.rowIndex - 1
         if i < 0:
             i = 0
     else:
         i = self.rowDispEle.rowIndex + 1
         if i >= tbodyDisp.rows.length:
             i = -1
     newRow = tbodyDisp.insertRow(i)
     numcols = self.rowDispEle.cells.length
     for i in range(numcols):
         newRow.insertCell(-1)
コード例 #25
0
 def _reset(self):
     self.mshtmlEditControl.selectNone()
     doc = self.mshtmlEditControl._getMshtmlControl().getIHTMLDocument()
     mshtmlBodyDispElement = getDispElement(doc.body)
     self.findRange = mshtmlBodyDispElement.createTextRange()
     self.currRange = None
コード例 #26
0
 def _reset(self):
     self.mshtmlEditControl.selectNone()
     doc = self.mshtmlEditControl._getMshtmlControl().getIHTMLDocument()
     mshtmlBodyDispElement = getDispElement(doc.body)
     self.findRange = mshtmlBodyDispElement.createTextRange()
     self.currRange = None