Advertisement
Guest User

Untitled

a guest
May 17th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.99 KB | None | 0 0
  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /*
  3.  * Thiss 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.  * This file incorporates work covered by the following license notice:
  10.  *
  11.  *   Licensed to the Apache Software Foundation (ASF) under one or more
  12.  *   contributor license agreements. See the NOTICE file distributed
  13.  *   with this work for additional information regarding copyright
  14.  *   ownership. The ASF licenses this file to you under the Apache
  15.  *   License, Version 2.0 (the "License"); you may not use this file
  16.  *   except in compliance with the License. You may obtain a copy of
  17.  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  18.  */
  19. #include "dbdatalabel.hxx"
  20. #include "address.hxx"
  21. #include "globalnames.hxx"
  22.  
  23. ScDBDataLabel::ScDBDataLabel(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bColH, bool bHasT) :
  24.     nTable      (nTab),
  25.     nStartHeaderCol(nCol1),
  26.     nStartHeaderRow(nRow1),
  27.     nEndHeaderCol(nCol2),
  28.     nEndHeaderRow(nRow2),
  29.     bIsColHeader(bColH),
  30.     bHasTotal   (bHasT)
  31. {
  32.     //Created the ScDataLabel
  33.     SAL_DEBUG("Created label collabel: "<<bIsColHeader<<" startcol: "<<nStartHeaderCol);
  34. }
  35. ScDBDataLabel::~ScDBDataLabel()
  36. {
  37.     //Will be cleaning up later
  38. }
  39. void ScDBDataLabel::GetHeaderDataRange(ScRange& rRange) const
  40. {
  41.     //Only return the range excluding the header and total cell if defined
  42.     //Is such on the fly arithmetic acceptable?
  43.     if (bHasTotal)//The header has a total cell
  44.     {
  45.         if(bIsColHeader)//it is a column header
  46.         {
  47.             //Here the data starts from Row1+1 and ends at Row2-1
  48.             SCROW newDataRow1 = nStartHeaderRow+1;
  49.             SCROW newDataRow2 = nEndHeaderRow-1;
  50.             rRange = ScRange( nStartHeaderCol, newDataRow1, nTable, nEndHeaderCol, newDataRow2, nTable );//Is such arithmetic tolerable?
  51.         }
  52.         else//it is a row header
  53.         {
  54.             //Here the data starts at Col1+1 and Ends at Col2-1
  55.             SCCOL newDataCol1 = nStartHeaderCol+1;
  56.             SCCOL newDataCol2 = nEndHeaderCol-1;
  57.             rRange = ScRange( newDataCol1 , nStartHeaderRow, nTable, newDataCol2, nEndHeaderRow, nTable );
  58.         }
  59.     }
  60.     else//Does not have a total cell, data extends right up till the end
  61.     {
  62.         if(bIsColHeader)//it is a column header
  63.         {
  64.             //Here the data starts from Row1+1 and ends at Row2
  65.             SCROW newDataRow1 = nStartHeaderRow+1;
  66.             rRange = ScRange( nStartHeaderCol, newDataRow1, nTable, nEndHeaderCol, nEndHeaderRow, nTable );
  67.         }
  68.         else//it is a row header
  69.         {
  70.             //Here the data starts at Col1+1 and ends at Col2
  71.             SCCOL newDataCol1 = nStartHeaderCol+1;
  72.             rRange = ScRange( newDataCol1, nStartHeaderRow, nTable, nEndHeaderCol, nEndHeaderRow, nTable );
  73.         }
  74.     }
  75. }
  76. void ScDBDataLabel::GetHeaderTotalCell( ScAddress& rAddr) const
  77. {
  78.     if(bIsColHeader)//It is a column header
  79.     {
  80.         rAddr = ScAddress( nStartHeaderCol, nEndHeaderRow, nTable );
  81.     }
  82.     else//It is a row header
  83.     {
  84.         rAddr = ScAddress( nEndHeaderCol, nStartHeaderRow, nTable );
  85.     }
  86. }    
  87. void ScDBDataLabel::GetHeaderNameCell( ScAddress& rAddr) const
  88. {
  89.     rAddr = ScAddress( nStartHeaderCol, nStartHeaderRow, nTable );
  90. }
  91. const ::rtl::OUString& ScDBDataLabel::GetHeaderName() const
  92. {
  93.     /*This method will return the string containing the name of teh header*/
  94.     /*I wanted to design it to access this string data at runtime, to */
  95.     /*proof the method against changing values of those header fields */
  96.     ::rtl::OUString hname = "Nothing";
  97.     return hname;
  98. }
  99. const ::rtl::OUString& ScDBDataLabel::GetHeaderUpperName() const
  100. {
  101.     ::rtl::OUString hUname = "NOTHING";
  102.     return hUname;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement