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