def set_noTableBorders(table):
    """Sets a table to have no borders."""
    borderLine = BorderLine()
    borderLine.OuterLineWidth = 0

    tableBorder = table.getPropertyValue("TableBorder")
    tableBorder.VerticalLine = borderLine
    tableBorder.HorizontalLine = borderLine
    tableBorder.LeftLine = borderLine
    tableBorder.RightLine = borderLine
    tableBorder.TopLine = borderLine
    tableBorder.BottomLine = borderLine
    table.setPropertyValue("TableBorder", tableBorder)
示例#2
0
    def __init__(self, xTextDocument, FrameText, Width, Height, XPos, YPos):
        self.xTextDocument = xTextDocument
        self.iWidth = Width
        self.iHeight = Height
        self.iXPos = XPos
        self.iYPos = YPos
        self.xFrame = None
        try:
            self.xFrame = \
                self.xTextDocument.createInstance(
                    "com.sun.star.text.TextFrame")
            self.setFramePosition()
            self.xFrame.AnchorType = AT_PAGE
            self.xFrame.SizeType = FIX

            self.xFrame.TextWrap = THROUGHT
            self.xFrame.Opaque = True
            self.xFrame.BackColor = 15790320

            myBorder = BorderLine()
            myBorder.OuterLineWidth = 0
            self.xFrame.LeftBorder = myBorder
            self.xFrame.RightBorder = myBorder
            self.xFrame.TopBorder = myBorder
            self.xFrame.BottomBorder = myBorder
            self.xFrame.Print = False
            xTextCursor = \
                self.xTextDocument.Text.createTextCursor()
            xTextCursor.gotoEnd(True)
            xText = self.xTextDocument.Text
            xText.insertTextContent(
                xTextCursor, self.xFrame,
                False)

            xFrameText = self.xFrame.Text
            xFrameCursor = xFrameText.createTextCursor()
            xFrameCursor.setPropertyValue("CharWeight", BOLD)
            xFrameCursor.setPropertyValue("CharColor", 16777215)
            xFrameCursor.setPropertyValue("CharFontName", "Albany")
            xFrameCursor.setPropertyValue("CharHeight", 18)

            xFrameText.insertString(xFrameCursor, FrameText, False)
        except Exception:
            traceback.print_exc()
示例#3
0
    def __init__(self, xTextDocument, FrameText, Width, Height, XPos, YPos):
        self.xTextDocument = xTextDocument
        self.iWidth = Width
        self.iHeight = Height
        self.iXPos = XPos
        self.iYPos = YPos
        self.xFrame = None
        try:
            self.xFrame = \
                self.xTextDocument.createInstance(
                    "com.sun.star.text.TextFrame")
            self.setFramePosition()
            self.xFrame.AnchorType = AT_PAGE
            self.xFrame.SizeType = FIX

            self.xFrame.TextWrap = THROUGH
            self.xFrame.Opaque = True
            self.xFrame.BackColor = 15790320

            myBorder = BorderLine()
            myBorder.OuterLineWidth = 0
            self.xFrame.LeftBorder = myBorder
            self.xFrame.RightBorder = myBorder
            self.xFrame.TopBorder = myBorder
            self.xFrame.BottomBorder = myBorder
            self.xFrame.Print = False
            xTextCursor = \
                self.xTextDocument.Text.createTextCursor()
            xTextCursor.gotoEnd(True)
            xText = self.xTextDocument.Text
            xText.insertTextContent(
                xTextCursor, self.xFrame,
                False)

            xFrameText = self.xFrame.Text
            xFrameCursor = xFrameText.createTextCursor()
            xFrameCursor.setPropertyValue("CharWeight", BOLD)
            xFrameCursor.setPropertyValue("CharColor", 16777215)
            xFrameCursor.setPropertyValue("CharFontName", "Albany")
            xFrameCursor.setPropertyValue("CharHeight", 18)

            xFrameText.insertString(xFrameCursor, FrameText, False)
        except Exception:
            traceback.print_exc()
示例#4
0
    def test_tableborder(self):
        xDoc = CheckTable._uno.openEmptyWriterDoc()
        # insert table
        xTable = xDoc.createInstance("com.sun.star.text.TextTable")
        xTable.initialize(3, 3)
        xText = xDoc.getText()
        xCursor = xText.createTextCursor()
        xText.insertTextContent(xCursor, xTable, False)

        border = xTable.getPropertyValue("TableBorder")

        self.__test_borderAsserts(border.TopLine, border.IsTopLineValid)
        self.__test_borderAsserts(border.BottomLine, border.IsBottomLineValid)
        self.__test_borderAsserts(border.LeftLine, border.IsLeftLineValid)
        self.__test_borderAsserts(border.RightLine, border.IsRightLineValid)
        self.__test_borderAsserts(border.HorizontalLine,
                                  border.IsHorizontalLineValid)
        self.__test_borderAsserts(border.VerticalLine,
                                  border.IsVerticalLineValid)

        self.__test_borderDistance(border)

        # set border
        border.TopLine = BorderLine(0, 11, 19, 19)
        border.BottomLine = BorderLine(0xFF, 00, 11, 00)
        border.HorizontalLine = BorderLine(0xFF00, 00, 90, 00)
        xTable.setPropertyValue("TableBorder", border)
        # read set border
        border = xTable.getPropertyValue("TableBorder")

        self.assertTrue(border.IsTopLineValid)
        self.assertEqual(11, border.TopLine.InnerLineWidth)
        self.assertEqual(19, border.TopLine.OuterLineWidth)
        self.assertEqual(19, border.TopLine.LineDistance)
        self.assertEqual(0, border.TopLine.Color)

        self.assertTrue(border.IsBottomLineValid)
        self.assertEqual(0, border.BottomLine.InnerLineWidth)
        self.assertEqual(11, border.BottomLine.OuterLineWidth)
        self.assertEqual(0, border.BottomLine.LineDistance)
        self.assertEqual(0xFF, border.BottomLine.Color)

        self.__test_borderAsserts(border.LeftLine, border.IsLeftLineValid)

        self.__test_borderAsserts(border.RightLine, border.IsRightLineValid)

        self.assertTrue(border.IsHorizontalLineValid)
        self.assertEqual(0, border.HorizontalLine.InnerLineWidth)
        self.assertEqual(90, border.HorizontalLine.OuterLineWidth)
        self.assertEqual(0, border.HorizontalLine.LineDistance)
        self.assertEqual(0xFF00, border.HorizontalLine.Color)

        self.__test_borderAsserts(border.VerticalLine,
                                  border.IsVerticalLineValid)

        self.__test_borderDistance(border)

        border2 = xTable.getPropertyValue("TableBorder2")
        self.assertTrue(border2.IsTopLineValid)
        self.assertEqual(11, border2.TopLine.InnerLineWidth)
        self.assertEqual(19, border2.TopLine.OuterLineWidth)
        self.assertEqual(19, border2.TopLine.LineDistance)
        self.assertEqual(0, border2.TopLine.Color)
        self.assertEqual(DOUBLE, border2.TopLine.LineStyle)
        self.assertEqual(49, border2.TopLine.LineWidth)

        self.assertTrue(border2.IsBottomLineValid)
        self.assertEqual(0, border2.BottomLine.InnerLineWidth)
        self.assertEqual(11, border2.BottomLine.OuterLineWidth)
        self.assertEqual(0, border2.BottomLine.LineDistance)
        self.assertEqual(0xFF, border2.BottomLine.Color)
        self.assertEqual(SOLID, border2.BottomLine.LineStyle)
        self.assertEqual(11, border2.BottomLine.LineWidth)

        self.__test_borderAssertsWithLineStyle(border2.LeftLine,
                                               border2.IsLeftLineValid)

        self.__test_borderAssertsWithLineStyle(border2.RightLine,
                                               border2.IsRightLineValid)

        self.assertTrue(border2.IsHorizontalLineValid)
        self.assertEqual(0, border2.HorizontalLine.InnerLineWidth)
        self.assertEqual(90, border2.HorizontalLine.OuterLineWidth)
        self.assertEqual(0, border2.HorizontalLine.LineDistance)
        self.assertEqual(0xFF00, border2.HorizontalLine.Color)
        self.assertEqual(SOLID, border2.HorizontalLine.LineStyle)
        self.assertEqual(90, border2.HorizontalLine.LineWidth)

        self.__test_borderAssertsWithLineStyle(border2.VerticalLine,
                                               border2.IsVerticalLineValid)

        self.__test_borderDistance(border2)
        # set border2
        border2.RightLine = BorderLine2(0, 0, 0, 0, THICKTHIN_LARGEGAP, 120)
        border2.LeftLine = BorderLine2(0, 0, 0, 0, EMBOSSED, 90)
        border2.VerticalLine = BorderLine2(0xFF, 0, 90, 0, DOTTED, 0)
        border2.HorizontalLine = BorderLine2(0xFF00, 0, 0, 0, DASHED, 11)
        xTable.setPropertyValue("TableBorder2", border2)
        # read set border2
        border2 = xTable.getPropertyValue("TableBorder2")

        self.assertTrue(border2.IsTopLineValid)
        self.assertEqual(11, border2.TopLine.InnerLineWidth)
        self.assertEqual(19, border2.TopLine.OuterLineWidth)
        self.assertEqual(19, border2.TopLine.LineDistance)
        self.assertEqual(0, border2.TopLine.Color)
        self.assertEqual(DOUBLE, border2.TopLine.LineStyle)
        self.assertEqual(49, border2.TopLine.LineWidth)

        self.assertTrue(border2.IsBottomLineValid)
        self.assertEqual(0, border2.BottomLine.InnerLineWidth)
        self.assertEqual(11, border2.BottomLine.OuterLineWidth)
        self.assertEqual(0, border2.BottomLine.LineDistance)
        self.assertEqual(0xFF, border2.BottomLine.Color)
        self.assertEqual(SOLID, border2.BottomLine.LineStyle)
        self.assertEqual(11, border2.BottomLine.LineWidth)

        self.assertTrue(border2.IsLeftLineValid)
        self.assertEqual(23, border2.LeftLine.InnerLineWidth)
        self.assertEqual(23, border2.LeftLine.OuterLineWidth)
        self.assertEqual(46, border2.LeftLine.LineDistance)
        self.assertEqual(0, border2.LeftLine.Color)
        self.assertEqual(EMBOSSED, border2.LeftLine.LineStyle)
        self.assertEqual(90, border2.LeftLine.LineWidth)

        self.assertTrue(border2.IsRightLineValid)
        self.assertEqual(53, border2.RightLine.InnerLineWidth)
        self.assertEqual(26, border2.RightLine.OuterLineWidth)
        self.assertEqual(41, border2.RightLine.LineDistance)
        self.assertEqual(0, border2.RightLine.Color)
        self.assertEqual(THICKTHIN_LARGEGAP, border2.RightLine.LineStyle)
        self.assertEqual(120, border2.RightLine.LineWidth)

        self.assertTrue(border2.IsHorizontalLineValid)
        self.assertEqual(0, border2.HorizontalLine.InnerLineWidth)
        self.assertEqual(11, border2.HorizontalLine.OuterLineWidth)
        self.assertEqual(0, border2.HorizontalLine.LineDistance)
        self.assertEqual(0xFF00, border2.HorizontalLine.Color)
        self.assertEqual(DASHED, border2.HorizontalLine.LineStyle)
        self.assertEqual(11, border2.HorizontalLine.LineWidth)

        self.assertTrue(border2.IsVerticalLineValid)
        self.assertEqual(0, border2.VerticalLine.InnerLineWidth)
        self.assertEqual(90, border2.VerticalLine.OuterLineWidth)
        self.assertEqual(0, border2.VerticalLine.LineDistance)
        self.assertEqual(0xFF, border2.VerticalLine.Color)
        self.assertEqual(DOTTED, border2.VerticalLine.LineStyle)
        self.assertEqual(90, border2.VerticalLine.LineWidth)

        self.__test_borderDistance(border2)

        # close document
        xDoc.dispose()
示例#5
0
    oSD = oHojaActiva.createSearchDescriptor()
    oSD.setSearchString(sRegion)
    oSD.SearchWords = True
    oSD.SearchCaseSensitive = True
    oSD.SearchType = 1
    oBuscarEn = oHojaActiva.getCellRangeByName("A1:Z254")
    oEncontrado = oBuscarEn.findFirst(oSD)
    if not oEncontrado is None:
        oCursor = oHojaActiva.createCursorByRange(oEncontrado)
        oCursor.collapseToCurrentRegion()
        Tablas.FormatearRegion(oCursor, mColoresRegiones[i],
                               mColumnasRegiones[i], mFilasTotalizadas[i],
                               mColumnasConNombre[i])

oTableBorder = TableBorder()
oBorderLine = BorderLine()
# Cuadrito de resumen
oBorderLine.OuterLineWidth = 5
oTableBorder.IsBottomLineValid = True
oTableBorder.IsLeftLineValid = True
oTableBorder.IsRightLineValid = True
oTableBorder.IsTopLineValid = True
oTableBorder.IsHorizontalLineValid = False
oTableBorder.IsVerticalLineValid = False
oTableBorder.LeftLine = oBorderLine
oTableBorder.RightLine = oBorderLine
oTableBorder.TopLine = oBorderLine
oTableBorder.BottomLine = oBorderLine

oSD = oHojaActiva.createSearchDescriptor()
oSD.setSearchString("Resumen")
示例#6
0
def FormatearRegion(oRango, color, ColumnasNumericas, UltimaFilaEsTotal,
                    SegundaFilaEsTitulo):
    from com.sun.star.table import TableBorder
    from com.sun.star.table import BorderLine
    oBorderLine = BorderLine()
    oBorderLine.OuterLineWidth = 5

    oTableBorder = TableBorder()
    oTableBorder.IsBottomLineValid = True
    oTableBorder.IsLeftLineValid = True
    oTableBorder.IsRightLineValid = True
    oTableBorder.IsTopLineValid = True
    oTableBorder.IsHorizontalLineValid = False
    oTableBorder.IsVerticalLineValid = False
    oTableBorder.LeftLine = oBorderLine
    oTableBorder.RightLine = oBorderLine
    oTableBorder.TopLine = oBorderLine
    oTableBorder.BottomLine = oBorderLine

    oSubRango = oRango.getCellRangeByPosition(0, 0, oRango.Columns.Count - 1,
                                              0)
    oSubRango.CharFontName = "Arial"
    oSubRango.CharHeight = 12
    oSubRango.CharWeight = 150
    oSubRango.CellBackColor = color
    #oSubRango.CharColor = RGB(0,0,0)
    #RGB(255,255,204)
    #.HoriJustify = com.sun.star.table.CellHoriJustify.CENTER
    #.Rows.Height = 900
    #.TableBorder = oTableBorder

    # si la 1º fila es ..... sacamos las negritas
    if oRango.getCellRangeByPosition(
            0, 0, 0, 0).FormulaArray[0][0] == "Saldo Deudores x Vtas":
        oRango.getCellRangeByPosition(0, 0, oRango.Columns.Count - 1,
                                      0).CharWeight = 100
        oRango.getCellRangeByPosition(1, 0, 1, 0).NumberFormat = 104
    # aca clavar el if si la 2ª fila es de titulo, entonces poner negritas
    if SegundaFilaEsTitulo:
        oRango.getCellRangeByPosition(0, 1, oRango.Columns.Count - 1,
                                      1).CharWeight = 150
        NumFilasTitulo = 2
    else:
        NumFilasTitulo = 1

    oSubRango = oRango.getCellRangeByPosition(0, 1, oRango.Columns.Count - 1,
                                              oRango.Rows.Count - 2)
    oSubRango.CharFontName = "Arial"
    oSubRango.CharHeight = 10

    if UltimaFilaEsTotal:
        oSubRango = oRango.getCellRangeByPosition(0, oRango.Rows.Count - 1,
                                                  oRango.Columns.Count - 1,
                                                  oRango.Rows.Count - 1)
        oSubRango.CharFontName = "Arial"
        oSubRango.CharHeight = 10
        oSubRango.CharWeight = 150
        oSubRango.TableBorder = oTableBorder

    for i in ColumnasNumericas:
        oSubRango = oRango.getCellRangeByPosition(i, NumFilasTitulo, i,
                                                  oRango.Rows.Count - 1)
        oSubRango.NumberFormat = 4
        oSubRango.Columns.OptimalWidth = True