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