1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: global2.cxx,v $
10 * $Revision: 1.23.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include <sfx2/docfile.hxx>
39 #include <sfx2/objsh.hxx>
40 #include <unotools/textsearch.hxx>
41 #include <svtools/pathoptions.hxx>
42 #include <svtools/useroptions.hxx>
43 #include <tools/urlobj.hxx>
44 #include <unotools/charclass.hxx>
47 #include <svtools/syslocale.hxx>
50 #include "rangeutl.hxx"
52 #include "rechead.hxx"
53 #include "compiler.hxx"
54 #include "paramisc.hxx"
57 #include "globstr.hrc"
61 // -----------------------------------------------------------------------
65 #define MAX_LABELS 256 //!!! aus fieldwnd.hxx, muss noch nach global.hxx ???
67 //------------------------------------------------------------------------
68 // struct ScImportParam:
70 ScImportParam::ScImportParam() :
82 ScImportParam::ScImportParam( const ScImportParam
& r
) :
89 aStatement (r
.aStatement
),
96 ScImportParam::~ScImportParam()
100 //UNUSED2009-05 void ScImportParam::Clear()
102 //UNUSED2009-05 nCol1 = nCol2 = 0;
103 //UNUSED2009-05 nRow1 = nRow2 = 0;
104 //UNUSED2009-05 bImport = FALSE;
105 //UNUSED2009-05 bNative = FALSE;
106 //UNUSED2009-05 bSql = TRUE;
107 //UNUSED2009-05 nType = ScDbTable;
108 //UNUSED2009-05 aDBName.Erase();
109 //UNUSED2009-05 aStatement.Erase();
112 ScImportParam
& ScImportParam::operator=( const ScImportParam
& r
)
120 aStatement
= r
.aStatement
;
128 BOOL
ScImportParam::operator==( const ScImportParam
& rOther
) const
130 return( nCol1
== rOther
.nCol1
&&
131 nRow1
== rOther
.nRow1
&&
132 nCol2
== rOther
.nCol2
&&
133 nRow2
== rOther
.nRow2
&&
134 bImport
== rOther
.bImport
&&
135 aDBName
== rOther
.aDBName
&&
136 aStatement
== rOther
.aStatement
&&
137 bNative
== rOther
.bNative
&&
138 bSql
== rOther
.bSql
&&
139 nType
== rOther
.nType
);
141 //! nQuerySh und pConnection sind gleich ?
145 //------------------------------------------------------------------------
146 // struct ScQueryParam:
148 ScQueryEntry::ScQueryEntry() :
150 bQueryByString(FALSE
),
162 ScQueryEntry::ScQueryEntry(const ScQueryEntry
& r
) :
163 bDoQuery(r
.bDoQuery
),
164 bQueryByString(r
.bQueryByString
),
165 bQueryByDate(r
.bQueryByDate
),
168 eConnect(r
.eConnect
),
169 pStr(new String(*r
.pStr
)),
176 ScQueryEntry::~ScQueryEntry()
186 ScQueryEntry
& ScQueryEntry::operator=( const ScQueryEntry
& r
)
188 bDoQuery
= r
.bDoQuery
;
189 bQueryByString
= r
.bQueryByString
;
190 bQueryByDate
= r
.bQueryByDate
;
192 eConnect
= r
.eConnect
;
207 void ScQueryEntry::Clear()
210 bQueryByString
= FALSE
;
211 bQueryByDate
= false;
226 BOOL
ScQueryEntry::operator==( const ScQueryEntry
& r
) const
228 return bDoQuery
== r
.bDoQuery
229 && bQueryByString
== r
.bQueryByString
230 && bQueryByDate
== r
.bQueryByDate
232 && eConnect
== r
.eConnect
233 && nField
== r
.nField
236 //! pSearchParam und pSearchText nicht vergleichen
239 utl::TextSearch
* ScQueryEntry::GetSearchTextPtr( BOOL bCaseSens
)
243 pSearchParam
= new utl::SearchParam( *pStr
, utl::SearchParam::SRCH_REGEXP
,
244 bCaseSens
, FALSE
, FALSE
);
245 pSearchText
= new utl::TextSearch( *pSearchParam
, *ScGlobal::pCharClass
);
250 //------------------------------------------------------------------------
251 // struct ScSubTotalParam:
253 ScSubTotalParam::ScSubTotalParam()
255 for ( USHORT i
=0; i
<MAXSUBTOTAL
; i
++ )
258 pSubTotals
[i
] = NULL
;
259 pFunctions
[i
] = NULL
;
265 //------------------------------------------------------------------------
267 ScSubTotalParam::ScSubTotalParam( const ScSubTotalParam
& r
) :
268 nCol1(r
.nCol1
),nRow1(r
.nRow1
),nCol2(r
.nCol2
),nRow2(r
.nRow2
),
269 bRemoveOnly(r
.bRemoveOnly
),bReplace(r
.bReplace
),bPagebreak(r
.bPagebreak
),bCaseSens(r
.bCaseSens
),
270 bDoSort(r
.bDoSort
),bAscending(r
.bAscending
),bUserDef(r
.bUserDef
),nUserIndex(r
.nUserIndex
),
271 bIncludePattern(r
.bIncludePattern
)
273 for (USHORT i
=0; i
<MAXSUBTOTAL
; i
++)
275 bGroupActive
[i
] = r
.bGroupActive
[i
];
276 nField
[i
] = r
.nField
[i
];
278 if ( (r
.nSubTotals
[i
] > 0) && r
.pSubTotals
[i
] && r
.pFunctions
[i
] )
280 nSubTotals
[i
] = r
.nSubTotals
[i
];
281 pSubTotals
[i
] = new SCCOL
[r
.nSubTotals
[i
]];
282 pFunctions
[i
] = new ScSubTotalFunc
[r
.nSubTotals
[i
]];
284 for (SCCOL j
=0; j
<r
.nSubTotals
[i
]; j
++)
286 pSubTotals
[i
][j
] = r
.pSubTotals
[i
][j
];
287 pFunctions
[i
][j
] = r
.pFunctions
[i
][j
];
293 pSubTotals
[i
] = NULL
;
294 pFunctions
[i
] = NULL
;
299 //------------------------------------------------------------------------
301 void ScSubTotalParam::Clear()
306 bPagebreak
=bCaseSens
=bUserDef
=bIncludePattern
=bRemoveOnly
= FALSE
;
307 bAscending
=bReplace
=bDoSort
= TRUE
;
309 for (USHORT i
=0; i
<MAXSUBTOTAL
; i
++)
311 bGroupActive
[i
] = FALSE
;
314 if ( (nSubTotals
[i
] > 0) && pSubTotals
[i
] && pFunctions
[i
] )
316 for ( SCCOL j
=0; j
<nSubTotals
[i
]; j
++ ) {
317 pSubTotals
[i
][j
] = 0;
318 pFunctions
[i
][j
] = SUBTOTAL_FUNC_NONE
;
324 //------------------------------------------------------------------------
326 ScSubTotalParam
& ScSubTotalParam::operator=( const ScSubTotalParam
& r
)
332 bRemoveOnly
= r
.bRemoveOnly
;
333 bReplace
= r
.bReplace
;
334 bPagebreak
= r
.bPagebreak
;
335 bCaseSens
= r
.bCaseSens
;
337 bAscending
= r
.bAscending
;
338 bUserDef
= r
.bUserDef
;
339 nUserIndex
= r
.nUserIndex
;
340 bIncludePattern
= r
.bIncludePattern
;
342 for (USHORT i
=0; i
<MAXSUBTOTAL
; i
++)
344 bGroupActive
[i
] = r
.bGroupActive
[i
];
345 nField
[i
] = r
.nField
[i
];
346 nSubTotals
[i
] = r
.nSubTotals
[i
];
348 if ( pSubTotals
[i
] ) delete [] pSubTotals
[i
];
349 if ( pFunctions
[i
] ) delete [] pFunctions
[i
];
351 if ( r
.nSubTotals
[i
] > 0 )
353 pSubTotals
[i
] = new SCCOL
[r
.nSubTotals
[i
]];
354 pFunctions
[i
] = new ScSubTotalFunc
[r
.nSubTotals
[i
]];
356 for (SCCOL j
=0; j
<r
.nSubTotals
[i
]; j
++)
358 pSubTotals
[i
][j
] = r
.pSubTotals
[i
][j
];
359 pFunctions
[i
][j
] = r
.pFunctions
[i
][j
];
365 pSubTotals
[i
] = NULL
;
366 pFunctions
[i
] = NULL
;
373 //------------------------------------------------------------------------
375 BOOL
ScSubTotalParam::operator==( const ScSubTotalParam
& rOther
) const
377 BOOL bEqual
= (nCol1
== rOther
.nCol1
)
378 && (nRow1
== rOther
.nRow1
)
379 && (nCol2
== rOther
.nCol2
)
380 && (nRow2
== rOther
.nRow2
)
381 && (bRemoveOnly
== rOther
.bRemoveOnly
)
382 && (bReplace
== rOther
.bReplace
)
383 && (bPagebreak
== rOther
.bPagebreak
)
384 && (bDoSort
== rOther
.bDoSort
)
385 && (bCaseSens
== rOther
.bCaseSens
)
386 && (bAscending
== rOther
.bAscending
)
387 && (bUserDef
== rOther
.bUserDef
)
388 && (nUserIndex
== rOther
.nUserIndex
)
389 && (bIncludePattern
== rOther
.bIncludePattern
);
394 for ( USHORT i
=0; i
<MAXSUBTOTAL
&& bEqual
; i
++ )
396 bEqual
= (bGroupActive
[i
] == rOther
.bGroupActive
[i
])
397 && (nField
[i
] == rOther
.nField
[i
])
398 && (nSubTotals
[i
] == rOther
.nSubTotals
[i
]);
400 if ( bEqual
&& (nSubTotals
[i
] > 0) )
402 bEqual
= (pSubTotals
!= NULL
) && (pFunctions
!= NULL
);
404 for (SCCOL j
=0; (j
<nSubTotals
[i
]) && bEqual
; j
++)
407 && (pSubTotals
[i
][j
] == rOther
.pSubTotals
[i
][j
])
408 && (pFunctions
[i
][j
] == rOther
.pFunctions
[i
][j
]);
417 //------------------------------------------------------------------------
419 void ScSubTotalParam::SetSubTotals( USHORT nGroup
,
420 const SCCOL
* ptrSubTotals
,
421 const ScSubTotalFunc
* ptrFunctions
,
424 DBG_ASSERT( (nGroup
<= MAXSUBTOTAL
),
425 "ScSubTotalParam::SetSubTotals(): nGroup > MAXSUBTOTAL!" );
426 DBG_ASSERT( ptrSubTotals
,
427 "ScSubTotalParam::SetSubTotals(): ptrSubTotals == NULL!" );
428 DBG_ASSERT( ptrFunctions
,
429 "ScSubTotalParam::SetSubTotals(): ptrFunctions == NULL!" );
430 DBG_ASSERT( (nCount
> 0),
431 "ScSubTotalParam::SetSubTotals(): nCount <= 0!" );
433 if ( ptrSubTotals
&& ptrFunctions
&& (nCount
> 0) && (nGroup
<= MAXSUBTOTAL
) )
435 // 0 wird als 1 aufgefasst, sonst zum Array-Index dekrementieren
439 delete [] pSubTotals
[nGroup
];
440 delete [] pFunctions
[nGroup
];
442 pSubTotals
[nGroup
] = new SCCOL
[nCount
];
443 pFunctions
[nGroup
] = new ScSubTotalFunc
[nCount
];
444 nSubTotals
[nGroup
] = static_cast<SCCOL
>(nCount
);
446 for ( USHORT i
=0; i
<nCount
; i
++ )
448 pSubTotals
[nGroup
][i
] = ptrSubTotals
[i
];
449 pFunctions
[nGroup
][i
] = ptrFunctions
[i
];
454 //------------------------------------------------------------------------
455 // struct ScConsolidateParam:
457 ScConsolidateParam::ScConsolidateParam() :
463 //------------------------------------------------------------------------
465 ScConsolidateParam::ScConsolidateParam( const ScConsolidateParam
& r
) :
466 nCol(r
.nCol
),nRow(r
.nRow
),nTab(r
.nTab
),
467 eFunction(r
.eFunction
),nDataAreaCount(0),
469 bByCol(r
.bByCol
),bByRow(r
.bByRow
),bReferenceData(r
.bReferenceData
)
471 if ( r
.nDataAreaCount
> 0 )
473 nDataAreaCount
= r
.nDataAreaCount
;
474 ppDataAreas
= new ScArea
*[nDataAreaCount
];
475 for ( USHORT i
=0; i
<nDataAreaCount
; i
++ )
476 ppDataAreas
[i
] = new ScArea( *(r
.ppDataAreas
[i
]) );
480 //------------------------------------------------------------------------
482 __EXPORT
ScConsolidateParam::~ScConsolidateParam()
487 //------------------------------------------------------------------------
489 void __EXPORT
ScConsolidateParam::ClearDataAreas()
493 for ( USHORT i
=0; i
<nDataAreaCount
; i
++ )
494 delete ppDataAreas
[i
];
495 delete [] ppDataAreas
;
501 //------------------------------------------------------------------------
503 void __EXPORT
ScConsolidateParam::Clear()
510 bByCol
= bByRow
= bReferenceData
= FALSE
;
511 eFunction
= SUBTOTAL_FUNC_SUM
;
514 //------------------------------------------------------------------------
516 ScConsolidateParam
& __EXPORT
ScConsolidateParam::operator=( const ScConsolidateParam
& r
)
523 bReferenceData
= r
.bReferenceData
;
524 eFunction
= r
.eFunction
;
525 SetAreas( r
.ppDataAreas
, r
.nDataAreaCount
);
530 //------------------------------------------------------------------------
532 BOOL __EXPORT
ScConsolidateParam::operator==( const ScConsolidateParam
& r
) const
534 BOOL bEqual
= (nCol
== r
.nCol
)
537 && (bByCol
== r
.bByCol
)
538 && (bByRow
== r
.bByRow
)
539 && (bReferenceData
== r
.bReferenceData
)
540 && (nDataAreaCount
== r
.nDataAreaCount
)
541 && (eFunction
== r
.eFunction
);
543 if ( nDataAreaCount
== 0 )
544 bEqual
= bEqual
&& (ppDataAreas
== NULL
) && (r
.ppDataAreas
== NULL
);
546 bEqual
= bEqual
&& (ppDataAreas
!= NULL
) && (r
.ppDataAreas
!= NULL
);
548 if ( bEqual
&& (nDataAreaCount
> 0) )
549 for ( USHORT i
=0; i
<nDataAreaCount
&& bEqual
; i
++ )
550 bEqual
= *(ppDataAreas
[i
]) == *(r
.ppDataAreas
[i
]);
555 //------------------------------------------------------------------------
557 void __EXPORT
ScConsolidateParam::SetAreas( ScArea
* const* ppAreas
, USHORT nCount
)
560 if ( ppAreas
&& nCount
> 0 )
562 ppDataAreas
= new ScArea
*[nCount
];
563 for ( USHORT i
=0; i
<nCount
; i
++ )
564 ppDataAreas
[i
] = new ScArea( *(ppAreas
[i
]) );
565 nDataAreaCount
= nCount
;
569 // -----------------------------------------------------------------------
571 PivotField::PivotField( SCsCOL nNewCol
, USHORT nNewFuncMask
) :
573 nFuncMask( nNewFuncMask
),
578 bool PivotField::operator==( const PivotField
& r
) const
580 return (nCol
== r
.nCol
)
581 && (nFuncMask
== r
.nFuncMask
)
582 && (nFuncCount
== r
.nFuncCount
)
583 && (maFieldRef
.ReferenceType
== r
.maFieldRef
.ReferenceType
)
584 && (maFieldRef
.ReferenceField
== r
.maFieldRef
.ReferenceField
)
585 && (maFieldRef
.ReferenceItemType
== r
.maFieldRef
.ReferenceItemType
)
586 && (maFieldRef
.ReferenceItemName
== r
.maFieldRef
.ReferenceItemName
);
589 //------------------------------------------------------------------------
590 // struct ScPivotParam:
592 ScPivotParam::ScPivotParam()
593 : nCol(0), nRow(0), nTab(0),
594 nPageCount(0), nColCount(0), nRowCount(0), nDataCount(0),
595 bIgnoreEmptyRows(FALSE
), bDetectCategories(FALSE
),
596 bMakeTotalCol(TRUE
), bMakeTotalRow(TRUE
)
600 //------------------------------------------------------------------------
602 ScPivotParam::ScPivotParam( const ScPivotParam
& r
)
603 : nCol( r
.nCol
), nRow( r
.nRow
), nTab( r
.nTab
),
604 nPageCount(0), nColCount(0), nRowCount(0), nDataCount(0),
605 bIgnoreEmptyRows(r
.bIgnoreEmptyRows
),
606 bDetectCategories(r
.bDetectCategories
),
607 bMakeTotalCol(r
.bMakeTotalCol
),
608 bMakeTotalRow(r
.bMakeTotalRow
)
610 SetPivotArrays ( r
.aPageArr
, r
.aColArr
, r
.aRowArr
, r
.aDataArr
,
611 r
.nPageCount
, r
.nColCount
, r
.nRowCount
, r
.nDataCount
);
613 SetLabelData(r
.maLabelArray
);
616 //------------------------------------------------------------------------
618 __EXPORT
ScPivotParam::~ScPivotParam()
622 //------------------------------------------------------------------------
624 //UNUSED2009-05 void __EXPORT ScPivotParam::Clear()
626 //UNUSED2009-05 nCol = 0;
627 //UNUSED2009-05 nRow = 0;
628 //UNUSED2009-05 nTab = 0;
629 //UNUSED2009-05 bIgnoreEmptyRows = bDetectCategories = FALSE;
630 //UNUSED2009-05 bMakeTotalCol = bMakeTotalRow = TRUE;
631 //UNUSED2009-05 ClearLabelData();
632 //UNUSED2009-05 ClearPivotArrays();
635 void __EXPORT
ScPivotParam::ClearPivotArrays()
637 memset( aPageArr
, 0, PIVOT_MAXPAGEFIELD
* sizeof(PivotField
) );
638 memset( aColArr
, 0, PIVOT_MAXFIELD
* sizeof(PivotField
) );
639 memset( aRowArr
, 0, PIVOT_MAXFIELD
* sizeof(PivotField
) );
640 memset( aDataArr
, 0, PIVOT_MAXFIELD
* sizeof(PivotField
) );
647 void ScPivotParam::SetLabelData(const vector
<ScDPLabelDataRef
>& r
)
649 vector
<ScDPLabelDataRef
> aNewArray
;
650 aNewArray
.reserve(r
.size());
651 for (vector
<ScDPLabelDataRef
>::const_iterator itr
= r
.begin(), itrEnd
= r
.end();
652 itr
!= itrEnd
; ++itr
)
654 ScDPLabelDataRef
p(new ScDPLabelData(**itr
));
655 aNewArray
.push_back(p
);
657 maLabelArray
.swap(aNewArray
);
660 //------------------------------------------------------------------------
662 void __EXPORT
ScPivotParam::SetPivotArrays ( const PivotField
* pPageArr
,
663 const PivotField
* pColArr
,
664 const PivotField
* pRowArr
,
665 const PivotField
* pDataArr
,
673 if ( pPageArr
&& pColArr
&& pRowArr
&& pDataArr
)
675 nPageCount
= (nPageCnt
>PIVOT_MAXPAGEFIELD
) ? PIVOT_MAXPAGEFIELD
: nPageCnt
;
676 nColCount
= (nColCnt
>PIVOT_MAXFIELD
) ? PIVOT_MAXFIELD
: nColCnt
;
677 nRowCount
= (nRowCnt
>PIVOT_MAXFIELD
) ? PIVOT_MAXFIELD
: nRowCnt
;
678 nDataCount
= (nDataCnt
>PIVOT_MAXFIELD
) ? PIVOT_MAXFIELD
: nDataCnt
;
680 memcpy( aPageArr
, pPageArr
, nPageCount
* sizeof(PivotField
) );
681 memcpy( aColArr
, pColArr
, nColCount
* sizeof(PivotField
) );
682 memcpy( aRowArr
, pRowArr
, nRowCount
* sizeof(PivotField
) );
683 memcpy( aDataArr
, pDataArr
, nDataCount
* sizeof(PivotField
) );
687 //------------------------------------------------------------------------
689 ScPivotParam
& __EXPORT
ScPivotParam::operator=( const ScPivotParam
& r
)
694 bIgnoreEmptyRows
= r
.bIgnoreEmptyRows
;
695 bDetectCategories
= r
.bDetectCategories
;
696 bMakeTotalCol
= r
.bMakeTotalCol
;
697 bMakeTotalRow
= r
.bMakeTotalRow
;
699 SetPivotArrays ( r
.aPageArr
, r
.aColArr
, r
.aRowArr
, r
.aDataArr
,
700 r
.nPageCount
, r
.nColCount
, r
.nRowCount
, r
.nDataCount
);
701 SetLabelData(r
.maLabelArray
);
705 //------------------------------------------------------------------------
707 BOOL __EXPORT
ScPivotParam::operator==( const ScPivotParam
& r
) const
709 BOOL bEqual
= (nCol
== r
.nCol
)
712 && (bIgnoreEmptyRows
== r
.bIgnoreEmptyRows
)
713 && (bDetectCategories
== r
.bDetectCategories
)
714 && (bMakeTotalCol
== r
.bMakeTotalCol
)
715 && (bMakeTotalRow
== r
.bMakeTotalRow
)
716 && (maLabelArray
.size() == r
.maLabelArray
.size())
717 && (nPageCount
== r
.nPageCount
)
718 && (nColCount
== r
.nColCount
)
719 && (nRowCount
== r
.nRowCount
)
720 && (nDataCount
== r
.nDataCount
);
726 for ( i
=0; i
<nPageCount
&& bEqual
; i
++ )
727 bEqual
= ( aPageArr
[i
] == r
.aPageArr
[i
] );
729 for ( i
=0; i
<nColCount
&& bEqual
; i
++ )
730 bEqual
= ( aColArr
[i
] == r
.aColArr
[i
] );
732 for ( i
=0; i
<nRowCount
&& bEqual
; i
++ )
733 bEqual
= ( aRowArr
[i
] == r
.aRowArr
[i
] );
735 for ( i
=0; i
<nDataCount
&& bEqual
; i
++ )
736 bEqual
= ( aDataArr
[i
] == r
.aDataArr
[i
] );
742 //------------------------------------------------------------------------
743 // struct ScSolveParam
745 ScSolveParam::ScSolveParam()
746 : pStrTargetVal( NULL
)
750 //------------------------------------------------------------------------
752 ScSolveParam::ScSolveParam( const ScSolveParam
& r
)
753 : aRefFormulaCell ( r
.aRefFormulaCell
),
754 aRefVariableCell( r
.aRefVariableCell
),
755 pStrTargetVal ( r
.pStrTargetVal
756 ? new String(*r
.pStrTargetVal
)
761 //------------------------------------------------------------------------
763 ScSolveParam::ScSolveParam( const ScAddress
& rFormulaCell
,
764 const ScAddress
& rVariableCell
,
765 const String
& rTargetValStr
)
766 : aRefFormulaCell ( rFormulaCell
),
767 aRefVariableCell( rVariableCell
),
768 pStrTargetVal ( new String(rTargetValStr
) )
772 //------------------------------------------------------------------------
774 ScSolveParam::~ScSolveParam()
776 delete pStrTargetVal
;
779 //------------------------------------------------------------------------
781 ScSolveParam
& __EXPORT
ScSolveParam::operator=( const ScSolveParam
& r
)
783 delete pStrTargetVal
;
785 aRefFormulaCell
= r
.aRefFormulaCell
;
786 aRefVariableCell
= r
.aRefVariableCell
;
787 pStrTargetVal
= r
.pStrTargetVal
788 ? new String(*r
.pStrTargetVal
)
793 //------------------------------------------------------------------------
795 BOOL
ScSolveParam::operator==( const ScSolveParam
& r
) const
797 BOOL bEqual
= (aRefFormulaCell
== r
.aRefFormulaCell
)
798 && (aRefVariableCell
== r
.aRefVariableCell
);
802 if ( !pStrTargetVal
&& !r
.pStrTargetVal
)
804 else if ( !pStrTargetVal
|| !r
.pStrTargetVal
)
806 else if ( pStrTargetVal
&& r
.pStrTargetVal
)
807 bEqual
= ( *pStrTargetVal
== *(r
.pStrTargetVal
) );
814 //------------------------------------------------------------------------
815 // struct ScTabOpParam
817 ScTabOpParam::ScTabOpParam( const ScTabOpParam
& r
)
818 : aRefFormulaCell ( r
.aRefFormulaCell
),
819 aRefFormulaEnd ( r
.aRefFormulaEnd
),
820 aRefRowCell ( r
.aRefRowCell
),
821 aRefColCell ( r
.aRefColCell
),
826 //------------------------------------------------------------------------
828 ScTabOpParam::ScTabOpParam( const ScRefAddress
& rFormulaCell
,
829 const ScRefAddress
& rFormulaEnd
,
830 const ScRefAddress
& rRowCell
,
831 const ScRefAddress
& rColCell
,
833 : aRefFormulaCell ( rFormulaCell
),
834 aRefFormulaEnd ( rFormulaEnd
),
835 aRefRowCell ( rRowCell
),
836 aRefColCell ( rColCell
),
841 //------------------------------------------------------------------------
843 ScTabOpParam
& ScTabOpParam::operator=( const ScTabOpParam
& r
)
845 aRefFormulaCell
= r
.aRefFormulaCell
;
846 aRefFormulaEnd
= r
.aRefFormulaEnd
;
847 aRefRowCell
= r
.aRefRowCell
;
848 aRefColCell
= r
.aRefColCell
;
853 //------------------------------------------------------------------------
855 BOOL __EXPORT
ScTabOpParam::operator==( const ScTabOpParam
& r
) const
857 return ( (aRefFormulaCell
== r
.aRefFormulaCell
)
858 && (aRefFormulaEnd
== r
.aRefFormulaEnd
)
859 && (aRefRowCell
== r
.aRefRowCell
)
860 && (aRefColCell
== r
.aRefColCell
)
861 && (nMode
== r
.nMode
) );
864 String
ScGlobal::GetAbsDocName( const String
& rFileName
,
865 SfxObjectShell
* pShell
)
868 if ( !pShell
->HasName() )
869 { // maybe relative to document path working directory
871 SvtPathOptions aPathOpt
;
872 aObj
.SetSmartURL( aPathOpt
.GetWorkPath() );
873 aObj
.setFinalSlash(); // it IS a path
875 aAbsName
= aObj
.smartRel2Abs( rFileName
, bWasAbs
).GetMainURL(INetURLObject::NO_DECODE
);
876 // returned string must be encoded because it's used directly to create SfxMedium
880 const SfxMedium
* pMedium
= pShell
->GetMedium();
884 aAbsName
= pMedium
->GetURLObject().smartRel2Abs( rFileName
, bWasAbs
).GetMainURL(INetURLObject::NO_DECODE
);
887 { // This can't happen, but ...
888 // just to be sure to have the same encoding
890 aObj
.SetSmartURL( aAbsName
);
891 aAbsName
= aObj
.GetMainURL(INetURLObject::NO_DECODE
);
898 String
ScGlobal::GetDocTabName( const String
& rFileName
,
899 const String
& rTabName
)
901 String
aDocTab( '\'' );
902 aDocTab
+= rFileName
;
904 while( (nPos
= aDocTab
.Search( '\'', nPos
))
907 aDocTab
.Insert( '\\', nPos
);
911 aDocTab
+= SC_COMPILER_FILE_TAB_SEP
;
912 aDocTab
+= rTabName
; // "'Doc'#Tab"
916 // ============================================================================
918 ScSimpleSharedString::StringTable::StringTable() :
921 // empty string (ID = 0)
922 maSharedStrings
.push_back(String());
923 maSharedStringIds
.insert( SharedStrMap::value_type(String(), mnStrCount
++) );
926 ScSimpleSharedString::StringTable::StringTable(const ScSimpleSharedString::StringTable
& r
) :
927 maSharedStrings(r
.maSharedStrings
),
928 maSharedStringIds(r
.maSharedStringIds
),
929 mnStrCount(r
.mnStrCount
)
933 ScSimpleSharedString::StringTable::~StringTable()
937 sal_Int32
ScSimpleSharedString::StringTable::insertString(const String
& aStr
)
939 SharedStrMap::const_iterator itr
= maSharedStringIds
.find(aStr
),
940 itrEnd
= maSharedStringIds
.end();
945 maSharedStrings
.push_back(aStr
);
946 maSharedStringIds
.insert( SharedStrMap::value_type(aStr
, mnStrCount
) );
954 sal_Int32
ScSimpleSharedString::StringTable::getStringId(const String
& aStr
)
956 SharedStrMap::const_iterator itr
= maSharedStringIds
.find(aStr
),
957 itrEnd
= maSharedStringIds
.end();
961 return insertString(aStr
);
966 const String
* ScSimpleSharedString::StringTable::getString(sal_Int32 nId
) const
968 if (nId
>= mnStrCount
)
971 return &maSharedStrings
[nId
];
974 // ----------------------------------------------------------------------------
976 ScSimpleSharedString::ScSimpleSharedString()
980 ScSimpleSharedString::ScSimpleSharedString(const ScSimpleSharedString
& r
) :
981 maStringTable(r
.maStringTable
)
985 ScSimpleSharedString::~ScSimpleSharedString()
989 sal_Int32
ScSimpleSharedString::insertString(const String
& aStr
)
991 return maStringTable
.insertString(aStr
);
994 const String
* ScSimpleSharedString::getString(sal_Int32 nId
)
996 return maStringTable
.getString(nId
);
999 sal_Int32
ScSimpleSharedString::getStringId(const String
& aStr
)
1001 return maStringTable
.getStringId(aStr
);