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()
151 bQueryByString
= FALSE
;
161 ScQueryEntry::ScQueryEntry(const ScQueryEntry
& r
)
163 bDoQuery
= r
.bDoQuery
;
164 bQueryByString
= r
.bQueryByString
;
166 eConnect
= r
.eConnect
;
169 pStr
= new String(*r
.pStr
);
174 ScQueryEntry::~ScQueryEntry()
184 ScQueryEntry
& ScQueryEntry::operator=( const ScQueryEntry
& r
)
186 bDoQuery
= r
.bDoQuery
;
187 bQueryByString
= r
.bQueryByString
;
189 eConnect
= r
.eConnect
;
204 void ScQueryEntry::Clear()
207 bQueryByString
= FALSE
;
222 BOOL
ScQueryEntry::operator==( const ScQueryEntry
& r
) const
224 return bDoQuery
== r
.bDoQuery
225 && bQueryByString
== r
.bQueryByString
227 && eConnect
== r
.eConnect
228 && nField
== r
.nField
231 //! pSearchParam und pSearchText nicht vergleichen
234 utl::TextSearch
* ScQueryEntry::GetSearchTextPtr( BOOL bCaseSens
)
238 pSearchParam
= new utl::SearchParam( *pStr
, utl::SearchParam::SRCH_REGEXP
,
239 bCaseSens
, FALSE
, FALSE
);
240 pSearchText
= new utl::TextSearch( *pSearchParam
, *ScGlobal::pCharClass
);
245 //------------------------------------------------------------------------
247 ScQueryParam::ScQueryParam()
253 //------------------------------------------------------------------------
255 ScQueryParam::ScQueryParam( const ScQueryParam
& r
) :
256 nCol1(r
.nCol1
),nRow1(r
.nRow1
),nCol2(r
.nCol2
),nRow2(r
.nRow2
),nTab(r
.nTab
),
257 bHasHeader(r
.bHasHeader
), bByRow(r
.bByRow
), bInplace(r
.bInplace
), bCaseSens(r
.bCaseSens
),
258 bRegExp(r
.bRegExp
), bMixedComparison(r
.bMixedComparison
),
259 bDuplicate(r
.bDuplicate
), bDestPers(r
.bDestPers
),
260 nDestTab(r
.nDestTab
), nDestCol(r
.nDestCol
), nDestRow(r
.nDestRow
),
261 nDynamicEndRow(r
.nDynamicEndRow
), bUseDynamicRange(r
.bUseDynamicRange
)
265 Resize( r
.nEntryCount
);
266 for (USHORT i
=0; i
<nEntryCount
; i
++)
267 pEntries
[i
] = r
.pEntries
[i
];
270 //------------------------------------------------------------------------
272 ScQueryParam::~ScQueryParam()
277 //------------------------------------------------------------------------
279 void ScQueryParam::Clear()
281 nCol1
=nCol2
=nDestCol
= 0;
282 nRow1
=nRow2
=nDestRow
= 0;
285 bHasHeader
= bCaseSens
= bRegExp
= bMixedComparison
= FALSE
;
286 bInplace
= bByRow
= bDuplicate
= bDestPers
= TRUE
;
288 bUseDynamicRange
= false;
291 for (USHORT i
=0; i
<MAXQUERY
; i
++)
295 //------------------------------------------------------------------------
297 ScQueryParam
& ScQueryParam::operator=( const ScQueryParam
& r
)
304 nDestTab
= r
.nDestTab
;
305 nDestCol
= r
.nDestCol
;
306 nDestRow
= r
.nDestRow
;
307 bHasHeader
= r
.bHasHeader
;
308 bInplace
= r
.bInplace
;
309 bCaseSens
= r
.bCaseSens
;
311 bMixedComparison
= r
.bMixedComparison
;
312 bDuplicate
= r
.bDuplicate
;
314 bDestPers
= r
.bDestPers
;
315 nDynamicEndRow
= r
.nDynamicEndRow
;
316 bUseDynamicRange
= r
.bUseDynamicRange
;
318 Resize( r
.nEntryCount
);
319 for (USHORT i
=0; i
<nEntryCount
; i
++)
320 pEntries
[i
] = r
.pEntries
[i
];
325 //------------------------------------------------------------------------
327 BOOL
ScQueryParam::operator==( const ScQueryParam
& rOther
) const
331 // Anzahl der Queries gleich?
333 USHORT nOtherUsed
= 0;
334 while ( nUsed
<nEntryCount
&& pEntries
[nUsed
].bDoQuery
) ++nUsed
;
335 while ( nOtherUsed
<rOther
.nEntryCount
&& rOther
.pEntries
[nOtherUsed
].bDoQuery
)
338 if ( (nUsed
== nOtherUsed
)
339 && (nCol1
== rOther
.nCol1
)
340 && (nRow1
== rOther
.nRow1
)
341 && (nCol2
== rOther
.nCol2
)
342 && (nRow2
== rOther
.nRow2
)
343 && (nTab
== rOther
.nTab
)
344 && (bHasHeader
== rOther
.bHasHeader
)
345 && (bByRow
== rOther
.bByRow
)
346 && (bInplace
== rOther
.bInplace
)
347 && (bCaseSens
== rOther
.bCaseSens
)
348 && (bRegExp
== rOther
.bRegExp
)
349 && (bMixedComparison
== rOther
.bMixedComparison
)
350 && (bDuplicate
== rOther
.bDuplicate
)
351 && (bDestPers
== rOther
.bDestPers
)
352 && (nDestTab
== rOther
.nDestTab
)
353 && (nDestCol
== rOther
.nDestCol
)
354 && (nDestRow
== rOther
.nDestRow
)
355 && (nDynamicEndRow
== rOther
.nDynamicEndRow
)
356 && (bUseDynamicRange
== rOther
.bUseDynamicRange
) )
359 for ( USHORT i
=0; i
<nUsed
&& bEqual
; i
++ )
360 bEqual
= pEntries
[i
] == rOther
.pEntries
[i
];
365 //------------------------------------------------------------------------
367 void ScQueryParam::DeleteQuery( SCSIZE nPos
)
369 if (nPos
<nEntryCount
)
371 for (SCSIZE i
=nPos
; i
+1<nEntryCount
; i
++)
372 pEntries
[i
] = pEntries
[i
+1];
374 pEntries
[nEntryCount
-1].Clear();
378 DBG_ERROR("Falscher Parameter bei ScQueryParam::DeleteQuery");
382 //------------------------------------------------------------------------
384 void ScQueryParam::Resize(SCSIZE nNew
)
386 if ( nNew
< MAXQUERY
)
387 nNew
= MAXQUERY
; // nie weniger als MAXQUERY
389 ScQueryEntry
* pNewEntries
= NULL
;
391 pNewEntries
= new ScQueryEntry
[nNew
];
393 SCSIZE nCopy
= Min( nEntryCount
, nNew
);
394 for (SCSIZE i
=0; i
<nCopy
; i
++)
395 pNewEntries
[i
] = pEntries
[i
];
400 pEntries
= pNewEntries
;
403 //------------------------------------------------------------------------
405 void ScQueryParam::MoveToDest()
409 SCsCOL nDifX
= ((SCsCOL
) nDestCol
) - ((SCsCOL
) nCol1
);
410 SCsROW nDifY
= ((SCsROW
) nDestRow
) - ((SCsROW
) nRow1
);
411 SCsTAB nDifZ
= ((SCsTAB
) nDestTab
) - ((SCsTAB
) nTab
);
413 nCol1
= sal::static_int_cast
<SCCOL
>( nCol1
+ nDifX
);
414 nRow1
= sal::static_int_cast
<SCROW
>( nRow1
+ nDifY
);
415 nCol2
= sal::static_int_cast
<SCCOL
>( nCol2
+ nDifX
);
416 nRow2
= sal::static_int_cast
<SCROW
>( nRow2
+ nDifY
);
417 nTab
= sal::static_int_cast
<SCTAB
>( nTab
+ nDifZ
);
418 nDynamicEndRow
= sal::static_int_cast
<SCROW
>( nDynamicEndRow
+ nDifY
);
419 for (USHORT i
=0; i
<nEntryCount
; i
++)
420 pEntries
[i
].nField
+= nDifX
;
426 DBG_ERROR("MoveToDest, bInplace == TRUE");
430 //------------------------------------------------------------------------
432 void ScQueryParam::FillInExcelSyntax(String
& aCellStr
, SCSIZE nIndex
)
434 if (aCellStr
.Len() > 0)
436 if ( nIndex
>= nEntryCount
)
439 ScQueryEntry
& rEntry
= pEntries
[nIndex
];
441 rEntry
.bDoQuery
= TRUE
;
442 // Operatoren herausfiltern
443 if (aCellStr
.GetChar(0) == '<')
445 if (aCellStr
.GetChar(1) == '>')
447 *rEntry
.pStr
= aCellStr
.Copy(2);
448 rEntry
.eOp
= SC_NOT_EQUAL
;
450 else if (aCellStr
.GetChar(1) == '=')
452 *rEntry
.pStr
= aCellStr
.Copy(2);
453 rEntry
.eOp
= SC_LESS_EQUAL
;
457 *rEntry
.pStr
= aCellStr
.Copy(1);
458 rEntry
.eOp
= SC_LESS
;
461 else if (aCellStr
.GetChar(0) == '>')
463 if (aCellStr
.GetChar(1) == '=')
465 *rEntry
.pStr
= aCellStr
.Copy(2);
466 rEntry
.eOp
= SC_GREATER_EQUAL
;
470 *rEntry
.pStr
= aCellStr
.Copy(1);
471 rEntry
.eOp
= SC_GREATER
;
476 if (aCellStr
.GetChar(0) == '=')
477 *rEntry
.pStr
= aCellStr
.Copy(1);
479 *rEntry
.pStr
= aCellStr
;
480 rEntry
.eOp
= SC_EQUAL
;
485 //------------------------------------------------------------------------
486 // struct ScSubTotalParam:
488 ScSubTotalParam::ScSubTotalParam()
490 for ( USHORT i
=0; i
<MAXSUBTOTAL
; i
++ )
493 pSubTotals
[i
] = NULL
;
494 pFunctions
[i
] = NULL
;
500 //------------------------------------------------------------------------
502 ScSubTotalParam::ScSubTotalParam( const ScSubTotalParam
& r
) :
503 nCol1(r
.nCol1
),nRow1(r
.nRow1
),nCol2(r
.nCol2
),nRow2(r
.nRow2
),
504 bRemoveOnly(r
.bRemoveOnly
),bReplace(r
.bReplace
),bPagebreak(r
.bPagebreak
),bCaseSens(r
.bCaseSens
),
505 bDoSort(r
.bDoSort
),bAscending(r
.bAscending
),bUserDef(r
.bUserDef
),nUserIndex(r
.nUserIndex
),
506 bIncludePattern(r
.bIncludePattern
)
508 for (USHORT i
=0; i
<MAXSUBTOTAL
; i
++)
510 bGroupActive
[i
] = r
.bGroupActive
[i
];
511 nField
[i
] = r
.nField
[i
];
513 if ( (r
.nSubTotals
[i
] > 0) && r
.pSubTotals
[i
] && r
.pFunctions
[i
] )
515 nSubTotals
[i
] = r
.nSubTotals
[i
];
516 pSubTotals
[i
] = new SCCOL
[r
.nSubTotals
[i
]];
517 pFunctions
[i
] = new ScSubTotalFunc
[r
.nSubTotals
[i
]];
519 for (SCCOL j
=0; j
<r
.nSubTotals
[i
]; j
++)
521 pSubTotals
[i
][j
] = r
.pSubTotals
[i
][j
];
522 pFunctions
[i
][j
] = r
.pFunctions
[i
][j
];
528 pSubTotals
[i
] = NULL
;
529 pFunctions
[i
] = NULL
;
534 //------------------------------------------------------------------------
536 void ScSubTotalParam::Clear()
541 bPagebreak
=bCaseSens
=bUserDef
=bIncludePattern
=bRemoveOnly
= FALSE
;
542 bAscending
=bReplace
=bDoSort
= TRUE
;
544 for (USHORT i
=0; i
<MAXSUBTOTAL
; i
++)
546 bGroupActive
[i
] = FALSE
;
549 if ( (nSubTotals
[i
] > 0) && pSubTotals
[i
] && pFunctions
[i
] )
551 for ( SCCOL j
=0; j
<nSubTotals
[i
]; j
++ ) {
552 pSubTotals
[i
][j
] = 0;
553 pFunctions
[i
][j
] = SUBTOTAL_FUNC_NONE
;
559 //------------------------------------------------------------------------
561 ScSubTotalParam
& ScSubTotalParam::operator=( const ScSubTotalParam
& r
)
567 bRemoveOnly
= r
.bRemoveOnly
;
568 bReplace
= r
.bReplace
;
569 bPagebreak
= r
.bPagebreak
;
570 bCaseSens
= r
.bCaseSens
;
572 bAscending
= r
.bAscending
;
573 bUserDef
= r
.bUserDef
;
574 nUserIndex
= r
.nUserIndex
;
575 bIncludePattern
= r
.bIncludePattern
;
577 for (USHORT i
=0; i
<MAXSUBTOTAL
; i
++)
579 bGroupActive
[i
] = r
.bGroupActive
[i
];
580 nField
[i
] = r
.nField
[i
];
581 nSubTotals
[i
] = r
.nSubTotals
[i
];
583 if ( pSubTotals
[i
] ) delete [] pSubTotals
[i
];
584 if ( pFunctions
[i
] ) delete [] pFunctions
[i
];
586 if ( r
.nSubTotals
[i
] > 0 )
588 pSubTotals
[i
] = new SCCOL
[r
.nSubTotals
[i
]];
589 pFunctions
[i
] = new ScSubTotalFunc
[r
.nSubTotals
[i
]];
591 for (SCCOL j
=0; j
<r
.nSubTotals
[i
]; j
++)
593 pSubTotals
[i
][j
] = r
.pSubTotals
[i
][j
];
594 pFunctions
[i
][j
] = r
.pFunctions
[i
][j
];
600 pSubTotals
[i
] = NULL
;
601 pFunctions
[i
] = NULL
;
608 //------------------------------------------------------------------------
610 BOOL
ScSubTotalParam::operator==( const ScSubTotalParam
& rOther
) const
612 BOOL bEqual
= (nCol1
== rOther
.nCol1
)
613 && (nRow1
== rOther
.nRow1
)
614 && (nCol2
== rOther
.nCol2
)
615 && (nRow2
== rOther
.nRow2
)
616 && (bRemoveOnly
== rOther
.bRemoveOnly
)
617 && (bReplace
== rOther
.bReplace
)
618 && (bPagebreak
== rOther
.bPagebreak
)
619 && (bDoSort
== rOther
.bDoSort
)
620 && (bCaseSens
== rOther
.bCaseSens
)
621 && (bAscending
== rOther
.bAscending
)
622 && (bUserDef
== rOther
.bUserDef
)
623 && (nUserIndex
== rOther
.nUserIndex
)
624 && (bIncludePattern
== rOther
.bIncludePattern
);
629 for ( USHORT i
=0; i
<MAXSUBTOTAL
&& bEqual
; i
++ )
631 bEqual
= (bGroupActive
[i
] == rOther
.bGroupActive
[i
])
632 && (nField
[i
] == rOther
.nField
[i
])
633 && (nSubTotals
[i
] == rOther
.nSubTotals
[i
]);
635 if ( bEqual
&& (nSubTotals
[i
] > 0) )
637 bEqual
= (pSubTotals
!= NULL
) && (pFunctions
!= NULL
);
639 for (SCCOL j
=0; (j
<nSubTotals
[i
]) && bEqual
; j
++)
642 && (pSubTotals
[i
][j
] == rOther
.pSubTotals
[i
][j
])
643 && (pFunctions
[i
][j
] == rOther
.pFunctions
[i
][j
]);
652 //------------------------------------------------------------------------
654 void ScSubTotalParam::SetSubTotals( USHORT nGroup
,
655 const SCCOL
* ptrSubTotals
,
656 const ScSubTotalFunc
* ptrFunctions
,
659 DBG_ASSERT( (nGroup
<= MAXSUBTOTAL
),
660 "ScSubTotalParam::SetSubTotals(): nGroup > MAXSUBTOTAL!" );
661 DBG_ASSERT( ptrSubTotals
,
662 "ScSubTotalParam::SetSubTotals(): ptrSubTotals == NULL!" );
663 DBG_ASSERT( ptrFunctions
,
664 "ScSubTotalParam::SetSubTotals(): ptrFunctions == NULL!" );
665 DBG_ASSERT( (nCount
> 0),
666 "ScSubTotalParam::SetSubTotals(): nCount <= 0!" );
668 if ( ptrSubTotals
&& ptrFunctions
&& (nCount
> 0) && (nGroup
<= MAXSUBTOTAL
) )
670 // 0 wird als 1 aufgefasst, sonst zum Array-Index dekrementieren
674 delete [] pSubTotals
[nGroup
];
675 delete [] pFunctions
[nGroup
];
677 pSubTotals
[nGroup
] = new SCCOL
[nCount
];
678 pFunctions
[nGroup
] = new ScSubTotalFunc
[nCount
];
679 nSubTotals
[nGroup
] = static_cast<SCCOL
>(nCount
);
681 for ( USHORT i
=0; i
<nCount
; i
++ )
683 pSubTotals
[nGroup
][i
] = ptrSubTotals
[i
];
684 pFunctions
[nGroup
][i
] = ptrFunctions
[i
];
689 //------------------------------------------------------------------------
690 // struct ScConsolidateParam:
692 ScConsolidateParam::ScConsolidateParam() :
698 //------------------------------------------------------------------------
700 ScConsolidateParam::ScConsolidateParam( const ScConsolidateParam
& r
) :
701 nCol(r
.nCol
),nRow(r
.nRow
),nTab(r
.nTab
),
702 eFunction(r
.eFunction
),nDataAreaCount(0),
704 bByCol(r
.bByCol
),bByRow(r
.bByRow
),bReferenceData(r
.bReferenceData
)
706 if ( r
.nDataAreaCount
> 0 )
708 nDataAreaCount
= r
.nDataAreaCount
;
709 ppDataAreas
= new ScArea
*[nDataAreaCount
];
710 for ( USHORT i
=0; i
<nDataAreaCount
; i
++ )
711 ppDataAreas
[i
] = new ScArea( *(r
.ppDataAreas
[i
]) );
715 //------------------------------------------------------------------------
717 __EXPORT
ScConsolidateParam::~ScConsolidateParam()
722 //------------------------------------------------------------------------
724 void __EXPORT
ScConsolidateParam::ClearDataAreas()
728 for ( USHORT i
=0; i
<nDataAreaCount
; i
++ )
729 delete ppDataAreas
[i
];
730 delete [] ppDataAreas
;
736 //------------------------------------------------------------------------
738 void __EXPORT
ScConsolidateParam::Clear()
745 bByCol
= bByRow
= bReferenceData
= FALSE
;
746 eFunction
= SUBTOTAL_FUNC_SUM
;
749 //------------------------------------------------------------------------
751 ScConsolidateParam
& __EXPORT
ScConsolidateParam::operator=( const ScConsolidateParam
& r
)
758 bReferenceData
= r
.bReferenceData
;
759 eFunction
= r
.eFunction
;
760 SetAreas( r
.ppDataAreas
, r
.nDataAreaCount
);
765 //------------------------------------------------------------------------
767 BOOL __EXPORT
ScConsolidateParam::operator==( const ScConsolidateParam
& r
) const
769 BOOL bEqual
= (nCol
== r
.nCol
)
772 && (bByCol
== r
.bByCol
)
773 && (bByRow
== r
.bByRow
)
774 && (bReferenceData
== r
.bReferenceData
)
775 && (nDataAreaCount
== r
.nDataAreaCount
)
776 && (eFunction
== r
.eFunction
);
778 if ( nDataAreaCount
== 0 )
779 bEqual
= bEqual
&& (ppDataAreas
== NULL
) && (r
.ppDataAreas
== NULL
);
781 bEqual
= bEqual
&& (ppDataAreas
!= NULL
) && (r
.ppDataAreas
!= NULL
);
783 if ( bEqual
&& (nDataAreaCount
> 0) )
784 for ( USHORT i
=0; i
<nDataAreaCount
&& bEqual
; i
++ )
785 bEqual
= *(ppDataAreas
[i
]) == *(r
.ppDataAreas
[i
]);
790 //------------------------------------------------------------------------
792 void __EXPORT
ScConsolidateParam::SetAreas( ScArea
* const* ppAreas
, USHORT nCount
)
795 if ( ppAreas
&& nCount
> 0 )
797 ppDataAreas
= new ScArea
*[nCount
];
798 for ( USHORT i
=0; i
<nCount
; i
++ )
799 ppDataAreas
[i
] = new ScArea( *(ppAreas
[i
]) );
800 nDataAreaCount
= nCount
;
804 // -----------------------------------------------------------------------
806 PivotField::PivotField( SCsCOL nNewCol
, USHORT nNewFuncMask
) :
808 nFuncMask( nNewFuncMask
),
813 bool PivotField::operator==( const PivotField
& r
) const
815 return (nCol
== r
.nCol
)
816 && (nFuncMask
== r
.nFuncMask
)
817 && (nFuncCount
== r
.nFuncCount
)
818 && (maFieldRef
.ReferenceType
== r
.maFieldRef
.ReferenceType
)
819 && (maFieldRef
.ReferenceField
== r
.maFieldRef
.ReferenceField
)
820 && (maFieldRef
.ReferenceItemType
== r
.maFieldRef
.ReferenceItemType
)
821 && (maFieldRef
.ReferenceItemName
== r
.maFieldRef
.ReferenceItemName
);
824 //------------------------------------------------------------------------
825 // struct ScPivotParam:
827 ScPivotParam::ScPivotParam()
828 : nCol(0), nRow(0), nTab(0),
829 nPageCount(0), nColCount(0), nRowCount(0), nDataCount(0),
830 bIgnoreEmptyRows(FALSE
), bDetectCategories(FALSE
),
831 bMakeTotalCol(TRUE
), bMakeTotalRow(TRUE
)
835 //------------------------------------------------------------------------
837 ScPivotParam::ScPivotParam( const ScPivotParam
& r
)
838 : nCol( r
.nCol
), nRow( r
.nRow
), nTab( r
.nTab
),
839 nPageCount(0), nColCount(0), nRowCount(0), nDataCount(0),
840 bIgnoreEmptyRows(r
.bIgnoreEmptyRows
),
841 bDetectCategories(r
.bDetectCategories
),
842 bMakeTotalCol(r
.bMakeTotalCol
),
843 bMakeTotalRow(r
.bMakeTotalRow
)
845 SetPivotArrays ( r
.aPageArr
, r
.aColArr
, r
.aRowArr
, r
.aDataArr
,
846 r
.nPageCount
, r
.nColCount
, r
.nRowCount
, r
.nDataCount
);
848 SetLabelData(r
.maLabelArray
);
851 //------------------------------------------------------------------------
853 __EXPORT
ScPivotParam::~ScPivotParam()
857 //------------------------------------------------------------------------
859 //UNUSED2009-05 void __EXPORT ScPivotParam::Clear()
861 //UNUSED2009-05 nCol = 0;
862 //UNUSED2009-05 nRow = 0;
863 //UNUSED2009-05 nTab = 0;
864 //UNUSED2009-05 bIgnoreEmptyRows = bDetectCategories = FALSE;
865 //UNUSED2009-05 bMakeTotalCol = bMakeTotalRow = TRUE;
866 //UNUSED2009-05 ClearPivotArrays();
867 //UNUSED2009-05 maLabelArray.clear();
870 void __EXPORT
ScPivotParam::ClearPivotArrays()
872 memset( aPageArr
, 0, PIVOT_MAXPAGEFIELD
* sizeof(PivotField
) );
873 memset( aColArr
, 0, PIVOT_MAXFIELD
* sizeof(PivotField
) );
874 memset( aRowArr
, 0, PIVOT_MAXFIELD
* sizeof(PivotField
) );
875 memset( aDataArr
, 0, PIVOT_MAXFIELD
* sizeof(PivotField
) );
882 void ScPivotParam::SetLabelData(const vector
<ScDPLabelDataRef
>& r
)
884 vector
<ScDPLabelDataRef
> aNewArray
;
885 aNewArray
.reserve(r
.size());
886 for (vector
<ScDPLabelDataRef
>::const_iterator itr
= r
.begin(), itrEnd
= r
.end();
887 itr
!= itrEnd
; ++itr
)
889 ScDPLabelDataRef
p(new ScDPLabelData(**itr
));
890 aNewArray
.push_back(p
);
892 maLabelArray
.swap(aNewArray
);
895 //------------------------------------------------------------------------
897 void __EXPORT
ScPivotParam::SetPivotArrays ( const PivotField
* pPageArr
,
898 const PivotField
* pColArr
,
899 const PivotField
* pRowArr
,
900 const PivotField
* pDataArr
,
908 if ( pPageArr
&& pColArr
&& pRowArr
&& pDataArr
)
910 nPageCount
= (nPageCnt
>PIVOT_MAXPAGEFIELD
) ? PIVOT_MAXPAGEFIELD
: nPageCnt
;
911 nColCount
= (nColCnt
>PIVOT_MAXFIELD
) ? PIVOT_MAXFIELD
: nColCnt
;
912 nRowCount
= (nRowCnt
>PIVOT_MAXFIELD
) ? PIVOT_MAXFIELD
: nRowCnt
;
913 nDataCount
= (nDataCnt
>PIVOT_MAXFIELD
) ? PIVOT_MAXFIELD
: nDataCnt
;
915 memcpy( aPageArr
, pPageArr
, nPageCount
* sizeof(PivotField
) );
916 memcpy( aColArr
, pColArr
, nColCount
* sizeof(PivotField
) );
917 memcpy( aRowArr
, pRowArr
, nRowCount
* sizeof(PivotField
) );
918 memcpy( aDataArr
, pDataArr
, nDataCount
* sizeof(PivotField
) );
922 //------------------------------------------------------------------------
924 ScPivotParam
& __EXPORT
ScPivotParam::operator=( const ScPivotParam
& r
)
929 bIgnoreEmptyRows
= r
.bIgnoreEmptyRows
;
930 bDetectCategories
= r
.bDetectCategories
;
931 bMakeTotalCol
= r
.bMakeTotalCol
;
932 bMakeTotalRow
= r
.bMakeTotalRow
;
934 SetPivotArrays ( r
.aPageArr
, r
.aColArr
, r
.aRowArr
, r
.aDataArr
,
935 r
.nPageCount
, r
.nColCount
, r
.nRowCount
, r
.nDataCount
);
936 SetLabelData(r
.maLabelArray
);
940 //------------------------------------------------------------------------
942 BOOL __EXPORT
ScPivotParam::operator==( const ScPivotParam
& r
) const
944 BOOL bEqual
= (nCol
== r
.nCol
)
947 && (bIgnoreEmptyRows
== r
.bIgnoreEmptyRows
)
948 && (bDetectCategories
== r
.bDetectCategories
)
949 && (bMakeTotalCol
== r
.bMakeTotalCol
)
950 && (bMakeTotalRow
== r
.bMakeTotalRow
)
951 && (maLabelArray
.size() == r
.maLabelArray
.size())
952 && (nPageCount
== r
.nPageCount
)
953 && (nColCount
== r
.nColCount
)
954 && (nRowCount
== r
.nRowCount
)
955 && (nDataCount
== r
.nDataCount
);
961 for ( i
=0; i
<nPageCount
&& bEqual
; i
++ )
962 bEqual
= ( aPageArr
[i
] == r
.aPageArr
[i
] );
964 for ( i
=0; i
<nColCount
&& bEqual
; i
++ )
965 bEqual
= ( aColArr
[i
] == r
.aColArr
[i
] );
967 for ( i
=0; i
<nRowCount
&& bEqual
; i
++ )
968 bEqual
= ( aRowArr
[i
] == r
.aRowArr
[i
] );
970 for ( i
=0; i
<nDataCount
&& bEqual
; i
++ )
971 bEqual
= ( aDataArr
[i
] == r
.aDataArr
[i
] );
977 //------------------------------------------------------------------------
978 // struct ScSolveParam
980 ScSolveParam::ScSolveParam()
981 : pStrTargetVal( NULL
)
985 //------------------------------------------------------------------------
987 ScSolveParam::ScSolveParam( const ScSolveParam
& r
)
988 : aRefFormulaCell ( r
.aRefFormulaCell
),
989 aRefVariableCell( r
.aRefVariableCell
),
990 pStrTargetVal ( r
.pStrTargetVal
991 ? new String(*r
.pStrTargetVal
)
996 //------------------------------------------------------------------------
998 ScSolveParam::ScSolveParam( const ScAddress
& rFormulaCell
,
999 const ScAddress
& rVariableCell
,
1000 const String
& rTargetValStr
)
1001 : aRefFormulaCell ( rFormulaCell
),
1002 aRefVariableCell( rVariableCell
),
1003 pStrTargetVal ( new String(rTargetValStr
) )
1007 //------------------------------------------------------------------------
1009 ScSolveParam::~ScSolveParam()
1011 delete pStrTargetVal
;
1014 //------------------------------------------------------------------------
1016 ScSolveParam
& __EXPORT
ScSolveParam::operator=( const ScSolveParam
& r
)
1018 delete pStrTargetVal
;
1020 aRefFormulaCell
= r
.aRefFormulaCell
;
1021 aRefVariableCell
= r
.aRefVariableCell
;
1022 pStrTargetVal
= r
.pStrTargetVal
1023 ? new String(*r
.pStrTargetVal
)
1028 //------------------------------------------------------------------------
1030 BOOL
ScSolveParam::operator==( const ScSolveParam
& r
) const
1032 BOOL bEqual
= (aRefFormulaCell
== r
.aRefFormulaCell
)
1033 && (aRefVariableCell
== r
.aRefVariableCell
);
1037 if ( !pStrTargetVal
&& !r
.pStrTargetVal
)
1039 else if ( !pStrTargetVal
|| !r
.pStrTargetVal
)
1041 else if ( pStrTargetVal
&& r
.pStrTargetVal
)
1042 bEqual
= ( *pStrTargetVal
== *(r
.pStrTargetVal
) );
1049 //------------------------------------------------------------------------
1050 // struct ScTabOpParam
1052 ScTabOpParam::ScTabOpParam( const ScTabOpParam
& r
)
1053 : aRefFormulaCell ( r
.aRefFormulaCell
),
1054 aRefFormulaEnd ( r
.aRefFormulaEnd
),
1055 aRefRowCell ( r
.aRefRowCell
),
1056 aRefColCell ( r
.aRefColCell
),
1061 //------------------------------------------------------------------------
1063 ScTabOpParam::ScTabOpParam( const ScRefAddress
& rFormulaCell
,
1064 const ScRefAddress
& rFormulaEnd
,
1065 const ScRefAddress
& rRowCell
,
1066 const ScRefAddress
& rColCell
,
1068 : aRefFormulaCell ( rFormulaCell
),
1069 aRefFormulaEnd ( rFormulaEnd
),
1070 aRefRowCell ( rRowCell
),
1071 aRefColCell ( rColCell
),
1076 //------------------------------------------------------------------------
1078 ScTabOpParam
& ScTabOpParam::operator=( const ScTabOpParam
& r
)
1080 aRefFormulaCell
= r
.aRefFormulaCell
;
1081 aRefFormulaEnd
= r
.aRefFormulaEnd
;
1082 aRefRowCell
= r
.aRefRowCell
;
1083 aRefColCell
= r
.aRefColCell
;
1088 //------------------------------------------------------------------------
1090 BOOL __EXPORT
ScTabOpParam::operator==( const ScTabOpParam
& r
) const
1092 return ( (aRefFormulaCell
== r
.aRefFormulaCell
)
1093 && (aRefFormulaEnd
== r
.aRefFormulaEnd
)
1094 && (aRefRowCell
== r
.aRefRowCell
)
1095 && (aRefColCell
== r
.aRefColCell
)
1096 && (nMode
== r
.nMode
) );
1099 String
ScGlobal::GetAbsDocName( const String
& rFileName
,
1100 SfxObjectShell
* pShell
)
1103 if ( !pShell
->HasName() )
1104 { // maybe relative to document path working directory
1106 SvtPathOptions aPathOpt
;
1107 aObj
.SetSmartURL( aPathOpt
.GetWorkPath() );
1108 aObj
.setFinalSlash(); // it IS a path
1109 bool bWasAbs
= true;
1110 aAbsName
= aObj
.smartRel2Abs( rFileName
, bWasAbs
).GetMainURL(INetURLObject::NO_DECODE
);
1111 // returned string must be encoded because it's used directly to create SfxMedium
1115 const SfxMedium
* pMedium
= pShell
->GetMedium();
1118 bool bWasAbs
= true;
1119 aAbsName
= pMedium
->GetURLObject().smartRel2Abs( rFileName
, bWasAbs
).GetMainURL(INetURLObject::NO_DECODE
);
1122 { // This can't happen, but ...
1123 // just to be sure to have the same encoding
1125 aObj
.SetSmartURL( aAbsName
);
1126 aAbsName
= aObj
.GetMainURL(INetURLObject::NO_DECODE
);
1133 String
ScGlobal::GetDocTabName( const String
& rFileName
,
1134 const String
& rTabName
)
1136 String
aDocTab( '\'' );
1137 aDocTab
+= rFileName
;
1138 xub_StrLen nPos
= 1;
1139 while( (nPos
= aDocTab
.Search( '\'', nPos
))
1140 != STRING_NOTFOUND
)
1142 aDocTab
.Insert( '\\', nPos
);
1146 aDocTab
+= SC_COMPILER_FILE_TAB_SEP
;
1147 aDocTab
+= rTabName
; // "'Doc'#Tab"
1151 // ============================================================================
1153 ScSimpleSharedString::StringTable::StringTable() :
1156 // empty string (ID = 0)
1157 maSharedStrings
.push_back(String());
1158 maSharedStringIds
.insert( SharedStrMap::value_type(String(), mnStrCount
++) );
1161 ScSimpleSharedString::StringTable::StringTable(const ScSimpleSharedString::StringTable
& r
) :
1162 maSharedStrings(r
.maSharedStrings
),
1163 maSharedStringIds(r
.maSharedStringIds
),
1164 mnStrCount(r
.mnStrCount
)
1168 ScSimpleSharedString::StringTable::~StringTable()
1172 sal_Int32
ScSimpleSharedString::StringTable::insertString(const String
& aStr
)
1174 SharedStrMap::const_iterator itr
= maSharedStringIds
.find(aStr
),
1175 itrEnd
= maSharedStringIds
.end();
1180 maSharedStrings
.push_back(aStr
);
1181 maSharedStringIds
.insert( SharedStrMap::value_type(aStr
, mnStrCount
) );
1182 return mnStrCount
++;
1189 sal_Int32
ScSimpleSharedString::StringTable::getStringId(const String
& aStr
)
1191 SharedStrMap::const_iterator itr
= maSharedStringIds
.find(aStr
),
1192 itrEnd
= maSharedStringIds
.end();
1195 // string not found.
1196 return insertString(aStr
);
1201 const String
* ScSimpleSharedString::StringTable::getString(sal_Int32 nId
) const
1203 if (nId
>= mnStrCount
)
1206 return &maSharedStrings
[nId
];
1209 // ----------------------------------------------------------------------------
1211 ScSimpleSharedString::ScSimpleSharedString()
1215 ScSimpleSharedString::ScSimpleSharedString(const ScSimpleSharedString
& r
) :
1216 maStringTable(r
.maStringTable
)
1220 ScSimpleSharedString::~ScSimpleSharedString()
1224 sal_Int32
ScSimpleSharedString::insertString(const String
& aStr
)
1226 return maStringTable
.insertString(aStr
);
1229 const String
* ScSimpleSharedString::getString(sal_Int32 nId
)
1231 return maStringTable
.getString(nId
);
1234 sal_Int32
ScSimpleSharedString::getStringId(const String
& aStr
)
1236 return maStringTable
.getStringId(aStr
);