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 // INCLUDE ---------------------------------------------------------------
30
31 #include <sfx2/docfile.hxx>
32 #include <sfx2/objsh.hxx>
33 #include <unotools/textsearch.hxx>
34 #include <unotools/pathoptions.hxx>
35 #include <unotools/useroptions.hxx>
36 #include <tools/urlobj.hxx>
37 #include <unotools/charclass.hxx>
38 #include <stdlib.h>
39 #include <ctype.h>
40 #include <unotools/syslocale.hxx>
41
42 #include "global.hxx"
43 #include "rangeutl.hxx"
44 #include "rechead.hxx"
45 #include "compiler.hxx"
46 #include "paramisc.hxx"
47
48 #include "sc.hrc"
49 #include "globstr.hrc"
50
51 using ::std::vector;
52
53 // -----------------------------------------------------------------------
54
55
56
57
58 //------------------------------------------------------------------------
59 // struct ScImportParam:
60
ScImportParam()61 ScImportParam::ScImportParam() :
62 nCol1(0),
63 nRow1(0),
64 nCol2(0),
65 nRow2(0),
66 bImport(sal_False),
67 bNative(sal_False),
68 bSql(sal_True),
69 nType(ScDbTable)
70 {
71 }
72
ScImportParam(const ScImportParam & r)73 ScImportParam::ScImportParam( const ScImportParam& r ) :
74 nCol1 (r.nCol1),
75 nRow1 (r.nRow1),
76 nCol2 (r.nCol2),
77 nRow2 (r.nRow2),
78 bImport (r.bImport),
79 aDBName (r.aDBName),
80 aStatement (r.aStatement),
81 bNative (r.bNative),
82 bSql (r.bSql),
83 nType (r.nType)
84 {
85 }
86
~ScImportParam()87 ScImportParam::~ScImportParam()
88 {
89 }
90
91 //UNUSED2009-05 void ScImportParam::Clear()
92 //UNUSED2009-05 {
93 //UNUSED2009-05 nCol1 = nCol2 = 0;
94 //UNUSED2009-05 nRow1 = nRow2 = 0;
95 //UNUSED2009-05 bImport = sal_False;
96 //UNUSED2009-05 bNative = sal_False;
97 //UNUSED2009-05 bSql = sal_True;
98 //UNUSED2009-05 nType = ScDbTable;
99 //UNUSED2009-05 aDBName.Erase();
100 //UNUSED2009-05 aStatement.Erase();
101 //UNUSED2009-05 }
102
operator =(const ScImportParam & r)103 ScImportParam& ScImportParam::operator=( const ScImportParam& r )
104 {
105 nCol1 = r.nCol1;
106 nRow1 = r.nRow1;
107 nCol2 = r.nCol2;
108 nRow2 = r.nRow2;
109 bImport = r.bImport;
110 aDBName = r.aDBName;
111 aStatement = r.aStatement;
112 bNative = r.bNative;
113 bSql = r.bSql;
114 nType = r.nType;
115
116 return *this;
117 }
118
operator ==(const ScImportParam & rOther) const119 sal_Bool ScImportParam::operator==( const ScImportParam& rOther ) const
120 {
121 return( nCol1 == rOther.nCol1 &&
122 nRow1 == rOther.nRow1 &&
123 nCol2 == rOther.nCol2 &&
124 nRow2 == rOther.nRow2 &&
125 bImport == rOther.bImport &&
126 aDBName == rOther.aDBName &&
127 aStatement == rOther.aStatement &&
128 bNative == rOther.bNative &&
129 bSql == rOther.bSql &&
130 nType == rOther.nType );
131
132 //! nQuerySh und pConnection sind gleich ?
133 }
134
135
136 //------------------------------------------------------------------------
137 // struct ScQueryParam:
138
ScQueryEntry()139 ScQueryEntry::ScQueryEntry() :
140 bDoQuery(sal_False),
141 bQueryByString(sal_False),
142 bQueryByDate(false),
143 nField(0),
144 eOp(SC_EQUAL),
145 eConnect(SC_AND),
146 pStr(new String),
147 nVal(0.0),
148 pSearchParam(NULL),
149 pSearchText(NULL)
150 {
151 }
152
ScQueryEntry(const ScQueryEntry & r)153 ScQueryEntry::ScQueryEntry(const ScQueryEntry& r) :
154 bDoQuery(r.bDoQuery),
155 bQueryByString(r.bQueryByString),
156 bQueryByDate(r.bQueryByDate),
157 nField(r.nField),
158 eOp(r.eOp),
159 eConnect(r.eConnect),
160 pStr(new String(*r.pStr)),
161 nVal(r.nVal),
162 pSearchParam(NULL),
163 pSearchText(NULL)
164 {
165 }
166
~ScQueryEntry()167 ScQueryEntry::~ScQueryEntry()
168 {
169 delete pStr;
170 if ( pSearchParam )
171 {
172 delete pSearchParam;
173 delete pSearchText;
174 }
175 }
176
operator =(const ScQueryEntry & r)177 ScQueryEntry& ScQueryEntry::operator=( const ScQueryEntry& r )
178 {
179 bDoQuery = r.bDoQuery;
180 bQueryByString = r.bQueryByString;
181 bQueryByDate = r.bQueryByDate;
182 eOp = r.eOp;
183 eConnect = r.eConnect;
184 nField = r.nField;
185 nVal = r.nVal;
186 *pStr = *r.pStr;
187 if ( pSearchParam )
188 {
189 delete pSearchParam;
190 delete pSearchText;
191 }
192 pSearchParam = NULL;
193 pSearchText = NULL;
194
195 return *this;
196 }
197
Clear()198 void ScQueryEntry::Clear()
199 {
200 bDoQuery = sal_False;
201 bQueryByString = sal_False;
202 bQueryByDate = false;
203 eOp = SC_EQUAL;
204 eConnect = SC_AND;
205 nField = 0;
206 nVal = 0.0;
207 pStr->Erase();
208 if ( pSearchParam )
209 {
210 delete pSearchParam;
211 delete pSearchText;
212 }
213 pSearchParam = NULL;
214 pSearchText = NULL;
215 }
216
operator ==(const ScQueryEntry & r) const217 sal_Bool ScQueryEntry::operator==( const ScQueryEntry& r ) const
218 {
219 return bDoQuery == r.bDoQuery
220 && bQueryByString == r.bQueryByString
221 && bQueryByDate == r.bQueryByDate
222 && eOp == r.eOp
223 && eConnect == r.eConnect
224 && nField == r.nField
225 && nVal == r.nVal
226 && *pStr == *r.pStr;
227 //! pSearchParam und pSearchText nicht vergleichen
228 }
229
GetSearchTextPtr(sal_Bool bCaseSens)230 utl::TextSearch* ScQueryEntry::GetSearchTextPtr( sal_Bool bCaseSens )
231 {
232 if ( !pSearchParam )
233 {
234 pSearchParam = new utl::SearchParam( *pStr, utl::SearchParam::SRCH_REGEXP,
235 bCaseSens, sal_False, sal_False );
236 pSearchText = new utl::TextSearch( *pSearchParam, *ScGlobal::pCharClass );
237 }
238 return pSearchText;
239 }
240
241 //------------------------------------------------------------------------
242 // struct ScSubTotalParam:
243
ScSubTotalParam()244 ScSubTotalParam::ScSubTotalParam()
245 {
246 for ( sal_uInt16 i=0; i<MAXSUBTOTAL; i++ )
247 {
248 nSubTotals[i] = 0;
249 pSubTotals[i] = NULL;
250 pFunctions[i] = NULL;
251 }
252
253 Clear();
254 }
255
256 //------------------------------------------------------------------------
257
ScSubTotalParam(const ScSubTotalParam & r)258 ScSubTotalParam::ScSubTotalParam( const ScSubTotalParam& r ) :
259 nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2),
260 bRemoveOnly(r.bRemoveOnly),bReplace(r.bReplace),bPagebreak(r.bPagebreak),bCaseSens(r.bCaseSens),
261 bDoSort(r.bDoSort),bAscending(r.bAscending),bUserDef(r.bUserDef),nUserIndex(r.nUserIndex),
262 bIncludePattern(r.bIncludePattern)
263 {
264 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
265 {
266 bGroupActive[i] = r.bGroupActive[i];
267 nField[i] = r.nField[i];
268
269 if ( (r.nSubTotals[i] > 0) && r.pSubTotals[i] && r.pFunctions[i] )
270 {
271 nSubTotals[i] = r.nSubTotals[i];
272 pSubTotals[i] = new SCCOL [r.nSubTotals[i]];
273 pFunctions[i] = new ScSubTotalFunc [r.nSubTotals[i]];
274
275 for (SCCOL j=0; j<r.nSubTotals[i]; j++)
276 {
277 pSubTotals[i][j] = r.pSubTotals[i][j];
278 pFunctions[i][j] = r.pFunctions[i][j];
279 }
280 }
281 else
282 {
283 nSubTotals[i] = 0;
284 pSubTotals[i] = NULL;
285 pFunctions[i] = NULL;
286 }
287 }
288 }
289
290 //------------------------------------------------------------------------
291
Clear()292 void ScSubTotalParam::Clear()
293 {
294 nCol1=nCol2= 0;
295 nRow1=nRow2 = 0;
296 nUserIndex = 0;
297 bPagebreak=bCaseSens=bUserDef=bIncludePattern=bRemoveOnly = sal_False;
298 bAscending=bReplace=bDoSort = sal_True;
299
300 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
301 {
302 bGroupActive[i] = sal_False;
303 nField[i] = 0;
304
305 if ( (nSubTotals[i] > 0) && pSubTotals[i] && pFunctions[i] )
306 {
307 for ( SCCOL j=0; j<nSubTotals[i]; j++ ) {
308 pSubTotals[i][j] = 0;
309 pFunctions[i][j] = SUBTOTAL_FUNC_NONE;
310 }
311 }
312 }
313 }
314
315 //------------------------------------------------------------------------
316
operator =(const ScSubTotalParam & r)317 ScSubTotalParam& ScSubTotalParam::operator=( const ScSubTotalParam& r )
318 {
319 nCol1 = r.nCol1;
320 nRow1 = r.nRow1;
321 nCol2 = r.nCol2;
322 nRow2 = r.nRow2;
323 bRemoveOnly = r.bRemoveOnly;
324 bReplace = r.bReplace;
325 bPagebreak = r.bPagebreak;
326 bCaseSens = r.bCaseSens;
327 bDoSort = r.bDoSort;
328 bAscending = r.bAscending;
329 bUserDef = r.bUserDef;
330 nUserIndex = r.nUserIndex;
331 bIncludePattern = r.bIncludePattern;
332
333 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
334 {
335 bGroupActive[i] = r.bGroupActive[i];
336 nField[i] = r.nField[i];
337 nSubTotals[i] = r.nSubTotals[i];
338
339 if ( pSubTotals[i] ) delete [] pSubTotals[i];
340 if ( pFunctions[i] ) delete [] pFunctions[i];
341
342 if ( r.nSubTotals[i] > 0 )
343 {
344 pSubTotals[i] = new SCCOL [r.nSubTotals[i]];
345 pFunctions[i] = new ScSubTotalFunc [r.nSubTotals[i]];
346
347 for (SCCOL j=0; j<r.nSubTotals[i]; j++)
348 {
349 pSubTotals[i][j] = r.pSubTotals[i][j];
350 pFunctions[i][j] = r.pFunctions[i][j];
351 }
352 }
353 else
354 {
355 nSubTotals[i] = 0;
356 pSubTotals[i] = NULL;
357 pFunctions[i] = NULL;
358 }
359 }
360
361 return *this;
362 }
363
364 //------------------------------------------------------------------------
365
operator ==(const ScSubTotalParam & rOther) const366 sal_Bool ScSubTotalParam::operator==( const ScSubTotalParam& rOther ) const
367 {
368 sal_Bool bEqual = (nCol1 == rOther.nCol1)
369 && (nRow1 == rOther.nRow1)
370 && (nCol2 == rOther.nCol2)
371 && (nRow2 == rOther.nRow2)
372 && (bRemoveOnly == rOther.bRemoveOnly)
373 && (bReplace == rOther.bReplace)
374 && (bPagebreak == rOther.bPagebreak)
375 && (bDoSort == rOther.bDoSort)
376 && (bCaseSens == rOther.bCaseSens)
377 && (bAscending == rOther.bAscending)
378 && (bUserDef == rOther.bUserDef)
379 && (nUserIndex == rOther.nUserIndex)
380 && (bIncludePattern== rOther.bIncludePattern);
381
382 if ( bEqual )
383 {
384 bEqual = sal_True;
385 for ( sal_uInt16 i=0; i<MAXSUBTOTAL && bEqual; i++ )
386 {
387 bEqual = (bGroupActive[i] == rOther.bGroupActive[i])
388 && (nField[i] == rOther.nField[i])
389 && (nSubTotals[i] == rOther.nSubTotals[i]);
390
391 if ( bEqual && (nSubTotals[i] > 0) )
392 {
393 bEqual = (pSubTotals != NULL) && (pFunctions != NULL);
394
395 for (SCCOL j=0; (j<nSubTotals[i]) && bEqual; j++)
396 {
397 bEqual = bEqual
398 && (pSubTotals[i][j] == rOther.pSubTotals[i][j])
399 && (pFunctions[i][j] == rOther.pFunctions[i][j]);
400 }
401 }
402 }
403 }
404
405 return bEqual;
406 }
407
408 //------------------------------------------------------------------------
409
SetSubTotals(sal_uInt16 nGroup,const SCCOL * ptrSubTotals,const ScSubTotalFunc * ptrFunctions,sal_uInt16 nCount)410 void ScSubTotalParam::SetSubTotals( sal_uInt16 nGroup,
411 const SCCOL* ptrSubTotals,
412 const ScSubTotalFunc* ptrFunctions,
413 sal_uInt16 nCount )
414 {
415 DBG_ASSERT( (nGroup <= MAXSUBTOTAL),
416 "ScSubTotalParam::SetSubTotals(): nGroup > MAXSUBTOTAL!" );
417 DBG_ASSERT( ptrSubTotals,
418 "ScSubTotalParam::SetSubTotals(): ptrSubTotals == NULL!" );
419 DBG_ASSERT( ptrFunctions,
420 "ScSubTotalParam::SetSubTotals(): ptrFunctions == NULL!" );
421 DBG_ASSERT( (nCount > 0),
422 "ScSubTotalParam::SetSubTotals(): nCount <= 0!" );
423
424 if ( ptrSubTotals && ptrFunctions && (nCount > 0) && (nGroup <= MAXSUBTOTAL) )
425 {
426 // 0 wird als 1 aufgefasst, sonst zum Array-Index dekrementieren
427 if (nGroup != 0)
428 nGroup--;
429
430 delete [] pSubTotals[nGroup];
431 delete [] pFunctions[nGroup];
432
433 pSubTotals[nGroup] = new SCCOL [nCount];
434 pFunctions[nGroup] = new ScSubTotalFunc [nCount];
435 nSubTotals[nGroup] = static_cast<SCCOL>(nCount);
436
437 for ( sal_uInt16 i=0; i<nCount; i++ )
438 {
439 pSubTotals[nGroup][i] = ptrSubTotals[i];
440 pFunctions[nGroup][i] = ptrFunctions[i];
441 }
442 }
443 }
444
445 //------------------------------------------------------------------------
446 // struct ScConsolidateParam:
447
ScConsolidateParam()448 ScConsolidateParam::ScConsolidateParam() :
449 ppDataAreas( NULL )
450 {
451 Clear();
452 }
453
454 //------------------------------------------------------------------------
455
ScConsolidateParam(const ScConsolidateParam & r)456 ScConsolidateParam::ScConsolidateParam( const ScConsolidateParam& r ) :
457 nCol(r.nCol),nRow(r.nRow),nTab(r.nTab),
458 eFunction(r.eFunction),nDataAreaCount(0),
459 ppDataAreas( NULL ),
460 bByCol(r.bByCol),bByRow(r.bByRow),bReferenceData(r.bReferenceData)
461 {
462 if ( r.nDataAreaCount > 0 )
463 {
464 nDataAreaCount = r.nDataAreaCount;
465 ppDataAreas = new ScArea*[nDataAreaCount];
466 for ( sal_uInt16 i=0; i<nDataAreaCount; i++ )
467 ppDataAreas[i] = new ScArea( *(r.ppDataAreas[i]) );
468 }
469 }
470
471 //------------------------------------------------------------------------
472
~ScConsolidateParam()473 __EXPORT ScConsolidateParam::~ScConsolidateParam()
474 {
475 ClearDataAreas();
476 }
477
478 //------------------------------------------------------------------------
479
ClearDataAreas()480 void __EXPORT ScConsolidateParam::ClearDataAreas()
481 {
482 if ( ppDataAreas )
483 {
484 for ( sal_uInt16 i=0; i<nDataAreaCount; i++ )
485 delete ppDataAreas[i];
486 delete [] ppDataAreas;
487 ppDataAreas = NULL;
488 }
489 nDataAreaCount = 0;
490 }
491
492 //------------------------------------------------------------------------
493
Clear()494 void __EXPORT ScConsolidateParam::Clear()
495 {
496 ClearDataAreas();
497
498 nCol = 0;
499 nRow = 0;
500 nTab = 0;
501 bByCol = bByRow = bReferenceData = sal_False;
502 eFunction = SUBTOTAL_FUNC_SUM;
503 }
504
505 //------------------------------------------------------------------------
506
operator =(const ScConsolidateParam & r)507 ScConsolidateParam& __EXPORT ScConsolidateParam::operator=( const ScConsolidateParam& r )
508 {
509 nCol = r.nCol;
510 nRow = r.nRow;
511 nTab = r.nTab;
512 bByCol = r.bByCol;
513 bByRow = r.bByRow;
514 bReferenceData = r.bReferenceData;
515 eFunction = r.eFunction;
516 SetAreas( r.ppDataAreas, r.nDataAreaCount );
517
518 return *this;
519 }
520
521 //------------------------------------------------------------------------
522
operator ==(const ScConsolidateParam & r) const523 sal_Bool __EXPORT ScConsolidateParam::operator==( const ScConsolidateParam& r ) const
524 {
525 sal_Bool bEqual = (nCol == r.nCol)
526 && (nRow == r.nRow)
527 && (nTab == r.nTab)
528 && (bByCol == r.bByCol)
529 && (bByRow == r.bByRow)
530 && (bReferenceData == r.bReferenceData)
531 && (nDataAreaCount == r.nDataAreaCount)
532 && (eFunction == r.eFunction);
533
534 if ( nDataAreaCount == 0 )
535 bEqual = bEqual && (ppDataAreas == NULL) && (r.ppDataAreas == NULL);
536 else
537 bEqual = bEqual && (ppDataAreas != NULL) && (r.ppDataAreas != NULL);
538
539 if ( bEqual && (nDataAreaCount > 0) )
540 for ( sal_uInt16 i=0; i<nDataAreaCount && bEqual; i++ )
541 bEqual = *(ppDataAreas[i]) == *(r.ppDataAreas[i]);
542
543 return bEqual;
544 }
545
546 //------------------------------------------------------------------------
547
SetAreas(ScArea * const * ppAreas,sal_uInt16 nCount)548 void __EXPORT ScConsolidateParam::SetAreas( ScArea* const* ppAreas, sal_uInt16 nCount )
549 {
550 ClearDataAreas();
551 if ( ppAreas && nCount > 0 )
552 {
553 ppDataAreas = new ScArea*[nCount];
554 for ( sal_uInt16 i=0; i<nCount; i++ )
555 ppDataAreas[i] = new ScArea( *(ppAreas[i]) );
556 nDataAreaCount = nCount;
557 }
558 }
559
560 //------------------------------------------------------------------------
561 // struct ScSolveParam
562
ScSolveParam()563 ScSolveParam::ScSolveParam()
564 : pStrTargetVal( NULL )
565 {
566 }
567
568 //------------------------------------------------------------------------
569
ScSolveParam(const ScSolveParam & r)570 ScSolveParam::ScSolveParam( const ScSolveParam& r )
571 : aRefFormulaCell ( r.aRefFormulaCell ),
572 aRefVariableCell( r.aRefVariableCell ),
573 pStrTargetVal ( r.pStrTargetVal
574 ? new String(*r.pStrTargetVal)
575 : NULL )
576 {
577 }
578
579 //------------------------------------------------------------------------
580
ScSolveParam(const ScAddress & rFormulaCell,const ScAddress & rVariableCell,const String & rTargetValStr)581 ScSolveParam::ScSolveParam( const ScAddress& rFormulaCell,
582 const ScAddress& rVariableCell,
583 const String& rTargetValStr )
584 : aRefFormulaCell ( rFormulaCell ),
585 aRefVariableCell( rVariableCell ),
586 pStrTargetVal ( new String(rTargetValStr) )
587 {
588 }
589
590 //------------------------------------------------------------------------
591
~ScSolveParam()592 ScSolveParam::~ScSolveParam()
593 {
594 delete pStrTargetVal;
595 }
596
597 //------------------------------------------------------------------------
598
operator =(const ScSolveParam & r)599 ScSolveParam& __EXPORT ScSolveParam::operator=( const ScSolveParam& r )
600 {
601 delete pStrTargetVal;
602
603 aRefFormulaCell = r.aRefFormulaCell;
604 aRefVariableCell = r.aRefVariableCell;
605 pStrTargetVal = r.pStrTargetVal
606 ? new String(*r.pStrTargetVal)
607 : NULL;
608 return *this;
609 }
610
611 //------------------------------------------------------------------------
612
operator ==(const ScSolveParam & r) const613 sal_Bool ScSolveParam::operator==( const ScSolveParam& r ) const
614 {
615 sal_Bool bEqual = (aRefFormulaCell == r.aRefFormulaCell)
616 && (aRefVariableCell == r.aRefVariableCell);
617
618 if ( bEqual )
619 {
620 if ( !pStrTargetVal && !r.pStrTargetVal )
621 bEqual = sal_True;
622 else if ( !pStrTargetVal || !r.pStrTargetVal )
623 bEqual = sal_False;
624 else if ( pStrTargetVal && r.pStrTargetVal )
625 bEqual = ( *pStrTargetVal == *(r.pStrTargetVal) );
626 }
627
628 return bEqual;
629 }
630
631
632 //------------------------------------------------------------------------
633 // struct ScTabOpParam
634
ScTabOpParam(const ScTabOpParam & r)635 ScTabOpParam::ScTabOpParam( const ScTabOpParam& r )
636 : aRefFormulaCell ( r.aRefFormulaCell ),
637 aRefFormulaEnd ( r.aRefFormulaEnd ),
638 aRefRowCell ( r.aRefRowCell ),
639 aRefColCell ( r.aRefColCell ),
640 nMode ( r.nMode )
641 {
642 }
643
644 //------------------------------------------------------------------------
645
ScTabOpParam(const ScRefAddress & rFormulaCell,const ScRefAddress & rFormulaEnd,const ScRefAddress & rRowCell,const ScRefAddress & rColCell,sal_uInt8 nMd)646 ScTabOpParam::ScTabOpParam( const ScRefAddress& rFormulaCell,
647 const ScRefAddress& rFormulaEnd,
648 const ScRefAddress& rRowCell,
649 const ScRefAddress& rColCell,
650 sal_uInt8 nMd)
651 : aRefFormulaCell ( rFormulaCell ),
652 aRefFormulaEnd ( rFormulaEnd ),
653 aRefRowCell ( rRowCell ),
654 aRefColCell ( rColCell ),
655 nMode ( nMd )
656 {
657 }
658
659 //------------------------------------------------------------------------
660
operator =(const ScTabOpParam & r)661 ScTabOpParam& ScTabOpParam::operator=( const ScTabOpParam& r )
662 {
663 aRefFormulaCell = r.aRefFormulaCell;
664 aRefFormulaEnd = r.aRefFormulaEnd;
665 aRefRowCell = r.aRefRowCell;
666 aRefColCell = r.aRefColCell;
667 nMode = r.nMode;
668 return *this;
669 }
670
671 //------------------------------------------------------------------------
672
operator ==(const ScTabOpParam & r) const673 sal_Bool __EXPORT ScTabOpParam::operator==( const ScTabOpParam& r ) const
674 {
675 return ( (aRefFormulaCell == r.aRefFormulaCell)
676 && (aRefFormulaEnd == r.aRefFormulaEnd)
677 && (aRefRowCell == r.aRefRowCell)
678 && (aRefColCell == r.aRefColCell)
679 && (nMode == r.nMode) );
680 }
681
GetAbsDocName(const String & rFileName,SfxObjectShell * pShell)682 String ScGlobal::GetAbsDocName( const String& rFileName,
683 SfxObjectShell* pShell )
684 {
685 String aAbsName;
686 if ( !pShell->HasName() )
687 { // maybe relative to document path working directory
688 INetURLObject aObj;
689 SvtPathOptions aPathOpt;
690 aObj.SetSmartURL( aPathOpt.GetWorkPath() );
691 aObj.setFinalSlash(); // it IS a path
692 bool bWasAbs = true;
693 aAbsName = aObj.smartRel2Abs( rFileName, bWasAbs ).GetMainURL(INetURLObject::NO_DECODE);
694 // returned string must be encoded because it's used directly to create SfxMedium
695 }
696 else
697 {
698 const SfxMedium* pMedium = pShell->GetMedium();
699 if ( pMedium )
700 {
701 bool bWasAbs = true;
702 aAbsName = pMedium->GetURLObject().smartRel2Abs( rFileName, bWasAbs ).GetMainURL(INetURLObject::NO_DECODE);
703 }
704 else
705 { // This can't happen, but ...
706 // just to be sure to have the same encoding
707 INetURLObject aObj;
708 aObj.SetSmartURL( aAbsName );
709 aAbsName = aObj.GetMainURL(INetURLObject::NO_DECODE);
710 }
711 }
712 return aAbsName;
713 }
714
715
GetDocTabName(const String & rFileName,const String & rTabName)716 String ScGlobal::GetDocTabName( const String& rFileName,
717 const String& rTabName )
718 {
719 String aDocTab( '\'' );
720 aDocTab += rFileName;
721 xub_StrLen nPos = 1;
722 while( (nPos = aDocTab.Search( '\'', nPos ))
723 != STRING_NOTFOUND )
724 { // escape Quotes
725 aDocTab.Insert( '\\', nPos );
726 nPos += 2;
727 }
728 aDocTab += '\'';
729 aDocTab += SC_COMPILER_FILE_TAB_SEP;
730 aDocTab += rTabName; // "'Doc'#Tab"
731 return aDocTab;
732 }
733
734