LCOV - code coverage report
Current view: top level - sc/source/ui/dbgui - sortkeydlg.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 75 0.0 %
Date: 2014-11-03 Functions: 0 16 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include "sortkeydlg.hxx"
      11             : #include "sortdlg.hxx"
      12             : #include <vcl/layout.hxx>
      13             : 
      14           0 : ScSortKeyItem::ScSortKeyItem(vcl::Window* pParent)
      15             : {
      16           0 :     m_pUIBuilder = new VclBuilder(pParent, getUIRootDir(), "modules/scalc/ui/sortkey.ui");
      17             : 
      18           0 :     get(m_pFrame, "SortKeyFrame");
      19           0 :     get(m_pFlSort, "sortft");
      20           0 :     get(m_pLbSort, "sortlb");
      21           0 :     get(m_pBtnUp, "up");
      22           0 :     get(m_pBtnDown, "down");
      23           0 : }
      24             : 
      25           0 : long ScSortKeyItem::getItemHeight() const
      26             : {
      27           0 :     return VclContainer::getLayoutRequisition(*m_pFrame).Height();
      28             : }
      29             : 
      30           0 : void ScSortKeyItem::DisableField()
      31             : {
      32           0 :     m_pFrame->Disable();
      33           0 : }
      34             : 
      35           0 : void ScSortKeyItem::EnableField()
      36             : {
      37           0 :     m_pFrame->Enable();
      38           0 : }
      39             : 
      40           0 : ScSortKeyWindow::ScSortKeyWindow(SfxTabPage* pParent, ScSortKeyItems& rSortKeyItems)
      41           0 :     : mrSortKeyItems(rSortKeyItems)
      42             : {
      43           0 :     pParent->get(m_pBox, "SortKeyWindow");
      44           0 :     if (!mrSortKeyItems.empty())
      45           0 :         nItemHeight = mrSortKeyItems.front().getItemHeight();
      46             :     else
      47             :     {
      48           0 :         ScSortKeyItem aTemp(m_pBox);
      49           0 :         nItemHeight = aTemp.getItemHeight();
      50             :     }
      51           0 : }
      52             : 
      53           0 : ScSortKeyWindow::~ScSortKeyWindow()
      54             : {
      55           0 :     mrSortKeyItems.clear();
      56           0 : }
      57             : 
      58           0 : void ScSortKeyWindow::AddSortKey( sal_uInt16 nItemNumber )
      59             : {
      60           0 :     ScSortKeyItem* pSortKeyItem = new ScSortKeyItem(m_pBox);
      61             : 
      62             :     // Set Sort key number
      63           0 :     OUString aLine = pSortKeyItem->m_pFlSort->GetText() +
      64           0 :                      OUString::number( nItemNumber );
      65           0 :     pSortKeyItem->m_pFlSort->SetText( aLine );
      66             : 
      67           0 :     mrSortKeyItems.push_back(pSortKeyItem);
      68           0 : }
      69             : 
      70           0 : void ScSortKeyWindow::DoScroll(sal_Int32 nNewPos)
      71             : {
      72           0 :     m_pBox->SetPosPixel(Point(0, nNewPos));
      73           0 : }
      74             : 
      75           0 : ScSortKeyCtrl::ScSortKeyCtrl(SfxTabPage* pParent, ScSortKeyItems& rItems)
      76             :     : m_aSortWin(pParent, rItems)
      77           0 :     , m_rScrolledWindow(*pParent->get<VclScrolledWindow>("SortCriteriaPage"))
      78           0 :     , m_rVertScroll(m_rScrolledWindow.getVertScrollBar())
      79             : {
      80           0 :     m_rScrolledWindow.setUserManagedScrolling(true);
      81             : 
      82           0 :     m_rVertScroll.EnableDrag();
      83           0 :     m_rVertScroll.Show(m_rScrolledWindow.GetStyle() & WB_VSCROLL);
      84             : 
      85           0 :     m_rVertScroll.SetRangeMin( 0 );
      86           0 :     m_rVertScroll.SetVisibleSize( 0xFFFF );
      87             : 
      88           0 :     Link aScrollLink = LINK( this, ScSortKeyCtrl, ScrollHdl );
      89           0 :     m_rVertScroll.SetScrollHdl( aScrollLink );
      90           0 : }
      91             : 
      92           0 : void ScSortKeyCtrl::checkAutoVScroll()
      93             : {
      94           0 :     WinBits nBits = m_rScrolledWindow.GetStyle();
      95           0 :     if (nBits & WB_VSCROLL)
      96           0 :         return;
      97           0 :     if (nBits & WB_AUTOVSCROLL)
      98             :     {
      99           0 :         bool bShow = m_rVertScroll.GetRangeMax() > m_rVertScroll.GetVisibleSize();
     100           0 :         if (bShow != m_rVertScroll.IsVisible())
     101           0 :             m_rVertScroll.Show(bShow);
     102             :     }
     103             : }
     104             : 
     105           0 : void ScSortKeyCtrl::setScrollRange()
     106             : {
     107           0 :     sal_Int32 nScrollOffset = m_aSortWin.GetItemHeight();
     108           0 :     sal_Int32 nVisibleItems = m_rScrolledWindow.getVisibleChildSize().Height() / nScrollOffset;
     109           0 :     m_rVertScroll.SetPageSize( nVisibleItems - 1 );
     110           0 :     m_rVertScroll.SetVisibleSize( nVisibleItems );
     111           0 :     m_rVertScroll.Scroll();
     112           0 :     checkAutoVScroll();
     113           0 : }
     114             : 
     115           0 : IMPL_LINK( ScSortKeyCtrl, ScrollHdl, ScrollBar*, pScrollBar )
     116             : {
     117           0 :     sal_Int32 nOffset = m_aSortWin.GetItemHeight();
     118           0 :     nOffset *= pScrollBar->GetThumbPos();
     119           0 :     m_aSortWin.DoScroll( -nOffset );
     120           0 :     return 0;
     121             : }
     122             : 
     123           0 : void ScSortKeyCtrl::AddSortKey( sal_uInt16 nItem )
     124             : {
     125           0 :     m_rVertScroll.SetRangeMax( nItem );
     126           0 :     m_rVertScroll.DoScroll( nItem );
     127           0 :     m_aSortWin.AddSortKey( nItem );
     128           0 :     checkAutoVScroll();
     129           0 : }
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10