[Libreoffice-commits] core.git: 8 commits - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Wed Jan 14 19:19:12 PST 2015


 sc/inc/document.hxx              |   30 +++++++++++++++-
 sc/inc/table.hxx                 |    1 
 sc/source/core/data/document.cxx |   21 +++++++++++
 sc/source/core/data/table2.cxx   |   21 +++++++++++
 sc/source/ui/inc/viewdata.hxx    |    1 
 sc/source/ui/unoobj/docuno.cxx   |   24 +++++++++++--
 sc/source/ui/view/gridwin4.cxx   |   70 ++++++++++++++++++++++++++++++++++-----
 sc/source/ui/view/viewdata.cxx   |    6 +++
 8 files changed, 160 insertions(+), 14 deletions(-)

New commits:
commit d04e06f6e41250d51c931dd9aa160c7d1b83941b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jan 14 22:16:33 2015 -0500

    Comment these out for now.  We'll use them later.
    
    Change-Id: I7e6afeea9368241bea8af141726e73c557475317

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 05fc3a0..366eb28 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -874,7 +874,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
 
 void ScGridWindow::PaintTile( VirtualDevice& rDevice,
                               int nOutputWidth, int nOutputHeight,
-                              int nTilePosX, int nTilePosY,
+                              int /*nTilePosX*/, int /*nTilePosY*/,
                               long nTileWidth, long nTileHeight )
 {
     // Output size is in pixels while tile position and size are in logical units (twips).
commit eb6b39c3002b6e05ef417cf477808479f7a3b763
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jan 14 22:11:35 2015 -0500

    Add TODO.  Text rendering is still weird.
    
    Change-Id: I2da98a82f2d2407f48960a4e53643cee63b4844d

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 85ab94f..05fc3a0 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -934,7 +934,9 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     aOutData.DrawShadow();
     aOutData.DrawFrame();
 
+    // TODO : Scaling of strings is incorrect.  Find out why.
     aOutData.DrawStrings(true);
+    // TODO : Edit texts don't get rendered at all.  Fix this.
     aOutData.DrawEdit(true);
 }
 
commit 31e5afcd7abcb27aa2af991aebdb184fa0e15849
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jan 14 16:14:50 2015 -0500

    Adjust zoom level for different output tile size.
    
    Change-Id: I54b9f3ca66035b66509c960ca79391446ecf8778

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index fc9879b..85ab94f 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -882,6 +882,24 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     // Assumption: always paint the whole sheet i.e. "visible" range is always
     // from (0,0) to last data position.
 
+    // Tile geometry is independent of the zoom level, but the output size is
+    // dependent of the zoom level.  Determine the correct zoom level before
+    // we start.
+
+    // TODO : zooming isn't perfect.  Find out why.
+    double nOutWTwips = static_cast<double>(nOutputWidth) / PIXEL_PER_TWIPS;
+    double nOutHTwips = static_cast<double>(nOutputHeight) / PIXEL_PER_TWIPS;
+
+    nOutWTwips /= nTileWidth;
+    nOutHTwips /= nTileHeight;
+    Fraction aFracX(nOutWTwips);
+    Fraction aFracY(nOutHTwips);
+
+    pViewData->SetZoom(aFracX, aFracY, true);
+    pViewData->RefreshZoom();
+
+    rDevice.SetOutputSizePixel(Size(nOutputWidth, nOutputHeight));
+
     SCTAB nTab = pViewData->GetTabNo();
     ScDocument* pDoc = pViewData->GetDocument();
     ScAddress aLastPos = pDoc->GetLastDataPos(nTab);
@@ -908,6 +926,9 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
     }
     aOutData.SetGridColor(aGridColor);
 
+    aOutData.DrawClear();
+    aOutData.DrawDocumentBackground();
+    aOutData.DrawBackground();
     aOutData.DrawGrid(true, false);
 
     aOutData.DrawShadow();
commit 169b93971bb16058ad83603cc6849a35e22929d7
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Jan 13 18:50:04 2015 -0500

    Set correct grid color.
    
    Change-Id: Ie8ccf61f0b04b718c930b14374843e3858c6278b

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 54d9d0e..fc9879b 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -897,6 +897,17 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
 
     ScOutputData aOutData(
         &rDevice, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab, 0, 0, nCol1, nRow1, nCol2, nRow2, fPPTX, fPPTY);
+
+    const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
+    Color aGridColor = rColorCfg.GetColorValue(svtools::CALCGRID, false).nColor;
+    if (aGridColor.GetColor() == COL_TRANSPARENT)
+    {
+        //  use view options' grid color only if color config has "automatic" color
+        const ScViewOptions& rOpts = pViewData->GetOptions();
+        aGridColor = rOpts.GetGridColor();
+    }
+    aOutData.SetGridColor(aGridColor);
+
     aOutData.DrawGrid(true, false);
 
     aOutData.DrawShadow();
commit 6a5f3ff796db42a616845323731bf796907797b8
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Jan 13 18:21:55 2015 -0500

    Tiled rendering, first cut.
    
    Very simple, without zooming.
    
    Change-Id: Ia5bd5c02dab3eedbaad07ebd81c4d7fe3c6a00c1

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index e163d4d..54d9d0e 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -877,13 +877,33 @@ void ScGridWindow::PaintTile( VirtualDevice& rDevice,
                               int nTilePosX, int nTilePosY,
                               long nTileWidth, long nTileHeight )
 {
-    (void) rDevice;
-    (void) nOutputWidth;
-    (void) nOutputHeight;
-    (void) nTilePosX;
-    (void) nTilePosY;
-    (void) nTileWidth;
-    (void) nTileHeight;
+    // Output size is in pixels while tile position and size are in logical units (twips).
+
+    // Assumption: always paint the whole sheet i.e. "visible" range is always
+    // from (0,0) to last data position.
+
+    SCTAB nTab = pViewData->GetTabNo();
+    ScDocument* pDoc = pViewData->GetDocument();
+    ScAddress aLastPos = pDoc->GetLastDataPos(nTab);
+
+    SCCOL nCol1 = 0, nCol2 = aLastPos.Col();
+    SCROW nRow1 = 0, nRow2 = aLastPos.Row();
+
+    double fPPTX = pViewData->GetPPTX();
+    double fPPTY = pViewData->GetPPTY();
+
+    ScTableInfo aTabInfo;
+    pDoc->FillInfo(aTabInfo, nCol1, nRow1, nCol2, nRow2, nTab, fPPTX, fPPTY, false, false, NULL);
+
+    ScOutputData aOutData(
+        &rDevice, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab, 0, 0, nCol1, nRow1, nCol2, nRow2, fPPTX, fPPTY);
+    aOutData.DrawGrid(true, false);
+
+    aOutData.DrawShadow();
+    aOutData.DrawFrame();
+
+    aOutData.DrawStrings(true);
+    aOutData.DrawEdit(true);
 }
 
 void ScGridWindow::CheckNeedsRepaint()
commit 8a0a1fbfc3aacb7e71c79da75c56698c1ea2378d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jan 12 21:59:50 2015 -0500

    Implement getDocumentSize().  Cell data only for now.
    
    Change-Id: I31e14f12aaee2d98103d1594ba5b511ebf91e333

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 61fa81d..ddf427d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1105,6 +1105,16 @@ public:
     SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
 
     /**
+     * Return the cell position representing the bottom-right corner of the
+     * smallest range that includes all non-empty cells for specified sheet.
+     *
+     * @param nTab sheet index.
+     *
+     * @return address of the last data position.
+     */
+    ScAddress GetLastDataPos( SCTAB nTab ) const;
+
+    /**
      * Return the smallest area containing at least all contiguous cells
      * having data. This area is a square containing also empty cells. It may
      * shrink or extend the area given as input Flags as modifiers:
@@ -1520,6 +1530,7 @@ public:
     SC_DLLPUBLIC void           SetManualHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bManual );
 
     SC_DLLPUBLIC sal_uInt16         GetColWidth( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
+    SC_DLLPUBLIC sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHiddenAsZero = true ) const;
     SC_DLLPUBLIC sal_uInt16         GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
     SC_DLLPUBLIC sal_uInt16         GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const;
     SC_DLLPUBLIC sal_uLong          GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHiddenAsZero = true ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 89a9a49..88a0461 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -721,6 +721,7 @@ public:
     void        SetManualHeight( SCROW nStartRow, SCROW nEndRow, bool bManual );
 
     sal_uInt16      GetColWidth( SCCOL nCol, bool bHiddenAsZero = true ) const;
+    sal_uLong GetColWidth( SCCOL nStartCol, SCCOL nEndCol, bool bHiddenAsZero = true ) const;
     SC_DLLPUBLIC sal_uInt16 GetRowHeight( SCROW nRow, SCROW* pStartRow = NULL, SCROW* pEndRow = NULL, bool bHiddenAsZero = true ) const;
     sal_uLong       GetRowHeight( SCROW nStartRow, SCROW nEndRow, bool bHiddenAsZero = true ) const;
     sal_uLong       GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 64a4284..43117b0 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1045,6 +1045,18 @@ SCROW ScDocument::GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nL
     return pTab->GetLastDataRow(nCol1, nCol2, nLastRow);
 }
 
+ScAddress ScDocument::GetLastDataPos( SCTAB nTab ) const
+{
+    const ScTable* pTab = FetchTable(nTab);
+    if (!pTab)
+        return ScAddress(ScAddress::INITIALIZE_INVALID);
+
+    SCCOL nCol;
+    SCROW nRow;
+    pTab->GetLastDataPos(nCol, nRow);
+    return ScAddress(nCol, nRow, nTab);
+}
+
 // connected area
 
 void ScDocument::GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
@@ -3894,6 +3906,15 @@ sal_uInt16 ScDocument::GetColWidth( SCCOL nCol, SCTAB nTab, bool bHiddenAsZero )
     return 0;
 }
 
+sal_uLong ScDocument::GetColWidth( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHiddenAsZero ) const
+{
+    const ScTable* pTab = FetchTable(nTab);
+    if (!pTab)
+        return 0;
+
+    return pTab->GetColWidth(nStartCol, nEndCol, bHiddenAsZero);
+}
+
 sal_uInt16 ScDocument::GetOriginalWidth( SCCOL nCol, SCTAB nTab ) const
 {
     if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] )
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index adc1626..160da7f 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2837,6 +2837,27 @@ sal_uInt16 ScTable::GetColWidth( SCCOL nCol, bool bHiddenAsZero ) const
         return (sal_uInt16) STD_COL_WIDTH;
 }
 
+sal_uLong ScTable::GetColWidth( SCCOL nStartCol, SCCOL nEndCol, bool bHiddenAsZero ) const
+{
+    if (!ValidCol(nStartCol) || !ValidCol(nEndCol) || nStartCol > nEndCol)
+        return 0;
+
+    sal_uLong nW = 0;
+    bool bHidden = false;
+    SCCOL nLastHiddenCol = -1;
+    for (SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol)
+    {
+        if (bHiddenAsZero && nCol > nLastHiddenCol)
+            bHidden = ColHidden(nCol, NULL, &nLastHiddenCol);
+
+        if (bHidden)
+            continue;
+
+        nW += pColWidth[nCol];
+    }
+    return nW;
+}
+
 sal_uInt16 ScTable::GetOriginalWidth( SCCOL nCol ) const        // immer die eingestellte
 {
     OSL_ENSURE(ValidCol(nCol),"wrong column number");
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 10f50aa..faf655b 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -488,10 +488,26 @@ int ScModelObj::getPart()
 
 Size ScModelObj::getDocumentSize()
 {
-    // TODO: not sure what we want to do here, maybe just return the size for a certain
-    // default minimum number of cells, e.g. 100x100 and more if more cells have
-    // content?
-    return Size();
+    Size aSize(10, 10); // minimum size
+
+    const ScViewData* pViewData = ScDocShell::GetViewData();
+    if (!pViewData)
+        return aSize;
+
+    SCTAB nTab = pViewData->GetTabNo();
+    const ScDocument& rDoc = pDocShell->GetDocument();
+    ScAddress aPos = rDoc.GetLastDataPos(nTab);
+    if (!aPos.IsValid())
+        return aSize;
+
+    // TWIPS
+    sal_uLong nH = rDoc.GetRowHeight(0, aPos.Row(), nTab, true);
+    sal_uLong nW = rDoc.GetColWidth(0, aPos.Col(), nTab, true);
+
+    aSize.setWidth(nW);
+    aSize.setHeight(nH);
+
+    return aSize;
 }
 
 uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
commit 83e8b259c3c0c0bc593ea0eb60dde0dc8299d970
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jan 12 18:50:11 2015 -0500

    Annotate this method.
    
    Change-Id: Ia8f518fd6e61562e95eddacafc9f7e49656826e8

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 57fcf74..61fa81d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1104,8 +1104,23 @@ public:
      */
     SCROW GetLastDataRow( SCTAB nTab, SCCOL nCol1, SCCOL nCol2, SCROW nLastRow ) const;
 
-    SC_DLLPUBLIC void           GetDataArea( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow,
-                                    SCCOL& rEndCol, SCROW& rEndRow, bool bIncludeOld, bool bOnlyDown ) const;
+    /**
+     * Return the smallest area containing at least all contiguous cells
+     * having data. This area is a square containing also empty cells. It may
+     * shrink or extend the area given as input Flags as modifiers:
+     *
+     * @param bIncludeOld when true, ensure that the returned area contains at
+     *                   least the initial area even if the actual data area
+     *                   is smaller than the initial area.
+     *
+     * @param bOnlyDown when true, extend / shrink the data area only in a
+     *                  downward direction i.e. only modify the end row
+     *                  position.
+     */
+    SC_DLLPUBLIC void GetDataArea(
+        SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
+        bool bIncludeOld, bool bOnlyDown ) const;
+
     SC_DLLPUBLIC bool           GetCellArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
     SC_DLLPUBLIC bool           GetTableArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow ) const;
     SC_DLLPUBLIC bool           GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
commit 403bf4defabf440e9a44ed77febc1b4aaa92e07d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jan 12 17:22:25 2015 -0500

    Provide const version that returns a const pointer.
    
    Change-Id: I6a07919af477f2641797b14838ee5ef563ffe532

diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 233c60a..634eb93 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -241,6 +241,7 @@ public:
 
     vcl::Window*         GetDialogParent();          // forwarded from tabvwsh
     ScGridWindow*   GetActiveWin();             // from View
+    const ScGridWindow* GetActiveWin() const;
     ScDrawView*     GetScDrawView();            // from View
     bool            IsMinimized();              // from View
 
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index b5950a0..357b900 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -2108,6 +2108,12 @@ ScGridWindow* ScViewData::GetActiveWin()
     return pView->GetActiveWin();
 }
 
+const ScGridWindow* ScViewData::GetActiveWin() const
+{
+    OSL_ENSURE( pView, "GetActiveWin() ohne View" );
+    return pView->GetActiveWin();
+}
+
 ScDrawView* ScViewData::GetScDrawView()
 {
     OSL_ENSURE( pView, "GetScDrawView() ohne View" );


More information about the Libreoffice-commits mailing list