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 : * 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 :
20 : #include "expbase.hxx"
21 : #include "document.hxx"
22 : #include "editutil.hxx"
23 :
24 3 : ScExportBase::ScExportBase( SvStream& rStrmP, ScDocument* pDocP,
25 : const ScRange& rRangeP )
26 : :
27 : rStrm( rStrmP ),
28 : aRange( rRangeP ),
29 : pDoc( pDocP ),
30 3 : pFormatter( pDocP->GetFormatTable() ),
31 6 : pEditEngine( NULL )
32 : {
33 3 : }
34 :
35 3 : ScExportBase::~ScExportBase()
36 : {
37 3 : delete pEditEngine;
38 3 : }
39 :
40 6 : bool ScExportBase::GetDataArea( SCTAB nTab, SCCOL& nStartCol,
41 : SCROW& nStartRow, SCCOL& nEndCol, SCROW& nEndRow ) const
42 : {
43 6 : pDoc->GetDataStart( nTab, nStartCol, nStartRow );
44 6 : pDoc->GetPrintArea( nTab, nEndCol, nEndRow, true );
45 6 : return TrimDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
46 : }
47 :
48 6 : bool ScExportBase::TrimDataArea( SCTAB nTab, SCCOL& nStartCol,
49 : SCROW& nStartRow, SCCOL& nEndCol, SCROW& nEndRow ) const
50 : {
51 12 : while ( nStartCol <= nEndCol && pDoc->ColHidden(nStartCol, nTab))
52 0 : ++nStartCol;
53 12 : while ( nStartCol <= nEndCol && pDoc->ColHidden(nEndCol, nTab))
54 0 : --nEndCol;
55 6 : nStartRow = pDoc->FirstVisibleRow(nStartRow, nEndRow, nTab);
56 6 : nEndRow = pDoc->LastVisibleRow(nStartRow, nEndRow, nTab);
57 12 : return nStartCol <= nEndCol && nStartRow <= nEndRow && nEndRow !=
58 12 : ::std::numeric_limits<SCROW>::max();
59 : }
60 :
61 3 : bool ScExportBase::IsEmptyTable( SCTAB nTab ) const
62 : {
63 3 : if ( !pDoc->HasTable( nTab ) || !pDoc->IsVisible( nTab ) )
64 0 : return true;
65 : SCCOL nStartCol, nEndCol;
66 : SCROW nStartRow, nEndRow;
67 3 : return !GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
68 : }
69 :
70 0 : ScFieldEditEngine& ScExportBase::GetEditEngine() const
71 : {
72 0 : if ( !pEditEngine )
73 0 : const_cast<ScExportBase*>(this)->pEditEngine = new ScFieldEditEngine(pDoc, pDoc->GetEditPool());
74 0 : return *pEditEngine;
75 30 : }
76 :
77 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|