Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
- /*
- * Thiss file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
- #include "dbdatalabel.hxx"
- #include "address.hxx"
- #include "globalnames.hxx"
- ScDBDataLabel::ScDBDataLabel(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, bool bColH, bool bHasT) :
- nTable (nTab),
- nStartHeaderCol(nCol1),
- nStartHeaderRow(nRow1),
- nEndHeaderCol(nCol2),
- nEndHeaderRow(nRow2),
- bIsColHeader(bColH),
- bHasTotal (bHasT)
- {
- //Created the ScDataLabel
- SAL_DEBUG("Created label collabel: "<<bIsColHeader<<" startcol: "<<nStartHeaderCol);
- }
- ScDBDataLabel::~ScDBDataLabel()
- {
- //Will be cleaning up later
- }
- void ScDBDataLabel::GetHeaderDataRange(ScRange& rRange) const
- {
- //Only return the range excluding the header and total cell if defined
- //Is such on the fly arithmetic acceptable?
- if (bHasTotal)//The header has a total cell
- {
- if(bIsColHeader)//it is a column header
- {
- //Here the data starts from Row1+1 and ends at Row2-1
- SCROW newDataRow1 = nStartHeaderRow+1;
- SCROW newDataRow2 = nEndHeaderRow-1;
- rRange = ScRange( nStartHeaderCol, newDataRow1, nTable, nEndHeaderCol, newDataRow2, nTable );//Is such arithmetic tolerable?
- }
- else//it is a row header
- {
- //Here the data starts at Col1+1 and Ends at Col2-1
- SCCOL newDataCol1 = nStartHeaderCol+1;
- SCCOL newDataCol2 = nEndHeaderCol-1;
- rRange = ScRange( newDataCol1 , nStartHeaderRow, nTable, newDataCol2, nEndHeaderRow, nTable );
- }
- }
- else//Does not have a total cell, data extends right up till the end
- {
- if(bIsColHeader)//it is a column header
- {
- //Here the data starts from Row1+1 and ends at Row2
- SCROW newDataRow1 = nStartHeaderRow+1;
- rRange = ScRange( nStartHeaderCol, newDataRow1, nTable, nEndHeaderCol, nEndHeaderRow, nTable );
- }
- else//it is a row header
- {
- //Here the data starts at Col1+1 and ends at Col2
- SCCOL newDataCol1 = nStartHeaderCol+1;
- rRange = ScRange( newDataCol1, nStartHeaderRow, nTable, nEndHeaderCol, nEndHeaderRow, nTable );
- }
- }
- }
- void ScDBDataLabel::GetHeaderTotalCell( ScAddress& rAddr) const
- {
- if(bIsColHeader)//It is a column header
- {
- rAddr = ScAddress( nStartHeaderCol, nEndHeaderRow, nTable );
- }
- else//It is a row header
- {
- rAddr = ScAddress( nEndHeaderCol, nStartHeaderRow, nTable );
- }
- }
- void ScDBDataLabel::GetHeaderNameCell( ScAddress& rAddr) const
- {
- rAddr = ScAddress( nStartHeaderCol, nStartHeaderRow, nTable );
- }
- const ::rtl::OUString& ScDBDataLabel::GetHeaderName() const
- {
- /*This method will return the string containing the name of teh header*/
- /*I wanted to design it to access this string data at runtime, to */
- /*proof the method against changing values of those header fields */
- ::rtl::OUString hname = "Nothing";
- return hname;
- }
- const ::rtl::OUString& ScDBDataLabel::GetHeaderUpperName() const
- {
- ::rtl::OUString hUname = "NOTHING";
- return hUname;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement