[Libreoffice-commits] .: 3 commits - basctl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 7 02:53:52 PDT 2012


 basctl/source/basicide/baside2.cxx  |   12 -
 basctl/source/basicide/baside2.hxx  |    2 
 basctl/source/basicide/baside3.cxx  |    6 
 basctl/source/basicide/bastypes.cxx |    4 
 basctl/source/basicide/layout.cxx   |  234 ++++++++++++++++++++----------------
 basctl/source/basicide/layout.hxx   |   37 +++--
 basctl/source/dlged/dlged.cxx       |   10 -
 basctl/source/inc/baside3.hxx       |    2 
 basctl/source/inc/bastypes.hxx      |    6 
 9 files changed, 182 insertions(+), 131 deletions(-)

New commits:
commit eab15a8a2e2b5f524edc0c990dcaa963b8f2a6c5
Author: Uray M. János <uray.janos at gmail.com>
Date:   Fri Sep 7 11:47:21 2012 +0200

    -Werror: initialize iLastWin with an invalid value
    
    iLastWin will get a valid value if !bEmpty
    
    Change-Id: I8f598b7a9d5e8317fca0ef0fcc3313bc0691f0da

diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx
index 0f672e2..b9a5e8e 100644
--- a/basctl/source/basicide/layout.cxx
+++ b/basctl/source/basicide/layout.cxx
@@ -283,8 +283,8 @@ void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect)
     // positioning separator lines and windows
     bool bPrevDocking = false; // is the previous window docked?
     long nStartPos = 0; // window position in the strip
-    unsigned iLastWin; // index of last docking window in the strip
-    // (iLastWin will be initialized if !bEmpty)
+    unsigned iLastWin = vItems.size(); // index of last docking window in the strip
+
     for (unsigned i = 0; i != vItems.size(); ++i)
     {
         // window
@@ -309,7 +309,7 @@ void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect)
             if (bPrevDocking)
             {
                 rSplit.Show();
-                // the actual pozition and size of the line
+                // the actual position and size of the line
                 rSplit.SetPosSizePixel(
                     MakePoint(nPos2 + nStartPos - nSplitThickness, nPos1),
                     MakeSize(nSplitThickness, nSize - nSplitThickness)
commit 70d1b98a53cae469aeadb070c5681c76d6e6996f
Author: Uray M. János <uray.janos at gmail.com>
Date:   Fri Sep 7 10:31:53 2012 +0200

    basctl: int -> long for Point and Size
    
    To be consequent, because Point and Size use long.
    
    Change-Id: I776a1839ee5d2cbdbcedad2b2922cb33b94c7b37

diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index 7de663d..13b1691 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -59,11 +59,11 @@ namespace
 
 namespace Print
 {
-    int const nLeftMargin = 1700;
-    int const nRightMargin = 900;
-    int const nTopMargin = 2000;
-    int const nBottomMargin = 1000;
-    int const nBorder = 300;
+    long const nLeftMargin = 1700;
+    long const nRightMargin = 900;
+    long const nTopMargin = 2000;
+    long const nBottomMargin = 1000;
+    long const nBorder = 300;
 }
 
 short const ValidWindow = 0x1234;
@@ -1558,7 +1558,7 @@ void ModulWindowLayout::BasicRemoveWatch ()
     aWatchWindow.RemoveSelectedWatch();
 }
 
-void ModulWindowLayout::OnFirstSize (int const nWidth, int const nHeight)
+void ModulWindowLayout::OnFirstSize (long const nWidth, long const nHeight)
 {
     AddToLeft(&rObjectCatalog, Size(nWidth * 0.20, nHeight * 0.75));
     AddToBottom(&aWatchWindow, Size(nWidth * 0.67, nHeight * 0.25));
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 489376c..b7d8975 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -424,7 +424,7 @@ protected:
     // Window:
     virtual void Paint (const Rectangle& rRect);
     // Layout:
-    virtual void OnFirstSize (int nWidth, int nHeight);
+    virtual void OnFirstSize (long nWidth, long nHeight);
 
 private:
     // main child window
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index 2d22e50..6197043 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -1530,7 +1530,7 @@ void DialogWindowLayout::GetState (SfxItemSet& rSet, unsigned nWhich)
     }
 }
 
-void DialogWindowLayout::OnFirstSize (int const nWidth, int const nHeight)
+void DialogWindowLayout::OnFirstSize (long const nWidth, long const nHeight)
 {
     AddToLeft(&rObjectCatalog, Size(nWidth * 0.25, nHeight * 0.35));
     if (pPropertyBrowser)
diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx
index 752f830..0f672e2 100644
--- a/basctl/source/basicide/layout.cxx
+++ b/basctl/source/basicide/layout.cxx
@@ -29,7 +29,7 @@ namespace basctl
 namespace
 {
 // the thickness of the splitting lines
-static int const nSplitThickness = 3;
+static long const nSplitThickness = 3;
 } // namespace
 
 // ctor for derived classes
@@ -80,7 +80,7 @@ void Layout::ArrangeWindows ()
     bInArrangeWindows = true;
 
     Size const aSize = GetOutputSizePixel();
-    int const nWidth = aSize.Width(), nHeight = aSize.Height();
+    long const nWidth = aSize.Width(), nHeight = aSize.Height();
     if (nWidth && nHeight) // non-empty size
     {
         // On first call the derived classes initializes the sizes of the
@@ -174,8 +174,8 @@ Layout::SplittedSide::SplittedSide (Layout* pParent, Side eSide) :
 // Add() -- adds a new window to the side (after construction)
 void Layout::SplittedSide::Add (DockingWindow* pWin, Size const& rSize)
 {
-    int const nSize1 = (bVertical ? rSize.Width() : rSize.Height()) + nSplitThickness;
-    int const nSize2 = bVertical ? rSize.Height() : rSize.Width();
+    long const nSize1 = (bVertical ? rSize.Width() : rSize.Height()) + nSplitThickness;
+    long const nSize2 = bVertical ? rSize.Height() : rSize.Width();
     // nSize
     if (nSize1 > nSize)
         nSize = nSize1;
@@ -215,11 +215,11 @@ void Layout::SplittedSide::Remove (DockingWindow* pWin)
 
 // creating a Point or a Size object
 // The coordinate order depends on bVertical (reversed if true).
-inline Size Layout::SplittedSide::MakeSize (int A, int B) const
+inline Size Layout::SplittedSide::MakeSize (long A, long B) const
 {
     return bVertical ? Size(B, A) : Size(A, B);
 }
-inline Point Layout::SplittedSide::MakePoint (int A, int B) const
+inline Point Layout::SplittedSide::MakePoint (long A, long B) const
 {
     return bVertical ? Point(B, A) : Point(A, B);
 }
@@ -240,7 +240,7 @@ bool Layout::SplittedSide::IsEmpty () const
 }
 
 // GetSize() -- returns the width or height of the strip (depending on the direction)
-int Layout::SplittedSide::GetSize () const
+long Layout::SplittedSide::GetSize () const
 {
     return IsEmpty() ? 0 : nSize;
 }
@@ -253,13 +253,13 @@ void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect)
     aRect = rRect;
 
     // the length of the side
-    int const nLength = bVertical ? aRect.GetSize().Height() : aRect.GetSize().Width();
-    int const nOtherSize = bVertical ? aRect.GetSize().Width() : aRect.GetSize().Height();
+    long const nLength = bVertical ? aRect.GetSize().Height() : aRect.GetSize().Width();
+    long const nOtherSize = bVertical ? aRect.GetSize().Width() : aRect.GetSize().Height();
     // bVertical ? horizontal pozition : vertical pozition
-    int const nPos1 = (bVertical ? aRect.Left() : aRect.Top()) +
+    long const nPos1 = (bVertical ? aRect.Left() : aRect.Top()) +
         (bLower ? 0 : nOtherSize - (nSize - nSplitThickness));
     // bVertical ? vertical position : horizontal position
-    int const nPos2 = bVertical ? aRect.Top() : aRect.Left();
+    long const nPos2 = bVertical ? aRect.Top() : aRect.Left();
 
     // main line
     bool const bEmpty = IsEmpty();
@@ -282,7 +282,7 @@ void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect)
 
     // positioning separator lines and windows
     bool bPrevDocking = false; // is the previous window docked?
-    int nStartPos = 0; // window position in the strip
+    long nStartPos = 0; // window position in the strip
     unsigned iLastWin; // index of last docking window in the strip
     // (iLastWin will be initialized if !bEmpty)
     for (unsigned i = 0; i != vItems.size(); ++i)
@@ -380,16 +380,16 @@ IMPL_LINK(Layout::SplittedSide, SplitHdl, Splitter*, pSplitter)
 void Layout::SplittedSide::CheckMarginsFor (Splitter* pSplitter)
 {
     // The splitter line cannot be closer to the edges than nMargin pixels.
-    static int const nMargin = 16;
+    static long const nMargin = 16;
     // Checking margins:
-    if (int const nLength = pSplitter->IsHorizontal() ?
+    if (long const nLength = pSplitter->IsHorizontal() ?
         aRect.GetWidth() : aRect.GetHeight()
     ) {
         // bounds
-        int const nLower = (pSplitter->IsHorizontal() ? aRect.Left() : aRect.Top()) + nMargin;
-        int const nUpper = nLower + nLength - 2*nMargin;
+        long const nLower = (pSplitter->IsHorizontal() ? aRect.Left() : aRect.Top()) + nMargin;
+        long const nUpper = nLower + nLength - 2*nMargin;
         // split position
-        int const nPos = pSplitter->GetSplitPosPixel();
+        long const nPos = pSplitter->GetSplitPosPixel();
         // checking bounds
         if (nPos < nLower)
             pSplitter->SetSplitPosPixel(nLower);
diff --git a/basctl/source/basicide/layout.hxx b/basctl/source/basicide/layout.hxx
index 127f77e..b65de96 100644
--- a/basctl/source/basicide/layout.hxx
+++ b/basctl/source/basicide/layout.hxx
@@ -67,7 +67,7 @@ protected:
     virtual void Resize ();
     virtual void DataChanged (DataChangedEvent const& rDCEvt);
     // new:
-    virtual void OnFirstSize (int nWidth, int nHeight) = 0;
+    virtual void OnFirstSize (long nWidth, long nHeight) = 0;
 
 private:
     // the main child window (either ModulWindow or DialogWindow)
@@ -85,7 +85,7 @@ private:
         void Add (DockingWindow*, Size const&);
         void Remove (DockingWindow*);
         bool IsEmpty () const;
-        int  GetSize () const;
+        long GetSize () const;
         void ArrangeIn (Rectangle const&);
 
     private:
@@ -98,9 +98,9 @@ private:
         // rectangle to move in
         Rectangle aRect;
         // size (width or height)
-        int nSize;
+        long nSize;
         // last position (between Add()s)
-        int nLastPos;
+        long nLastPos;
         // the main splitting line
         Splitter aSplitter;
         // the dockable windows (and some data)
@@ -113,15 +113,15 @@ private:
             // the window may fill the space of the adjacent currently
             // non-docking windows, but this change is not stored in these
             // variables. These change only when the splitter lines are moved.
-            int nStartPos, nEndPos;
+            long nStartPos, nEndPos;
             // splitter line window before the window
             // (the first one is always nullptr)
             boost::shared_ptr<Splitter> pSplit;
         };
         std::vector<Item> vItems;
     private:
-        Point MakePoint (int, int) const;
-        Size MakeSize (int, int) const;
+        Point MakePoint (long, long) const;
+        Size MakeSize (long, long) const;
     private:
         static bool IsDocking (DockingWindow const&);
     private:
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index 9d31198..9dfb431 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -1124,11 +1124,11 @@ void DlgEditor::ClearModifyFlag()
 
 namespace Print
 {
-    int const nLeftMargin = 1700;
-    int const nRightMargin = 900;
-    int const nTopMargin = 2000;
-    int const nBottomMargin = 1000;
-    int const nBorder = 300;
+    long const nLeftMargin = 1700;
+    long const nRightMargin = 900;
+    long const nTopMargin = 2000;
+    long const nBottomMargin = 1000;
+    long const nBorder = 300;
 }
 
 void lcl_PrintHeader( Printer* pPrinter, const ::rtl::OUString& rTitle ) // not working yet
diff --git a/basctl/source/inc/baside3.hxx b/basctl/source/inc/baside3.hxx
index 5e389c5..9b239e5 100644
--- a/basctl/source/inc/baside3.hxx
+++ b/basctl/source/inc/baside3.hxx
@@ -140,7 +140,7 @@ public:
     virtual void UpdateDebug (bool){};
 protected:
     // Layout:
-    virtual void OnFirstSize (int nWidth, int nHeight);
+    virtual void OnFirstSize (long nWidth, long nHeight);
 
 private:
     // child window
commit 19e7696b0f3e6771b630220379f00d306b44ec3d
Author: Uray M. János <uray.janos at gmail.com>
Date:   Fri Sep 7 10:01:42 2012 +0200

    Basic IDE: Filling space of non-docking windows
    
    Now if we make e.g. the stack window floating, then the watch window
    will occupy the whole width of the line (and vice versa, also for the
    Dialog Editor with object catalog and property browser). If we put it
    back again, than we get back the previous state of the strip.
    
    Change-Id: I634614ff2e9d5f790ad759656a79a38d49c4afc4

diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index 6b137d2..2d22e50 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -1437,13 +1437,15 @@ void DialogWindowLayout::ShowPropertyBrowser ()
     {
         // creating
         pPropertyBrowser = new PropBrw(*this);
+        pPropertyBrowser->Show();
         // after OnFirstSize():
         if (HasSize())
             AddPropertyBrowser();
         // updating if neccessary
         UpdatePropertyBrowser();
     }
-    pPropertyBrowser->Show();
+    else
+        pPropertyBrowser->Show();
     // refreshing the button state
     if (SfxBindings* pBindings = GetBindingsPtr())
         pBindings->Invalidate(SID_SHOW_PROPERTYBROWSER);
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx
index bc4d32b..384566d 100644
--- a/basctl/source/basicide/bastypes.cxx
+++ b/basctl/source/basicide/bastypes.cxx
@@ -308,6 +308,10 @@ void DockingWindow::ResizeIfDocking (Point const& rPos, Size const& rSize)
             SetPosSizePixel(rPos, rSize);
     }
 }
+void DockingWindow::ResizeIfDocking (Size const& rSize)
+{
+    ResizeIfDocking(aDockingRect.TopLeft(), rSize);
+}
 
 // Sets the parent Layout window.
 // The physical parent is set only when the window is docking.
diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx
index 32edb58..752f830 100644
--- a/basctl/source/basicide/layout.cxx
+++ b/basctl/source/basicide/layout.cxx
@@ -73,34 +73,36 @@ void Layout::Resize()
 // ArrangeWindows() -- arranges the child windows
 void Layout::ArrangeWindows ()
 {
-    Size const aSize = GetOutputSizePixel();
-    int const nWidth = aSize.Width(), nHeight = aSize.Height();
-    if (!nWidth || !nHeight) // empty size
-        return;
-
     // prevent recursion via OnFirstSize() -> Add() -> ArrangeWindows()
-    static bool bRecursion = false;
-    if (bRecursion)
+    static bool bInArrangeWindows = false;
+    if (bInArrangeWindows)
         return;
-    bRecursion = true;
+    bInArrangeWindows = true;
 
-    // on first call
-    if (bFirstSize)
+    Size const aSize = GetOutputSizePixel();
+    int const nWidth = aSize.Width(), nHeight = aSize.Height();
+    if (nWidth && nHeight) // non-empty size
     {
-        bFirstSize = false;
-        this->OnFirstSize(nWidth, nHeight); // virtual
-    }
+        // On first call the derived classes initializes the sizes of the
+        // docking windows. This cannot be done at construction because
+        // the Layout has empty size at that point.
+        if (bFirstSize)
+        {
+            bFirstSize = false;
+            this->OnFirstSize(nWidth, nHeight); // virtual
+        }
 
-    // sides
-    aBottomSide.ArrangeIn(Rectangle(Point(0, 0), aSize));
-    aLeftSide.ArrangeIn(Rectangle(Point(0, 0), Size(nWidth, nHeight - aBottomSide.GetSize())));
-    // child in the middle
-    pChild->SetPosSizePixel(
-        Point(aLeftSide.GetSize(), 0),
-        Size(nWidth - aLeftSide.GetSize(), nHeight - aBottomSide.GetSize())
-    );
+        // sides
+        aBottomSide.ArrangeIn(Rectangle(Point(0, 0), aSize));
+        aLeftSide.ArrangeIn(Rectangle(Point(0, 0), Size(nWidth, nHeight - aBottomSide.GetSize())));
+        // child in the middle
+        pChild->SetPosSizePixel(
+            Point(aLeftSide.GetSize(), 0),
+            Size(nWidth - aLeftSide.GetSize(), nHeight - aBottomSide.GetSize())
+        );
+    }
 
-    bRecursion = false;
+    bInArrangeWindows = false;
 }
 
 void Layout::DockaWindow (DockingWindow*)
@@ -159,7 +161,6 @@ void Layout::DataChanged (DataChangedEvent const& rDCEvt)
 // ctor
 Layout::SplittedSide::SplittedSide (Layout* pParent, Side eSide) :
     rLayout(*pParent),
-    bFirstArrange(true),
     bVertical(eSide == Left || eSide == Right),
     bLower(eSide == Left || eSide == Top),
     nSize(0),
@@ -179,19 +180,18 @@ void Layout::SplittedSide::Add (DockingWindow* pWin, Size const& rSize)
     if (nSize1 > nSize)
         nSize = nSize1;
     // window
-    vWindows.push_back(pWin);
-    // split line
-    if (vWindows.size() > 1)
+    Item aItem;
+    aItem.pWin = pWin;
+    aItem.nStartPos = vItems.empty() ? 0 : vItems.back().nEndPos + nSplitThickness;
+    aItem.nEndPos = aItem.nStartPos + nSize2;
+    // splitter
+    if (!vItems.empty())
     {
-        vSplitters.push_back(boost::make_shared<Splitter>(
-            &rLayout, bVertical ? WB_VSCROLL : WB_HSCROLL
-        ));
-        Splitter& rSplitter = *vSplitters.back();
-        rSplitter.SetSplitPosPixel(nLastPos - nSplitThickness);
-        InitSplitter(rSplitter);
+        aItem.pSplit = boost::make_shared<Splitter>(&rLayout, bVertical ? WB_VSCROLL : WB_HSCROLL);
+        aItem.pSplit->SetSplitPosPixel(aItem.nStartPos - nSplitThickness);
+        InitSplitter(*aItem.pSplit);
     }
-    // nLastPos
-    nLastPos += nSize2 + nSplitThickness;
+    vItems.push_back(aItem);
     // refresh
     rLayout.ArrangeWindows();
 }
@@ -200,22 +200,17 @@ void Layout::SplittedSide::Add (DockingWindow* pWin, Size const& rSize)
 void Layout::SplittedSide::Remove (DockingWindow* pWin)
 {
     // contains?
-    std::vector<DockingWindow*>::iterator const itWin =
-        std::find(vWindows.begin(), vWindows.end(), pWin);
-    if (itWin == vWindows.end())
+    unsigned iWin;
+    for (iWin = 0; iWin != vItems.size(); ++iWin)
+        if (vItems[iWin].pWin == pWin)
+            break;
+    if (iWin == vItems.size())
         return;
-    // index
-    unsigned const iWin = itWin - vWindows.begin();
-    // nLastPos
-    if (iWin == vWindows.size() - 1) // that is the last one
-        nLastPos = vSplitters.back()->GetSplitPosPixel() + nSplitThickness;
     // remove
-    vWindows.erase(itWin);
-    // remove a splitter line
-    if (!vSplitters.empty())
-        vSplitters.pop_back();
-    // refresh
-    rLayout.ArrangeWindows();
+    vItems.erase(vItems.begin() + iWin);
+    // if that was the first one, remove the first splitter line
+    if (iWin == 0 && !vItems.empty())
+        vItems.front().pSplit.reset();
 }
 
 // creating a Point or a Size object
@@ -229,11 +224,17 @@ inline Point Layout::SplittedSide::MakePoint (int A, int B) const
     return bVertical ? Point(B, A) : Point(A, B);
 }
 
+// IsDocking() -- is this window currently docking in the strip?
+bool Layout::SplittedSide::IsDocking (DockingWindow const& rWin)
+{
+    return rWin.IsVisible() && !rWin.IsFloatingMode();
+}
+
 // IsEmpty() -- are there no windows docked in this strip?
 bool Layout::SplittedSide::IsEmpty () const
 {
-    for (unsigned i = 0; i != vWindows.size(); ++i)
-        if (vWindows[i]->IsVisible() && !vWindows[i]->IsFloatingMode())
+    for (unsigned i = 0; i != vItems.size(); ++i)
+        if (IsDocking(*vItems[i].pWin))
             return false;
     return true;
 }
@@ -261,57 +262,61 @@ void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect)
     int const nPos2 = bVertical ? aRect.Top() : aRect.Left();
 
     // main line
+    bool const bEmpty = IsEmpty();
+    // shown if any of the windows is docked
+    if (!bEmpty)
     {
-        // shown if any of the windows is docked
-        if (!IsEmpty())
-        {
-            aSplitter.Show();
-            // split position
-            aSplitter.SetSplitPosPixel((bLower ? nSize : nPos1) - nSplitThickness);
-            // the actual position and size
-            aSplitter.SetPosSizePixel(
-                MakePoint(nPos2, aSplitter.GetSplitPosPixel()),
-                MakeSize(nLength, nSplitThickness)
-            );
-            // dragging rectangle
-            aSplitter.SetDragRectPixel(aRect);
-        }
-        else
-            aSplitter.Hide();
+        aSplitter.Show();
+        // split position
+        aSplitter.SetSplitPosPixel((bLower ? nSize : nPos1) - nSplitThickness);
+        // the actual position and size
+        aSplitter.SetPosSizePixel(
+            MakePoint(nPos2, aSplitter.GetSplitPosPixel()),
+            MakeSize(nLength, nSplitThickness)
+        );
+        // dragging rectangle
+        aSplitter.SetDragRectPixel(aRect);
     }
+    else
+        aSplitter.Hide();
 
     // positioning separator lines and windows
-    bool bPrevDocked = false; // is the previous window docked?
-    int nStartPos = nPos2; // window position in the strip
-    for (unsigned i = 0; i != vWindows.size(); ++i)
+    bool bPrevDocking = false; // is the previous window docked?
+    int nStartPos = 0; // window position in the strip
+    unsigned iLastWin; // index of last docking window in the strip
+    // (iLastWin will be initialized if !bEmpty)
+    for (unsigned i = 0; i != vItems.size(); ++i)
     {
         // window
-        DockingWindow& rWin = *vWindows[i];
-        bool const bDocked = rWin.IsVisible() && !rWin.IsFloatingMode();
-        // The window is docked between nStartPos and nEndPos along.
-        int const nEndPos = i == vWindows.size() - 1 ?
-            nPos2 + nLength : vSplitters[i]->GetSplitPosPixel();
+        DockingWindow& rWin = *vItems[i].pWin;
+        bool const bDocking = IsDocking(rWin);
+        if (bDocking)
+            iLastWin = i;
+        // sizing window
         rWin.ResizeIfDocking(
-            MakePoint(nStartPos, nPos1),
-            MakeSize(nEndPos - nStartPos, nSize - nSplitThickness)
+            MakePoint(nPos2 + nStartPos, nPos1),
+            MakeSize(vItems[i].nEndPos - nStartPos, nSize - nSplitThickness)
         );
         // splitting line before the window
         if (i > 0)
         {
-            Splitter& rSplit = *vSplitters[i - 1];
+            Splitter& rSplit = *vItems[i].pSplit;
             // If neither of two adjacent windows are docked,
             // the splitting line is hidden.
-            if (bDocked || bPrevDocked)
+            // If this window is docking but the previous isn't,
+            // then the splitting line is also hidden, because this window
+            // will occupy the space of the previous.
+            if (bPrevDocking)
             {
                 rSplit.Show();
                 // the actual pozition and size of the line
                 rSplit.SetPosSizePixel(
-                    MakePoint(nStartPos - nSplitThickness, nPos1),
+                    MakePoint(nPos2 + nStartPos - nSplitThickness, nPos1),
                     MakeSize(nSplitThickness, nSize - nSplitThickness)
                 );
                 // the dragging rectangle
                 rSplit.SetDragRectPixel(Rectangle(
-                    MakePoint(bVertical ? aRect.Top() : aRect.Left(), nPos1),
+                    MakePoint(nPos2, nPos1),
                     MakeSize(nLength, nSize - nSplitThickness)
                 ));
             }
@@ -319,26 +324,53 @@ void Layout::SplittedSide::ArrangeIn (Rectangle const& rRect)
                 rSplit.Hide();
         }
         // next
-        bPrevDocked = bDocked;
-        nStartPos = nEndPos + nSplitThickness;
+        bPrevDocking = bDocking;
+        if (bDocking)
+            nStartPos = vItems[i].nEndPos + nSplitThickness;
+        // We only set nStartPos if this window is docking, because otherwise
+        // the next window will occupy also the space of this window.
     }
 
-    // first arrange
-    bFirstArrange = false;
+    // filling the remaining space with the last docking window
+    if (!bEmpty && vItems[iLastWin].nEndPos != nLength)
+    {
+        Item& rItem = vItems[iLastWin];
+        Size aSize = rItem.pWin->GetDockingSize();
+        (bVertical ? aSize.Height() : aSize.Width()) += nLength - rItem.nEndPos;
+        rItem.pWin->ResizeIfDocking(aSize);
+        // and hiding the split line after the window
+        if (iLastWin < vItems.size() - 1)
+            vItems[iLastWin + 1].pSplit->Hide();
+    }
 }
 
 IMPL_LINK(Layout::SplittedSide, SplitHdl, Splitter*, pSplitter)
 {
     // checking margins
     CheckMarginsFor(pSplitter);
-    // nSize has to be changed?
+    // changing stored sizes
     if (pSplitter == &aSplitter)
     {
+        // nSize
         if (bLower)
             nSize = pSplitter->GetSplitPosPixel();
         else
             nSize = (bVertical ? aRect.Right() : aRect.Bottom()) + 1 - pSplitter->GetSplitPosPixel();
     }
+    else
+    {
+        // Item::nStartPos, Item::nLength
+        for (unsigned i = 1; i < vItems.size(); ++i)
+        {
+            if (vItems[i].pSplit.get() == pSplitter)
+            {
+                // before the line
+                vItems[i - 1].nEndPos = pSplitter->GetSplitPosPixel();
+                // after the line
+                vItems[i].nStartPos = pSplitter->GetSplitPosPixel() + nSplitThickness;
+            }
+        }
+    }
     // arranging windows
     rLayout.ArrangeWindows();
 
diff --git a/basctl/source/basicide/layout.hxx b/basctl/source/basicide/layout.hxx
index 6a63547..127f77e 100644
--- a/basctl/source/basicide/layout.hxx
+++ b/basctl/source/basicide/layout.hxx
@@ -91,8 +91,6 @@ private:
     private:
         // the layout window
         Layout& rLayout;
-        // ArrangeIn() is called at first time?
-        bool bFirstArrange;
         // horizontal or vertical strip?
         bool bVertical;
         // lower (top or left) or higher (bottom or right) strip?
@@ -105,15 +103,28 @@ private:
         int nLastPos;
         // the main splitting line
         Splitter aSplitter;
-        // the dockable windows
-        std::vector<DockingWindow*> vWindows;
-        // splitting lines between the docking windows (vWindows.size() - 1)
-        std::vector<boost::shared_ptr<Splitter> > vSplitters;
-
+        // the dockable windows (and some data)
+        struct Item
+        {
+            // pointer to the dockable window
+            DockingWindow* pWin;
+            // starting and ending position in the strip
+            // They may be different from the actual window position, because
+            // the window may fill the space of the adjacent currently
+            // non-docking windows, but this change is not stored in these
+            // variables. These change only when the splitter lines are moved.
+            int nStartPos, nEndPos;
+            // splitter line window before the window
+            // (the first one is always nullptr)
+            boost::shared_ptr<Splitter> pSplit;
+        };
+        std::vector<Item> vItems;
     private:
         Point MakePoint (int, int) const;
         Size MakeSize (int, int) const;
     private:
+        static bool IsDocking (DockingWindow const&);
+    private:
         DECL_LINK(SplitHdl, Splitter*);
         void CheckMarginsFor (Splitter*);
         void InitSplitter (Splitter&);
diff --git a/basctl/source/inc/bastypes.hxx b/basctl/source/inc/bastypes.hxx
index 6d24dae..d7d2e69 100644
--- a/basctl/source/inc/bastypes.hxx
+++ b/basctl/source/inc/bastypes.hxx
@@ -82,6 +82,8 @@ public:
     DockingWindow (Layout* pParent);
 public:
     void ResizeIfDocking (Point const&, Size const&);
+    void ResizeIfDocking (Size const&);
+    Size GetDockingSize () const { return aDockingRect.GetSize(); }
     void SetLayoutWindow (Layout*);
 public:
     void Show (bool = true);
@@ -228,9 +230,9 @@ public:
 
     virtual void OnNewDocument ();
     virtual char const* GetHid () const = 0;
-    virtual ItemType GetType () const = 0; // TODO
+    virtual ItemType GetType () const = 0;
     void InsertLibInfo () const;
-    bool Is (ScriptDocument const&, rtl::OUString const&, rtl::OUString const&, ItemType, bool bFindSuspended); // TODO
+    bool Is (ScriptDocument const&, rtl::OUString const&, rtl::OUString const&, ItemType, bool bFindSuspended);
     virtual bool HasActiveEditor () const;
 };
 


More information about the Libreoffice-commits mailing list