LCOV - code coverage report
Current view: top level - sc/source/ui/dialogs - searchresults.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 43 0.0 %
Date: 2014-04-14 Functions: 0 8 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 "searchresults.hxx"
      11             : 
      12             : #include <svtools/simptabl.hxx>
      13             : #include <svtools/treelistentry.hxx>
      14             : #include "dociter.hxx"
      15             : #include "document.hxx"
      16             : #include "rangeutl.hxx"
      17             : #include "tabvwsh.hxx"
      18             : 
      19           0 : SearchResults::SearchResults(ScDocument *pDoc) :
      20             :     ModelessDialog(NULL, "SearchResultsDialog", "modules/scalc/ui/searchresults.ui")
      21           0 :     , mpDoc(pDoc)
      22             : {
      23           0 :     SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("results");
      24           0 :     Size aControlSize(150, 120);
      25           0 :     aControlSize = pContainer->LogicToPixel(aControlSize, MAP_APPFONT);
      26           0 :     pContainer->set_width_request(aControlSize.Width());
      27           0 :     pContainer->set_height_request(aControlSize.Height());
      28             : 
      29           0 :     mpList = new SvSimpleTable(*pContainer);
      30           0 :     long nTabs[] = {3, 0, 40, 60};
      31           0 :     mpList->SetTabs(&nTabs[0]);
      32           0 :     mpList->InsertHeaderEntry("Sheet\tCell\tContent");
      33           0 :     mpList->SetSelectHdl( LINK(this, SearchResults, ListSelectHdl) );
      34           0 : }
      35             : 
      36           0 : SearchResults::~SearchResults()
      37             : {
      38           0 :     delete mpList;
      39           0 : }
      40             : 
      41           0 : void SearchResults::Show(const ScRangeList &rMatchedRanges)
      42             : {
      43           0 :     mpList->Clear();
      44           0 :     mpList->SetUpdateMode(false);
      45           0 :     for (size_t i = 0, n = rMatchedRanges.size(); i < n; ++i)
      46             :     {
      47           0 :         ScCellIterator aIter(mpDoc, *rMatchedRanges[i]);
      48           0 :         for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
      49             :         {
      50           0 :             ScAddress aAddress = aIter.GetPos();
      51           0 :             OUString sAddress;
      52             :             ScRangeStringConverter::GetStringFromAddress(sAddress, aAddress,
      53           0 :                     mpDoc, formula::FormulaGrammar::CONV_OOO);
      54           0 :             mpList->InsertEntry(sAddress.replace('.', '\t') + "\t" + mpDoc->GetString(aAddress));
      55           0 :         }
      56           0 :     }
      57           0 :     mpList->SetUpdateMode(true);
      58           0 :     ModelessDialog::Show();
      59           0 : }
      60             : 
      61           0 : IMPL_LINK_NOARG( SearchResults, ListSelectHdl )
      62             : {
      63           0 :     SvTreeListEntry *pEntry = mpList->FirstSelected();
      64           0 :     ScAddress aAddress;
      65           0 :     sal_Int32 nOffset = 0;
      66           0 :     OUString sAddress = mpList->GetEntryText(pEntry).replaceFirst("\t", ".");
      67             :     ScRangeStringConverter::GetAddressFromString(aAddress, sAddress,
      68           0 :             mpDoc, formula::FormulaGrammar::CONV_OOO, nOffset, '\t');
      69           0 :     ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
      70           0 :     pScViewShell->SetTabNo(aAddress.Tab());
      71           0 :     pScViewShell->SetCursor(aAddress.Col(), aAddress.Row());
      72           0 :     pScViewShell->AlignToCursor(aAddress.Col(), aAddress.Row(), SC_FOLLOW_JUMP);
      73           0 :     return 0;
      74           0 : }
      75             : 
      76             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10