xref: /aoo4110/main/sc/source/filter/rtf/expbase.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sc.hxx"
26 
27 
28 
29 
30 #include "expbase.hxx"
31 #include "document.hxx"
32 #include "editutil.hxx"
33 
34 
35 //------------------------------------------------------------------
36 
37 #if defined(UNX)
38 const sal_Char __FAR_DATA ScExportBase::sNewLine = '\012';
39 #else
40 const sal_Char __FAR_DATA ScExportBase::sNewLine[] = "\015\012";
41 #endif
42 
43 
ScExportBase(SvStream & rStrmP,ScDocument * pDocP,const ScRange & rRangeP)44 ScExportBase::ScExportBase( SvStream& rStrmP, ScDocument* pDocP,
45 				const ScRange& rRangeP )
46 			:
47 			rStrm( rStrmP ),
48 			aRange( rRangeP ),
49 			pDoc( pDocP ),
50 			pFormatter( pDocP->GetFormatTable() ),
51 			pEditEngine( NULL )
52 {
53 }
54 
55 
~ScExportBase()56 ScExportBase::~ScExportBase()
57 {
58 	delete pEditEngine;
59 }
60 
61 
GetDataArea(SCTAB nTab,SCCOL & nStartCol,SCROW & nStartRow,SCCOL & nEndCol,SCROW & nEndRow) const62 sal_Bool ScExportBase::GetDataArea( SCTAB nTab, SCCOL& nStartCol,
63 			SCROW& nStartRow, SCCOL& nEndCol, SCROW& nEndRow ) const
64 {
65 	pDoc->GetDataStart( nTab, nStartCol, nStartRow );
66 	pDoc->GetPrintArea( nTab, nEndCol, nEndRow, sal_True );
67 	return TrimDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
68 }
69 
70 
TrimDataArea(SCTAB nTab,SCCOL & nStartCol,SCROW & nStartRow,SCCOL & nEndCol,SCROW & nEndRow) const71 sal_Bool ScExportBase::TrimDataArea( SCTAB nTab, SCCOL& nStartCol,
72 			SCROW& nStartRow, SCCOL& nEndCol, SCROW& nEndRow ) const
73 {
74     SCCOL nLastCol;
75 	while ( nStartCol <= nEndCol && pDoc->ColHidden(nStartCol, nTab, nLastCol))
76 		++nStartCol;
77 	while ( nStartCol <= nEndCol && pDoc->ColHidden(nEndCol, nTab, nLastCol))
78 		--nEndCol;
79     nStartRow = pDoc->FirstVisibleRow(nStartRow, nEndRow, nTab);
80     nEndRow = pDoc->LastVisibleRow(nStartRow, nEndRow, nTab);
81     return nStartCol <= nEndCol && nStartRow <= nEndRow && nEndRow !=
82         ::std::numeric_limits<SCROW>::max();
83 }
84 
85 
IsEmptyTable(SCTAB nTab) const86 sal_Bool ScExportBase::IsEmptyTable( SCTAB nTab ) const
87 {
88 	if ( !pDoc->HasTable( nTab ) || !pDoc->IsVisible( nTab ) )
89 		return sal_True;
90 	SCCOL nStartCol, nEndCol;
91 	SCROW nStartRow, nEndRow;
92 	return !GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
93 }
94 
95 
GetEditEngine() const96 ScFieldEditEngine& ScExportBase::GetEditEngine() const
97 {
98 	if ( !pEditEngine )
99 		((ScExportBase*)this)->pEditEngine = new ScFieldEditEngine( pDoc->GetEditPool() );
100 	return *pEditEngine;
101 }
102 
103 
104