summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNiklas Nebel <nn@openoffice.org>2009-11-16 14:43:11 +0100
committerNiklas Nebel <nn@openoffice.org>2009-11-16 14:43:11 +0100
commit4fa24255a27fd48325ec48a3ec31dae6388a1444 (patch)
treeb462d7021be196d11bc54a32ca95f253ee6ff527 /sc
parent61556666b9ba6437eaa53a40ff9e6c525e442d15 (diff)
parenta02a44429145de0a67f3b75656f10b146490feec (diff)
validityref: merge with DEV300_m64
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/compiler.hxx73
-rw-r--r--sc/inc/document.hxx5
-rw-r--r--sc/inc/docuno.hxx1
-rw-r--r--sc/inc/externalrefmgr.hxx48
-rw-r--r--sc/inc/sc.hrc7
-rw-r--r--sc/sdi/cellsh.sdi5
-rw-r--r--sc/sdi/drtxtob.sdi2
-rw-r--r--sc/sdi/editsh.sdi2
-rw-r--r--sc/sdi/makefile.mk6
-rw-r--r--sc/sdi/scalc.sdi100
-rw-r--r--sc/source/core/data/bcaslot.cxx59
-rw-r--r--sc/source/core/data/cell2.cxx4
-rw-r--r--sc/source/core/data/documen3.cxx8
-rw-r--r--sc/source/core/data/document.cxx20
-rw-r--r--sc/source/core/data/poolhelp.cxx17
-rw-r--r--sc/source/core/data/postit.cxx36
-rw-r--r--sc/source/core/inc/bcaslot.hxx1
-rw-r--r--sc/source/core/inc/poolhelp.hxx4
-rw-r--r--sc/source/core/tool/address.cxx107
-rw-r--r--sc/source/core/tool/compiler.cxx145
-rw-r--r--sc/source/core/tool/interpr4.cxx2
-rw-r--r--sc/source/core/tool/rangenam.cxx58
-rw-r--r--sc/source/core/tool/rangeutl.cxx4
-rw-r--r--sc/source/core/tool/reftokenhelper.cxx2
-rw-r--r--sc/source/core/tool/token.cxx2
-rw-r--r--sc/source/filter/excel/excdoc.cxx59
-rw-r--r--sc/source/filter/excel/excimp8.cxx6
-rw-r--r--sc/source/filter/excel/excrecds.cxx32
-rw-r--r--sc/source/filter/excel/exctools.cxx2
-rw-r--r--sc/source/filter/excel/impop.cxx17
-rw-r--r--sc/source/filter/excel/makefile.mk1
-rw-r--r--sc/source/filter/excel/read.cxx49
-rw-r--r--sc/source/filter/excel/xeformula.cxx13
-rw-r--r--sc/source/filter/excel/xepivot.cxx3
-rw-r--r--sc/source/filter/excel/xestream.cxx5
-rw-r--r--sc/source/filter/excel/xichart.cxx4
-rw-r--r--sc/source/filter/excel/xicontent.cxx19
-rw-r--r--sc/source/filter/excel/xilink.cxx40
-rw-r--r--sc/source/filter/excel/xistream.cxx6
-rw-r--r--sc/source/filter/excel/xistyle.cxx323
-rw-r--r--sc/source/filter/excel/xlformula.cxx7
-rw-r--r--sc/source/filter/excel/xlroot.cxx6
-rw-r--r--sc/source/filter/excel/xltools.cxx84
-rw-r--r--sc/source/filter/ftools/ftools.cxx6
-rw-r--r--sc/source/filter/inc/excrecds.hxx12
-rw-r--r--sc/source/filter/inc/ftools.hxx4
-rw-r--r--sc/source/filter/inc/imp_op.hxx2
-rw-r--r--sc/source/filter/inc/root.hxx1
-rw-r--r--sc/source/filter/inc/xcl97rec.hxx85
-rw-r--r--sc/source/filter/inc/xestream.hxx1
-rw-r--r--sc/source/filter/inc/xistream.hxx4
-rw-r--r--sc/source/filter/inc/xistyle.hxx71
-rw-r--r--sc/source/filter/inc/xlconst.hxx27
-rw-r--r--sc/source/filter/inc/xlroot.hxx3
-rw-r--r--sc/source/filter/inc/xlstyle.hxx8
-rw-r--r--sc/source/filter/inc/xltools.hxx15
-rw-r--r--sc/source/filter/xcl97/xcl97rec.cxx134
-rw-r--r--sc/source/filter/xml/XMLDDELinksContext.cxx15
-rw-r--r--sc/source/filter/xml/XMLTableShapeResizer.cxx6
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx2
-rw-r--r--sc/source/filter/xml/xmlexternaltabi.cxx28
-rw-r--r--sc/source/filter/xml/xmlwrap.cxx24
-rw-r--r--sc/source/ui/app/scmod2.cxx9
-rw-r--r--sc/source/ui/docshell/arealink.cxx8
-rw-r--r--sc/source/ui/docshell/dbdocimp.cxx17
-rw-r--r--sc/source/ui/docshell/docfunc.cxx8
-rw-r--r--sc/source/ui/docshell/docsh.cxx44
-rw-r--r--sc/source/ui/docshell/docsh3.cxx4
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx128
-rw-r--r--sc/source/ui/docshell/impex.cxx4
-rw-r--r--sc/source/ui/drawfunc/drtxtob.cxx6
-rw-r--r--sc/source/ui/drawfunc/drtxtob2.cxx2
-rw-r--r--sc/source/ui/navipi/navipi.src2
-rw-r--r--sc/source/ui/pagedlg/pagedlg.src2
-rw-r--r--sc/source/ui/src/globstr.src14
-rw-r--r--sc/source/ui/src/hdrcont.src8
-rw-r--r--sc/source/ui/src/optdlg.src2
-rw-r--r--sc/source/ui/src/popup.src12
-rw-r--r--sc/source/ui/undo/undoblk.cxx6
-rw-r--r--sc/source/ui/undo/undoblk3.cxx20
-rw-r--r--sc/source/ui/undo/undodat.cxx18
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx2
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx22
-rw-r--r--sc/source/ui/unoobj/docuno.cxx19
-rw-r--r--sc/source/ui/unoobj/scdetect.cxx2
-rw-r--r--sc/source/ui/unoobj/servuno.cxx131
-rw-r--r--sc/source/ui/vba/makefile.mk7
-rw-r--r--sc/source/ui/view/cellsh.cxx6
-rw-r--r--sc/source/ui/view/cellsh1.cxx39
-rw-r--r--sc/source/ui/view/editsh.cxx6
-rw-r--r--sc/source/ui/view/tabview3.cxx2
-rw-r--r--sc/source/ui/view/viewfun3.cxx2
-rw-r--r--sc/source/ui/view/viewfun4.cxx2
93 files changed, 1454 insertions, 942 deletions
diff --git a/sc/inc/compiler.hxx b/sc/inc/compiler.hxx
index 76293479660c..c981af2dad18 100644
--- a/sc/inc/compiler.hxx
+++ b/sc/inc/compiler.hxx
@@ -64,7 +64,7 @@
// constants and data types also for external modules (ScInterpreter et al)
#define MAXCODE 512 /* maximum number of tokens in formula */
-#define MAXSTRLEN 256 /* maximum length of input string of one symbol */
+#define MAXSTRLEN 1024 /* maximum length of input string of one symbol */
#define MAXJUMPCOUNT 32 /* maximum number of jumps (ocChose) */
// flag values of CharTable
@@ -91,6 +91,8 @@
#define SC_COMPILER_C_ODF_RBRACKET 0x00080000 // ODF ']' reference bracket
#define SC_COMPILER_C_ODF_LABEL_OP 0x00100000 // ODF '!!' automatic intersection of labels
#define SC_COMPILER_C_ODF_NAME_MARKER 0x00200000 // ODF '$$' marker that starts a defined (range) name
+#define SC_COMPILER_C_CHAR_NAME 0x00400000 // start character of a defined name
+#define SC_COMPILER_C_NAME 0x00800000 // continuation character of a defined name
#define SC_COMPILER_FILE_TAB_SEP '#' // 'Doc'#Tab
@@ -217,6 +219,14 @@ typedef formula::SimpleIntrusiveReference< struct ScRawToken > ScRawTokenRef;
class SC_DLLPUBLIC ScCompiler : public formula::FormulaCompiler
{
public:
+
+ enum EncodeUrlMode
+ {
+ ENCODE_BY_GRAMMAR,
+ ENCODE_ALWAYS,
+ ENCODE_NEVER,
+ };
+
struct Convention
{
const formula::FormulaGrammar::AddressConvention meConv;
@@ -313,6 +323,7 @@ private:
SCsTAB nMaxTab; // last sheet in document
sal_Int32 mnRangeOpPosInSymbol; // if and where a range operator is in symbol
const Convention *pConv;
+ EncodeUrlMode meEncodeUrlMode;
bool mbCloseBrackets; // whether to close open brackets automatically, default TRUE
bool mbExtendedErrorDetection;
bool mbRewind; // whether symbol is to be rewound to some step during lexical analysis
@@ -373,6 +384,8 @@ public:
void SetGrammar( const formula::FormulaGrammar::Grammar eGrammar );
+ void SetEncodeUrlMode( EncodeUrlMode eMode );
+ EncodeUrlMode GetEncodeUrlMode() const;
private:
/** Set grammar and reference convention from within SetFormulaLanguage()
or SetGrammar().
@@ -435,28 +448,66 @@ public:
BOOL HasModifiedRange();
- /// If the character is allowed as first character in sheet names or references
+ /** If the character is allowed as first character in sheet names or
+ references, includes '$' and '?'. */
static inline BOOL IsCharWordChar( String const & rStr,
xub_StrLen nPos,
const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO )
{
sal_Unicode c = rStr.GetChar( nPos );
- return c < 128 ?
- static_cast<BOOL>(
- (pConventions[eConv]->mpCharTable[ UINT8(c) ] & SC_COMPILER_C_CHAR_WORD) == SC_COMPILER_C_CHAR_WORD) :
- ScGlobal::pCharClass->isLetterNumeric( rStr, nPos );
+ if (c < 128)
+ {
+ return pConventions[eConv] ? static_cast<BOOL>(
+ (pConventions[eConv]->mpCharTable[ UINT8(c) ] & SC_COMPILER_C_CHAR_WORD) == SC_COMPILER_C_CHAR_WORD) :
+ FALSE; // no convention => assume invalid
+ }
+ else
+ return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos );
}
- /// If the character is allowed in sheet names or references
+ /** If the character is allowed in sheet names, thus may be part of a
+ reference, includes '$' and '?' and such. */
static inline BOOL IsWordChar( String const & rStr,
xub_StrLen nPos,
const formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO )
{
sal_Unicode c = rStr.GetChar( nPos );
- return c < 128 ?
- static_cast<BOOL>(
- (pConventions[eConv]->mpCharTable[ UINT8(c) ] & SC_COMPILER_C_WORD) == SC_COMPILER_C_WORD) :
- ScGlobal::pCharClass->isLetterNumeric( rStr, nPos );
+ if (c < 128)
+ {
+ return pConventions[eConv] ? static_cast<BOOL>(
+ (pConventions[eConv]->mpCharTable[ UINT8(c) ] & SC_COMPILER_C_WORD) == SC_COMPILER_C_WORD) :
+ FALSE; // convention not known => assume invalid
+ }
+ else
+ return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos );
+ }
+
+ /** If the character is allowed as tested by nFlags (SC_COMPILER_C_...
+ bits) for all known address conventions. If more than one bit is given
+ in nFlags, all bits must match. If bTestLetterNumeric is FALSE and
+ char>=128, no LetterNumeric test is done and FALSE is returned. */
+ static inline bool IsCharFlagAllConventions( String const & rStr,
+ xub_StrLen nPos,
+ ULONG nFlags,
+ bool bTestLetterNumeric = true )
+ {
+ sal_Unicode c = rStr.GetChar( nPos );
+ if (c < 128)
+ {
+ for ( int nConv = formula::FormulaGrammar::CONV_UNSPECIFIED;
+ ++nConv < formula::FormulaGrammar::CONV_LAST; )
+ {
+ if (pConventions[nConv] &&
+ ((pConventions[nConv]->mpCharTable[ UINT8(c) ] & nFlags) != nFlags))
+ return false;
+ // convention not known => assume valid
+ }
+ return true;
+ }
+ else if (bTestLetterNumeric)
+ return ScGlobal::pCharClass->isLetterNumeric( rStr, nPos );
+ else
+ return false;
}
private:
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 67d36861d10a..5f75108c2ebf 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -610,8 +610,8 @@ public:
const String& aFileName,
const String& aTabName );
- bool HasExternalRefManager() { return pExternalRefMgr.get(); }
- SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager();
+ bool HasExternalRefManager() const { return pExternalRefMgr.get(); }
+ SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager() const;
bool IsInExternalReferenceMarking() const;
void MarkUsedExternalReferences();
bool MarkUsedExternalReferences( ScTokenArray & rArr );
@@ -832,6 +832,7 @@ public:
void SetDirty();
void SetDirty( const ScRange& );
void SetTableOpDirty( const ScRange& ); // for Interpreter TableOp
+ void InterpretDirtyCells( const ScRangeList& rRanges );
void CalcAll();
SC_DLLPUBLIC void CalcAfterLoad();
void CompileAll();
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index 0d69c9f68670..5966e446d0c3 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -114,6 +114,7 @@ private:
com::sun::star::uno::Reference<com::sun::star::uno::XAggregation> GetFormatter();
rtl::OUString maBuildId;
+ sal_Int32 mnXlsWriteProtPass;
protected:
const SfxItemPropertySet& GetPropertySet() const { return aPropSet; }
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index 9b12dba52f1f..bf795f04fe1c 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -422,10 +422,13 @@ public:
/** Source document meta-data container. */
struct SrcFileData
{
- String maFileName;
+ String maFileName; /// original file name as loaded from the file.
+ String maRealFileName; /// file name created from the relative name.
String maRelativeName;
String maFilterName;
String maFilterOptions;
+
+ void maybeCreateRealFileName(const String& rOwnDocName);
};
public:
@@ -576,7 +579,21 @@ public:
*/
void convertToAbsName(String& rFile) const;
sal_uInt16 getExternalFileId(const String& rFile);
- const String* getExternalFileName(sal_uInt16 nFileId) const;
+
+ /**
+ * It returns a pointer to the name of the URI associated with a given
+ * external file ID. In case the original document has moved, it returns
+ * an URI adjusted for the relocation.
+ *
+ * @param nFileId file ID for an external document
+ * @param bForceOriginal If true, it always returns the original document
+ * URI even if the referring document has relocated.
+ * If false, it returns an URI adjusted for
+ * relocated document.
+ *
+ * @return const String* external document URI.
+ */
+ const String* getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal = false);
bool hasExternalFile(sal_uInt16 nFileId) const;
bool hasExternalFile(const String& rFile) const;
const SrcFileData* getExternalFileData(sal_uInt16 nFileId) const;
@@ -585,8 +602,15 @@ public:
const String* getRealRangeName(sal_uInt16 nFileId, const String& rRangeName) const;
void refreshNames(sal_uInt16 nFileId);
void breakLink(sal_uInt16 nFileId);
- void switchSrcFile(sal_uInt16 nFileId, const String& rNewFile);
+ void switchSrcFile(sal_uInt16 nFileId, const String& rNewFile, const String& rNewFilter);
+ /**
+ * Set a relative file path for the specified file ID. Note that the
+ * caller must ensure that the passed URL is a valid relative URL.
+ *
+ * @param nFileId file ID for an external document
+ * @param rRelUrl relative URL
+ */
void setRelativeFileName(sal_uInt16 nFileId, const String& rRelUrl);
/**
@@ -607,8 +631,11 @@ public:
* Re-generates relative names for all stored source files. This is
* necessary when exporting to an ods document, to ensure that all source
* files have their respective relative names for xlink:href export.
+ *
+ * @param rBaseFileUrl Absolute URL of the content.xml fragment of the
+ * document being exported.
*/
- void resetSrcFileData();
+ void resetSrcFileData(const String& rBaseFileUrl);
/**
* Update a single referencing cell position.
@@ -675,6 +702,19 @@ private:
void maybeLinkExternalFile(sal_uInt16 nFileId);
+ /**
+ * Try to create a "real" file name from the relative path. The original
+ * file name may not point to the real document when the referencing and
+ * referenced documents have been moved.
+ *
+ * For the real file name to be created, the relative name should not be
+ * empty before calling this method, or the real file name will not be
+ * created.
+ *
+ * @param nFileId file ID for an external document
+ */
+ void maybeCreateRealFileName(sal_uInt16 nFileId);
+
bool compileTokensByCell(const ScAddress& rCell);
/**
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 6633637ab3cb..461a3eb970c2 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -677,7 +677,6 @@
#define FILE_MENU_END (SC_FUNCTION_START + 20)
#define EDIT_MENU_START (FILE_MENU_END)
-#define FID_PASTE_CONTENTS (EDIT_MENU_START)
#define FID_DELETE_CELLCONTENTS (EDIT_MENU_START + 1)
#define FID_DELETE_CELL (EDIT_MENU_START + 2)
#define FID_DELETE_TABLE (EDIT_MENU_START + 3)
@@ -858,8 +857,6 @@
#define RID_INPUTBAR_END (RID_INPUTBAR_START+1)
#define DRAW_BAR_START (RID_INPUTBAR_END)
-//! SID_OBJECT_MIRROR wird sicher mal allgemein
-#define SID_OBJECT_MIRROR (DRAW_BAR_START)
#define SID_DRAWTOABOVE (DRAW_BAR_START+15)
#define SID_DRAWTOBELOW (DRAW_BAR_START+16)
//#define SID_GROUP (DRAW_BAR_START+17)
@@ -1108,10 +1105,6 @@
#define SID_DELETE_SCENARIO (SID_NEW_SLOTS+95)
#define SID_EDIT_SCENARIO (SID_NEW_SLOTS+96)
-#define SID_GET_CLPBRD_FORMAT_COUNT (SID_NEW_SLOTS+97)
-#define SID_GET_CLPBRD_FORMAT_BY_IDX (SID_NEW_SLOTS+98)
-#define SID_GET_CLPBRD_FORMAT_NAME (SID_NEW_SLOTS+99)
-
// idl Parameter ---------------------------------------------------------
//aus sfx: #define FN_PARAM_1 (SC_PARAM_START)
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
index 730004f77011..bdabc363738f 100644
--- a/sc/sdi/cellsh.sdi
+++ b/sc/sdi/cellsh.sdi
@@ -156,11 +156,8 @@ interface CellSelection
SID_CUT [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_COPY [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
SID_PASTE [ ExecMethod = ExecuteEdit; StateMethod = GetClipState; ]
- FID_PASTE_CONTENTS [ ExecMethod = ExecuteEdit; StateMethod = GetClipState; ]
+ SID_PASTE_SPECIAL [ ExecMethod = ExecuteEdit; StateMethod = GetClipState; ]
SID_CLIPBOARD_FORMAT_ITEMS [ ExecMethod = ExecuteEdit; StateMethod = GetClipState; ]
- SID_GET_CLPBRD_FORMAT_COUNT [ ExecMethod = ExecuteEdit; ]
- SID_GET_CLPBRD_FORMAT_BY_IDX [ ExecMethod = ExecuteEdit; ]
- SID_GET_CLPBRD_FORMAT_NAME [ ExecMethod = ExecuteEdit; ]
SID_EXTERNAL_SOURCE [ ExecMethod = ExecuteEdit; StateMethod = GetBlockState; ]
FID_MERGE_ON [ ExecMethod = Execute; StateMethod = GetState; ]
FID_MERGE_OFF [ ExecMethod = Execute; StateMethod = GetState; ]
diff --git a/sc/sdi/drtxtob.sdi b/sc/sdi/drtxtob.sdi
index 0d226895af4a..34d850bed6c2 100644
--- a/sc/sdi/drtxtob.sdi
+++ b/sc/sdi/drtxtob.sdi
@@ -61,7 +61,7 @@ interface TableDrawText
SID_CUT [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
SID_COPY [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
SID_PASTE [ ExecMethod = Execute; StateMethod = GetClipState; Export = FALSE; ]
- FID_PASTE_CONTENTS [ ExecMethod = Execute; StateMethod = GetClipState; Export = FALSE; ]
+ SID_PASTE_SPECIAL [ ExecMethod = Execute; StateMethod = GetClipState; Export = FALSE; ]
SID_CLIPBOARD_FORMAT_ITEMS [ ExecMethod = Execute; StateMethod = GetClipState; Export = FALSE; ]
SID_SELECTALL [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
SID_CHARMAP [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
diff --git a/sc/sdi/editsh.sdi b/sc/sdi/editsh.sdi
index c8ad37208744..da5ca92c0f1a 100644
--- a/sc/sdi/editsh.sdi
+++ b/sc/sdi/editsh.sdi
@@ -44,7 +44,7 @@ interface TableText
SID_CUT [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
SID_COPY [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
SID_PASTE [ ExecMethod = Execute; StateMethod = GetClipState; Export = FALSE; ]
- FID_PASTE_CONTENTS [ ExecMethod = Execute; StateMethod = GetClipState; Export = FALSE; ]
+ SID_PASTE_SPECIAL [ ExecMethod = Execute; StateMethod = GetClipState; Export = FALSE; ]
SID_CLIPBOARD_FORMAT_ITEMS [ ExecMethod = Execute; StateMethod = GetClipState; Export = FALSE; ]
SID_SELECTALL [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
SID_CHARMAP [ ExecMethod = Execute; StateMethod = GetState; Export = FALSE; ]
diff --git a/sc/sdi/makefile.mk b/sc/sdi/makefile.mk
index 8431c62307b9..f0f7d12885d8 100644
--- a/sc/sdi/makefile.mk
+++ b/sc/sdi/makefile.mk
@@ -41,7 +41,7 @@ SVSDIINC=$(PRJ)$/source$/ui$/inc
# --- Files --------------------------------------------------------
-
+.IF "$(L10N_framework)"==""
SDI1NAME=$(TARGET)
#SIDHRCNAME=SCSLOTS.HRC
SDI1EXPORT=scalc
@@ -66,7 +66,9 @@ SVSDI1DEPEND= \
mediash.sdi \
pgbrksh.sdi \
scslots.hrc \
- $(INC)$/sc.hrc
+ $(INC)$/sc.hrc \
+ $(SOLARINCXDIR)$/svxslots.ilb
+.ENDIF
# --- Targets -------------------------------------------------------
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index 2372c1dd03a0..de3e3fff56bd 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -2705,81 +2705,6 @@ SfxVoidItem FunctionDialog SID_OPENDLG_FUNCTION
]
//--------------------------------------------------------------------------
-SfxUInt32Item GetClipboardFormat SID_GET_CLPBRD_FORMAT_BY_IDX
-(SfxUInt16Item Index SID_GET_CLPBRD_FORMAT_BY_IDX)
-[
- /* flags: */
- AutoUpdate = FALSE,
- Cachable = Volatile,
- FastCall = TRUE,
- HasCoreId = FALSE,
- HasDialog = TRUE,
- ReadOnlyDoc = FALSE,
- Toggle = FALSE,
- Container = FALSE,
- RecordAbsolute = FALSE,
- RecordPerSet;
- Asynchron;
-
- /* config: */
- AccelConfig = FALSE,
- MenuConfig = FALSE,
- StatusBarConfig = FALSE,
- ToolBoxConfig = FALSE,
- GroupId = GID_EDIT;
-]
-
-//--------------------------------------------------------------------------
-SfxUInt16Item GetClipboardFormatCount SID_GET_CLPBRD_FORMAT_COUNT
-()
-[
- /* flags: */
- AutoUpdate = FALSE,
- Cachable = Volatile,
- FastCall = TRUE,
- HasCoreId = FALSE,
- HasDialog = TRUE,
- ReadOnlyDoc = FALSE,
- Toggle = FALSE,
- Container = FALSE,
- RecordAbsolute = FALSE,
- RecordPerSet;
- Asynchron;
-
- /* config: */
- AccelConfig = FALSE,
- MenuConfig = FALSE,
- StatusBarConfig = FALSE,
- ToolBoxConfig = FALSE,
- GroupId = GID_EDIT;
-]
-
-//--------------------------------------------------------------------------
-SfxStringItem GetClipboardFormatName SID_GET_CLPBRD_FORMAT_NAME
-(SfxUInt32Item Format SID_GET_CLPBRD_FORMAT_NAME)
-[
- /* flags: */
- AutoUpdate = FALSE,
- Cachable = Volatile,
- FastCall = TRUE,
- HasCoreId = FALSE,
- HasDialog = TRUE,
- ReadOnlyDoc = FALSE,
- Toggle = FALSE,
- Container = FALSE,
- RecordAbsolute = FALSE,
- RecordPerSet;
- Asynchron;
-
- /* config: */
- AccelConfig = FALSE,
- MenuConfig = FALSE,
- StatusBarConfig = FALSE,
- ToolBoxConfig = FALSE,
- GroupId = GID_EDIT;
-]
-
-//--------------------------------------------------------------------------
SfxVoidItem GoalSeek SID_SOLVE
()
[
@@ -5012,31 +4937,6 @@ SfxVoidItem PageFormatDialog SID_FORMATPAGE
]
//--------------------------------------------------------------------------
-SfxInt16Item PasteSpecial FID_PASTE_CONTENTS
-(SfxUInt32Item Format FID_PASTE_CONTENTS)
-[
- /* flags: */
- AutoUpdate = FALSE,
- Cachable = Volatile,
- FastCall = TRUE,
- HasCoreId = FALSE,
- HasDialog = TRUE,
- ReadOnlyDoc = FALSE,
- Toggle = FALSE,
- Container = FALSE,
- RecordAbsolute = FALSE,
- RecordPerSet;
- Synchron;
-
- /* config: */
- AccelConfig = TRUE,
- MenuConfig = TRUE,
- StatusBarConfig = FALSE,
- ToolBoxConfig = TRUE,
- GroupId = GID_EDIT;
-]
-
-//--------------------------------------------------------------------------
SfxVoidItem PreviousPage SID_PREVIEW_PREVIOUS
()
[
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index 85f8a4921242..d3d86be58440 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -353,6 +353,21 @@ void ScBroadcastAreaSlot::UpdateRemove( UpdateRefMode eUpdateRefMode,
}
+void ScBroadcastAreaSlot::UpdateRemoveArea( ScBroadcastArea* pArea )
+{
+ ScBroadcastAreas::iterator aIter( aBroadcastAreaTbl.find( pArea));
+ if (aIter == aBroadcastAreaTbl.end())
+ return;
+ if (*aIter != pArea)
+ DBG_ERRORFILE( "UpdateRemoveArea: area pointer mismatch");
+ else
+ {
+ aBroadcastAreaTbl.erase( aIter);
+ pArea->DecRef();
+ }
+}
+
+
void ScBroadcastAreaSlot::UpdateInsert( ScBroadcastArea* pArea )
{
::std::pair< ScBroadcastAreas::iterator, bool > aPair =
@@ -732,6 +747,50 @@ void ScBroadcastAreaSlotMachine::UpdateBroadcastAreas(
}
}
+ // Updating an area's range will modify the hash key, remove areas from all
+ // affected slots. Will be reinserted later with the updated range.
+ ScBroadcastArea* pChain = pUpdateChain;
+ while (pChain)
+ {
+ ScBroadcastArea* pArea = pChain;
+ pChain = pArea->GetUpdateChainNext();
+ ScRange aRange( pArea->GetRange());
+ // remove from slots
+ for (SCTAB nTab = aRange.aStart.Tab(); nTab <= aRange.aEnd.Tab() && pArea->GetRef(); ++nTab)
+ {
+ TableSlotsMap::iterator iTab( aTableSlotsMap.find( nTab));
+ if (iTab == aTableSlotsMap.end())
+ {
+ DBG_ERRORFILE( "UpdateBroadcastAreas: Where's the TableSlot?!?");
+ continue; // for
+ }
+ ScBroadcastAreaSlot** ppSlots = (*iTab).second->getSlots();
+ SCSIZE nStart, nEnd, nRowBreak;
+ ComputeAreaPoints( aRange, nStart, nEnd, nRowBreak );
+ SCSIZE nOff = nStart;
+ SCSIZE nBreak = nOff + nRowBreak;
+ ScBroadcastAreaSlot** pp = ppSlots + nOff;
+ while ( nOff <= nEnd && pArea->GetRef() )
+ {
+ if (*pp)
+ (*pp)->UpdateRemoveArea( pArea);
+ if ( nOff < nBreak )
+ {
+ ++nOff;
+ ++pp;
+ }
+ else
+ {
+ nStart += BCA_SLOTS_ROW;
+ nOff = nStart;
+ pp = ppSlots + nOff;
+ nBreak = nOff + nRowBreak;
+ }
+ }
+ }
+
+ }
+
// shift sheets
if (nDz)
{
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index 0b2a5a551ccb..acac874704c6 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -134,8 +134,8 @@ void ScEditCell::GetString( String& rString ) const
EditEngine& rEngine = pDoc->GetEditEngine();
rEngine.SetText( *pData );
rString = ScEditUtil::GetMultilineString(rEngine); // string with line separators between paragraphs
- // kurze Strings fuer Formeln merken
- if ( rString.Len() < MAXSTRLEN )
+ // cache short strings for formulas
+ if ( rString.Len() < 256 )
((ScEditCell*)this)->pString = new String( rString ); //! non-const
}
else
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 4ba4a225c21f..17650028db70 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -440,10 +440,11 @@ BOOL ScDocument::LinkExternalTab( SCTAB& rTab, const String& aDocTab,
return TRUE;
}
-ScExternalRefManager* ScDocument::GetExternalRefManager()
+ScExternalRefManager* ScDocument::GetExternalRefManager() const
{
+ ScDocument* pThis = const_cast<ScDocument*>(this);
if (!pExternalRefMgr.get())
- pExternalRefMgr.reset(new ScExternalRefManager(this));
+ pThis->pExternalRefMgr.reset( new ScExternalRefManager( pThis));
return pExternalRefMgr.get();
}
@@ -1733,11 +1734,8 @@ const ScDocOptions& ScDocument::GetDocOptions() const
void ScDocument::SetDocOptions( const ScDocOptions& rOpt )
{
- USHORT d,m,y;
-
DBG_ASSERT( pDocOptions, "No DocOptions! :-(" );
*pDocOptions = rOpt;
- rOpt.GetDate( d,m,y );
xPoolHelper->SetFormTableOpt(rOpt);
}
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index c74d804de352..8b04d5a0500e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2880,6 +2880,26 @@ void ScDocument::SetTableOpDirty( const ScRange& rRange )
}
+void ScDocument::InterpretDirtyCells( const ScRangeList& rRanges )
+{
+ ULONG nRangeCount = rRanges.Count();
+ for (ULONG nPos=0; nPos<nRangeCount; nPos++)
+ {
+ ScCellIterator aIter( this, *rRanges.GetObject(nPos) );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ if ( static_cast<ScFormulaCell*>(pCell)->GetDirty() && GetAutoCalc() )
+ static_cast<ScFormulaCell*>(pCell)->Interpret();
+ }
+ pCell = aIter.GetNext();
+ }
+ }
+}
+
+
void ScDocument::AddTableOpFormulaCell( ScFormulaCell* pCell )
{
ScInterpreterTableOpParams* p = aTableOpList.Last();
diff --git a/sc/source/core/data/poolhelp.cxx b/sc/source/core/data/poolhelp.cxx
index ff8f7bb76c5c..d85e16ad135f 100644
--- a/sc/source/core/data/poolhelp.cxx
+++ b/sc/source/core/data/poolhelp.cxx
@@ -95,14 +95,29 @@ SvNumberFormatter* ScPoolHelper::GetFormTable() const
pFormTable->SetColorLink( LINK( m_pSourceDoc, ScDocument, GetUserDefinedColor ) );
pFormTable->SetEvalDateFormat( NF_EVALDATEFORMAT_INTL_FORMAT );
+ UseDocOptions(); // null date, year2000, std precision
+ }
+ return pFormTable;
+}
+
+void ScPoolHelper::UseDocOptions() const
+{
+ if (pFormTable)
+ {
USHORT d,m,y;
aOpt.GetDate( d,m,y );
pFormTable->ChangeNullDate( d,m,y );
pFormTable->ChangeStandardPrec( (USHORT)aOpt.GetStdPrecision() );
pFormTable->SetYear2000( aOpt.GetYear2000() );
}
- return pFormTable;
}
+
+void ScPoolHelper::SetFormTableOpt(const ScDocOptions& rOpt)
+{
+ aOpt = rOpt;
+ UseDocOptions(); // #i105512# if the number formatter exists, update its settings
+}
+
void ScPoolHelper::SourceDocumentGone()
{
// reset all pointers to the source document
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index c53694b7674c..7a08f352ed91 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -652,7 +652,9 @@ void ScPostIt::CreateCaptionFromInitData( const ScAddress& rPos ) const
been created already. */
OSL_ENSURE( !mrDoc.IsUndo() && !mrDoc.IsClipboard(), "ScPostIt::CreateCaptionFromInitData - note caption should not be created in undo/clip documents" );
- if( !maNoteData.mpCaption )
+ /* #i104915# Never try to create notes in Undo document, leads to
+ crash due to missing document members (e.g. row height array). */
+ if( !maNoteData.mpCaption && !mrDoc.IsUndo() )
{
// ScNoteCaptionCreator c'tor creates the caption and inserts it into the document and maNoteData
ScNoteCaptionCreator aCreator( mrDoc, rPos, maNoteData );
@@ -704,8 +706,13 @@ void ScPostIt::CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCapti
OSL_ENSURE( !maNoteData.mpCaption, "ScPostIt::CreateCaption - unexpected caption object found" );
maNoteData.mpCaption = 0;
- // drawing layer may be missing, if a note is copied into a clipboard document
+ /* #i104915# Never try to create notes in Undo document, leads to
+ crash due to missing document members (e.g. row height array). */
OSL_ENSURE( !mrDoc.IsUndo(), "ScPostIt::CreateCaption - note caption should not be created in undo documents" );
+ if( mrDoc.IsUndo() )
+ return;
+
+ // drawing layer may be missing, if a note is copied into a clipboard document
if( mrDoc.IsClipboard() )
mrDoc.InitDrawLayer();
@@ -786,19 +793,16 @@ SdrCaptionObj* ScNoteUtil::CreateTempCaption(
OUStringBuffer aBuffer( rUserText );
// add plain text of invisible (!) cell note (no formatting etc.)
SdrCaptionObj* pNoteCaption = 0;
- if( const ScPostIt* pNote = rDoc.GetNote( rPos ) )
+ const ScPostIt* pNote = rDoc.GetNote( rPos );
+ if( pNote && !pNote->IsCaptionShown() )
{
- if( !pNote->IsCaptionShown() )
- {
- if( aBuffer.getLength() > 0 )
- aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\n--------\n" ) );
- aBuffer.append( pNote->GetText() );
- pNoteCaption = pNote->GetOrCreateCaption( rPos );
- }
+ if( aBuffer.getLength() > 0 )
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\n--------\n" ) ).append( pNote->GetText() );
+ pNoteCaption = pNote->GetOrCreateCaption( rPos );
}
// create a caption if any text exists
- if( aBuffer.getLength() == 0 )
+ if( !pNoteCaption && (aBuffer.getLength() == 0) )
return 0;
// prepare visible rectangle (add default distance to all borders)
@@ -811,20 +815,24 @@ SdrCaptionObj* ScNoteUtil::CreateTempCaption(
// create the caption object
ScCaptionCreator aCreator( rDoc, rPos, true, bTailFront );
SdrCaptionObj* pCaption = aCreator.GetCaption();
+
// insert caption into page (needed to set caption text)
rDrawPage.InsertObject( pCaption );
- // set the text to the object
- pCaption->SetText( aBuffer.makeStringAndClear() );
- // set formatting (must be done after setting text) and resize the box to fit the text
+ // clone the edit text object, unless user text is present, then set this text
if( pNoteCaption && (rUserText.getLength() == 0) )
{
+ if( OutlinerParaObject* pOPO = pNoteCaption->GetOutlinerParaObject() )
+ pCaption->SetOutlinerParaObject( new OutlinerParaObject( *pOPO ) );
+ // set formatting (must be done after setting text) and resize the box to fit the text
pCaption->SetMergedItemSetAndBroadcast( pNoteCaption->GetMergedItemSet() );
Rectangle aCaptRect( pCaption->GetLogicRect().TopLeft(), pNoteCaption->GetLogicRect().GetSize() );
pCaption->SetLogicRect( aCaptRect );
}
else
{
+ // if pNoteCaption is null, then aBuffer contains some text
+ pCaption->SetText( aBuffer.makeStringAndClear() );
ScCaptionUtil::SetDefaultItems( *pCaption, rDoc );
// adjust caption size to text size
long nMaxWidth = ::std::min< long >( aVisRect.GetWidth() * 2 / 3, SC_NOTECAPTION_MAXWIDTH_TEMP );
diff --git a/sc/source/core/inc/bcaslot.hxx b/sc/source/core/inc/bcaslot.hxx
index ef2f77b55684..79335a35fa7e 100644
--- a/sc/source/core/inc/bcaslot.hxx
+++ b/sc/source/core/inc/bcaslot.hxx
@@ -192,6 +192,7 @@ public:
void UpdateRemove( UpdateRefMode eUpdateRefMode,
const ScRange& rRange,
SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
+ void UpdateRemoveArea( ScBroadcastArea* pArea );
void UpdateInsert( ScBroadcastArea* pArea );
};
diff --git a/sc/source/core/inc/poolhelp.hxx b/sc/source/core/inc/poolhelp.hxx
index a60b8db462ab..00474d63c080 100644
--- a/sc/source/core/inc/poolhelp.hxx
+++ b/sc/source/core/inc/poolhelp.hxx
@@ -54,6 +54,8 @@ private:
mutable SfxItemPool* pEnginePool; // EditEnginePool
ScDocument* m_pSourceDoc;
+ void UseDocOptions() const;
+
public:
ScPoolHelper( ScDocument* pSourceDoc );
virtual ~ScPoolHelper();
@@ -68,7 +70,7 @@ public:
SfxItemPool* GetEditPool() const;
SfxItemPool* GetEnginePool() const;
- void SetFormTableOpt(const ScDocOptions& rOpt) { aOpt = rOpt; }
+ void SetFormTableOpt(const ScDocOptions& rOpt);
};
#endif
diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx
index 8bfeaaa72289..259018e213ce 100644
--- a/sc/source/core/tool/address.cxx
+++ b/sc/source/core/tool/address.cxx
@@ -218,18 +218,55 @@ static bool lcl_ScRange_External_TabSpan(
return true;
}
-// Returns NULL if the string should be a sheet name, but is invalid.
-// Returns a pointer to the first character after the sheet name, if there was
-// any, else pointer to start.
+/** Returns NULL if the string should be a sheet name, but is invalid.
+ Returns a pointer to the first character after the sheet name, if there was
+ any, else pointer to start.
+ @param pMsoxlQuoteStop
+ Starting _within_ a quoted name, but still may be 3D; quoted name stops
+ at pMsoxlQuoteStop
+ */
static const sal_Unicode *
lcl_XL_ParseSheetRef( const sal_Unicode* start,
String& rExternTabName,
- bool allow_3d )
+ bool allow_3d,
+ const sal_Unicode* pMsoxlQuoteStop )
{
String aTabName;
const sal_Unicode *p = start;
- if( *p == '\'' ) // XL only seems to use single quotes for sheet names
+ // XL only seems to use single quotes for sheet names.
+ if (pMsoxlQuoteStop)
+ {
+ const sal_Unicode* pCurrentStart = p;
+ while (p < pMsoxlQuoteStop)
+ {
+ if (*p == '\'')
+ {
+ // We pre-analyzed the quoting, no checks needed here.
+ if (*++p == '\'')
+ {
+ aTabName.Append( pCurrentStart,
+ sal::static_int_cast<xub_StrLen>( p - pCurrentStart));
+ pCurrentStart = ++p;
+ }
+ }
+ else if (*p == ':')
+ {
+ break; // while
+ }
+ else
+ ++p;
+ }
+ if (pCurrentStart < p)
+ aTabName.Append( pCurrentStart, sal::static_int_cast<xub_StrLen>( p - pCurrentStart));
+ if (!aTabName.Len())
+ return NULL;
+ if (p == pMsoxlQuoteStop)
+ ++p; // position on ! of ...'!...
+ if( *p != '!' && ( !allow_3d || *p != ':' ) )
+ return (!allow_3d && *p == ':') ? p : start;
+ }
+ else if( *p == '\'')
{
p = lcl_ParseQuotedName(p, aTabName);
if (!aTabName.Len())
@@ -290,8 +327,8 @@ lcl_XL_ParseSheetRef( const sal_Unicode* start,
break;
}
- if( *p != '!' &&( !allow_3d || *p != ':' ) )
- return start;
+ if( *p != '!' && ( !allow_3d || *p != ':' ) )
+ return (!allow_3d && *p == ':') ? p : start;
aTabName.Append( start, sal::static_int_cast<xub_StrLen>( p - start ) );
}
@@ -318,6 +355,7 @@ const sal_Unicode* ScRange::Parse_XL_Header(
rStartTabName.Erase();
rEndTabName.Erase();
rExternDocName.Erase();
+ const sal_Unicode* pMsoxlQuoteStop = NULL;
if (*p == '[')
{
++p;
@@ -371,9 +409,47 @@ const sal_Unicode* ScRange::Parse_XL_Header(
}
rExternDocName = ScGlobal::GetAbsDocName(rExternDocName, pDoc->GetDocumentShell());
}
+ else if (*p == '\'')
+ {
+ // Sickness in Excel's ODF msoxl namespace:
+ // 'E:\[EXTDATA8.XLS]Sheet1'!$A$7 or
+ // 'E:\[EXTDATA12B.XLSB]Sheet1:Sheet3'!$A$11
+ // But, 'Sheet1'!B3 would also be a valid!
+ // Excel does not allow [ and ] characters in sheet names though.
+ p = lcl_ParseQuotedName(p, rExternDocName);
+ if (!*p || *p != '!')
+ return start;
+ if (rExternDocName.Len())
+ {
+ xub_StrLen nOpen = rExternDocName.Search( '[');
+ if (nOpen == STRING_NOTFOUND)
+ rExternDocName.Erase();
+ else
+ {
+ xub_StrLen nClose = rExternDocName.Search( ']', nOpen+1);
+ if (nClose == STRING_NOTFOUND)
+ rExternDocName.Erase();
+ else
+ {
+ rExternDocName.Erase( nClose);
+ rExternDocName.Erase( nOpen, 1);
+ pMsoxlQuoteStop = p - 1; // the ' quote char
+ // There may be embedded escaped quotes, just matching the
+ // doc name's length may not work.
+ for (p = start; *p != '['; ++p)
+ ;
+ for ( ; *p != ']'; ++p)
+ ;
+ ++p;
+ }
+ }
+ }
+ if (!rExternDocName.Len())
+ p = start;
+ }
startTabs = p;
- p = lcl_XL_ParseSheetRef( p, rStartTabName, !bOnlyAcceptSingle );
+ p = lcl_XL_ParseSheetRef( p, rStartTabName, !bOnlyAcceptSingle, pMsoxlQuoteStop);
if( NULL == p )
return start; // invalid tab
if (bOnlyAcceptSingle && *p == ':')
@@ -383,7 +459,7 @@ const sal_Unicode* ScRange::Parse_XL_Header(
nFlags |= SCA_VALID_TAB | SCA_TAB_3D | SCA_TAB_ABSOLUTE;
if( *p == ':' ) // 3d ref
{
- p = lcl_XL_ParseSheetRef( p+1, rEndTabName, false );
+ p = lcl_XL_ParseSheetRef( p+1, rEndTabName, false, pMsoxlQuoteStop);
if( p == NULL )
{
nFlags = nSaveFlags;
@@ -413,7 +489,12 @@ const sal_Unicode* ScRange::Parse_XL_Header(
// Use the current tab, it needs to be passed in. : aEnd.SetTab( .. );
}
- if (!rExternDocName.Len())
+ if (rExternDocName.Len())
+ {
+ ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
+ pRefMgr->convertToAbsName( rExternDocName);
+ }
+ else
{
// Internal reference.
if (!rStartTabName.Len())
@@ -594,7 +675,8 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
if (p && p[0] != 0)
{
// any trailing invalid character must invalidate the whole address.
- nFlags &= ~(SCA_VALID | SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB);
+ nFlags &= ~(SCA_VALID | SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB |
+ SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2);
return nFlags;
}
@@ -661,7 +743,8 @@ lcl_ScRange_Parse_XL_R1C1( ScRange& r,
if (p && p[0] != 0)
{
// any trailing invalid character must invalidate the whole address.
- nFlags &= ~(SCA_VALID | SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB);
+ nFlags &= ~(SCA_VALID | SCA_VALID_COL | SCA_VALID_ROW | SCA_VALID_TAB |
+ SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2);
return nFlags;
}
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 0da842e6ca5a..df7131397aef 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -372,6 +372,15 @@ void ScCompiler::SetGrammar( const FormulaGrammar::Grammar eGrammar )
}
}
+void ScCompiler::SetEncodeUrlMode( EncodeUrlMode eMode )
+{
+ meEncodeUrlMode = eMode;
+}
+
+ScCompiler::EncodeUrlMode ScCompiler::GetEncodeUrlMode() const
+{
+ return meEncodeUrlMode;
+}
void ScCompiler::SetFormulaLanguage( const ScCompiler::OpCodeMapPtr & xMap )
{
@@ -461,22 +470,22 @@ ScCompiler::Convention::Convention( FormulaGrammar::AddressConvention eConv )
/* + */ t[43] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_EXP | SC_COMPILER_C_VALUE_SIGN;
/* , */ t[44] = SC_COMPILER_C_CHAR_VALUE | SC_COMPILER_C_VALUE;
/* - */ t[45] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_EXP | SC_COMPILER_C_VALUE_SIGN;
-/* . */ t[46] = SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_VALUE | SC_COMPILER_C_VALUE | SC_COMPILER_C_IDENT;
+/* . */ t[46] = SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_VALUE | SC_COMPILER_C_VALUE | SC_COMPILER_C_IDENT | SC_COMPILER_C_NAME;
/* / */ t[47] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
for (i = 48; i < 58; i++)
-/* 0-9 */ t[i] = SC_COMPILER_C_CHAR_VALUE | SC_COMPILER_C_WORD | SC_COMPILER_C_VALUE | SC_COMPILER_C_VALUE_EXP | SC_COMPILER_C_VALUE_VALUE | SC_COMPILER_C_IDENT;
+/* 0-9 */ t[i] = SC_COMPILER_C_CHAR_VALUE | SC_COMPILER_C_WORD | SC_COMPILER_C_VALUE | SC_COMPILER_C_VALUE_EXP | SC_COMPILER_C_VALUE_VALUE | SC_COMPILER_C_IDENT | SC_COMPILER_C_NAME;
/* : */ t[58] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD;
/* ; */ t[59] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
/* < */ t[60] = SC_COMPILER_C_CHAR_BOOL | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
/* = */ t[61] = SC_COMPILER_C_CHAR | SC_COMPILER_C_BOOL | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
/* > */ t[62] = SC_COMPILER_C_CHAR_BOOL | SC_COMPILER_C_BOOL | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* ? */ t[63] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD;
+/* ? */ t[63] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_NAME;
/* @ */ // FREE
for (i = 65; i < 91; i++)
-/* A-Z */ t[i] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT;
+/* A-Z */ t[i] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT | SC_COMPILER_C_CHAR_NAME | SC_COMPILER_C_NAME;
if (FormulaGrammar::CONV_ODF == meConv)
{
@@ -491,11 +500,11 @@ ScCompiler::Convention::Convention( FormulaGrammar::AddressConvention eConv )
/* ] */ // FREE
}
/* ^ */ t[94] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP;
-/* _ */ t[95] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT;
+/* _ */ t[95] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT | SC_COMPILER_C_CHAR_NAME | SC_COMPILER_C_NAME;
/* ` */ // FREE
for (i = 97; i < 123; i++)
-/* a-z */ t[i] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT;
+/* a-z */ t[i] = SC_COMPILER_C_CHAR_WORD | SC_COMPILER_C_WORD | SC_COMPILER_C_CHAR_IDENT | SC_COMPILER_C_IDENT | SC_COMPILER_C_CHAR_NAME | SC_COMPILER_C_NAME;
/* { */ t[123] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP; // array open
/* | */ t[124] = SC_COMPILER_C_CHAR | SC_COMPILER_C_WORD_SEP | SC_COMPILER_C_VALUE_SEP; // array row sep (Should be OOo specific)
@@ -995,14 +1004,19 @@ struct ConventionOOO_A1 : public Convention_A1
bool makeExternalSingleRefStr( ::rtl::OUStringBuffer& rBuffer, sal_uInt16 nFileId,
const String& rTabName, const ScSingleRefData& rRef,
- ScExternalRefManager* pRefMgr, bool bDisplayTabName ) const
+ ScExternalRefManager* pRefMgr, bool bDisplayTabName, bool bEncodeUrl ) const
{
if (bDisplayTabName)
{
String aFile;
const String* p = pRefMgr->getExternalFileName(nFileId);
if (p)
- aFile = *p;
+ {
+ if (bEncodeUrl)
+ aFile = *p;
+ else
+ aFile = INetURLObject::decode(*p, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
+ }
aFile.SearchAndReplaceAllAscii("'", String::CreateFromAscii("''"));
rBuffer.append(sal_Unicode('\''));
@@ -1036,7 +1050,23 @@ struct ConventionOOO_A1 : public Convention_A1
if (bODF)
rBuffer.append( sal_Unicode('['));
- makeExternalSingleRefStr(rBuffer, nFileId, rTabName, aRef, pRefMgr, true);
+
+ bool bEncodeUrl = true;
+ switch (rCompiler.GetEncodeUrlMode())
+ {
+ case ScCompiler::ENCODE_BY_GRAMMAR:
+ bEncodeUrl = bODF;
+ break;
+ case ScCompiler::ENCODE_ALWAYS:
+ bEncodeUrl = true;
+ break;
+ case ScCompiler::ENCODE_NEVER:
+ bEncodeUrl = false;
+ break;
+ default:
+ ;
+ }
+ makeExternalSingleRefStr(rBuffer, nFileId, rTabName, aRef, pRefMgr, true, bEncodeUrl);
if (bODF)
rBuffer.append( sal_Unicode(']'));
}
@@ -1058,9 +1088,25 @@ struct ConventionOOO_A1 : public Convention_A1
if (bODF)
rBuffer.append( sal_Unicode('['));
// Ensure that there's always a closing bracket, no premature returns.
+ bool bEncodeUrl = true;
+ switch (rCompiler.GetEncodeUrlMode())
+ {
+ case ScCompiler::ENCODE_BY_GRAMMAR:
+ bEncodeUrl = bODF;
+ break;
+ case ScCompiler::ENCODE_ALWAYS:
+ bEncodeUrl = true;
+ break;
+ case ScCompiler::ENCODE_NEVER:
+ bEncodeUrl = false;
+ break;
+ default:
+ ;
+ }
+
do
{
- if (!makeExternalSingleRefStr(rBuffer, nFileId, rTabName, aRef.Ref1, pRefMgr, true))
+ if (!makeExternalSingleRefStr(rBuffer, nFileId, rTabName, aRef.Ref1, pRefMgr, true, bEncodeUrl))
break;
rBuffer.append(sal_Unicode(':'));
@@ -1086,7 +1132,7 @@ struct ConventionOOO_A1 : public Convention_A1
else if (bODF)
rBuffer.append( sal_Unicode('.')); // need at least the sheet separator in ODF
makeExternalSingleRefStr( rBuffer, nFileId, aLastTabName,
- aRef.Ref2, pRefMgr, bDisplayTabName);
+ aRef.Ref2, pRefMgr, bDisplayTabName, bEncodeUrl);
} while (0);
if (bODF)
rBuffer.append( sal_Unicode(']'));
@@ -1248,7 +1294,7 @@ struct ConventionXL
return lcl_makeExternalNameStr( rFile, rName, sal_Unicode('!'), false);
}
- static void makeExternalDocStr( ::rtl::OUStringBuffer& rBuffer, const String& rFullName )
+ static void makeExternalDocStr( ::rtl::OUStringBuffer& rBuffer, const String& rFullName, bool bEncodeUrl )
{
// Format that is easier to deal with inside OOo, because we use file
// URL, and all characetrs are allowed. Check if it makes sense to do
@@ -1259,8 +1305,14 @@ struct ConventionXL
rBuffer.append(sal_Unicode('['));
rBuffer.append(sal_Unicode('\''));
- const sal_Unicode* pBuf = rFullName.GetBuffer();
- xub_StrLen nLen = rFullName.Len();
+ String aFullName;
+ if (bEncodeUrl)
+ aFullName = rFullName;
+ else
+ aFullName = INetURLObject::decode(rFullName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS);
+
+ const sal_Unicode* pBuf = aFullName.GetBuffer();
+ xub_StrLen nLen = aFullName.Len();
for (xub_StrLen i = 0; i < nLen; ++i)
{
const sal_Unicode c = pBuf[i];
@@ -1473,7 +1525,8 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
ScSingleRefData aRef(rRef);
aRef.CalcAbsIfRel(rCompiler.GetPos());
- ConventionXL::makeExternalDocStr(rBuffer, *pFullName);
+ ConventionXL::makeExternalDocStr(
+ rBuffer, *pFullName, rCompiler.GetEncodeUrlMode() == ScCompiler::ENCODE_ALWAYS);
ScRangeStringConverter::AppendTableName(rBuffer, rTabName);
rBuffer.append(sal_Unicode('!'));
@@ -1496,7 +1549,8 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
ScComplexRefData aRef(rRef);
aRef.CalcAbsIfRel(rCompiler.GetPos());
- ConventionXL::makeExternalDocStr(rBuffer, *pFullName);
+ ConventionXL::makeExternalDocStr(
+ rBuffer, *pFullName, rCompiler.GetEncodeUrlMode() == ScCompiler::ENCODE_ALWAYS);
ConventionXL::makeExternalTabNameRange(rBuffer, rTabName, aTabNames, aRef);
rBuffer.append(sal_Unicode('!'));
@@ -1677,7 +1731,8 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
ScSingleRefData aRef(rRef);
aRef.CalcAbsIfRel(rCompiler.GetPos());
- ConventionXL::makeExternalDocStr(rBuffer, *pFullName);
+ ConventionXL::makeExternalDocStr(
+ rBuffer, *pFullName, rCompiler.GetEncodeUrlMode() == ScCompiler::ENCODE_ALWAYS);
ScRangeStringConverter::AppendTableName(rBuffer, rTabName);
rBuffer.append(sal_Unicode('!'));
@@ -1701,7 +1756,8 @@ struct ConventionXL_R1C1 : public ScCompiler::Convention, public ConventionXL
ScComplexRefData aRef(rRef);
aRef.CalcAbsIfRel(rCompiler.GetPos());
- ConventionXL::makeExternalDocStr(rBuffer, *pFullName);
+ ConventionXL::makeExternalDocStr(
+ rBuffer, *pFullName, rCompiler.GetEncodeUrlMode() == ScCompiler::ENCODE_ALWAYS);
ConventionXL::makeExternalTabNameRange(rBuffer, rTabName, aTabNames, aRef);
rBuffer.append(sal_Unicode('!'));
@@ -1753,6 +1809,7 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos,ScTokenArra
mnPredetectedReference(0),
mnRangeOpPosInSymbol(-1),
pConv( pConvOOO_A1 ),
+ meEncodeUrlMode( ENCODE_BY_GRAMMAR ),
mbCloseBrackets( true ),
mbExtendedErrorDetection( false ),
mbRewind( false )
@@ -1768,6 +1825,7 @@ ScCompiler::ScCompiler( ScDocument* pDocument, const ScAddress& rPos)
mnPredetectedReference(0),
mnRangeOpPosInSymbol(-1),
pConv( pConvOOO_A1 ),
+ meEncodeUrlMode( ENCODE_BY_GRAMMAR ),
mbCloseBrackets( true ),
mbExtendedErrorDetection( false ),
mbRewind( false )
@@ -2220,14 +2278,16 @@ Label_MaskStateMachine:
static const int kQuote = (1 << 4);
// Past ' closing quote.
static const int kClose = (1 << 5);
+ // Encountered # file/sheet separator.
+ static const int kFileSep = (1 << 6);
// Past . sheet name separator.
- static const int kPast = (1 << 6);
+ static const int kPast = (1 << 7);
// Marked name $$ follows sheet name separator, detected
// while we're still on the separator. Will be cleared when
// entering the name.
- static const int kMarkAhead = (1 << 7);
+ static const int kMarkAhead = (1 << 8);
// In marked defined name.
- static const int kDefName = (1 << 8);
+ static const int kDefName = (1 << 9);
bool bAddToSymbol = true;
if ((nMask & SC_COMPILER_C_ODF_RBRACKET) && !(nRefInName & kOpen))
@@ -2251,7 +2311,9 @@ Label_MaskStateMachine:
{
// Not in col/row yet.
- if ('$' == c && '$' == pSrc[0] && !(nRefInName & kOpen))
+ if (SC_COMPILER_FILE_TAB_SEP == c && (nRefInName & kFileSep))
+ nRefInName = 0;
+ else if ('$' == c && '$' == pSrc[0] && !(nRefInName & kOpen))
{
nRefInName &= ~kMarkAhead;
if (!(nRefInName & kDefName))
@@ -2298,16 +2360,20 @@ Label_MaskStateMachine:
}
else
{
- if ('\'' == pSrc[0])
- {
- // escapes embedded quote
- nRefInName |= kQuote;
- }
- else
+ switch (pSrc[0])
{
- // quote not followed by quote => close
- nRefInName |= kClose;
- nRefInName &= ~kOpen;
+ case '\'':
+ // escapes embedded quote
+ nRefInName |= kQuote;
+ break;
+ case SC_COMPILER_FILE_TAB_SEP:
+ // sheet name should follow
+ nRefInName |= kFileSep;
+ // fallthru
+ default:
+ // quote not followed by quote => close
+ nRefInName |= kClose;
+ nRefInName &= ~kOpen;
}
bAddToSymbol = !(nRefInName & kDefName);
}
@@ -2802,6 +2868,23 @@ BOOL ScCompiler::IsReference( const String& rName )
mbRewind = true;
return true; // end all checks
}
+ else
+ {
+ // Special treatment for the 'E:\[doc]Sheet1:Sheet3'!D5 Excel sickness,
+ // mnRangeOpPosInSymbol did not catch the range operator as it is
+ // within a quoted name.
+ switch (pConv->meConv)
+ {
+ case FormulaGrammar::CONV_XL_A1:
+ case FormulaGrammar::CONV_XL_R1C1:
+ case FormulaGrammar::CONV_XL_OOX:
+ if (rName.GetChar(0) == '\'' && IsDoubleReference( rName))
+ return true;
+ break;
+ default:
+ ; // nothing
+ }
+ }
return false;
}
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index a5644985206f..11fd414c81f2 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3279,7 +3279,7 @@ void ScInterpreter::ScCalcTeam()
if( !bShown )
{
ShowTheTeam();
- String aTeam( RTL_CONSTASCII_USTRINGPARAM( "Ballach, Nebel, Rentz, Rathke, Marmion" ) );
+ String aTeam( RTL_CONSTASCII_USTRINGPARAM( "Nebel, Benisch, Rentz, Rathke" ) );
if ( (GetByte() == 1) && ::rtl::math::approxEqual( GetDouble(), 1996) )
aTeam.AppendAscii( " (a word with 'B': -Olk, -Nietsch, -Daeumling)" );
PushString( aTeam );
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 3f0cadbadb7f..7795256dce3c 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -453,48 +453,45 @@ void ScRangeData::UpdateTabRef(SCTAB nOldTable, USHORT nFlag, SCTAB nNewTable)
}
}
-// wie beim Uebernehmen von Namen in Excel
void ScRangeData::MakeValidName( String& rName ) // static
{
//ScCompiler::InitSymbolsNative();
- // ungueltige Zeichen vorne weglassen
+ // strip leading invalid characters
xub_StrLen nPos = 0;
xub_StrLen nLen = rName.Len();
- while ( nPos < nLen && !ScCompiler::IsWordChar( rName, nPos) )
+ while ( nPos < nLen && !ScCompiler::IsCharFlagAllConventions( rName, nPos, SC_COMPILER_C_NAME) )
++nPos;
if ( nPos>0 )
rName.Erase(0,nPos);
- // wenn vorne ein ungueltiges Anfangszeichen steht, '_' davor
- if ( rName.Len() && !ScCompiler::IsCharWordChar( rName, 0 ) )
+ // if the first character is an invalid start character, precede with '_'
+ if ( rName.Len() && !ScCompiler::IsCharFlagAllConventions( rName, 0, SC_COMPILER_C_CHAR_NAME ) )
rName.Insert('_',0);
- // ungueltige durch '_' ersetzen
+ // replace invalid with '_'
nLen = rName.Len();
for (nPos=0; nPos<nLen; nPos++)
{
- if ( !ScCompiler::IsWordChar( rName, nPos) )
+ if ( !ScCompiler::IsCharFlagAllConventions( rName, nPos, SC_COMPILER_C_NAME) )
rName.SetChar( nPos, '_' );
}
- // Name darf keine Referenz beinhalten, wie in IsNameValid
+ // Ensure that the proposed name is not a reference under any convention,
+ // same as in IsNameValid()
ScAddress aAddr;
- ScRange aRange;
- int nConv = FormulaGrammar::CONV_UNSPECIFIED; // use int so that op++ works
-
- // Ensure that the proposed name is not an address under any convention
- while ( ++nConv != FormulaGrammar::CONV_LAST )
- {
+ ScRange aRange;
+ for (int nConv = FormulaGrammar::CONV_UNSPECIFIED; ++nConv < FormulaGrammar::CONV_LAST; )
+ {
ScAddress::Details details( static_cast<FormulaGrammar::AddressConvention>( nConv ) );
- while( aRange.Parse( rName, NULL, details )
- || aAddr.Parse( rName, NULL, details ) )
+ // Don't check Parse on VALID, any partial only VALID may result in
+ // #REF! during compile later!
+ while (aRange.Parse( rName, NULL, details) || aAddr.Parse( rName, NULL, details))
{
- //! Range Parse auch bei Bereich mit ungueltigem Tabellennamen gueltig
- //! Address Parse dito, Name erzeugt deswegen bei Compile ein #REF!
- if ( rName.SearchAndReplace( ':', '_' ) == STRING_NOTFOUND
- && rName.SearchAndReplace( '.', '_' ) == STRING_NOTFOUND )
+ //! Range Parse is partially valid also with invalid sheet name,
+ //! Address Parse dito, during compile name would generate a #REF!
+ if ( rName.SearchAndReplace( '.', '_' ) == STRING_NOTFOUND )
rName.Insert('_',0);
}
}
@@ -502,26 +499,25 @@ void ScRangeData::MakeValidName( String& rName ) // static
BOOL ScRangeData::IsNameValid( const String& rName, ScDocument* pDoc )
{
- /* If changed, ScfTools::ConvertToScDefinedName (sc/source/filter/ftools/ftools.cxx)
- needs to be changed too. */
+ /* XXX If changed, sc/source/filter/ftools/ftools.cxx
+ * ScfTools::ConvertToScDefinedName needs to be changed too. */
xub_StrLen nPos = 0;
xub_StrLen nLen = rName.Len();
- if ( !nLen || !ScCompiler::IsCharWordChar( rName, nPos++ ) )
+ if ( !nLen || !ScCompiler::IsCharFlagAllConventions( rName, nPos++, SC_COMPILER_C_CHAR_NAME ) )
return FALSE;
while ( nPos < nLen )
{
- if ( !ScCompiler::IsWordChar( rName, nPos++ ) )
+ if ( !ScCompiler::IsCharFlagAllConventions( rName, nPos++, SC_COMPILER_C_NAME ) )
return FALSE;
}
- // Parse nicht auf VALID pruefen, es reicht, wenn irgendein Bestandteil
- // erkannt wurde
+ ScAddress aAddr;
ScRange aRange;
- if( aRange.Parse( rName, pDoc ) ) // THIS IS WRONG
- return FALSE;
- else
+ for (int nConv = FormulaGrammar::CONV_UNSPECIFIED; ++nConv < FormulaGrammar::CONV_LAST; )
{
- ScAddress aAddr;
- if ( aAddr.Parse( rName, pDoc ) ) // THIS IS WRONG
+ ScAddress::Details details( static_cast<FormulaGrammar::AddressConvention>( nConv ) );
+ // Don't check Parse on VALID, any partial only VALID may result in
+ // #REF! during compile later!
+ if (aRange.Parse( rName, pDoc, details) || aAddr.Parse( rName, pDoc, details))
return FALSE;
}
return TRUE;
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index b1654421b12c..4a26a5004799 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -786,7 +786,7 @@ static void lcl_appendCellAddress(
if (rExtInfo.mbExternal)
{
ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
- const String* pFilePath = pRefMgr->getExternalFileName(rExtInfo.mnFileId);
+ const String* pFilePath = pRefMgr->getExternalFileName(rExtInfo.mnFileId, true);
if (!pFilePath)
return;
@@ -821,7 +821,7 @@ static void lcl_appendCellRangeAddress(
DBG_ASSERT(rExtInfo1.mnFileId == rExtInfo2.mnFileId, "File IDs do not match between 1st and 2nd addresses.");
ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
- const String* pFilePath = pRefMgr->getExternalFileName(rExtInfo1.mnFileId);
+ const String* pFilePath = pRefMgr->getExternalFileName(rExtInfo1.mnFileId, true);
if (!pFilePath)
return;
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index e129abdcf97f..d0f2b8233de0 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -51,7 +51,7 @@ using ::rtl::OUString;
void ScRefTokenHelper::compileRangeRepresentation(
vector<ScSharedTokenRef>& rRefTokens, const OUString& rRangeStr, ScDocument* pDoc, FormulaGrammar::Grammar eGrammar)
{
- const sal_Unicode cSep = ';';
+ const sal_Unicode cSep = GetScCompilerNativeSymbol(ocSep).GetChar(0);
const sal_Unicode cQuote = '\'';
bool bFailure = false;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 0f03d31d3fc8..6c5c6a03b773 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -119,7 +119,7 @@ IMPL_FIXEDMEMPOOL_NEWDEL( ImpTokenIterator, 32, 16 )
// Align MemPools on 4k boundaries - 64 bytes (4k is a MUST for OS/2)
// Since RawTokens are temporary for the compiler, don't align on 4k and waste memory.
-// ScRawToken size is FixMembers + MAXSTRLEN ~= 264
+// ScRawToken size is FixMembers + MAXSTRLEN + ~4 ~= 1036
IMPL_FIXEDMEMPOOL_NEWDEL( ScRawToken, 8, 4 )
// Some ScDoubleRawToken, FixMembers + sizeof(double) ~= 16
const USHORT nMemPoolDoubleRawToken = 0x0400 / sizeof(ScDoubleRawToken);
diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx
index d1b08b9cfc68..c72d165c7972 100644
--- a/sc/source/filter/excel/excdoc.cxx
+++ b/sc/source/filter/excel/excdoc.cxx
@@ -144,12 +144,12 @@ static void lcl_AddWorkbookProtection( XclExpRecordList<>& aRecList, ExcTable& s
}
#endif
-static void lcl_AddScenariosAndFilters( XclExpRecordList<>& aRecList, ExcTable& self, SCTAB mnScTab )
+static void lcl_AddScenariosAndFilters( XclExpRecordList<>& aRecList, const XclExpRoot& rRoot, SCTAB nScTab )
{
// Scenarios
- aRecList.AppendNewRecord( new ExcEScenarioManager( self.GetDoc(), mnScTab ) );
+ aRecList.AppendNewRecord( new ExcEScenarioManager( rRoot, nScTab ) );
// filter
- aRecList.AppendRecord( self.GetFilterManager().CreateRecord( mnScTab ) );
+ aRecList.AppendRecord( rRoot.GetFilterManager().CreateRecord( nScTab ) );
}
@@ -205,20 +205,47 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
rR.pObjRecs = NULL; // per sheet
+ sal_uInt16 nWriteProtHash = 0;
+ if( SfxObjectShell* pDocShell = GetDocShell() )
+ {
+ ScfPropertySet aPropSet( pDocShell->GetModel() );
+ sal_Int32 nApiHash = 0;
+ if( aPropSet.GetProperty( nApiHash, CREATE_OUSTRING( "WriteProtectionPassword" ) ) && (0 < nApiHash) && (nApiHash <= SAL_MAX_UINT16) )
+ {
+ nWriteProtHash = static_cast< sal_uInt16 >( nApiHash );
+ Add( new XclExpEmptyRecord( EXC_ID_WRITEPROT ) );
+ }
+ }
+
+ // TODO: correct codepage for BIFF5?
+ sal_uInt16 nCodePage = XclTools::GetXclCodePage( (GetBiff() <= EXC_BIFF5) ? RTL_TEXTENCODING_MS_1252 : RTL_TEXTENCODING_UNICODE );
+
if( GetBiff() <= EXC_BIFF5 )
+ {
+ Add( new XclExpEmptyRecord( EXC_ID_INTERFACEHDR ) );
+ Add( new XclExpUInt16Record( EXC_ID_MMS, 0 ) );
+ Add( new XclExpEmptyRecord( EXC_ID_TOOLBARHDR ) );
+ Add( new XclExpEmptyRecord( EXC_ID_TOOLBAREND ) );
+ Add( new XclExpEmptyRecord( EXC_ID_INTERFACEEND ) );
Add( new ExcDummy_00 );
+ }
else
{
- if ( IsDocumentEncrypted() )
- Add( new XclExpFilePass(GetRoot()) );
-
- Add( new XclExpInterfaceHdr );
- Add( new XclExpMMS );
- Add( new XclExpInterfaceEnd );
+ if( IsDocumentEncrypted() )
+ Add( new XclExpFilePass( GetRoot() ) );
+ Add( new XclExpInterfaceHdr( nCodePage ) );
+ Add( new XclExpUInt16Record( EXC_ID_MMS, 0 ) );
+ Add( new XclExpEmptyRecord( EXC_ID_INTERFACEEND ) );
Add( new XclExpWriteAccess );
- Add( new XclExpCodePage );
- Add( new XclExpDSF );
- Add( new XclExpExcel9File );
+ }
+
+ Add( new XclExpFileSharing( GetRoot(), nWriteProtHash ) );
+ Add( new XclExpUInt16Record( EXC_ID_CODEPAGE, nCodePage ) );
+
+ if( GetBiff() == EXC_BIFF8 )
+ {
+ Add( new XclExpBoolRecord( EXC_ID_DSF, false ) );
+ Add( new XclExpEmptyRecord( EXC_ID_XL9FILE ) );
rR.pTabId = new XclExpChTrTabId( Max( nExcTabCount, nCodenames ) );
Add( rR.pTabId );
if( HasVbaStorage() )
@@ -228,10 +255,10 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList )
if( rCodeName.Len() )
Add( new XclCodename( rCodeName ) );
}
-
- Add( new XclExpFnGroupCount );
}
+ Add( new XclExpUInt16Record( EXC_ID_FNGROUPCOUNT, 14 ) );
+
// erst Namen- und Tabellen-Eintraege aufbauen
String aName;
@@ -473,7 +500,7 @@ void ExcTable::FillAsTable( size_t nCodeNameIdx )
aRecList.AppendRecord( CreateRecord( EXC_ID_EXTERNSHEET ) );
if ( eBiff == EXC_BIFF8 )
- lcl_AddScenariosAndFilters( aRecList, *this, mnScTab );
+ lcl_AddScenariosAndFilters( aRecList, GetRoot(), mnScTab );
// cell table: DEFCOLWIDTH, COLINFO, DIMENSIONS, ROW, cell records
aRecList.AppendRecord( mxCellTable );
@@ -585,7 +612,7 @@ void ExcTable::FillAsXmlTable( size_t nCodeNameIdx )
// web queries
Add( new XclExpWebQueryBuffer( GetRoot() ) );
- lcl_AddScenariosAndFilters( aRecList, *this, mnScTab );
+ lcl_AddScenariosAndFilters( aRecList, GetRoot(), mnScTab );
// MERGEDCELLS record, generated by the cell table
aRecList.AppendRecord( mxCellTable->CreateRecord( EXC_ID_MERGEDCELLS ) );
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 1d209b91bc68..deaa3b375c6d 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -165,14 +165,14 @@ void ImportExcel8::Boundsheet( void )
UINT8 nLen;
UINT16 nGrbit;
- aIn.Ignore( 4 );
+ aIn.DisableDecryption();
+ maSheetOffsets.push_back( aIn.ReaduInt32() );
+ aIn.EnableDecryption();
aIn >> nGrbit >> nLen;
String aName( aIn.ReadUniString( nLen ) );
GetTabInfo().AppendXclTabName( aName, nBdshtTab );
- *pExcRoot->pTabNameBuff << aName;
-
SCTAB nScTab = static_cast< SCTAB >( nBdshtTab );
if( nScTab > 0 )
{
diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx
index bff8d4cba246..4ee5f70dc938 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -107,17 +107,10 @@ using ::rtl::OString;
//--------------------------------------------------------- class ExcDummy_00 -
const BYTE ExcDummy_00::pMyData[] = {
- 0xe1, 0x00, 0x00, 0x00, // INTERFACEHDR
- 0xc1, 0x00, 0x02, 0x00, 0x00, 0x00, // MMS
- 0xbf, 0x00, 0x00, 0x00, // TOOLBARHDR
- 0xc0, 0x00, 0x00, 0x00, // TOOLBAREND
- 0xe2, 0x00, 0x00, 0x00, // INTERFACEEND
- 0x5c, 0x00, 0x20, 0x00, 0x04, 0x4d, 0x72, 0x20, 0x58, // WRITEACCESS
+ 0x5c, 0x00, 0x20, 0x00, 0x04, 'C', 'a', 'l', 'c', // WRITEACCESS
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x42, 0x00, 0x02, 0x00, 0xe4, 0x04, // CODEPAGE
- 0x9c, 0x00, 0x02, 0x00, 0x0e, 0x00 // FNGROUPCOUNT
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
};
const sal_Size ExcDummy_00::nMyLen = sizeof( ExcDummy_00::pMyData );
@@ -315,27 +308,6 @@ sal_Size ExcEof::GetLen( void ) const
-//----------------------------------------------------- class ExcFngroupcount -
-
-void ExcFngroupcount::SaveCont( XclExpStream& rStrm )
-{
- rStrm << ( UINT16 ) 0x000E; // copied from Excel
-}
-
-
-UINT16 ExcFngroupcount::GetNum( void ) const
-{
- return 0x009C;
-}
-
-
-sal_Size ExcFngroupcount::GetLen( void ) const
-{
- return 2;
-}
-
-
-
//--------------------------------------------------------- class ExcDummy_00 -
sal_Size ExcDummy_00::GetLen( void ) const
diff --git a/sc/source/filter/excel/exctools.cxx b/sc/source/filter/excel/exctools.cxx
index 11400ca20742..d698278d9d3c 100644
--- a/sc/source/filter/excel/exctools.cxx
+++ b/sc/source/filter/excel/exctools.cxx
@@ -68,7 +68,6 @@ RootData::RootData( void )
{
eDateiTyp = BiffX;
pExtSheetBuff = NULL;
- pTabNameBuff = NULL;
pShrfmlaBuff = NULL;
pExtNameBuff = NULL;
pFmlaConverter = NULL;
@@ -90,7 +89,6 @@ RootData::RootData( void )
RootData::~RootData()
{
delete pExtSheetBuff;
- delete pTabNameBuff;
delete pShrfmlaBuff;
delete pExtNameBuff;
delete pAutoFilterBuffer;
diff --git a/sc/source/filter/excel/impop.cxx b/sc/source/filter/excel/impop.cxx
index 5a0ae1f9a972..9b868f4d3268 100644
--- a/sc/source/filter/excel/impop.cxx
+++ b/sc/source/filter/excel/impop.cxx
@@ -136,7 +136,6 @@ ImportExcel::ImportExcel( XclImpRootData& rImpData, SvStream& rStrm ):
pExcRoot->pIR = this; // ExcRoot -> XclImpRoot
pExcRoot->eDateiTyp = BiffX;
pExcRoot->pExtSheetBuff = new ExtSheetBuffer( pExcRoot ); //&aExtSheetBuff;
- pExcRoot->pTabNameBuff = new NameBuffer( pExcRoot ); //&aTabNameBuff;
pExcRoot->pShrfmlaBuff = new ShrfmlaBuffer( pExcRoot ); //&aShrfrmlaBuff;
pExcRoot->pExtNameBuff = new ExtNameBuff ( *this );
@@ -180,9 +179,19 @@ void ImportExcel::ReadFileSharing()
{
sal_uInt16 nRecommendReadOnly, nPasswordHash;
maStrm >> nRecommendReadOnly >> nPasswordHash;
+
if( (nRecommendReadOnly != 0) || (nPasswordHash != 0) )
if( SfxItemSet* pItemSet = GetMedium().GetItemSet() )
pItemSet->Put( SfxBoolItem( SID_DOC_READONLY, TRUE ) );
+
+ if( nPasswordHash != 0 )
+ {
+ if( SfxObjectShell* pDocShell = GetDocShell() )
+ {
+ ScfPropertySet aPropSet( pDocShell->GetModel() );
+ aPropSet.SetProperty( CREATE_OUSTRING( "WriteProtectionPassword" ), static_cast< sal_Int32 >( nPasswordHash ) );
+ }
+ }
}
sal_uInt16 ImportExcel::ReadXFIndex( bool bBiff2 )
@@ -688,14 +697,14 @@ void ImportExcel::Boundsheet( void )
if( GetBiff() == EXC_BIFF5 )
{
- aIn.Ignore( 4 );
+ aIn.DisableDecryption();
+ maSheetOffsets.push_back( aIn.ReaduInt32() );
+ aIn.EnableDecryption();
aIn >> nGrbit;
}
String aName( aIn.ReadByteString( FALSE ) );
- *pExcRoot->pTabNameBuff << aName;
-
SCTAB nScTab = static_cast< SCTAB >( nBdshtTab );
if( nScTab > 0 )
{
diff --git a/sc/source/filter/excel/makefile.mk b/sc/source/filter/excel/makefile.mk
index 5b483f04729d..4c94b0712d89 100644
--- a/sc/source/filter/excel/makefile.mk
+++ b/sc/source/filter/excel/makefile.mk
@@ -121,6 +121,7 @@ EXCEPTIONSFILES = \
$(SLO)$/excimp8.obj \
$(SLO)$/excrecds.obj \
$(SLO)$/expop2.obj \
+ $(SLO)$/impop.obj \
$(SLO)$/namebuff.obj \
$(SLO)$/tokstack.obj \
$(SLO)$/xecontent.obj \
diff --git a/sc/source/filter/excel/read.cxx b/sc/source/filter/excel/read.cxx
index a4a286d27171..afa66422ca44 100644
--- a/sc/source/filter/excel/read.cxx
+++ b/sc/source/filter/excel/read.cxx
@@ -99,9 +99,28 @@ FltError ImportExcel::Read( void )
::std::auto_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
+ /* #i104057# Need to track a base position for progress bar calculation,
+ because sheet substreams may not be in order of sheets. */
+ sal_Size nProgressBasePos = 0;
+ sal_Size nProgressBaseSize = 0;
+
while( eAkt != Z_Ende )
{
- aIn.StartNextRecord();
+ if( eAkt == Z_Biff5E )
+ {
+ sal_uInt16 nScTab = GetCurrScTab();
+ if( nScTab < maSheetOffsets.size() )
+ {
+ nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos);
+ nProgressBasePos = maSheetOffsets[ nScTab ];
+ aIn.StartNextRecord( nProgressBasePos );
+ }
+ else
+ eAkt = Z_Ende;
+ }
+ else
+ aIn.StartNextRecord();
+
nOpcode = aIn.GetRecId();
if( !aIn.IsValid() )
@@ -124,8 +143,11 @@ FltError ImportExcel::Read( void )
break;
}
+ if( eAkt == Z_Ende )
+ break;
+
if( eAkt != Z_Biff5TPre && eAkt != Z_Biff5WPre )
- pProgress->ProgressAbs( aIn.GetSvStreamPos() );
+ pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
switch( eAkt )
{
@@ -804,9 +826,28 @@ FltError ImportExcel8::Read( void )
::std::auto_ptr< ScfSimpleProgressBar > pProgress( new ScfSimpleProgressBar(
aIn.GetSvStreamSize(), GetDocShell(), STR_LOAD_DOC ) );
+ /* #i104057# Need to track a base position for progress bar calculation,
+ because sheet substreams may not be in order of sheets. */
+ sal_Size nProgressBasePos = 0;
+ sal_Size nProgressBaseSize = 0;
+
while( eAkt != EXC_STATE_END )
{
- aIn.StartNextRecord();
+ if( eAkt == EXC_STATE_BEFORE_SHEET )
+ {
+ sal_uInt16 nScTab = GetCurrScTab();
+ if( nScTab < maSheetOffsets.size() )
+ {
+ nProgressBaseSize += (aIn.GetSvStreamPos() - nProgressBasePos);
+ nProgressBasePos = maSheetOffsets[ nScTab ];
+ aIn.StartNextRecord( nProgressBasePos );
+ }
+ else
+ eAkt = EXC_STATE_END;
+ }
+ else
+ aIn.StartNextRecord();
+
if( !aIn.IsValid() )
{
// #124240# #i63591# finalize table if EOF is missing
@@ -830,7 +871,7 @@ FltError ImportExcel8::Read( void )
break;
if( eAkt != EXC_STATE_SHEET_PRE && eAkt != EXC_STATE_GLOBALS_PRE )
- pProgress->ProgressAbs( aIn.GetSvStreamPos() );
+ pProgress->ProgressAbs( nProgressBaseSize + aIn.GetSvStreamPos() - nProgressBasePos );
sal_uInt16 nRecId = aIn.GetRecId();
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index ef15b16030cf..849ac080bb1d 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -2170,10 +2170,15 @@ void XclExpFmlaCompImpl::PushOperatorPos( sal_uInt16 nTokPos, const XclExpOperan
sal_uInt16 XclExpFmlaCompImpl::PopOperandPos()
{
- DBG_ASSERT( !mxData->maOpPosStack.empty(), "XclExpFmlaCompImpl::PopOperandPos - token stack broken" );
- sal_uInt16 nTokPos = mxData->maOpPosStack.back();
- mxData->maOpPosStack.pop_back();
- return nTokPos;
+ DBG_ASSERT( !mxData->mbOk || !mxData->maOpPosStack.empty(), "XclExpFmlaCompImpl::PopOperandPos - token stack broken" );
+ mxData->mbOk &= !mxData->maOpPosStack.empty();
+ if( mxData->mbOk )
+ {
+ sal_uInt16 nTokPos = mxData->maOpPosStack.back();
+ mxData->maOpPosStack.pop_back();
+ return nTokPos;
+ }
+ return 0;
}
namespace {
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index 4695c2c191cf..69b323e1e718 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -662,6 +662,9 @@ XclExpPivotCache::XclExpPivotCache( const XclExpRoot& rRoot, const ScDPObject& r
if( 2 * (nDocRow2 - nDocRow1) < (nSrcRow2 - nSrcRow1) )
::set_flag( maPCInfo.mnFlags, EXC_SXDB_SAVEDATA, false );
+ // #160184# Excel must refresh tables to make drilldown working
+ ::set_flag( maPCInfo.mnFlags, EXC_SXDB_REFRESH_LOAD );
+
// adjust row indexes, keep one row of empty area to surely have the empty cache item
if( nSrcRow1 < nDocRow1 )
nSrcRow1 = nDocRow1 - 1;
diff --git a/sc/source/filter/excel/xestream.cxx b/sc/source/filter/excel/xestream.cxx
index 45ced68de006..10d23eccdf27 100644
--- a/sc/source/filter/excel/xestream.cxx
+++ b/sc/source/filter/excel/xestream.cxx
@@ -985,11 +985,6 @@ bool XclExpXmlStream::importDocument() throw()
return false;
}
-sal_Int32 XclExpXmlStream::getSchemeClr( sal_Int32 /*nColorSchemeToken*/ ) const
-{
- return -1;
-}
-
oox::vml::Drawing* XclExpXmlStream::getVmlDrawing()
{
return 0;
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 2d920b0a0bd4..dc542a1c1eeb 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -2159,7 +2159,9 @@ void XclImpChChart3d::ReadChChart3d( XclImpStream& rStrm )
void XclImpChChart3d::Convert( ScfPropertySet& rPropSet, bool b3dWallChart ) const
{
namespace cssd = ::com::sun::star::drawing;
- DBG_ASSERT( ::get_flag( maData.mnFlags, EXC_CHCHART3D_HASWALLS ) == b3dWallChart, "XclImpChChart3d::Convert - wrong wall flag" );
+
+// #i104057# do not assert this, written by broken external generators
+// DBG_ASSERT( ::get_flag( maData.mnFlags, EXC_CHCHART3D_HASWALLS ) == b3dWallChart, "XclImpChChart3d::Convert - wrong wall flag" );
sal_Int32 nRotationY = 0;
sal_Int32 nRotationX = 0;
diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx
index b57297b344dc..7b5fb222a12b 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -377,14 +377,33 @@ void XclImpHyperlink::ConvertToValidTabName(String& rUrl)
String aNewUrl(sal_Unicode('#')), aTabName;
bool bInQuote = false;
+ bool bQuoteTabName = false;
for (xub_StrLen i = 1; i < n; ++i)
{
c = rUrl.GetChar(i);
if (c == sal_Unicode('\''))
{
+ if (bInQuote && i+1 < n && rUrl.GetChar(i+1) == sal_Unicode('\''))
+ {
+ // Two consecutive single quotes ('') signify a single literal
+ // quite. When this occurs, the whole table name needs to be
+ // quoted.
+ bQuoteTabName = true;
+ aTabName.Append(c);
+ aTabName.Append(c);
+ ++i;
+ continue;
+ }
+
bInQuote = !bInQuote;
if (!bInQuote && aTabName.Len() > 0)
+ {
+ if (bQuoteTabName)
+ aNewUrl.Append(sal_Unicode('\''));
aNewUrl.Append(aTabName);
+ if (bQuoteTabName)
+ aNewUrl.Append(sal_Unicode('\''));
+ }
}
else if (bInQuote)
aTabName.Append(c);
diff --git a/sc/source/filter/excel/xilink.cxx b/sc/source/filter/excel/xilink.cxx
index 9033ecc125bd..00268215a5dc 100644
--- a/sc/source/filter/excel/xilink.cxx
+++ b/sc/source/filter/excel/xilink.cxx
@@ -153,6 +153,7 @@ struct XclImpXti
sal_uInt16 mnSupbook; /// Index to SUPBOOK record.
sal_uInt16 mnSBTabFirst; /// Index to the first sheet of the range in the SUPBOOK.
sal_uInt16 mnSBTabLast; /// Index to the last sheet of the range in the SUPBOOK.
+ inline explicit XclImpXti() : mnSupbook( SAL_MAX_UINT16 ), mnSBTabFirst( SAL_MAX_UINT16 ), mnSBTabLast( SAL_MAX_UINT16 ) {}
};
inline XclImpStream& operator>>( XclImpStream& rStrm, XclImpXti& rXti )
@@ -204,8 +205,10 @@ public:
const String& GetMacroName( sal_uInt16 nExtSheet, sal_uInt16 nExtName ) const;
private:
+ /** Returns the specified XTI (link entry from BIFF8 EXTERNSHEET record). */
+ const XclImpXti* GetXti( sal_uInt16 nXtiIndex ) const;
/** Returns the specified SUPBOOK (external document). */
- const XclImpSupbook* GetSupbook( sal_uInt32 nXtiIndex ) const;
+ const XclImpSupbook* GetSupbook( sal_uInt16 nXtiIndex ) const;
//UNUSED2009-05 /** Returns the SUPBOOK (external workbook) specified by its URL. */
//UNUSED2009-05 const XclImpSupbook* GetSupbook( const String& rUrl ) const;
@@ -222,10 +225,10 @@ private:
//UNUSED2009-05 sal_uInt16 nSupbook, sal_uInt16 nSBTabStart ) const;
private:
- typedef ScfDelList< XclImpXti > XclImpXtiList;
+ typedef ::std::vector< XclImpXti > XclImpXtiVector;
typedef ScfDelList< XclImpSupbook > XclImpSupbookList;
- XclImpXtiList maXtiList; /// List of all XTI structures.
+ XclImpXtiVector maXtiList; /// List of all XTI structures.
XclImpSupbookList maSupbookList; /// List of external documents.
bool mbCreated; /// true = Calc sheets already created.
};
@@ -582,15 +585,17 @@ void XclImpLinkManagerImpl::ReadExternsheet( XclImpStream& rStrm )
{
sal_uInt16 nXtiCount;
rStrm >> nXtiCount;
-
- XclImpXti* pXti;
- while( nXtiCount )
- {
- pXti = new XclImpXti;
- rStrm >> *pXti;
- maXtiList.Append( pXti );
- --nXtiCount;
- }
+ DBG_ASSERT( static_cast< sal_Size >( nXtiCount * 6 ) == rStrm.GetRecLeft(), "XclImpLinkManagerImpl::ReadExternsheet - invalid count" );
+ nXtiCount = static_cast< sal_uInt16 >( ::std::min< sal_Size >( nXtiCount, rStrm.GetRecLeft() / 6 ) );
+
+ /* #i104057# A weird external XLS generator writes multiple EXTERNSHEET
+ records instead of only one as expected. Surprisingly, Excel seems to
+ insert the entries of the second record before the entries of the first
+ record. */
+ XclImpXtiVector aNewEntries( nXtiCount );
+ for( XclImpXtiVector::iterator aIt = aNewEntries.begin(), aEnd = aNewEntries.end(); rStrm.IsValid() && (aIt != aEnd); ++aIt )
+ rStrm >> *aIt;
+ maXtiList.insert( maXtiList.begin(), aNewEntries.begin(), aNewEntries.end() );
LoadCachedValues();
}
@@ -627,7 +632,7 @@ bool XclImpLinkManagerImpl::IsSelfRef( sal_uInt16 nXtiIndex ) const
bool XclImpLinkManagerImpl::GetScTabRange(
SCTAB& rnFirstScTab, SCTAB& rnLastScTab, sal_uInt16 nXtiIndex ) const
{
- if( const XclImpXti* pXti = maXtiList.GetObject( nXtiIndex ) )
+ if( const XclImpXti* pXti = GetXti( nXtiIndex ) )
{
if (maSupbookList.GetObject(pXti->mnSupbook))
{
@@ -671,9 +676,14 @@ const String& XclImpLinkManagerImpl::GetMacroName( sal_uInt16 nExtSheet, sal_uIn
return pSupbook ? pSupbook->GetMacroName( nExtName ) : EMPTY_STRING;
}
-const XclImpSupbook* XclImpLinkManagerImpl::GetSupbook( sal_uInt32 nXtiIndex ) const
+const XclImpXti* XclImpLinkManagerImpl::GetXti( sal_uInt16 nXtiIndex ) const
+{
+ return (nXtiIndex < maXtiList.size()) ? &maXtiList[ nXtiIndex ] : 0;
+}
+
+const XclImpSupbook* XclImpLinkManagerImpl::GetSupbook( sal_uInt16 nXtiIndex ) const
{
- const XclImpXti* pXti = maXtiList.GetObject( nXtiIndex );
+ const XclImpXti* pXti = GetXti( nXtiIndex );
return pXti ? maSupbookList.GetObject( pXti->mnSupbook ) : 0;
}
diff --git a/sc/source/filter/excel/xistream.cxx b/sc/source/filter/excel/xistream.cxx
index b168c4389c4c..a040f21b1c4f 100644
--- a/sc/source/filter/excel/xistream.cxx
+++ b/sc/source/filter/excel/xistream.cxx
@@ -414,6 +414,12 @@ bool XclImpStream::StartNextRecord()
return mbValidRec;
}
+bool XclImpStream::StartNextRecord( sal_Size nNextRecPos )
+{
+ mnNextRecPos = nNextRecPos;
+ return StartNextRecord();
+}
+
void XclImpStream::ResetRecord( bool bContLookup, sal_uInt16 nAltContId )
{
if( mbValidRec )
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index 7f1627e89e7f..07368f6db680 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -968,9 +968,7 @@ XclImpXF::XclImpXF( const XclImpRoot& rRoot ) :
XclImpRoot( rRoot ),
mpStyleSheet( 0 ),
mnXclNumFmt( 0 ),
- mnXclFont( 0 ),
- mbWasBuiltIn( false ),
- mbForceCreate( false )
+ mnXclFont( 0 )
{
}
@@ -1088,32 +1086,61 @@ void XclImpXF::ReadXF( XclImpStream& rStrm )
}
}
-void XclImpXF::SetStyleName( const String& rStyleName )
+const ScPatternAttr& XclImpXF::CreatePattern( bool bSkipPoolDefs )
{
- DBG_ASSERT( IsStyleXF(), "XclImpXF::SetStyleName - not a style XF" );
- DBG_ASSERT( rStyleName.Len(), "XclImpXF::SetStyleName - style name empty" );
- if( IsStyleXF() && !maStyleName.Len() )
+ if( mpPattern.get() )
+ return *mpPattern;
+
+ // create new pattern attribute set
+ mpPattern.reset( new ScPatternAttr( GetDoc().GetPool() ) );
+ SfxItemSet& rItemSet = mpPattern->GetItemSet();
+
+ // parent cell style
+ if( IsCellXF() && !mpStyleSheet )
{
- maStyleName = rStyleName;
- mbForceCreate = true;
+ mpStyleSheet = GetXFBuffer().CreateStyleSheet( mnParent );
+ if( XclImpXF* pParentXF = GetXFBuffer().GetXF( mnParent ) )
+ UpdateUsedFlags( *pParentXF );
}
-}
-void XclImpXF::SetBuiltInStyleName( sal_uInt8 nStyleId, sal_uInt8 nLevel )
-{
- DBG_ASSERT( IsStyleXF(), "XclImpXF::SetStyleName - not a style XF" );
- if( IsStyleXF() && !maStyleName.Len() )
+ // cell protection
+ if( mbProtUsed )
+ maProtection.FillToItemSet( rItemSet, bSkipPoolDefs );
+
+ // font
+ if( mbFontUsed )
+ GetFontBuffer().FillToItemSet( rItemSet, EXC_FONTITEM_CELL, mnXclFont, bSkipPoolDefs );
+
+ // value format
+ if( mbFmtUsed )
{
- mbWasBuiltIn = true;
- maStyleName = XclTools::GetBuiltInStyleName( nStyleId, nLevel );
- mbForceCreate = nStyleId == EXC_STYLE_NORMAL; // force creation of "Default" style
+ GetNumFmtBuffer().FillToItemSet( rItemSet, mnXclNumFmt, bSkipPoolDefs );
+ // Trace occurrences of Windows date formats
+ GetTracer().TraceDates( mnXclNumFmt );
}
-}
-void XclImpXF::CreateUserStyle()
-{
- if( IsStyleXF() && mbForceCreate )
- CreateStyleSheet();
+ // alignment
+ if( mbAlignUsed )
+ maAlignment.FillToItemSet( rItemSet, GetFontBuffer().GetFont( mnXclFont ), bSkipPoolDefs );
+
+ // border
+ if( mbBorderUsed )
+ {
+ maBorder.FillToItemSet( rItemSet, GetPalette(), bSkipPoolDefs );
+ GetTracer().TraceBorderLineStyle(maBorder.mnLeftLine > EXC_LINE_HAIR ||
+ maBorder.mnRightLine > EXC_LINE_HAIR || maBorder.mnTopLine > EXC_LINE_HAIR ||
+ maBorder.mnBottomLine > EXC_LINE_HAIR );
+ }
+
+ // area
+ if( mbAreaUsed )
+ {
+ maArea.FillToItemSet( rItemSet, GetPalette(), bSkipPoolDefs );
+ GetTracer().TraceFillPattern(maArea.mnPattern != EXC_PATT_NONE &&
+ maArea.mnPattern != EXC_PATT_SOLID);
+ }
+
+ return *mpPattern;
}
void XclImpXF::ApplyPattern(
@@ -1176,94 +1203,100 @@ void XclImpXF::UpdateUsedFlags( const XclImpXF& rParentXF )
mbAreaUsed = !rParentXF.mbAreaUsed || !(maArea == rParentXF.maArea);
}
-const ScPatternAttr& XclImpXF::CreatePattern( bool bSkipPoolDefs )
-{
- if( mpPattern.get() )
- return *mpPattern;
-
- // create new pattern attribute set
- mpPattern.reset( new ScPatternAttr( GetDoc().GetPool() ) );
- SfxItemSet& rItemSet = mpPattern->GetItemSet();
-
- // parent cell style
- if( IsCellXF() )
- {
- if( XclImpXF* pParentXF = GetXFBuffer().GetXF( mnParent ) )
- {
- mpStyleSheet = pParentXF->CreateStyleSheet();
- UpdateUsedFlags( *pParentXF );
- }
- }
-
- // cell protection
- if( mbProtUsed )
- maProtection.FillToItemSet( rItemSet, bSkipPoolDefs );
+// ----------------------------------------------------------------------------
- // font
- if( mbFontUsed )
- GetFontBuffer().FillToItemSet( rItemSet, EXC_FONTITEM_CELL, mnXclFont, bSkipPoolDefs );
+XclImpStyle::XclImpStyle( const XclImpRoot& rRoot ) :
+ XclImpRoot( rRoot ),
+ mnXfId( EXC_XF_NOTFOUND ),
+ mnBuiltinId( EXC_STYLE_USERDEF ),
+ mnLevel( EXC_STYLE_NOLEVEL ),
+ mbBuiltin( false ),
+ mbCustom( false ),
+ mbHidden( false ),
+ mpStyleSheet( 0 )
+{
+}
- // value format
- if( mbFmtUsed )
- {
- GetNumFmtBuffer().FillToItemSet( rItemSet, mnXclNumFmt, bSkipPoolDefs );
- // Trace occurrences of Windows date formats
- GetTracer().TraceDates( mnXclNumFmt );
- }
+void XclImpStyle::ReadStyle( XclImpStream& rStrm )
+{
+ DBG_ASSERT_BIFF( GetBiff() >= EXC_BIFF3 );
- // alignment
- if( mbAlignUsed )
- maAlignment.FillToItemSet( rItemSet, GetFontBuffer().GetFont( mnXclFont ), bSkipPoolDefs );
+ sal_uInt16 nXFIndex;
+ rStrm >> nXFIndex;
+ mnXfId = nXFIndex & EXC_STYLE_XFMASK;
+ mbBuiltin = ::get_flag( nXFIndex, EXC_STYLE_BUILTIN );
- // border
- if( mbBorderUsed )
+ if( mbBuiltin )
{
- maBorder.FillToItemSet( rItemSet, GetPalette(), bSkipPoolDefs );
- GetTracer().TraceBorderLineStyle(maBorder.mnLeftLine > EXC_LINE_HAIR ||
- maBorder.mnRightLine > EXC_LINE_HAIR || maBorder.mnTopLine > EXC_LINE_HAIR ||
- maBorder.mnBottomLine > EXC_LINE_HAIR );
+ rStrm >> mnBuiltinId >> mnLevel;
}
-
- // area
- if( mbAreaUsed )
+ else
{
- maArea.FillToItemSet( rItemSet, GetPalette(), bSkipPoolDefs );
- GetTracer().TraceFillPattern(maArea.mnPattern != EXC_PATT_NONE &&
- maArea.mnPattern != EXC_PATT_SOLID);
+ maName = (GetBiff() <= EXC_BIFF5) ? rStrm.ReadByteString( false ) : rStrm.ReadUniString();
+ // #i103281# check if this is a new built-in style introduced in XL2007
+ if( (GetBiff() == EXC_BIFF8) && (rStrm.GetNextRecId() == EXC_ID_STYLEEXT) && rStrm.StartNextRecord() )
+ {
+ sal_uInt8 nExtFlags;
+ rStrm.Ignore( 12 );
+ rStrm >> nExtFlags;
+ mbBuiltin = ::get_flag( nExtFlags, EXC_STYLEEXT_BUILTIN );
+ mbCustom = ::get_flag( nExtFlags, EXC_STYLEEXT_CUSTOM );
+ mbHidden = ::get_flag( nExtFlags, EXC_STYLEEXT_HIDDEN );
+ if( mbBuiltin )
+ {
+ rStrm.Ignore( 1 ); // category
+ rStrm >> mnBuiltinId >> mnLevel;
+ }
+ }
}
-
- return *mpPattern;
}
-ScStyleSheet* XclImpXF::CreateStyleSheet()
+ScStyleSheet* XclImpStyle::CreateStyleSheet()
{
- if( !mpStyleSheet && maStyleName.Len() ) // valid name implies style XF
+ // #i1624# #i1768# ignore unnamed user styles
+ if( !mpStyleSheet && (maFinalName.Len() > 0) )
{
- // there may be a user-defined "Default" - test on built-in too!
- bool bDefStyle = mbWasBuiltIn && (maStyleName == ScGlobal::GetRscString( STR_STYLENAME_STANDARD ));
+ bool bCreatePattern = false;
+ XclImpXF* pXF = GetXFBuffer().GetXF( mnXfId );
+
+ bool bDefStyle = mbBuiltin && (mnBuiltinId == EXC_STYLE_NORMAL);
if( bDefStyle )
{
- // set all flags to true to get all items in CreatePattern()
- SetAllUsedFlags( true );
+ // set all flags to true to get all items in XclImpXF::CreatePattern()
+ if( pXF ) pXF->SetAllUsedFlags( true );
// use existing "Default" style sheet
mpStyleSheet = static_cast< ScStyleSheet* >( GetStyleSheetPool().Find(
ScGlobal::GetRscString( STR_STYLENAME_STANDARD ), SFX_STYLE_FAMILY_PARA ) );
- DBG_ASSERT( mpStyleSheet, "XclImpXF::CreateStyleSheet - Default style not found" );
+ DBG_ASSERT( mpStyleSheet, "XclImpStyle::CreateStyleSheet - Default style not found" );
+ bCreatePattern = true;
}
else
{
- /* mbWasBuiltIn==true forces renaming of equal-named user defined styles
- to be able to re-export built-in styles correctly. */
- mpStyleSheet = &ScfTools::MakeCellStyleSheet( GetStyleSheetPool(), maStyleName, mbWasBuiltIn );
+ /* #i103281# do not create another style sheet of the same name,
+ if it exists already. This is needed to prevent that styles
+ pasted from clipboard get duplicated over and over. */
+ mpStyleSheet = static_cast< ScStyleSheet* >( GetStyleSheetPool().Find( maFinalName, SFX_STYLE_FAMILY_PARA ) );
+ if( !mpStyleSheet )
+ {
+ mpStyleSheet = &static_cast< ScStyleSheet& >( GetStyleSheetPool().Make( maFinalName, SFX_STYLE_FAMILY_PARA, SFXSTYLEBIT_USERDEF ) );
+ bCreatePattern = true;
+ }
}
// bDefStyle==true omits default pool items in CreatePattern()
- if( mpStyleSheet )
- mpStyleSheet->GetItemSet().Put( CreatePattern( bDefStyle ).GetItemSet() );
+ if( bCreatePattern && mpStyleSheet && pXF )
+ mpStyleSheet->GetItemSet().Put( pXF->CreatePattern( bDefStyle ).GetItemSet() );
}
return mpStyleSheet;
}
+void XclImpStyle::CreateUserStyle( const String& rFinalName )
+{
+ maFinalName = rFinalName;
+ if( !IsBuiltin() || mbCustom )
+ CreateStyleSheet();
+}
+
// ----------------------------------------------------------------------------
XclImpXFBuffer::XclImpXFBuffer( const XclImpRoot& rRoot ) :
@@ -1274,6 +1307,9 @@ XclImpXFBuffer::XclImpXFBuffer( const XclImpRoot& rRoot ) :
void XclImpXFBuffer::Initialize()
{
maXFList.Clear();
+ maBuiltinStyles.Clear();
+ maUserStyles.Clear();
+ maStylesByXf.clear();
}
void XclImpXFBuffer::ReadXF( XclImpStream& rStrm )
@@ -1281,39 +1317,15 @@ void XclImpXFBuffer::ReadXF( XclImpStream& rStrm )
XclImpXF* pXF = new XclImpXF( GetRoot() );
pXF->ReadXF( rStrm );
maXFList.Append( pXF );
-
- if( (GetBiff() >= EXC_BIFF3) && (maXFList.Count() == 1) )
- // set the name of the "Default" cell style (always the first XF in an Excel file)
- pXF->SetBuiltInStyleName( EXC_STYLE_NORMAL, 0 );
}
void XclImpXFBuffer::ReadStyle( XclImpStream& rStrm )
{
- DBG_ASSERT_BIFF( GetBiff() >= EXC_BIFF3 );
-
- sal_uInt16 nXFIndex;
- rStrm >> nXFIndex;
-
- XclImpXF* pXF = GetXF( nXFIndex & EXC_STYLE_XFMASK ); // bits 0...11 are used for XF index
- if( pXF && pXF->IsStyleXF() )
- {
- if( ::get_flag( nXFIndex, EXC_STYLE_BUILTIN ) ) // built-in styles
- {
- sal_uInt8 nStyleId, nLevel;
- rStrm >> nStyleId >> nLevel;
- pXF->SetBuiltInStyleName( nStyleId, nLevel );
- }
- else // user-defined styles
- {
- String aStyleName;
- if( GetBiff() <= EXC_BIFF5 )
- aStyleName = rStrm.ReadByteString( false ); // 8 bit length
- else
- aStyleName = rStrm.ReadUniString();
- if( aStyleName.Len() ) // #i1624# #i1768# ignore unnamed styles
- pXF->SetStyleName( aStyleName );
- }
- }
+ XclImpStyle* pStyle = new XclImpStyle( GetRoot() );
+ pStyle->ReadStyle( rStrm );
+ (pStyle->IsBuiltin() ? maBuiltinStyles : maUserStyles).Append( pStyle );
+ DBG_ASSERT( maStylesByXf.count( pStyle->GetXfId() ) == 0, "XclImpXFBuffer::ReadStyle - multiple styles with equal XF identifier" );
+ maStylesByXf[ pStyle->GetXfId() ] = pStyle;
}
sal_uInt16 XclImpXFBuffer::GetFontIndex( sal_uInt16 nXFIndex ) const
@@ -1327,10 +1339,93 @@ const XclImpFont* XclImpXFBuffer::GetFont( sal_uInt16 nXFIndex ) const
return GetFontBuffer().GetFont( GetFontIndex( nXFIndex ) );
}
+namespace {
+
+/** Functor for case-insensitive string comparison, usable in maps etc. */
+struct IgnoreCaseCompare
+{
+ inline bool operator()( const String& rName1, const String& rName2 ) const
+ { return rName1.CompareIgnoreCaseToAscii( rName2 ) == COMPARE_LESS; }
+};
+
+} // namespace
+
void XclImpXFBuffer::CreateUserStyles()
{
- for( XclImpXF* pXF = maXFList.First(); pXF; pXF = maXFList.Next() )
- pXF->CreateUserStyle();
+ // calculate final names of all styles
+ typedef ::std::map< String, XclImpStyle*, IgnoreCaseCompare > CellStyleNameMap;
+ typedef ::std::vector< XclImpStyle* > XclImpStyleVector;
+
+ CellStyleNameMap aCellStyles;
+ XclImpStyleVector aConflictNameStyles;
+
+ /* First, reserve style names that are built-in in Calc. This causes that
+ imported cell styles get different unused names and thus do not try to
+ overwrite these built-in styles. For BIFF4 workbooks (which contain a
+ separate list of cell styles per sheet), reserve all existing styles if
+ current sheet is not the first sheet (this styles buffer will be
+ initialized again for every new sheet). This will create unique names
+ for styles in different sheets with the same name. Assuming that the
+ BIFF4W import filter is never used to import from clipboard... */
+ bool bReserveAll = (GetBiff() == EXC_BIFF4) && (GetCurrScTab() > 0);
+ SfxStyleSheetIterator aStyleIter( GetDoc().GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
+ String aStandardName = ScGlobal::GetRscString( STR_STYLENAME_STANDARD );
+ for( SfxStyleSheetBase* pStyleSheet = aStyleIter.First(); pStyleSheet; pStyleSheet = aStyleIter.Next() )
+ if( (pStyleSheet->GetName() != aStandardName) && (bReserveAll || !pStyleSheet->IsUserDefined()) )
+ if( aCellStyles.count( pStyleSheet->GetName() ) == 0 )
+ aCellStyles[ pStyleSheet->GetName() ] = 0;
+
+ /* Calculate names of built-in styles. Store styles with reserved names
+ in the aConflictNameStyles list. */
+ for( XclImpStyle* pStyle = maBuiltinStyles.First(); pStyle; pStyle = maBuiltinStyles.Next() )
+ {
+ String aStyleName = XclTools::GetBuiltInStyleName( pStyle->GetBuiltinId(), pStyle->GetName(), pStyle->GetLevel() );
+ DBG_ASSERT( bReserveAll || (aCellStyles.count( aStyleName ) == 0),
+ "XclImpXFBuffer::CreateUserStyles - multiple styles with equal built-in identifier" );
+ if( aCellStyles.count( aStyleName ) > 0 )
+ aConflictNameStyles.push_back( pStyle );
+ else
+ aCellStyles[ aStyleName ] = pStyle;
+ }
+
+ /* Calculate names of user defined styles. Store styles with reserved
+ names in the aConflictNameStyles list. */
+ for( XclImpStyle* pStyle = maUserStyles.First(); pStyle; pStyle = maUserStyles.Next() )
+ {
+ // #i1624# #i1768# ignore unnamed user styles
+ if( pStyle->GetName().Len() > 0 )
+ {
+ if( aCellStyles.count( pStyle->GetName() ) > 0 )
+ aConflictNameStyles.push_back( pStyle );
+ else
+ aCellStyles[ pStyle->GetName() ] = pStyle;
+ }
+ }
+
+ // find unused names for all styles with conflicting names
+ for( XclImpStyleVector::iterator aIt = aConflictNameStyles.begin(), aEnd = aConflictNameStyles.end(); aIt != aEnd; ++aIt )
+ {
+ XclImpStyle* pStyle = *aIt;
+ String aUnusedName;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ aUnusedName.Assign( pStyle->GetName() ).Append( ' ' ).Append( String::CreateFromInt32( ++nIndex ) );
+ }
+ while( aCellStyles.count( aUnusedName ) > 0 );
+ aCellStyles[ aUnusedName ] = pStyle;
+ }
+
+ // set final names and create user-defined and modified built-in cell styles
+ for( CellStyleNameMap::iterator aIt = aCellStyles.begin(), aEnd = aCellStyles.end(); aIt != aEnd; ++aIt )
+ if( aIt->second )
+ aIt->second->CreateUserStyle( aIt->first );
+}
+
+ScStyleSheet* XclImpXFBuffer::CreateStyleSheet( sal_uInt16 nXFIndex )
+{
+ XclImpStyleMap::iterator aIt = maStylesByXf.find( nXFIndex );
+ return (aIt == maStylesByXf.end()) ? 0 : aIt->second->CreateStyleSheet();
}
void XclImpXFBuffer::ApplyPattern(
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index 5e6c85b49077..b8c18eb3e7c0 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -30,18 +30,13 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sc.hxx"
-
-// XXX xestream.hxx MUST be included before xlformula.hxx because of the
-// redifinition of the CREATE_OUSTRING() macro, which is in oox/helper.hxx
-// (indirectly included via xestream.hxx) and ../inc/ftools.hxx (indirectly
-// included via xlformula.hxx) that does an undef first. Ugly.
-#include "xestream.hxx"
#include "xlformula.hxx"
#include "compiler.hxx"
#include "rangenam.hxx"
#include "token.hxx"
#include "tokenarray.hxx"
+#include "xestream.hxx"
#include "xistream.hxx"
#include "xlroot.hxx"
diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx
index 29522f4f50ff..0b6af9da2e63 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -35,6 +35,7 @@
#include <vcl/svapp.hxx>
#include <svtools/stritem.hxx>
#include <svtools/languageoptions.hxx>
+#include <svtools/useroptions.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/printer.hxx>
#include <sfx2/docfile.hxx>
@@ -95,6 +96,11 @@ XclRootData::XclRootData( XclBiff eBiff, SfxMedium& rMedium,
mnScTab( 0 ),
mbExport( bExport )
{
+ // user name
+ maUserName = SvtUserOptions().GetLastName();
+ if( maUserName.Len() == 0 )
+ maUserName = CREATE_STRING( "Calc" );
+
// default script type, e.g. for empty cells
switch( ScGlobal::GetDefaultScriptType() )
{
diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx
index ef38a0037ca0..6398e25b9be7 100644
--- a/sc/source/filter/excel/xltools.cxx
+++ b/sc/source/filter/excel/xltools.cxx
@@ -426,16 +426,19 @@ rtl_TextEncoding XclTools::GetTextEncoding( sal_uInt16 nCodePage )
return pEntry->meTextEnc;
}
-//UNUSED2008-05 sal_uInt16 XclTools::GetXclCodePage( rtl_TextEncoding eTextEnc )
-//UNUSED2008-05 {
-//UNUSED2008-05 const XclCodePageEntry* pEntry = ::std::find_if( pCodePageTable, pCodePageTableEnd, XclCodePageEntry_TEPred( eTextEnc ) );
-//UNUSED2008-05 if( pEntry == pCodePageTableEnd )
-//UNUSED2008-05 {
-//UNUSED2008-05 DBG_ERROR1( "XclTools::GetXclCodePage - unsupported text encoding: %d", eTextEnc );
-//UNUSED2008-05 return 1252;
-//UNUSED2008-05 }
-//UNUSED2008-05 return pEntry->mnCodePage;
-//UNUSED2008-05 }
+sal_uInt16 XclTools::GetXclCodePage( rtl_TextEncoding eTextEnc )
+{
+ if( eTextEnc == RTL_TEXTENCODING_UNICODE )
+ return 1200; // for BIFF8
+
+ const XclCodePageEntry* pEntry = ::std::find_if( pCodePageTable, pCodePageTableEnd, XclCodePageEntry_TEPred( eTextEnc ) );
+ if( pEntry == pCodePageTableEnd )
+ {
+ DBG_ERROR1( "XclTools::GetXclCodePage - unsupported text encoding: %d", eTextEnc );
+ return 1252;
+ }
+ return pEntry->mnCodePage;
+}
// font names -----------------------------------------------------------------
@@ -511,7 +514,8 @@ sal_Unicode XclTools::GetBuiltInDefNameIndex( const String& rDefName )
// built-in style names -------------------------------------------------------
-const String XclTools::maStyleNamePrefix( RTL_CONSTASCII_USTRINGPARAM( "Excel_BuiltIn_" ) );
+const String XclTools::maStyleNamePrefix1( RTL_CONSTASCII_USTRINGPARAM( "Excel_BuiltIn_" ) );
+const String XclTools::maStyleNamePrefix2( RTL_CONSTASCII_USTRINGPARAM( "Excel Built-in " ) );
static const sal_Char* const ppcStyleNames[] =
{
@@ -527,21 +531,35 @@ static const sal_Char* const ppcStyleNames[] =
"Followed_Hyperlink"
};
-String XclTools::GetBuiltInStyleName( sal_uInt8 nStyleId, sal_uInt8 nLevel )
+String XclTools::GetBuiltInStyleName( sal_uInt8 nStyleId, const String& rName, sal_uInt8 nLevel )
{
String aStyleName;
if( nStyleId == EXC_STYLE_NORMAL ) // "Normal" becomes "Default" style
+ {
aStyleName = ScGlobal::GetRscString( STR_STYLENAME_STANDARD );
- else if( nStyleId < STATIC_TABLE_SIZE( ppcStyleNames ) )
- aStyleName.Assign( maStyleNamePrefix ).AppendAscii( ppcStyleNames[ nStyleId ] );
-
- if( (nStyleId == EXC_STYLE_ROWLEVEL) || (nStyleId == EXC_STYLE_COLLEVEL) )
- aStyleName.Append( String::CreateFromInt32( nLevel + 1 ) );
+ }
+ else
+ {
+ aStyleName = maStyleNamePrefix1;
+ if( nStyleId < STATIC_TABLE_SIZE( ppcStyleNames ) )
+ aStyleName.AppendAscii( ppcStyleNames[ nStyleId ] );
+ else if( rName.Len() > 0 )
+ aStyleName.Append( rName );
+ else
+ aStyleName.Append( String::CreateFromInt32( nStyleId ) );
+ if( (nStyleId == EXC_STYLE_ROWLEVEL) || (nStyleId == EXC_STYLE_COLLEVEL) )
+ aStyleName.Append( String::CreateFromInt32( nLevel + 1 ) );
+ }
return aStyleName;
}
+String XclTools::GetBuiltInStyleName( const String& rStyleName )
+{
+ return String( maStyleNamePrefix1 ).Append( rStyleName );
+}
+
bool XclTools::IsBuiltInStyleName( const String& rStyleName, sal_uInt8* pnStyleId, xub_StrLen* pnNextChar )
{
// "Default" becomes "Normal"
@@ -553,10 +571,15 @@ bool XclTools::IsBuiltInStyleName( const String& rStyleName, sal_uInt8* pnStyleI
}
// try the other built-in styles
- xub_StrLen nPrefixLen = maStyleNamePrefix.Len();
sal_uInt8 nFoundId = 0;
xub_StrLen nNextChar = 0;
- if( rStyleName.EqualsIgnoreCaseAscii( maStyleNamePrefix, 0, nPrefixLen ) )
+
+ xub_StrLen nPrefixLen = 0;
+ if( rStyleName.EqualsIgnoreCaseAscii( maStyleNamePrefix1, 0, maStyleNamePrefix1.Len() ) )
+ nPrefixLen = maStyleNamePrefix1.Len();
+ else if( rStyleName.EqualsIgnoreCaseAscii( maStyleNamePrefix2, 0, maStyleNamePrefix2.Len() ) )
+ nPrefixLen = maStyleNamePrefix2.Len();
+ if( nPrefixLen > 0 )
{
String aShortName;
for( sal_uInt8 nId = 0; nId < STATIC_TABLE_SIZE( ppcStyleNames ); ++nId )
@@ -583,14 +606,14 @@ bool XclTools::IsBuiltInStyleName( const String& rStyleName, sal_uInt8* pnStyleI
if( pnStyleId ) *pnStyleId = EXC_STYLE_USERDEF;
if( pnNextChar ) *pnNextChar = 0;
- return false;
+ return nPrefixLen > 0; // also return true for unknown built-in styles
}
bool XclTools::GetBuiltInStyleId( sal_uInt8& rnStyleId, sal_uInt8& rnLevel, const String& rStyleName )
{
sal_uInt8 nStyleId;
xub_StrLen nNextChar;
- if( IsBuiltInStyleName( rStyleName, &nStyleId, &nNextChar ) )
+ if( IsBuiltInStyleName( rStyleName, &nStyleId, &nNextChar ) && (nStyleId != EXC_STYLE_USERDEF) )
{
if( (nStyleId == EXC_STYLE_ROWLEVEL) || (nStyleId == EXC_STYLE_COLLEVEL) )
{
@@ -617,24 +640,25 @@ bool XclTools::GetBuiltInStyleId( sal_uInt8& rnStyleId, sal_uInt8& rnLevel, cons
// conditional formatting style names -----------------------------------------
-const String XclTools::maCFStyleNamePrefix( RTL_CONSTASCII_USTRINGPARAM( "Excel_CondFormat_" ) );
+const String XclTools::maCFStyleNamePrefix1( RTL_CONSTASCII_USTRINGPARAM( "Excel_CondFormat_" ) );
+const String XclTools::maCFStyleNamePrefix2( RTL_CONSTASCII_USTRINGPARAM( "ConditionalStyle_" ) );
String XclTools::GetCondFormatStyleName( SCTAB nScTab, sal_Int32 nFormat, sal_uInt16 nCondition )
{
- return String( maCFStyleNamePrefix ).Append( String::CreateFromInt32( nScTab + 1 ) ).
+ return String( maCFStyleNamePrefix1 ).Append( String::CreateFromInt32( nScTab + 1 ) ).
Append( '_' ).Append( String::CreateFromInt32( nFormat + 1 ) ).
Append( '_' ).Append( String::CreateFromInt32( nCondition + 1 ) );
}
bool XclTools::IsCondFormatStyleName( const String& rStyleName, xub_StrLen* pnNextChar )
{
- xub_StrLen nPrefixLen = maCFStyleNamePrefix.Len();
- if( rStyleName.EqualsIgnoreCaseAscii( maCFStyleNamePrefix, 0, nPrefixLen ) )
- {
- if( pnNextChar ) *pnNextChar = nPrefixLen;
- return true;
- }
- return false;
+ xub_StrLen nPrefixLen = 0;
+ if( rStyleName.EqualsIgnoreCaseAscii( maCFStyleNamePrefix1, 0, maCFStyleNamePrefix1.Len() ) )
+ nPrefixLen = maCFStyleNamePrefix1.Len();
+ else if( rStyleName.EqualsIgnoreCaseAscii( maCFStyleNamePrefix2, 0, maCFStyleNamePrefix2.Len() ) )
+ nPrefixLen = maCFStyleNamePrefix2.Len();
+ if( pnNextChar ) *pnNextChar = nPrefixLen;
+ return nPrefixLen > 0;
}
// stream handling ------------------------------------------------------------
diff --git a/sc/source/filter/ftools/ftools.cxx b/sc/source/filter/ftools/ftools.cxx
index 98faeb9f03d4..2271a8f35d4d 100644
--- a/sc/source/filter/ftools/ftools.cxx
+++ b/sc/source/filter/ftools/ftools.cxx
@@ -160,13 +160,15 @@ Color ScfTools::GetMixedColor( const Color& rFore, const Color& rBack, sal_uInt8
// *** conversion of names *** ------------------------------------------------
+/* XXX As in sc/source/core/tool/rangenam.cxx ScRangeData::IsValidName() */
+
void ScfTools::ConvertToScDefinedName( String& rName )
{
xub_StrLen nLen = rName.Len();
- if( nLen && !ScCompiler::IsCharWordChar( rName, 0 ) )
+ if( nLen && !ScCompiler::IsCharFlagAllConventions( rName, 0, SC_COMPILER_C_CHAR_NAME ) )
rName.SetChar( 0, '_' );
for( xub_StrLen nPos = 1; nPos < nLen; ++nPos )
- if( !ScCompiler::IsWordChar( rName, nPos ) )
+ if( !ScCompiler::IsCharFlagAllConventions( rName, nPos, SC_COMPILER_C_NAME ) )
rName.SetChar( nPos, '_' );
}
diff --git a/sc/source/filter/inc/excrecds.hxx b/sc/source/filter/inc/excrecds.hxx
index 568032aa317f..79607802ccdc 100644
--- a/sc/source/filter/inc/excrecds.hxx
+++ b/sc/source/filter/inc/excrecds.hxx
@@ -210,18 +210,6 @@ public:
};
-//----------------------------------------------------- class ExcFngroupcount -
-
-class ExcFngroupcount : public ExcRecord
-{
-private:
- virtual void SaveCont( XclExpStream& rStrm );
-public:
- virtual UINT16 GetNum( void ) const;
- virtual sal_Size GetLen( void ) const;
-};
-
-
//--------------------------------------------------------- class ExcDummy_00 -
// INTERFACEHDR to FNGROUPCOUNT (see excrecds.cxx)
diff --git a/sc/source/filter/inc/ftools.hxx b/sc/source/filter/inc/ftools.hxx
index 393775e721f7..5fd338a73bb5 100644
--- a/sc/source/filter/inc/ftools.hxx
+++ b/sc/source/filter/inc/ftools.hxx
@@ -38,6 +38,7 @@
#include <tools/string.hxx>
#include <tools/list.hxx>
#include <tools/debug.hxx>
+#include <oox/helper/helper.hxx>
#include "filter.hxx"
#include "scdllapi.h"
@@ -50,9 +51,6 @@
/** Expands to a temporary String, created from an ASCII character array. */
#define CREATE_STRING( ascii ) String( RTL_CONSTASCII_USTRINGPARAM( ascii ) )
-/** Expands to a temporary ::rtl::OUString, created from an ASCII character array. */
-#undef CREATE_OUSTRING
-#define CREATE_OUSTRING( ascii ) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ascii ) )
// items and item sets --------------------------------------------------------
diff --git a/sc/source/filter/inc/imp_op.hxx b/sc/source/filter/inc/imp_op.hxx
index ab5513ead1ed..fa0e6b7f5074 100644
--- a/sc/source/filter/inc/imp_op.hxx
+++ b/sc/source/filter/inc/imp_op.hxx
@@ -99,6 +99,8 @@ protected:
XclImpStream maStrm; // input stream
XclImpStream& aIn; // input stream
+ ScfUInt32Vec maSheetOffsets;
+
NameBuffer* pExtNameBuff; // ... externe Namen (Ind.-Basis=1)
ExcelToSc* pFormConv; // Formel-Konverter
diff --git a/sc/source/filter/inc/root.hxx b/sc/source/filter/inc/root.hxx
index 3aa94ca542b1..ffff5dd9ff94 100644
--- a/sc/source/filter/inc/root.hxx
+++ b/sc/source/filter/inc/root.hxx
@@ -67,7 +67,6 @@ struct RootData // -> Inkarnation jeweils im ImportExcel-Objekt!
{
BiffTyp eDateiTyp; // feine Differenzierung
ExtSheetBuffer* pExtSheetBuff;
- NameBuffer* pTabNameBuff;
ShrfmlaBuffer* pShrfmlaBuff;
ExtNameBuff* pExtNameBuff;
ExcelToSc* pFmlaConverter;
diff --git a/sc/source/filter/inc/xcl97rec.hxx b/sc/source/filter/inc/xcl97rec.hxx
index 649a7bd02702..ef97a60a8a8e 100644
--- a/sc/source/filter/inc/xcl97rec.hxx
+++ b/sc/source/filter/inc/xcl97rec.hxx
@@ -412,7 +412,7 @@ private:
sal_Size nRecLen;
XclExpString sName;
XclExpString sComment;
- static XclExpString sUsername;
+ XclExpString sUserName;
UINT8 nProtected;
inline ExcEScenarioCell* _First() { return (ExcEScenarioCell*) List::First(); }
@@ -424,7 +424,7 @@ private:
protected:
public:
- ExcEScenario( ScDocument& rDoc, SCTAB nTab );
+ ExcEScenario( const XclExpRoot& rRoot, SCTAB nTab );
virtual ~ExcEScenario();
virtual UINT16 GetNum() const;
@@ -450,7 +450,7 @@ private:
protected:
public:
- ExcEScenarioManager( ScDocument& rDoc, SCTAB nTab );
+ ExcEScenarioManager( const XclExpRoot& rRoot, SCTAB nTab );
virtual ~ExcEScenarioManager();
virtual void Save( XclExpStream& rStrm );
@@ -558,53 +558,14 @@ private:
// ============================================================================
-class XclExpFnGroupCount : public XclExpRecord
-{
-public:
- explicit XclExpFnGroupCount();
- virtual ~XclExpFnGroupCount();
-
-private:
- virtual void WriteBody( XclExpStream& rStrm );
-};
-
-// ============================================================================
-
/** Beginning of User Interface Records */
-class XclExpInterfaceHdr : public XclExpRecord
+class XclExpInterfaceHdr : public XclExpUInt16Record
{
public:
- explicit XclExpInterfaceHdr();
- virtual ~XclExpInterfaceHdr();
+ explicit XclExpInterfaceHdr( sal_uInt16 nCodePage );
private:
- virtual void WriteBody( XclExpStream& rStrm );
-};
-
-// ============================================================================
-
-/** Beginning of User Interface Records */
-class XclExpInterfaceEnd : public XclExpRecord
-{
-public:
- explicit XclExpInterfaceEnd();
- virtual ~XclExpInterfaceEnd();
-
-private:
- virtual void WriteBody( XclExpStream& rStrm );
-};
-
-// ============================================================================
-
-/** ADDMENU/DELMENU Record Group Count */
-class XclExpMMS : public XclExpRecord
-{
-public:
- explicit XclExpMMS();
- virtual ~XclExpMMS();
-
-private:
- virtual void WriteBody( XclExpStream& rStrm );
+ virtual void WriteBody( XclExpStream& rStrm );
};
// ============================================================================
@@ -623,26 +584,19 @@ private:
// ============================================================================
-class XclExpCodePage : public XclExpRecord
+class XclExpFileSharing : public XclExpRecord
{
public:
- explicit XclExpCodePage();
- virtual ~XclExpCodePage();
-
-private:
- virtual void WriteBody( XclExpStream& rStrm );
-};
+ explicit XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash );
-// ============================================================================
+ virtual void Save( XclExpStream& rStrm );
-class XclExpDSF : public XclExpRecord
-{
-public:
- explicit XclExpDSF();
- virtual ~XclExpDSF();
+private:
+ virtual void WriteBody( XclExpStream& rStrm );
private:
- virtual void WriteBody( XclExpStream& rStrm );
+ XclExpString maUserName;
+ sal_uInt16 mnPasswordHash;
};
// ============================================================================
@@ -671,19 +625,6 @@ private:
// ============================================================================
-/** What's this record for? It is a zero-byte record. */
-class XclExpExcel9File : public XclExpRecord
-{
-public:
- explicit XclExpExcel9File();
- virtual ~XclExpExcel9File();
-
-private:
- virtual void WriteBody( XclExpStream& rStrm );
-};
-
-// ============================================================================
-
class XclExpRecalcId : public XclExpDummyRecord
{
public:
diff --git a/sc/source/filter/inc/xestream.hxx b/sc/source/filter/inc/xestream.hxx
index 44e02d075317..857d756e2133 100644
--- a/sc/source/filter/inc/xestream.hxx
+++ b/sc/source/filter/inc/xestream.hxx
@@ -333,7 +333,6 @@ public:
// only needed for import; ignore
virtual bool importDocument() throw();
- virtual sal_Int32 getSchemeClr( sal_Int32 nColorSchemeToken ) const;
virtual oox::vml::Drawing* getVmlDrawing();
virtual const oox::drawingml::Theme* getCurrentTheme() const;
virtual const oox::drawingml::table::TableStyleListPtr getTableStyles();
diff --git a/sc/source/filter/inc/xistream.hxx b/sc/source/filter/inc/xistream.hxx
index 3ee461f163fe..bbc1cc04fde5 100644
--- a/sc/source/filter/inc/xistream.hxx
+++ b/sc/source/filter/inc/xistream.hxx
@@ -269,6 +269,10 @@ public:
CONTINUE usage is switched on.
@return false = no record found (end of stream). */
bool StartNextRecord();
+ /** Sets stream pointer to the start of the record content for the record
+ at the passed absolute stream position.
+ @return false = no record found (end of stream). */
+ bool StartNextRecord( sal_Size nNextRecPos );
/** Sets stream pointer to begin of record content.
@param bContLookup Automatic CONTINUE lookup on/off. In difference
to other stream settings, this setting is persistent until next call of
diff --git a/sc/source/filter/inc/xistyle.hxx b/sc/source/filter/inc/xistyle.hxx
index fe43aa75c331..a67458366057 100644
--- a/sc/source/filter/inc/xistyle.hxx
+++ b/sc/source/filter/inc/xistyle.hxx
@@ -397,21 +397,14 @@ public:
/** Reads an XF record. */
void ReadXF( XclImpStream& rStrm );
- /** Sets the style name of this XF, if it is a style XF.
- @descr Additionally creates this user-defined style in the Calc document. */
- void SetStyleName( const String& rStyleName );
- /** Sets the style name of this XF from a built-in Excel style, if it is a style XF.
- @descr Does not create the style in the Calc document. This is done on demand
- in CreatePattern(), if the style is really used. */
- void SetBuiltInStyleName( sal_uInt8 nStyleId, sal_uInt8 nLevel );
-
- inline const String& GetStyleName() const { return maStyleName; }
inline sal_uInt8 GetHorAlign() const { return maAlignment.mnHorAlign; }
inline sal_uInt8 GetVerAlign() const { return maAlignment.mnVerAlign; }
inline sal_uInt16 GetFontIndex() const { return mnXclFont; }
- /** Creates the Calc style sheet, if this is a user-defined style. */
- void CreateUserStyle();
+ /** Creates a Calc item set containing an item set with all cell properties.
+ @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items.
+ @return A read-only reference to the item set stored internally. */
+ const ScPatternAttr& CreatePattern( bool bSkipPoolDefs = false );
/** Inserts all formatting attributes to the specified area in the Calc document.
@param nForcedNumFmt If not set to NUMBERFORMAT_ENTRY_NOT_FOUND, it will overwrite
@@ -436,20 +429,10 @@ private:
/** Sets own "attribute used" flags, if attributes are different from passed parent XF. */
void UpdateUsedFlags( const XclImpXF& rParentXF );
- /** Creates a Calc item set containing an item set with all cell properties.
- @param bSkipPoolDefs true = Do not put items equal to pool default; false = Put all items.
- @return A read-only reference to the item set stored internally. */
- const ScPatternAttr& CreatePattern( bool bSkipPoolDefs = false );
- /** Creates a cell style sheet and inserts it into the Calc document.
- @descr Creates a style sheet only for style XFs with a valid style name.
- @return The pointer to the cell style sheet, or 0, if there is no style sheet. */
- ScStyleSheet* CreateStyleSheet();
-
private:
typedef ::std::auto_ptr< ScPatternAttr > ScPatternAttrPtr;
ScPatternAttrPtr mpPattern; /// Calc item set.
- String maStyleName; /// Name of the style sheet.
ScStyleSheet* mpStyleSheet; /// Calc cell style sheet.
XclImpCellProt maProtection; /// Cell protection flags.
@@ -458,9 +441,42 @@ private:
XclImpCellArea maArea; /// Background area style.
sal_uInt16 mnXclNumFmt; /// Index to number format.
sal_uInt16 mnXclFont; /// Index to font record.
+};
+
+// ----------------------------------------------------------------------------
- bool mbWasBuiltIn; /// true = XF was an Excel built-in style.
- bool mbForceCreate; /// true = Force creation of style sheet.
+/** Contains all data of a cell style associated with an XF record. */
+class XclImpStyle : protected XclImpRoot
+{
+public:
+ explicit XclImpStyle( const XclImpRoot& rRoot );
+
+ /** Reads a STYLE record. */
+ void ReadStyle( XclImpStream& rStrm );
+
+ inline const String& GetName() const { return maName; }
+ inline sal_uInt16 GetXfId() const { return mnXfId; }
+ inline bool IsBuiltin() const { return mbBuiltin && (mnBuiltinId != EXC_STYLE_USERDEF); }
+ inline sal_uInt8 GetBuiltinId() const { return mnBuiltinId; }
+ inline sal_uInt8 GetLevel() const { return mnLevel; }
+
+ /** Creates a cell style sheet and inserts it into the Calc document.
+ @return The pointer to the cell style sheet, or 0, if there is no style sheet. */
+ ScStyleSheet* CreateStyleSheet();
+ /** Creates the Calc style sheet, if this is a user-defined style. */
+ void CreateUserStyle( const String& rFinalName );
+
+private:
+ String maName; /// Cell style name.
+ sal_uInt16 mnXfId; /// Formatting for this cell style.
+ sal_uInt8 mnBuiltinId; /// Identifier for builtin styles.
+ sal_uInt8 mnLevel; /// Level for builtin column/row styles.
+ bool mbBuiltin; /// True = builtin style.
+ bool mbCustom; /// True = customized builtin style.
+ bool mbHidden; /// True = style not visible in GUI.
+
+ String maFinalName; /// Final name used in the Calc document.
+ ScStyleSheet* mpStyleSheet; /// Calc cell style sheet.
};
// ----------------------------------------------------------------------------
@@ -491,6 +507,9 @@ public:
/** Creates all user defined style sheets. */
void CreateUserStyles();
+ /** Creates a cell style sheet of the passed XF and inserts it into the Calc document.
+ @return The pointer to the cell style sheet, or 0, if there is no style sheet. */
+ ScStyleSheet* CreateStyleSheet( sal_uInt16 nXFIndex );
/** Inserts formatting attributes from an XF to the specified area in the Calc document.
@param nForcedNumFmt If not set to NUMBERFORMAT_ENTRY_NOT_FOUND, it will overwrite
@@ -501,7 +520,13 @@ public:
SCTAB nScTab, const XclImpXFIndex& rXFIndex );
private:
+ typedef ScfDelList< XclImpStyle > XclImpStyleList;
+ typedef ::std::map< sal_uInt16, XclImpStyle* > XclImpStyleMap;
+
ScfDelList< XclImpXF > maXFList; /// List of contents of all XF record.
+ XclImpStyleList maBuiltinStyles; /// List of built-in cell styles.
+ XclImpStyleList maUserStyles; /// List of user defined cell styles.
+ XclImpStyleMap maStylesByXf; /// Maps XF records to cell styles.
};
// Buffer for XF indexes in cells =============================================
diff --git a/sc/source/filter/inc/xlconst.hxx b/sc/source/filter/inc/xlconst.hxx
index eebaa76e4702..eeb3fb3982b9 100644
--- a/sc/source/filter/inc/xlconst.hxx
+++ b/sc/source/filter/inc/xlconst.hxx
@@ -205,6 +205,10 @@ const sal_uInt16 EXC_WSBOOL_FITTOPAGE = 0x0100;
const sal_uInt16 EXC_WSBOOL_DEFAULTFLAGS = 0x04C1;
+// (0x0086) WRITEPROT ---------------------------------------------------------
+
+const sal_uInt16 EXC_ID_WRITEPROT = 0x0086;
+
// (0x008C) COUNTRY -----------------------------------------------------------
const sal_uInt16 EXC_ID_COUNTRY = 0x008C;
@@ -213,6 +217,10 @@ const sal_uInt16 EXC_ID_COUNTRY = 0x008C;
const sal_uInt16 EXC_ID_FILTERMODE = 0x009B;
+// (0x009C) FNGROUPCOUNT ------------------------------------------------------
+
+const sal_uInt16 EXC_ID_FNGROUPCOUNT = 0x009C;
+
// (0x009D) AUTOFILTERINFO ----------------------------------------------------
const sal_uInt16 EXC_ID_AUTOFILTERINFO = 0x009D;
@@ -221,15 +229,34 @@ const sal_uInt16 EXC_ID_AUTOFILTERINFO = 0x009D;
const sal_uInt16 EXC_ID_AUTOFILTER = 0x009E;
+// (0x00BF, 0x00C0, 0x00C1) TOOLBARHDR, TOOLBAREND, MMS -----------------------
+
+const sal_uInt16 EXC_ID_TOOLBARHDR = 0x00BF;
+const sal_uInt16 EXC_ID_TOOLBAREND = 0x00C0;
+const sal_uInt16 EXC_ID_MMS = 0x00C1;
+
+// (0x00E1, 0x00E2) INTERFACEHDR, INTERFACEEND --------------------------------
+
+const sal_uInt16 EXC_ID_INTERFACEHDR = 0x00E1;
+const sal_uInt16 EXC_ID_INTERFACEEND = 0x00E2;
+
// (0x0160) USESELFS ----------------------------------------------------------
const sal_uInt16 EXC_ID_USESELFS = 0x0160;
+// (0x0161) DSF ---------------------------------------------------------------
+
+const sal_uInt16 EXC_ID_DSF = 0x0161;
+
// (0x01AA,0x01AB) USERSVIEWBEGIN, USERSVIEWEND -------------------------------
const sal_uInt16 EXC_ID_USERSVIEWBEGIN = 0x01AA;
const sal_uInt16 EXC_ID_USERSVIEWEND = 0x01AB;
+// (0x01C0) XL9FILE --------------------------------------------------------
+
+const sal_uInt16 EXC_ID_XL9FILE = 0x01C0;
+
// (0x8xx) Future records -----------------------------------------------------
/** Enumerates different header types of future records. */
diff --git a/sc/source/filter/inc/xlroot.hxx b/sc/source/filter/inc/xlroot.hxx
index 8571dafcbc74..8b0873b25475 100644
--- a/sc/source/filter/inc/xlroot.hxx
+++ b/sc/source/filter/inc/xlroot.hxx
@@ -94,6 +94,7 @@ struct XclRootData
ScDocument& mrDoc; /// The source or destination document.
String maDocUrl; /// Document URL of imported/exported file.
String maBasePath; /// Base path of imported/exported file (path of maDocUrl).
+ String maUserName; /// Current user name.
const String maDefPassword; /// The default password used for stream encryption.
rtl_TextEncoding meTextEnc; /// Text encoding to import/export byte strings.
LanguageType meSysLang; /// System language.
@@ -185,6 +186,8 @@ public:
inline const String& GetDocUrl() const { return mrData.maDocUrl; }
/** Returns the base path of the imported/exported file. */
inline const String& GetBasePath() const { return mrData.maBasePath; }
+ /** Returns the current user name. */
+ inline const String& GetUserName() const { return mrData.maUserName; }
/** Returns the default password used for stream encryption. */
inline const String& GetDefaultPassword() const { return mrData.maDefPassword; }
diff --git a/sc/source/filter/inc/xlstyle.hxx b/sc/source/filter/inc/xlstyle.hxx
index 9d02f0720efc..9613abfc8725 100644
--- a/sc/source/filter/inc/xlstyle.hxx
+++ b/sc/source/filter/inc/xlstyle.hxx
@@ -242,6 +242,14 @@ const sal_uInt8 EXC_STYLE_USERDEF = 0xFF; /// No built-in styl
const sal_uInt8 EXC_STYLE_LEVELCOUNT = 7; /// Number of outline level styles.
const sal_uInt8 EXC_STYLE_NOLEVEL = 0xFF; /// Default value for unused level.
+// (0x0892) STYLEEXT ----------------------------------------------------------
+
+const sal_uInt16 EXC_ID_STYLEEXT = 0x0892;
+
+const sal_uInt8 EXC_STYLEEXT_BUILTIN = 0x01;
+const sal_uInt8 EXC_STYLEEXT_HIDDEN = 0x02;
+const sal_uInt8 EXC_STYLEEXT_CUSTOM = 0x04;
+
// Structs and classes ========================================================
// Color data =================================================================
diff --git a/sc/source/filter/inc/xltools.hxx b/sc/source/filter/inc/xltools.hxx
index 459a5c9b3a78..392b0a2ae1fc 100644
--- a/sc/source/filter/inc/xltools.hxx
+++ b/sc/source/filter/inc/xltools.hxx
@@ -167,8 +167,8 @@ public:
@return The corresponding text encoding or RTL_TEXTENCODING_DONTKNOW. */
static rtl_TextEncoding GetTextEncoding( sal_uInt16 nCodePage );
-//UNUSED2008-05 /** Returns an Excel code page from a text encoding. */
-//UNUSED2008-05 static sal_uInt16 GetXclCodePage( rtl_TextEncoding eTextEnc );
+ /** Returns an Excel code page from a text encoding. */
+ static sal_uInt16 GetXclCodePage( rtl_TextEncoding eTextEnc );
// font names -------------------------------------------------------------
@@ -194,9 +194,12 @@ public:
/** Returns the specified built-in cell style name.
@param nStyleId The identifier of the built-in style.
+ @param rName Default name for unknown styles.
@param nLevel The zero-based outline level for RowLevel and ColLevel styles.
@return The style name or an empty string, if the parameters are not valid. */
- static String GetBuiltInStyleName( sal_uInt8 nStyleId, sal_uInt8 nLevel );
+ static String GetBuiltInStyleName( sal_uInt8 nStyleId, const String& rName, sal_uInt8 nLevel );
+ /** Returns the passed style name with a special built-in prefix. */
+ static String GetBuiltInStyleName( const String& rStyleName );
/** Returns true, if the passed string is a name of an Excel built-in style.
@param pnStyleId If not 0, the found style identifier will be returned here.
@param pnNextChar If not 0, the index of the char after the evaluated substring will be returned here. */
@@ -230,8 +233,10 @@ public:
// ------------------------------------------------------------------------
private:
static const String maDefNamePrefix; /// Prefix for built-in defined names.
- static const String maStyleNamePrefix; /// Prefix for built-in cell style names.
- static const String maCFStyleNamePrefix; /// Prefix for cond. formatting style names.
+ static const String maStyleNamePrefix1; /// Prefix for built-in cell style names.
+ static const String maStyleNamePrefix2; /// Prefix for built-in cell style names from OOX filter.
+ static const String maCFStyleNamePrefix1; /// Prefix for cond. formatting style names.
+ static const String maCFStyleNamePrefix2; /// Prefix for cond. formatting style names from OOX filter.
};
// read/write colors ----------------------------------------------------------
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index ac71dbb01fbb..608b13c49ac3 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -65,7 +65,6 @@
#include <svx/eeitem.hxx>
#include <svx/msoleexp.hxx>
-#include <svtools/useroptions.hxx>
#include <unotools/localedatawrapper.hxx>
#include <stdio.h>
@@ -1033,15 +1032,14 @@ void ExcEScenarioCell::SaveXml( XclExpXmlStream& rStrm )
-XclExpString ExcEScenario::sUsername;
-
-ExcEScenario::ExcEScenario( ScDocument& rDoc, SCTAB nTab )
+ExcEScenario::ExcEScenario( const XclExpRoot& rRoot, SCTAB nTab )
{
String sTmpName;
String sTmpComm;
Color aDummyCol;
USHORT nFlags;
+ ScDocument& rDoc = rRoot.GetDoc();
rDoc.GetName( nTab, sTmpName );
sName.Assign( sTmpName, EXC_STR_8BITLENGTH );
nRecLen = 8 + sName.GetBufferSize();
@@ -1052,14 +1050,8 @@ ExcEScenario::ExcEScenario( ScDocument& rDoc, SCTAB nTab )
nRecLen += sComment.GetSize();
nProtected = (nFlags & SC_SCENARIO_PROTECT) ? 1 : 0;
- if( !sUsername.Len() )
- {
- SvtUserOptions aUserOpt;
- sUsername.Assign( aUserOpt.GetLastName(), EXC_STR_DEFAULT, 255 );
- }
- if( !sUsername.Len() )
- sUsername.Assign( String::CreateFromAscii( "SC" ) );
- nRecLen += sUsername.GetSize();
+ sUserName.Assign( rRoot.GetUserName(), EXC_STR_DEFAULT, 255 );
+ nRecLen += sUserName.GetSize();
const ScRangeList* pRList = rDoc.GetScenarioRanges( nTab );
if( !pRList )
@@ -1118,11 +1110,11 @@ void ExcEScenario::SaveCont( XclExpStream& rStrm )
<< (UINT8) 0 // fHidden
<< (UINT8) sName.Len() // length of scen name
<< (UINT8) sComment.Len() // length of comment
- << (UINT8) sUsername.Len(); // length of user name
+ << (UINT8) sUserName.Len(); // length of user name
sName.WriteFlagField( rStrm );
sName.WriteBuffer( rStrm );
- rStrm << sUsername;
+ rStrm << sUserName;
if( sComment.Len() )
rStrm << sComment;
@@ -1154,7 +1146,7 @@ void ExcEScenario::SaveXml( XclExpXmlStream& rStrm )
XML_locked, XclXmlUtils::ToPsz( nProtected ),
// OOXTODO: XML_hidden,
XML_count, OString::valueOf( (sal_Int32) List::Count() ).getStr(),
- XML_user, XESTRING_TO_PSZ( sUsername ),
+ XML_user, XESTRING_TO_PSZ( sUserName ),
XML_comment, XESTRING_TO_PSZ( sComment ),
FSEND );
@@ -1167,9 +1159,10 @@ void ExcEScenario::SaveXml( XclExpXmlStream& rStrm )
-ExcEScenarioManager::ExcEScenarioManager( ScDocument& rDoc, SCTAB nTab ) :
+ExcEScenarioManager::ExcEScenarioManager( const XclExpRoot& rRoot, SCTAB nTab ) :
nActive( 0 )
{
+ ScDocument& rDoc = rRoot.GetDoc();
if( rDoc.IsScenario( nTab ) )
return;
@@ -1178,7 +1171,7 @@ ExcEScenarioManager::ExcEScenarioManager( ScDocument& rDoc, SCTAB nTab ) :
while( rDoc.IsScenario( nNewTab ) )
{
- Append( new ExcEScenario( rDoc, nNewTab ) );
+ Append( new ExcEScenario( rRoot, nNewTab ) );
if( rDoc.IsActiveScenario( nNewTab ) )
nActive = static_cast<sal_uInt16>(nNewTab - nFirstTab);
@@ -1453,67 +1446,15 @@ void XclExpFilePass::WriteBody( XclExpStream& rStrm )
// ============================================================================
-XclExpFnGroupCount::XclExpFnGroupCount() :
- XclExpRecord(0x009C, 2)
-{
-}
-
-XclExpFnGroupCount::~XclExpFnGroupCount()
-{
-}
-
-void XclExpFnGroupCount::WriteBody( XclExpStream& rStrm )
-{
- rStrm << static_cast<sal_uInt16>(14);
-}
-
-// ============================================================================
-
-XclExpInterfaceHdr::XclExpInterfaceHdr() :
- XclExpRecord(0x00E1, 2)
-{
-}
-
-XclExpInterfaceHdr::~XclExpInterfaceHdr()
+XclExpInterfaceHdr::XclExpInterfaceHdr( sal_uInt16 nCodePage ) :
+ XclExpUInt16Record( EXC_ID_INTERFACEHDR, nCodePage )
{
}
void XclExpInterfaceHdr::WriteBody( XclExpStream& rStrm )
{
- // The value must be the same value as the CODEPAGE record.
rStrm.DisableEncryption();
- rStrm << static_cast<sal_uInt16>(0x04B0);
-}
-
-// ============================================================================
-
-XclExpInterfaceEnd::XclExpInterfaceEnd() :
- XclExpRecord(0x00E2, 0)
-{
-}
-
-XclExpInterfaceEnd::~XclExpInterfaceEnd()
-{
-}
-
-void XclExpInterfaceEnd::WriteBody( XclExpStream& /*rStrm*/ )
-{
-}
-
-// ============================================================================
-
-XclExpMMS::XclExpMMS() :
- XclExpRecord(0x00C1, 2)
-{
-}
-
-XclExpMMS::~XclExpMMS()
-{
-}
-
-void XclExpMMS::WriteBody( XclExpStream& rStrm )
-{
- rStrm << static_cast<sal_uInt16>(0x0000);
+ rStrm << GetValue();
}
// ============================================================================
@@ -1552,35 +1493,25 @@ void XclExpWriteAccess::WriteBody( XclExpStream& rStrm )
// ============================================================================
-XclExpCodePage::XclExpCodePage() :
- XclExpRecord(0x0042, 2)
-{
-}
-
-XclExpCodePage::~XclExpCodePage()
-{
-}
-
-void XclExpCodePage::WriteBody( XclExpStream& rStrm )
-{
- // 0x04B0 : UTF-16 (BIFF8)
- rStrm << static_cast<sal_uInt16>(0x04B0);
-}
-
-// ============================================================================
-
-XclExpDSF::XclExpDSF() :
- XclExpRecord(0x0161, 2)
+XclExpFileSharing::XclExpFileSharing( const XclExpRoot& rRoot, sal_uInt16 nPasswordHash ) :
+ XclExpRecord( EXC_ID_FILESHARING ),
+ mnPasswordHash( nPasswordHash )
{
+ if( rRoot.GetBiff() <= EXC_BIFF5 )
+ maUserName.AssignByte( rRoot.GetUserName(), rRoot.GetTextEncoding(), EXC_STR_8BITLENGTH );
+ else
+ maUserName.Assign( rRoot.GetUserName() );
}
-XclExpDSF::~XclExpDSF()
+void XclExpFileSharing::Save( XclExpStream& rStrm )
{
+ if( mnPasswordHash != 0 )
+ XclExpRecord::Save( rStrm );
}
-void XclExpDSF::WriteBody( XclExpStream& rStrm )
+void XclExpFileSharing::WriteBody( XclExpStream& rStrm )
{
- rStrm << static_cast<sal_uInt16>(0x0000);
+ rStrm << sal_uInt16( 0 ) << mnPasswordHash << maUserName;
}
// ============================================================================
@@ -1617,21 +1548,6 @@ void XclExpProt4RevPass::WriteBody( XclExpStream& rStrm )
// ============================================================================
-XclExpExcel9File::XclExpExcel9File() :
- XclExpRecord(0x01C0, 0)
-{
-}
-
-XclExpExcel9File::~XclExpExcel9File()
-{
-}
-
-void XclExpExcel9File::WriteBody( XclExpStream& /*rStrm*/ )
-{
-}
-
-// ============================================================================
-
static const sal_uInt8 nDataRecalcId[] = {
0xC1, 0x01, 0x00, 0x00, 0x54, 0x8D, 0x01, 0x00
};
diff --git a/sc/source/filter/xml/XMLDDELinksContext.cxx b/sc/source/filter/xml/XMLDDELinksContext.cxx
index c0872ae07668..ce77178500bb 100644
--- a/sc/source/filter/xml/XMLDDELinksContext.cxx
+++ b/sc/source/filter/xml/XMLDDELinksContext.cxx
@@ -163,9 +163,20 @@ void ScXMLDDELinkContext::EndElement()
{
if (nPosition > -1 && nColumns && nRows && GetScImport().GetDocument())
{
+ bool bSizeMatch = (static_cast<size_t>(nColumns * nRows) == aDDELinkTable.size());
+ DBG_ASSERT( bSizeMatch, "ScXMLDDELinkContext::EndElement: matrix dimension doesn't match cells count");
+ // Excel writes bad ODF in that it does not write the
+ // table:number-columns-repeated attribute of the
+ // <table:table-column> element, but apparently uses the number of
+ // <table:table-cell> elements within a <table:table-row> element to
+ // determine the column count instead. Be lenient ...
+ if (!bSizeMatch && nColumns == 1)
+ {
+ nColumns = aDDELinkTable.size() / nRows;
+ DBG_ASSERT( static_cast<size_t>(nColumns * nRows) == aDDELinkTable.size(),
+ "ScXMLDDELinkContext::EndElement: adapted matrix dimension doesn't match either");
+ }
ScMatrixRef pMatrix = new ScMatrix( static_cast<SCSIZE>(nColumns), static_cast<SCSIZE>(nRows) );
-
- DBG_ASSERT(static_cast<sal_uInt32>(nColumns * nRows) == aDDELinkTable.size(), "there is a wrong cells count");
sal_Int32 nCol(0);
sal_Int32 nRow(-1);
sal_Int32 nIndex(0);
diff --git a/sc/source/filter/xml/XMLTableShapeResizer.cxx b/sc/source/filter/xml/XMLTableShapeResizer.cxx
index 88c5fbf248b1..ca6d23a6459a 100644
--- a/sc/source/filter/xml/XMLTableShapeResizer.cxx
+++ b/sc/source/filter/xml/XMLTableShapeResizer.cxx
@@ -106,6 +106,12 @@ void ScMyShapeResizer::CreateChartListener(ScDocument* pDoc,
//otherwise the charts keep their first visual representation which was created at a moment where the calc itself was not loaded completly and is incorect therefor
if( (rImport.getImportFlags() & IMPORT_ALL) == IMPORT_ALL )
pCL->SetDirty( TRUE );
+ else
+ {
+ // #i104899# If a formula cell is already dirty, further changes aren't propagated.
+ // This can happen easily now that row heights aren't updated for all sheets.
+ pDoc->InterpretDirtyCells( *pCL->GetRangeList() );
+ }
pCollection->Insert( pCL );
pCL->StartListeningTo();
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index a35a426e4831..df7e99955bfd 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3902,7 +3902,7 @@ void ScXMLExport::WriteExternalRefCaches()
return;
ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
- pRefMgr->resetSrcFileData();
+ pRefMgr->resetSrcFileData(GetOrigFileName());
sal_uInt16 nCount = pRefMgr->getExternalFileCount();
for (sal_uInt16 nFileId = 0; nFileId < nCount; ++nFileId)
{
diff --git a/sc/source/filter/xml/xmlexternaltabi.cxx b/sc/source/filter/xml/xmlexternaltabi.cxx
index 7eabdff07b9b..b53431843a57 100644
--- a/sc/source/filter/xml/xmlexternaltabi.cxx
+++ b/sc/source/filter/xml/xmlexternaltabi.cxx
@@ -100,6 +100,32 @@ SvXMLImportContext* ScXMLExternalRefTabSourceContext::CreateChildContext(
return new SvXMLImportContext(GetImport(), nPrefix, rLocalName);
}
+/**
+ * Make sure the URL is a valid relative URL, mainly to avoid storing
+ * absolute URL as relative URL by accident. For now, we only check the first
+ * three characters which are assumed to be always '../', because the relative
+ * URL for an external document is always in reference to the content.xml
+ * fragment of the original document.
+ */
+static bool lcl_isValidRelativeURL(const OUString& rUrl)
+{
+ sal_Int32 n = ::std::min( rUrl.getLength(), static_cast<sal_Int32>(3));
+ if (n < 3)
+ return false;
+ const sal_Unicode* p = rUrl.getStr();
+ for (sal_Int32 i = 0; i < n; ++i)
+ {
+ sal_Unicode c = p[i];
+ if (i < 2 && c != '.')
+ // the path must begin with '..'
+ return false;
+ else if (i == 2 && c != '/')
+ // a '/' path separator must follow
+ return false;
+ }
+ return true;
+}
+
void ScXMLExternalRefTabSourceContext::EndElement()
{
ScDocument* pDoc = mrScImport.GetDocument();
@@ -107,7 +133,7 @@ void ScXMLExternalRefTabSourceContext::EndElement()
return;
ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
- if (!maRelativeUrl.equals(mrExternalRefInfo.maFileUrl))
+ if (lcl_isValidRelativeURL(maRelativeUrl))
pRefMgr->setRelativeFileName(mrExternalRefInfo.mnFileId, maRelativeUrl);
pRefMgr->setFilterData(mrExternalRefInfo.mnFileId, maFilterName, maFilterOptions);
}
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index dbf672993310..7bc5396fcb5b 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -265,7 +265,24 @@ sal_uInt32 ScXMLImportWrapper::ImportFromComponent(uno::Reference<lang::XMultiSe
}
catch( xml::sax::SAXParseException& r )
{
- if( bEncrypted )
+ // sax parser sends wrapped exceptions,
+ // try to find the original one
+ xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r);
+ sal_Bool bTryChild = sal_True;
+
+ while( bTryChild )
+ {
+ xml::sax::SAXException aTmp;
+ if ( aSaxEx.WrappedException >>= aTmp )
+ aSaxEx = aTmp;
+ else
+ bTryChild = sal_False;
+ }
+
+ packages::zip::ZipIOException aBrokenPackage;
+ if ( aSaxEx.WrappedException >>= aBrokenPackage )
+ return ERRCODE_IO_BROKENPACKAGE;
+ else if( bEncrypted )
nReturn = ERRCODE_SFX_WRONGPASSWORD;
else
{
@@ -298,7 +315,10 @@ sal_uInt32 ScXMLImportWrapper::ImportFromComponent(uno::Reference<lang::XMultiSe
}
catch( xml::sax::SAXException& r )
{
- if( bEncrypted )
+ packages::zip::ZipIOException aBrokenPackage;
+ if ( r.WrappedException >>= aBrokenPackage )
+ return ERRCODE_IO_BROKENPACKAGE;
+ else if( bEncrypted )
nReturn = ERRCODE_SFX_WRONGPASSWORD;
else
{
diff --git a/sc/source/ui/app/scmod2.cxx b/sc/source/ui/app/scmod2.cxx
index 2424b62c5414..4001ebe62036 100644
--- a/sc/source/ui/app/scmod2.cxx
+++ b/sc/source/ui/app/scmod2.cxx
@@ -37,7 +37,8 @@
#include <svx/unolingu.hxx>
#include <svtools/lingucfg.hxx>
-
+#include <i18npool/mslangid.hxx>
+#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/linguistic2/XThesaurus.hpp>
#include <com/sun/star/lang/Locale.hpp>
@@ -62,9 +63,9 @@ void ScModule::GetSpellSettings( USHORT& rDefLang, USHORT& rCjkLang, USHORT& rCt
SvtLinguOptions aOptions;
aConfig.GetOptions( aOptions );
- rDefLang = aOptions.nDefaultLanguage;
- rCjkLang = aOptions.nDefaultLanguage_CJK;
- rCtlLang = aOptions.nDefaultLanguage_CTL;
+ rDefLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN);
+ rCjkLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN);
+ rCtlLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
rAutoSpell = aOptions.bIsSpellAuto;
}
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index a9e5f7ce8218..fd3a562ecb42 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -355,12 +355,12 @@ BOOL ScAreaLink::Refresh( const String& rNewFile, const String& rNewFilter,
}
else
pUndoDoc->InitUndo( pDoc, nDestTab, nDestTab ); // nur Zieltabelle
- pDoc->CopyToDocument( aOldRange, IDF_ALL, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( aOldRange, IDF_ALL & ~IDF_NOTE, FALSE, pUndoDoc );
}
else // ohne Einfuegen
{
pUndoDoc->InitUndo( pDoc, nDestTab, nDestTab ); // nur Zieltabelle
- pDoc->CopyToDocument( aMaxRange, IDF_ALL, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( aMaxRange, IDF_ALL & ~IDF_NOTE, FALSE, pUndoDoc );
}
}
@@ -370,7 +370,7 @@ BOOL ScAreaLink::Refresh( const String& rNewFile, const String& rNewFilter,
if (bDoInsert)
pDoc->FitBlock( aOldRange, aNewRange ); // incl. loeschen
else
- pDoc->DeleteAreaTab( aMaxRange, IDF_ALL );
+ pDoc->DeleteAreaTab( aMaxRange, IDF_ALL & ~IDF_NOTE );
// Daten kopieren
@@ -426,7 +426,7 @@ BOOL ScAreaLink::Refresh( const String& rNewFile, const String& rNewFilter,
{
pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
pRedoDoc->InitUndo( pDoc, nDestTab, nDestTab );
- pDoc->CopyToDocument( aNewRange, IDF_ALL, FALSE, pRedoDoc );
+ pDoc->CopyToDocument( aNewRange, IDF_ALL & ~IDF_NOTE, FALSE, pRedoDoc );
pImpl->m_pDocSh->GetUndoManager()->AddUndoAction(
new ScUndoUpdateAreaLink( pImpl->m_pDocSh,
diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx
index ae176868162e..09e4dd7aa4af 100644
--- a/sc/source/ui/docshell/dbdocimp.cxx
+++ b/sc/source/ui/docshell/dbdocimp.cxx
@@ -576,18 +576,21 @@ BOOL ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
if (bRecord)
{
+ // do not touch notes (ScUndoImportData does not support drawing undo)
+ sal_uInt16 nCopyFlags = IDF_ALL & ~IDF_NOTE;
+
// nFormulaCols is set only if column count is unchanged
pDoc->CopyToDocument( rParam.nCol1, rParam.nRow1, nTab,
nEndCol+nFormulaCols, nEndRow, nTab,
- IDF_ALL, FALSE, pUndoDoc );
+ nCopyFlags, FALSE, pUndoDoc );
if ( rParam.nCol2 > nEndCol )
pDoc->CopyToDocument( nEndCol+1, rParam.nRow1, nTab,
nUndoEndCol, nUndoEndRow, nTab,
- IDF_ALL, FALSE, pUndoDoc );
+ nCopyFlags, FALSE, pUndoDoc );
if ( rParam.nRow2 > nEndRow )
pDoc->CopyToDocument( rParam.nCol1, nEndRow+1, nTab,
nUndoEndCol+nFormulaCols, nUndoEndRow, nTab,
- IDF_ALL, FALSE, pUndoDoc );
+ nCopyFlags, FALSE, pUndoDoc );
}
//
@@ -601,7 +604,7 @@ BOOL ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
ScRange aDelRange( rParam.nCol1, rParam.nRow1, nTab,
rParam.nCol2, rParam.nRow2, nTab );
- pDoc->DeleteAreaTab( aDelRange, IDF_ALL ); // ohne die Formeln
+ pDoc->DeleteAreaTab( aDelRange, IDF_ALL & ~IDF_NOTE ); // ohne die Formeln
ScRange aOld( rParam.nCol1, rParam.nRow1, nTab,
rParam.nCol2+nFormulaCols, rParam.nRow2, nTab );
@@ -611,10 +614,10 @@ BOOL ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
}
else if ( nEndCol < rParam.nCol2 ) // DeleteArea calls PutInOrder
pDoc->DeleteArea( nEndCol+1, rParam.nRow1, rParam.nCol2, rParam.nRow2,
- aNewMark, IDF_CONTENTS );
+ aNewMark, IDF_CONTENTS & ~IDF_NOTE );
// CopyToDocument doesn't remove contents
- pDoc->DeleteAreaTab( rParam.nCol1, rParam.nRow1, nEndCol, nEndRow, nTab, IDF_CONTENTS );
+ pDoc->DeleteAreaTab( rParam.nCol1, rParam.nRow1, nEndCol, nEndRow, nTab, IDF_CONTENTS & ~IDF_NOTE );
// #41216# remove each column from ImportDoc after copying to reduce memory usage
BOOL bOldAutoCalc = pDoc->GetAutoCalc();
@@ -671,7 +674,7 @@ BOOL ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
if (nFormulaCols > 0) // include filled formulas for redo
pDoc->CopyToDocument( rParam.nCol1, rParam.nRow1, nTab,
nEndCol+nFormulaCols, nEndRow, nTab,
- IDF_ALL, FALSE, pRedoDoc );
+ IDF_ALL & ~IDF_NOTE, FALSE, pRedoDoc );
ScDBData* pRedoDBData = pDBData ? new ScDBData( *pDBData ) : NULL;
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 608c1c688ea9..cb5d2ead509f 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -2016,7 +2016,7 @@ BOOL ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
nScenarioCount ++;
pDoc->CopyToDocument( nUndoStartX, nUndoStartY, i, nUndoEndX, nUndoEndY, i+nScenarioCount,
- IDF_ALL, FALSE, pUndoDoc );
+ IDF_ALL | IDF_NOCAPTIONS, FALSE, pUndoDoc );
}
}
@@ -2277,7 +2277,7 @@ BOOL ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
}
ScDrawLayer::SetGlobalDrawPersist(aDragShellRef);
- ScClipParam aClipParam(ScRange(nStartCol, nStartRow, 0, nEndCol, nEndRow, 0), false);
+ ScClipParam aClipParam(ScRange(nStartCol, nStartRow, 0, nEndCol, nEndRow, 0), bCut);
pDoc->CopyToClip(aClipParam, pClipDoc, &aSourceMark, false, bScenariosAdded, true);
ScDrawLayer::SetGlobalDrawPersist(NULL);
@@ -3577,7 +3577,7 @@ BOOL ScDocFunc::EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark,
//! auch bei Undo selektierte Tabellen beruecksichtigen
pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
- pDoc->CopyToDocument( rRange, IDF_ALL, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( rRange, IDF_ALL & ~IDF_NOTE, FALSE, pUndoDoc );
}
// use TokenArray if given, string (and flags) otherwise
@@ -3665,7 +3665,7 @@ BOOL ScDocFunc::TabOp( const ScRange& rRange, const ScMarkData* pTabMark,
//! auch bei Undo selektierte Tabellen beruecksichtigen
ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
- pDoc->CopyToDocument( rRange, IDF_ALL, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( rRange, IDF_ALL & ~IDF_NOTE, FALSE, pUndoDoc );
rDocShell.GetUndoManager()->AddUndoAction(
new ScUndoTabOp( &rDocShell,
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 716d0f6c4bd9..a78ebf7b3127 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1856,38 +1856,28 @@ BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed )
aDocument.SetExtDocOptions( pExtDocOpt = new ScExtDocOptions );
pViewShell->GetViewData()->WriteExtOptions( *pExtDocOpt );
-#if ENABLE_SHEET_PROTECTION
- bool bNeedRetypePassDlg = ScPassHashHelper::needsPassHashRegen(aDocument, PASSHASH_XL);
- if (bNeedRetypePassDlg && !pViewShell->ExecuteRetypePassDlg(PASSHASH_XL))
+ /* #115980# #i104990# If the imported document contains a medium
+ password, determine if we can save it, otherwise ask the users
+ whether they want to save without it. */
+ if( !::sfx2::CheckMSPasswordCapabilityForExport( aFltName ) )
{
- SetError( ERRCODE_ABORT );
- return false;
- }
-#else
-
- do
- {
- SfxItemSet* pSet = rMed.GetItemSet();
- if (!pSet)
- break;
-
- const SfxPoolItem* pItem = NULL;
- if (SFX_ITEM_SET != pSet->GetItemState(SID_PASSWORD, sal_True, &pItem))
- // password is not set.
- break;
-
- /* #115980 #If the imported document contained an encrypted password -
- determine if we should save without it. */
- bDoSave = ScWarnPassword::WarningOnPassword( rMed );
-
- if (bDoSave)
+ SfxItemSet* pItemSet = rMed.GetItemSet();
+ const SfxPoolItem* pItem = 0;
+ if( pItemSet && pItemSet->GetItemState( SID_PASSWORD, sal_True, &pItem ) == SFX_ITEM_SET )
{
- // #i42858# warn only one time
- pSet->ClearItem(SID_PASSWORD);
+ bDoSave = ScWarnPassword::WarningOnPassword( rMed );
+ // #i42858# remove password from medium (warn only one time)
+ if( bDoSave )
+ pItemSet->ClearItem( SID_PASSWORD );
}
}
- while (false);
+#if ENABLE_SHEET_PROTECTION
+ if( bDoSave )
+ {
+ bool bNeedRetypePassDlg = ScPassHashHelper::needsPassHashRegen( aDocument, PASSHASH_XL );
+ bDoSave = !bNeedRetypePassDlg || pViewShell->ExecuteRetypePassDlg( PASSHASH_XL );
+ }
#endif
}
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index fcbfb648ae14..380f4635cdcf 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -483,6 +483,10 @@ OutputDevice* ScDocShell::GetRefDevice()
USHORT ScDocShell::SetPrinter( SfxPrinter* pNewPrinter, USHORT nDiffFlags )
{
+ SfxPrinter *pOld = aDocument.GetPrinter( FALSE );
+ if ( pOld && pOld->IsPrinting() )
+ return SFX_PRINTERROR_BUSY;
+
if (nDiffFlags & SFX_PRINTER_PRINTER)
{
if ( aDocument.GetPrinter() != pNewPrinter )
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 9cc0b274028e..f74e8c519fb6 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -384,11 +384,6 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
return TokenArrayRef();
DocItem& rDoc = itrDoc->second;
- RangeArrayMap::const_iterator itrRange = rDoc.maRangeArrays.find(rRange);
- if (itrRange != rDoc.maRangeArrays.end())
- {
- return itrRange->second;
- }
TableNameIndexMap::iterator itrTabId = rDoc.maTableNameIndex.find(
ScGlobal::pCharClass->upper(rTabName));
@@ -410,6 +405,13 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
// not all tables are cached.
return TokenArrayRef();
+ ScRange aCacheRange( nCol1, nRow1, static_cast<SCTAB>(nTabFirstId), nCol2, nRow2, static_cast<SCTAB>(nTabLastId));
+ RangeArrayMap::const_iterator itrRange = rDoc.maRangeArrays.find( aCacheRange);
+ if (itrRange != rDoc.maRangeArrays.end())
+ {
+ return itrRange->second;
+ }
+
TokenArrayRef pArray(new ScTokenArray);
bool bFirstTab = true;
for (size_t nTab = nTabFirstId; nTab <= nTabLastId; ++nTab)
@@ -462,7 +464,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
bFirstTab = false;
}
- rDoc.maRangeArrays.insert(RangeArrayMap::value_type(rRange, pArray));
+ rDoc.maRangeArrays.insert( RangeArrayMap::value_type( aCacheRange, pArray));
return pArray;
}
@@ -545,13 +547,13 @@ void ScExternalRefCache::setCellRangeData(sal_uInt16 nFileId, const ScRange& rRa
return;
}
- size_t nTab1 = itrTabName->second;
+ size_t nTabFirstId = itrTabName->second;
SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row();
SCCOL nCol1 = rRange.aStart.Col(), nCol2 = rRange.aEnd.Col();
vector<SingleRangeData>::const_iterator itrDataBeg = rData.begin(), itrDataEnd = rData.end();
for (vector<SingleRangeData>::const_iterator itrData = itrDataBeg; itrData != itrDataEnd; ++itrData)
{
- size_t i = nTab1 + ::std::distance(itrDataBeg, itrData);
+ size_t i = nTabFirstId + ::std::distance(itrDataBeg, itrData);
TableTypeRef& pTabData = rDoc.maTables[i];
if (!pTabData.get())
pTabData.reset(new Table);
@@ -575,7 +577,9 @@ void ScExternalRefCache::setCellRangeData(sal_uInt16 nFileId, const ScRange& rRa
}
}
- rDoc.maRangeArrays.insert(RangeArrayMap::value_type(rRange, pArray));
+ size_t nTabLastId = nTabFirstId + rRange.aEnd.Tab() - rRange.aStart.Tab();
+ ScRange aCacheRange( nCol1, nRow1, static_cast<SCTAB>(nTabFirstId), nCol2, nRow2, static_cast<SCTAB>(nTabLastId));
+ rDoc.maRangeArrays.insert( RangeArrayMap::value_type( aCacheRange, pArray));
}
bool ScExternalRefCache::isDocInitialized(sal_uInt16 nFileId)
@@ -950,9 +954,18 @@ ScExternalRefCache::TableTypeRef ScExternalRefCache::getCacheTable(sal_uInt16 nF
ScExternalRefCache::TableTypeRef ScExternalRefCache::getCacheTable(sal_uInt16 nFileId, const String& rTabName, bool bCreateNew, size_t* pnIndex)
{
+ // In API, the index is transported as cached sheet ID of type sal_Int32 in
+ // sheet::SingleReference.Sheet or sheet::ComplexReference.Reference1.Sheet
+ // in a sheet::FormulaToken, choose a sensible value for N/A. Effectively
+ // being 0xffffffff
+ const size_t nNotAvailable = static_cast<size_t>( static_cast<sal_Int32>( -1));
+
DocItem* pDoc = getDocItem(nFileId);
if (!pDoc)
+ {
+ if (pnIndex) *pnIndex = nNotAvailable;
return TableTypeRef();
+ }
DocItem& rDoc = *pDoc;
@@ -966,7 +979,10 @@ ScExternalRefCache::TableTypeRef ScExternalRefCache::getCacheTable(sal_uInt16 nF
}
if (!bCreateNew)
+ {
+ if (pnIndex) *pnIndex = nNotAvailable;
return TableTypeRef();
+ }
// Specified table doesn't exist yet. Create one.
nIndex = rDoc.maTables.size();
@@ -1045,7 +1061,7 @@ void ScExternalRefLink::DataChanged(const String& /*rMimeType*/, const Any& /*rV
else
{
// The source document has changed.
- pMgr->switchSrcFile(mnFileId, aFile);
+ pMgr->switchSrcFile(mnFileId, aFile, aFilter);
maFilterName = aFilter;
}
}
@@ -1891,24 +1907,17 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, Stri
if (!pFileData)
return NULL;
+ // Always load the document by using the path created from the relative
+ // path. If the referenced document is not there, simply exit. The
+ // original file name should be used only when the relative path is not
+ // given.
String aFile = pFileData->maFileName;
- if (!isFileLoadable(aFile))
- {
- // The original file path is not loadable. Try the relative path.
- // Note that the path is relative to the content.xml substream which
- // is one-level higher than the file itself.
+ maybeCreateRealFileName(nFileId);
+ if (pFileData->maRealFileName.Len())
+ aFile = pFileData->maRealFileName;
- if (!pFileData->maRelativeName.Len())
- return NULL;
-
- INetURLObject aBaseURL(getOwnDocumentName());
- aBaseURL.insertName(OUString::createFromAscii("content.xml"));
- bool bWasAbs = false;
- aFile = aBaseURL.smartRel2Abs(pFileData->maRelativeName, bWasAbs).GetMainURL(INetURLObject::NO_DECODE);
- if (!isFileLoadable(aFile))
- // Ok, I've tried both paths but no success. Bail out.
- return NULL;
- }
+ if (!isFileLoadable(aFile))
+ return NULL;
String aOptions;
ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false);
@@ -1960,6 +1969,9 @@ SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, Stri
bool ScExternalRefManager::isFileLoadable(const String& rFile) const
{
+ if (!rFile.Len())
+ return false;
+
if (isOwnDocument(rFile))
return false;
@@ -1994,6 +2006,32 @@ void ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId)
maLinkedDocs.insert(LinkedDocMap::value_type(nFileId, true));
}
+void ScExternalRefManager::SrcFileData::maybeCreateRealFileName(const String& rOwnDocName)
+{
+ if (!maRelativeName.Len())
+ // No relative path given. Nothing to do.
+ return;
+
+ if (maRealFileName.Len())
+ // Real file name already created. Nothing to do.
+ return;
+
+ // Formulate the absolute file path from the relative path.
+ const String& rRelPath = maRelativeName;
+ INetURLObject aBaseURL(rOwnDocName);
+ aBaseURL.insertName(OUString::createFromAscii("content.xml"));
+ bool bWasAbs = false;
+ maRealFileName = aBaseURL.smartRel2Abs(rRelPath, bWasAbs).GetMainURL(INetURLObject::NO_DECODE);
+}
+
+void ScExternalRefManager::maybeCreateRealFileName(sal_uInt16 nFileId)
+{
+ if (nFileId >= maSrcFiles.size())
+ return;
+
+ maSrcFiles[nFileId].maybeCreateRealFileName(getOwnDocumentName());
+}
+
bool ScExternalRefManager::compileTokensByCell(const ScAddress& rCell)
{
ScBaseCell* pCell;
@@ -2064,12 +2102,20 @@ sal_uInt16 ScExternalRefManager::getExternalFileId(const String& rFile)
return static_cast<sal_uInt16>(maSrcFiles.size() - 1);
}
-const String* ScExternalRefManager::getExternalFileName(sal_uInt16 nFileId) const
+const String* ScExternalRefManager::getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal)
{
if (nFileId >= maSrcFiles.size())
return NULL;
- return &maSrcFiles[nFileId].maFileName;
+ if (bForceOriginal)
+ return &maSrcFiles[nFileId].maFileName;
+
+ maybeCreateRealFileName(nFileId);
+
+ if (maSrcFiles[nFileId].maRealFileName.Len())
+ return &maSrcFiles[nFileId].maRealFileName;
+ else
+ return &maSrcFiles[nFileId].maFileName;
}
bool ScExternalRefManager::hasExternalFile(sal_uInt16 nFileId) const
@@ -2138,10 +2184,17 @@ void ScExternalRefManager::breakLink(sal_uInt16 nFileId)
notifyAllLinkListeners(nFileId, LINK_BROKEN);
}
-void ScExternalRefManager::switchSrcFile(sal_uInt16 nFileId, const String& rNewFile)
+void ScExternalRefManager::switchSrcFile(sal_uInt16 nFileId, const String& rNewFile, const String& rNewFilter)
{
maSrcFiles[nFileId].maFileName = rNewFile;
maSrcFiles[nFileId].maRelativeName.Erase();
+ maSrcFiles[nFileId].maRealFileName.Erase();
+ if (!maSrcFiles[nFileId].maFilterName.Equals(rNewFilter))
+ {
+ // Filter type has changed.
+ maSrcFiles[nFileId].maFilterName = rNewFilter;
+ maSrcFiles[nFileId].maFilterOptions.Erase();
+ }
refreshNames(nFileId);
}
@@ -2175,19 +2228,18 @@ bool ScExternalRefManager::hasExternalData() const
return !maSrcFiles.empty();
}
-void ScExternalRefManager::resetSrcFileData()
+void ScExternalRefManager::resetSrcFileData(const String& rBaseFileUrl)
{
- INetURLObject aBaseURL(getOwnDocumentName());
- aBaseURL.insertName(OUString::createFromAscii("content.xml"));
- String aBaseUrlStr = aBaseURL.GetMainURL(INetURLObject::NO_DECODE);
for (vector<SrcFileData>::iterator itr = maSrcFiles.begin(), itrEnd = maSrcFiles.end();
itr != itrEnd; ++itr)
{
- if (!itr->maRelativeName.Len())
- {
- itr->maRelativeName = URIHelper::simpleNormalizedMakeRelative(
- aBaseUrlStr, itr->maFileName);
- }
+ // Re-generate relative file name from the absolute file name.
+ String aAbsName = itr->maRealFileName;
+ if (!aAbsName.Len())
+ aAbsName = itr->maFileName;
+
+ itr->maRelativeName = URIHelper::simpleNormalizedMakeRelative(
+ rBaseFileUrl, aAbsName);
}
}
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 67186f84a84a..1561e4c6efeb 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -253,7 +253,7 @@ BOOL ScImportExport::StartPaste()
{
pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
pUndoDoc->InitUndo( pDoc, aRange.aStart.Tab(), aRange.aEnd.Tab() );
- pDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( aRange, IDF_ALL | IDF_NOCAPTIONS, FALSE, pUndoDoc );
}
return TRUE;
}
@@ -270,7 +270,7 @@ void ScImportExport::EndPaste()
{
ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
pRedoDoc->InitUndo( pDoc, aRange.aStart.Tab(), aRange.aEnd.Tab() );
- pDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pRedoDoc );
+ pDoc->CopyToDocument( aRange, IDF_ALL | IDF_NOCAPTIONS, FALSE, pRedoDoc );
ScMarkData aDestMark;
aDestMark.SelectOneTable( aRange.aStart.Tab() );
pDocSh->GetUndoManager()->AddUndoAction(
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
index 8c175f0cd3a9..d241843f9745 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -201,7 +201,7 @@ void __EXPORT ScDrawTextObjectBar::Execute( SfxRequest &rReq )
}
break;
- case FID_PASTE_CONTENTS:
+ case SID_PASTE_SPECIAL:
ExecutePasteContents( rReq );
break;
@@ -467,7 +467,7 @@ IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pData
SfxBindings& rBindings = pViewData->GetBindings();
rBindings.Invalidate( SID_PASTE );
- rBindings.Invalidate( FID_PASTE_CONTENTS );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
}
return 0;
@@ -502,7 +502,7 @@ void __EXPORT ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
switch (nWhich)
{
case SID_PASTE:
- case FID_PASTE_CONTENTS:
+ case SID_PASTE_SPECIAL:
if( !bPastePossible )
rSet.DisableItem( nWhich );
break;
diff --git a/sc/source/ui/drawfunc/drtxtob2.cxx b/sc/source/ui/drawfunc/drtxtob2.cxx
index a011de6fa0e9..d05e0568c1ca 100644
--- a/sc/source/ui/drawfunc/drtxtob2.cxx
+++ b/sc/source/ui/drawfunc/drtxtob2.cxx
@@ -91,7 +91,7 @@ void __EXPORT ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq )
break;
case SID_PASTE:
- case FID_PASTE_CONTENTS:
+ case SID_PASTE_SPECIAL:
case SID_CLIPBOARD_FORMAT_ITEMS:
case SID_HYPERLINK_SETLINK:
{
diff --git a/sc/source/ui/navipi/navipi.src b/sc/source/ui/navipi/navipi.src
index f5eaeb56bae1..6d5baba4d075 100644
--- a/sc/source/ui/navipi/navipi.src
+++ b/sc/source/ui/navipi/navipi.src
@@ -320,7 +320,7 @@ String SCSTR_CONTENT_OLEOBJECT
};
String SCSTR_CONTENT_NOTE
{
- Text [ en-US ] = "Notes" ;
+ Text [ en-US ] = "Comments" ;
};
String SCSTR_CONTENT_AREALINK
{
diff --git a/sc/source/ui/pagedlg/pagedlg.src b/sc/source/ui/pagedlg/pagedlg.src
index a031fbe464c9..6db6b1c06cc7 100644
--- a/sc/source/ui/pagedlg/pagedlg.src
+++ b/sc/source/ui/pagedlg/pagedlg.src
@@ -175,7 +175,7 @@ TabPage RID_SCPAGE_TABLE
{
Pos = MAP_APPFONT ( 12 , 101 ) ;
Size = MAP_APPFONT ( 142 , 10 ) ;
- Text [ en-US ] = "~Notes" ;
+ Text [ en-US ] = "~Comments" ;
TabStop = TRUE ;
};
CheckBox BTN_OBJECTS
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index c5b8cfd1a9e8..fb3890616aa0 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -304,23 +304,23 @@ Resource RID_GLOBSTR
};
String STR_UNDO_INSERTNOTE
{
- Text [ en-US ] = "Insert Note" ;
+ Text [ en-US ] = "Insert Comment" ;
};
String STR_UNDO_DELETENOTE
{
- Text [ en-US ] = "Delete Note" ;
+ Text [ en-US ] = "Delete Comment" ;
};
String STR_UNDO_SHOWNOTE
{
- Text [ en-US ] = "Show Note" ;
+ Text [ en-US ] = "Show Comment" ;
};
String STR_UNDO_HIDENOTE
{
- Text [ en-US ] = "Hide note" ;
+ Text [ en-US ] = "Hide Comment" ;
};
String STR_UNDO_EDITNOTE
{
- Text [ en-US ] = "Edit Note" ;
+ Text [ en-US ] = "Edit Comment" ;
};
String STR_UNDO_DEC_INDENT
{
@@ -1020,7 +1020,7 @@ Resource RID_GLOBSTR
};
String STR_NOTES
{
- Text [ en-US ] = "Notes" ;
+ Text [ en-US ] = "Comments" ;
};
String STR_QUERY_DELTAB
{
@@ -1260,7 +1260,7 @@ Resource RID_GLOBSTR
};
String STR_SCATTR_PAGE_NOTES
{
- Text [ en-US ] = "Notes" ;
+ Text [ en-US ] = "Comments" ;
};
String STR_SCATTR_PAGE_GRID
{
diff --git a/sc/source/ui/src/hdrcont.src b/sc/source/ui/src/hdrcont.src
index 6b80e2597b87..7ba7b6a1c8fe 100644
--- a/sc/source/ui/src/hdrcont.src
+++ b/sc/source/ui/src/hdrcont.src
@@ -136,8 +136,8 @@ Menu RID_POPUP_ROWHEADER
PART2
MenuItem
{
- Identifier = FID_PASTE_CONTENTS ;
- HelpId = FID_PASTE_CONTENTS ;
+ Identifier = SID_PASTE_SPECIAL ;
+ HelpId = SID_PASTE_SPECIAL ;
Text [ en-US ] = "P~aste Special..." ;
};
};
@@ -214,8 +214,8 @@ Menu RID_POPUP_COLHEADER
PART2
MenuItem
{
- Identifier = FID_PASTE_CONTENTS ;
- HelpId = FID_PASTE_CONTENTS ;
+ Identifier = SID_PASTE_SPECIAL ;
+ HelpId = SID_PASTE_SPECIAL ;
Text [ en-US ] = "Paste ~Special..." ;
};
};
diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src
index ed84da38b742..66e42d08dcef 100644
--- a/sc/source/ui/src/optdlg.src
+++ b/sc/source/ui/src/optdlg.src
@@ -363,7 +363,7 @@ TabPage RID_SCPAGE_CONTENT
{
Pos = MAP_APPFONT ( 139 , 40 ) ;
Size = MAP_APPFONT ( 112 , 10 ) ;
- Text [ en-US ] = "~Note indicator" ;
+ Text [ en-US ] = "~Comment indicator" ;
};
CheckBox CB_VALUE
{
diff --git a/sc/source/ui/src/popup.src b/sc/source/ui/src/popup.src
index 05d10b9813bd..b03c0c0ae135 100644
--- a/sc/source/ui/src/popup.src
+++ b/sc/source/ui/src/popup.src
@@ -86,19 +86,19 @@ Menu RID_POPUP_CELLS
{
Identifier = SID_INSERT_POSTIT ;
HelpId = SID_INSERT_POSTIT ;
- Text [ en-US ] = "Insert ~Note" ;
+ Text [ en-US ] = "Insert Co~mment" ;
};
MenuItem
{
Identifier = SID_DELETE_NOTE ;
HelpId = SID_DELETE_NOTE ;
- Text [ en-US ] = "D~elete Note" ;
+ Text [ en-US ] = "D~elete Comment" ;
};
MenuItem
{
Identifier = FID_NOTE_VISIBLE ;
HelpId = FID_NOTE_VISIBLE ;
- Text [ en-US ] = "Sho~w Note" ;
+ Text [ en-US ] = "Sho~w Comment" ;
};
//------------------------------
MenuItem { Separator = TRUE ; };
@@ -126,8 +126,8 @@ Menu RID_POPUP_CELLS
MenuItem
{
- Identifier = FID_PASTE_CONTENTS ;
- HelpId = FID_PASTE_CONTENTS ;
+ Identifier = SID_PASTE_SPECIAL ;
+ HelpId = SID_PASTE_SPECIAL ;
Text [ en-US ] = "P~aste Special..." ;
};
//------------------------------
@@ -524,7 +524,7 @@ Menu RID_POPUP_PAGEBREAK
{
Identifier = FID_NOTE_VISIBLE ;
HelpId = FID_NOTE_VISIBLE ;
- Text [ en-US ] = "Sho~w Note" ;
+ Text [ en-US ] = "Sho~w Comment" ;
};
};
};
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 3df8e99348c0..8cc45d41a2e6 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -442,7 +442,7 @@ void ScUndoDeleteCells::DoChange( const BOOL bUndo )
for( i=0; i<nCount && bUndo; i++ )
{
pRefUndoDoc->CopyToDocument( aEffRange.aStart.Col(), aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Col(), aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i],
- IDF_ALL, FALSE, pDoc );
+ IDF_ALL | IDF_NOCAPTIONS, FALSE, pDoc );
}
ScRange aWorkRange( aEffRange );
@@ -1729,8 +1729,8 @@ void __EXPORT ScUndoEnterMatrix::Undo()
ScDocument* pDoc = pDocShell->GetDocument();
- pDoc->DeleteAreaTab( aBlockRange, IDF_ALL );
- pUndoDoc->CopyToDocument( aBlockRange, IDF_ALL, FALSE, pDoc );
+ pDoc->DeleteAreaTab( aBlockRange, IDF_ALL & ~IDF_NOTE );
+ pUndoDoc->CopyToDocument( aBlockRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
pDocShell->PostPaint( aBlockRange, PAINT_GRID );
pDocShell->PostDataChanged();
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
index ea1e303d6ae3..4a94827ed1ec 100644
--- a/sc/source/ui/undo/undoblk3.cxx
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -1340,8 +1340,8 @@ void __EXPORT ScUndoTabOp::Undo()
pDocShell->UpdatePaintExt( nExtFlags, aRange );
ScDocument* pDoc = pDocShell->GetDocument();
- pDoc->DeleteAreaTab( aRange,IDF_ALL );
- pUndoDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pDoc );
+ pDoc->DeleteAreaTab( aRange,IDF_ALL & ~IDF_NOTE );
+ pUndoDoc->CopyToDocument( aRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
pDocShell->PostPaint( aRange, PAINT_GRID, nExtFlags );
pDocShell->PostDataChanged();
ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
@@ -2023,14 +2023,14 @@ void ScUndoUpdateAreaLink::DoChange( const BOOL bUndo ) const
if ( bWithInsert )
{
pDoc->FitBlock( aNewRange, aOldRange );
- pDoc->DeleteAreaTab( aOldRange, IDF_ALL );
- pUndoDoc->UndoToDocument( aOldRange, IDF_ALL, FALSE, pDoc );
+ pDoc->DeleteAreaTab( aOldRange, IDF_ALL & ~IDF_NOTE );
+ pUndoDoc->UndoToDocument( aOldRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
}
else
{
ScRange aCopyRange( aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ) );
- pDoc->DeleteAreaTab( aCopyRange, IDF_ALL );
- pUndoDoc->CopyToDocument( aCopyRange, IDF_ALL, FALSE, pDoc );
+ pDoc->DeleteAreaTab( aCopyRange, IDF_ALL & ~IDF_NOTE );
+ pUndoDoc->CopyToDocument( aCopyRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
}
}
else
@@ -2038,14 +2038,14 @@ void ScUndoUpdateAreaLink::DoChange( const BOOL bUndo ) const
if ( bWithInsert )
{
pDoc->FitBlock( aOldRange, aNewRange );
- pDoc->DeleteAreaTab( aNewRange, IDF_ALL );
- pRedoDoc->CopyToDocument( aNewRange, IDF_ALL, FALSE, pDoc );
+ pDoc->DeleteAreaTab( aNewRange, IDF_ALL & ~IDF_NOTE );
+ pRedoDoc->CopyToDocument( aNewRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
}
else
{
ScRange aCopyRange( aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ) );
- pDoc->DeleteAreaTab( aCopyRange, IDF_ALL );
- pRedoDoc->CopyToDocument( aCopyRange, IDF_ALL, FALSE, pDoc );
+ pDoc->DeleteAreaTab( aCopyRange, IDF_ALL & ~IDF_NOTE );
+ pRedoDoc->CopyToDocument( aCopyRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
}
}
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index f16409b37239..7ab321ac0c1d 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -1302,8 +1302,8 @@ void __EXPORT ScUndoImportData::Undo()
for (SCCOL nCopyCol = nCol1; nCopyCol <= nCol2; nCopyCol++)
{
pDoc->CopyToDocument( nCopyCol,nRow1,nTab, nCopyCol,nRow2,nTab,
- IDF_CONTENTS, FALSE, pRedoDoc );
- pDoc->DeleteAreaTab( nCopyCol,nRow1, nCopyCol,nRow2, nTab, IDF_CONTENTS );
+ IDF_CONTENTS & ~IDF_NOTE, FALSE, pRedoDoc );
+ pDoc->DeleteAreaTab( nCopyCol,nRow1, nCopyCol,nRow2, nTab, IDF_CONTENTS & ~IDF_NOTE );
pDoc->DoColResize( nTab, nCopyCol, nCopyCol, 0 );
}
pDoc->SetAutoCalc( bOldAutoCalc );
@@ -1321,7 +1321,7 @@ void __EXPORT ScUndoImportData::Undo()
pRedoDBData->GetArea( aNew );
pDoc->DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(),
- aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL );
+ aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL & ~IDF_NOTE );
aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols ); // FitBlock auch fuer Formeln
aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols );
@@ -1329,11 +1329,11 @@ void __EXPORT ScUndoImportData::Undo()
}
else
pDoc->DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1,
- nEndCol,nEndRow, nTab, IDF_ALL );
+ nEndCol,nEndRow, nTab, IDF_ALL & ~IDF_NOTE );
pUndoDoc->CopyToDocument( aImportParam.nCol1,aImportParam.nRow1,nTab,
nEndCol+nFormulaCols,nEndRow,nTab,
- IDF_ALL, FALSE, pDoc );
+ IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
if (pCurrentData)
{
@@ -1395,16 +1395,16 @@ void __EXPORT ScUndoImportData::Redo()
pDoc->FitBlock( aOld, aNew );
pDoc->DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(),
- aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL );
+ aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL & ~IDF_NOTE );
- pRedoDoc->CopyToDocument( aNew, IDF_ALL, FALSE, pDoc ); // incl. Formeln
+ pRedoDoc->CopyToDocument( aNew, IDF_ALL & ~IDF_NOTE, FALSE, pDoc ); // incl. Formeln
}
else
{
pDoc->DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1,
- nEndCol,nEndRow, nTab, IDF_ALL );
+ nEndCol,nEndRow, nTab, IDF_ALL & ~IDF_NOTE );
pRedoDoc->CopyToDocument( aImportParam.nCol1,aImportParam.nRow1,nTab,
- nEndCol,nEndRow,nTab, IDF_ALL, FALSE, pDoc );
+ nEndCol,nEndRow,nTab, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
}
if (pCurrentData)
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index cfe51aed6edc..f3418a84e2ef 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1093,7 +1093,7 @@ BOOL lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
{
pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
pUndoDoc->InitUndo( pDoc, nTab, nTab );
- pDoc->CopyToDocument( rRange, IDF_CONTENTS, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( rRange, IDF_CONTENTS|IDF_NOCAPTIONS, FALSE, pUndoDoc );
}
pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index d63fbb837e44..07ed8709ab01 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -500,6 +500,10 @@ void Chart2Positioner::glueState()
ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr);
SCCOLROW n1 = aData.Ref1.nCol;
SCCOLROW n2 = aData.Ref2.nCol;
+ if (n1 > MAXCOL)
+ n1 = MAXCOL;
+ if (n2 > MAXCOL)
+ n2 = MAXCOL;
SCCOLROW nTmp = n2 - n1 + 1;
if (n1 < mnStartCol)
mnStartCol = static_cast<SCCOL>(n1);
@@ -510,14 +514,18 @@ void Chart2Positioner::glueState()
n1 = aData.Ref1.nRow;
n2 = aData.Ref2.nRow;
+ if (n1 > MAXROW)
+ n1 = MAXROW;
+ if (n2 > MAXROW)
+ n2 = MAXROW;
nTmp = n2 - n1 + 1;
if (n1 < mnStartRow)
- mnStartRow = static_cast<SCCOL>(n1);
+ mnStartRow = static_cast<SCROW>(n1);
if (n2 > nEndRow)
- nEndRow = static_cast<SCCOL>(n2);
+ nEndRow = static_cast<SCROW>(n2);
if (nTmp > nMaxRows)
- nMaxRows = static_cast<SCCOL>(nTmp);
+ nMaxRows = static_cast<SCROW>(nTmp);
}
// total column size ?
@@ -534,6 +542,14 @@ void Chart2Positioner::glueState()
meGlue = GLUETYPE_COLS;
return;
}
+ // #i103540# prevent invalid vector size
+ if ((nC <= 0) || (nR <= 0))
+ {
+ invalidateGlue();
+ mnStartCol = 0;
+ mnStartRow = 0;
+ return;
+ }
sal_uInt32 nCR = static_cast<sal_uInt32>(nC*nR);
const sal_uInt8 nHole = 0;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index cd63adc33989..3e2295d73471 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -221,7 +221,8 @@ ScModelObj::ScModelObj( ScDocShell* pDocSh ) :
aPropSet( lcl_GetDocOptPropertyMap() ),
pDocShell( pDocSh ),
pPrintFuncCache( NULL ),
- maChangesListeners( m_aMutex )
+ maChangesListeners( m_aMutex ),
+ mnXlsWriteProtPass( 0 )
{
// pDocShell may be NULL if this is the base of a ScDocOptionsObj
if ( pDocShell )
@@ -1448,6 +1449,14 @@ void SAL_CALL ScModelObj::setPropertyValue(
if ( aObjName.getLength() )
pDoc->RestoreChartListener( aObjName );
}
+ else if ( aString.EqualsAscii( "WriteProtectionPassword" ) )
+ {
+ /* This is a hack for #160550# to preserve the write-protection
+ password in an XLS roundtrip. This property MUST NOT be used
+ for any other purpose. This property will be deleted when the
+ feature "Write Protection With Password" will be implemented. */
+ aValue >>= mnXlsWriteProtPass;
+ }
if ( aNewOpt != rOldOpt )
{
@@ -1610,6 +1619,14 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyNa
{
ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL) );
}
+ else if ( aString.EqualsAscii( "WriteProtectionPassword" ) )
+ {
+ /* This is a hack for #160550# to preserve the write-protection
+ password in an XLS roundtrip. This property MUST NOT be used
+ for any other purpose. This property will be deleted when the
+ feature "Write Protection With Password" will be implemented. */
+ aRet <<= mnXlsWriteProtPass;
+ }
}
return aRet;
diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx
index 1b17c2e130ac..6ed8181091ac 100644
--- a/sc/source/ui/unoobj/scdetect.cxx
+++ b/sc/source/ui/unoobj/scdetect.cxx
@@ -350,7 +350,7 @@ static BOOL lcl_IsAnyXMLFilter( const SfxFilter* pFilter )
// maybe that IsStorage() already created an error!
if ( bIsStorage )
{
- uno::Reference < embed::XStorage > xStorage(aMedium.GetStorage());
+ uno::Reference < embed::XStorage > xStorage(aMedium.GetStorage( sal_False ));
if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE )
{
// error during storage creation means _here_ that the medium
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
index 71f45e6ab12b..1f51bc1646af 100644
--- a/sc/source/ui/unoobj/servuno.cxx
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -65,55 +65,71 @@ using namespace ::com::sun::star;
//------------------------------------------------------------------------
+//
+struct ProvNamesId_Type
+{
+ const char * pName;
+ sal_uInt16 nType;
+};
-static const sal_Char* __FAR_DATA aProvNames[SC_SERVICE_COUNT] =
- {
- "com.sun.star.sheet.Spreadsheet", // SC_SERVICE_SHEET
- "com.sun.star.text.TextField.URL", // SC_SERVICE_URLFIELD
- "com.sun.star.text.TextField.PageNumber", // SC_SERVICE_PAGEFIELD
- "com.sun.star.text.TextField.PageCount", // SC_SERVICE_PAGESFIELD
- "com.sun.star.text.TextField.Date", // SC_SERVICE_DATEFIELD
- "com.sun.star.text.TextField.Time", // SC_SERVICE_TIMEFIELD
- "com.sun.star.text.TextField.DocumentTitle",// SC_SERVICE_TITLEFIELD
- "com.sun.star.text.TextField.FileName", // SC_SERVICE_FILEFIELD
- "com.sun.star.text.TextField.SheetName", // SC_SERVICE_SHEETFIELD
- "com.sun.star.style.CellStyle", // SC_SERVICE_CELLSTYLE
- "com.sun.star.style.PageStyle", // SC_SERVICE_PAGESTYLE
- "com.sun.star.sheet.TableAutoFormat", // SC_SERVICE_AUTOFORMAT
- "com.sun.star.sheet.SheetCellRanges", // SC_SERVICE_CELLRANGES
- "com.sun.star.drawing.GradientTable", // SC_SERVICE_GRADTAB
- "com.sun.star.drawing.HatchTable", // SC_SERVICE_HATCHTAB
- "com.sun.star.drawing.BitmapTable", // SC_SERVICE_BITMAPTAB
- "com.sun.star.drawing.TransparencyGradientTable", // SC_SERVICE_TRGRADTAB
- "com.sun.star.drawing.MarkerTable", // SC_SERVICE_MARKERTAB
- "com.sun.star.drawing.DashTable", // SC_SERVICE_DASHTAB
- "com.sun.star.text.NumberingRules", // SC_SERVICE_NUMRULES
- "com.sun.star.sheet.Defaults", // SC_SERVICE_DOCDEFLTS
- "com.sun.star.drawing.Defaults", // SC_SERVICE_DRAWDEFLTS
- "com.sun.star.comp.SpreadsheetSettings", // SC_SERVICE_DOCSPRSETT
- "com.sun.star.document.Settings", // SC_SERVICE_DOCCONF
- "com.sun.star.image.ImageMapRectangleObject",// SC_SERVICE_IMAP_RECT
- "com.sun.star.image.ImageMapCircleObject", // SC_SERVICE_IMAP_CIRC
- "com.sun.star.image.ImageMapPolygonObject", // SC_SERVICE_IMAP_POLY
+static const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
+{
+ { "com.sun.star.sheet.Spreadsheet", SC_SERVICE_SHEET },
+ { "com.sun.star.text.TextField.URL", SC_SERVICE_URLFIELD },
+ { "com.sun.star.text.TextField.PageNumber", SC_SERVICE_PAGEFIELD },
+ { "com.sun.star.text.TextField.PageCount", SC_SERVICE_PAGESFIELD },
+ { "com.sun.star.text.TextField.Date", SC_SERVICE_DATEFIELD },
+ { "com.sun.star.text.TextField.Time", SC_SERVICE_TIMEFIELD },
+ { "com.sun.star.text.TextField.DocumentTitle", SC_SERVICE_TITLEFIELD },
+ { "com.sun.star.text.TextField.FileName", SC_SERVICE_FILEFIELD },
+ { "com.sun.star.text.TextField.SheetName", SC_SERVICE_SHEETFIELD },
+ { "com.sun.star.style.CellStyle", SC_SERVICE_CELLSTYLE },
+ { "com.sun.star.style.PageStyle", SC_SERVICE_PAGESTYLE },
+ { "com.sun.star.sheet.TableAutoFormat", SC_SERVICE_AUTOFORMAT },
+ { "com.sun.star.sheet.SheetCellRanges", SC_SERVICE_CELLRANGES },
+ { "com.sun.star.drawing.GradientTable", SC_SERVICE_GRADTAB },
+ { "com.sun.star.drawing.HatchTable", SC_SERVICE_HATCHTAB },
+ { "com.sun.star.drawing.BitmapTable", SC_SERVICE_BITMAPTAB },
+ { "com.sun.star.drawing.TransparencyGradientTable", SC_SERVICE_TRGRADTAB },
+ { "com.sun.star.drawing.MarkerTable", SC_SERVICE_MARKERTAB },
+ { "com.sun.star.drawing.DashTable", SC_SERVICE_DASHTAB },
+ { "com.sun.star.text.NumberingRules", SC_SERVICE_NUMRULES },
+ { "com.sun.star.sheet.Defaults", SC_SERVICE_DOCDEFLTS },
+ { "com.sun.star.drawing.Defaults", SC_SERVICE_DRAWDEFLTS },
+ { "com.sun.star.comp.SpreadsheetSettings", SC_SERVICE_DOCSPRSETT },
+ { "com.sun.star.document.Settings", SC_SERVICE_DOCCONF },
+ { "com.sun.star.image.ImageMapRectangleObject", SC_SERVICE_IMAP_RECT },
+ { "com.sun.star.image.ImageMapCircleObject", SC_SERVICE_IMAP_CIRC },
+ { "com.sun.star.image.ImageMapPolygonObject", SC_SERVICE_IMAP_POLY },
// #100263# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
- "com.sun.star.document.ExportGraphicObjectResolver", // SC_SERVICE_EXPORT_GOR
- "com.sun.star.document.ImportGraphicObjectResolver", // SC_SERVICE_IMPORT_GOR
- "com.sun.star.document.ExportEmbeddedObjectResolver", // SC_SERVICE_EXPORT_EOR
- "com.sun.star.document.ImportEmbeddedObjectResolver", // SC_SERVICE_IMPORT_EOR
-
- SC_SERVICENAME_VALBIND, // SC_SERVICE_VALBIND
- SC_SERVICENAME_LISTCELLBIND, // SC_SERVICE_LISTCELLBIND
- SC_SERVICENAME_LISTSOURCE, // SC_SERVICE_LISTSOURCE
- SC_SERVICENAME_CELLADDRESS, // SC_SERVICE_CELLADDRESS
- SC_SERVICENAME_RANGEADDRESS, // SC_SERVICE_RANGEADDRESS
-
- "com.sun.star.sheet.DocumentSettings", // SC_SERVICE_SHEETDOCSET
-
- SC_SERVICENAME_CHDATAPROV, // SC_SERVICE_CHDATAPROV
- SC_SERVICENAME_FORMULAPARS, // SC_SERVICE_FORMULAPARS
- SC_SERVICENAME_OPCODEMAPPER // SC_SERVICE_OPCODEMAPPER
- };
+ { "com.sun.star.document.ExportGraphicObjectResolver", SC_SERVICE_EXPORT_GOR },
+ { "com.sun.star.document.ImportGraphicObjectResolver", SC_SERVICE_IMPORT_GOR },
+ { "com.sun.star.document.ExportEmbeddedObjectResolver", SC_SERVICE_EXPORT_EOR },
+ { "com.sun.star.document.ImportEmbeddedObjectResolver", SC_SERVICE_IMPORT_EOR },
+
+ { SC_SERVICENAME_VALBIND, SC_SERVICE_VALBIND },
+ { SC_SERVICENAME_LISTCELLBIND, SC_SERVICE_LISTCELLBIND },
+ { SC_SERVICENAME_LISTSOURCE, SC_SERVICE_LISTSOURCE },
+ { SC_SERVICENAME_CELLADDRESS, SC_SERVICE_CELLADDRESS },
+ { SC_SERVICENAME_RANGEADDRESS, SC_SERVICE_RANGEADDRESS },
+
+ { "com.sun.star.sheet.DocumentSettings",SC_SERVICE_SHEETDOCSET },
+
+ { SC_SERVICENAME_CHDATAPROV, SC_SERVICE_CHDATAPROV },
+ { SC_SERVICENAME_FORMULAPARS, SC_SERVICE_FORMULAPARS },
+ { SC_SERVICENAME_OPCODEMAPPER, SC_SERVICE_OPCODEMAPPER },
+
+ // case-correct versions of the service names (#i102468#)
+ { "com.sun.star.text.textfield.URL", SC_SERVICE_URLFIELD },
+ { "com.sun.star.text.textfield.PageNumber", SC_SERVICE_PAGEFIELD },
+ { "com.sun.star.text.textfield.PageCount", SC_SERVICE_PAGESFIELD },
+ { "com.sun.star.text.textfield.Date", SC_SERVICE_DATEFIELD },
+ { "com.sun.star.text.textfield.Time", SC_SERVICE_TIMEFIELD },
+ { "com.sun.star.text.textfield.DocumentTitle", SC_SERVICE_TITLEFIELD },
+ { "com.sun.star.text.textfield.FileName", SC_SERVICE_FILEFIELD },
+ { "com.sun.star.text.textfield.SheetName", SC_SERVICE_SHEETFIELD },
+};
//
// old service names that were in 567 still work in createInstance,
@@ -186,11 +202,17 @@ sal_uInt16 ScServiceProvider::GetProviderType(const String& rServiceName)
{
if (rServiceName.Len())
{
- USHORT i;
- for (i=0; i<SC_SERVICE_COUNT; i++)
- if (rServiceName.EqualsAscii( aProvNames[i] ))
- return i;
+ const sal_uInt16 nEntries =
+ sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
+ for (sal_uInt16 i = 0; i < nEntries; i++)
+ {
+ if (rServiceName.EqualsAscii( aProvNamesId[i].pName ))
+ {
+ return aProvNamesId[i].nType;
+ }
+ }
+ USHORT i;
for (i=0; i<SC_SERVICE_COUNT; i++)
{
DBG_ASSERT( aOldNames[i], "ScServiceProvider::GetProviderType: no oldname => crash");
@@ -369,10 +391,13 @@ uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
uno::Sequence<rtl::OUString> ScServiceProvider::GetAllServiceNames()
{
- uno::Sequence<rtl::OUString> aRet(SC_SERVICE_COUNT);
+ const sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
+ uno::Sequence<rtl::OUString> aRet(nEntries);
rtl::OUString* pArray = aRet.getArray();
- for (sal_uInt16 i = 0; i < SC_SERVICE_COUNT; i++)
- pArray[i] = rtl::OUString::createFromAscii( aProvNames[i] );
+ for (sal_uInt16 i = 0; i < nEntries; i++)
+ {
+ pArray[i] = rtl::OUString::createFromAscii( aProvNamesId[i].pName );
+ }
return aRet;
}
diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk
index fb1cc00488b8..71727297d078 100644
--- a/sc/source/ui/vba/makefile.mk
+++ b/sc/source/ui/vba/makefile.mk
@@ -45,7 +45,7 @@ DLLPRE =
dummy:
@echo "not building vba..."
.ENDIF
-
+.IF "$(L10N_framework)"==""
INCPRE=$(INCCOM)$/$(TARGET)
# ------------------------------------------------------------------
@@ -135,11 +135,13 @@ SLOFILES= \
$(SLO)$/vbaspinbutton.obj \
$(SLO)$/vbaimage.obj \
$(SLO)$/service.obj
-
+.ENDIF
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
+.IF "$(L10N_framework)"==""
+
ALLTAR : \
$(MISC)$/$(TARGET).don \
@@ -149,3 +151,4 @@ $(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
+$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
echo $@
+.ENDIF
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
index 0090ec42a0e9..c2d0f68fc6ef 100644
--- a/sc/source/ui/view/cellsh.cxx
+++ b/sc/source/ui/view/cellsh.cxx
@@ -442,7 +442,7 @@ IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
SfxBindings& rBindings = GetViewData()->GetBindings();
rBindings.Invalidate( SID_PASTE );
- rBindings.Invalidate( FID_PASTE_CONTENTS );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
}
return 0;
@@ -452,7 +452,7 @@ IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
void __EXPORT ScCellShell::GetClipState( SfxItemSet& rSet )
{
// SID_PASTE
-// FID_PASTE_CONTENTS
+// SID_PASTE_SPECIAL
// SID_CLIPBOARD_FORMAT_ITEMS
if ( !pImpl->m_pClipEvtLstnr )
@@ -489,7 +489,7 @@ void __EXPORT ScCellShell::GetClipState( SfxItemSet& rSet )
if (bDisable)
{
rSet.DisableItem( SID_PASTE );
- rSet.DisableItem( FID_PASTE_CONTENTS );
+ rSet.DisableItem( SID_PASTE_SPECIAL );
rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
}
else if ( rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) != SFX_ITEM_UNKNOWN )
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 7f632f62c2ba..f610e28b3fc5 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1387,7 +1387,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
pTabViewShell->CellContentChanged(); // => PasteFromXXX ???
break;
- case FID_PASTE_CONTENTS:
+ case SID_PASTE_SPECIAL:
// Unterscheidung, ob eigene oder fremde Daten,
// dadurch FID_INS_CELL_CONTENTS ueberfluessig
{
@@ -1485,43 +1485,6 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
break;
-#if 0
- // clipboard slots were used only for old basic:
-
- case SID_GET_CLPBRD_FORMAT_COUNT:
- rReq.SetReturnValue( SfxUInt16Item( nSlot, Clipboard::GetFormatCount() ) );
- break;
-
- case SID_GET_CLPBRD_FORMAT_BY_IDX:
- if (pReqArgs)
- {
- const SfxPoolItem* pItem;
- if ( pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET &&
- pItem->ISA(SfxUInt16Item) )
- {
- USHORT nCount = Clipboard::GetFormatCount();
- USHORT nPos = ((const SfxUInt16Item*)pItem)->GetValue(); // 1-based
- if ( nPos && nPos <= nCount )
- rReq.SetReturnValue( SfxUInt32Item( nSlot, Clipboard::GetFormat(--nPos) ) );
- }
- }
- break;
-
- case SID_GET_CLPBRD_FORMAT_NAME:
- if (pReqArgs)
- {
- const SfxPoolItem* pItem;
- if ( pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET &&
- pItem->ISA(SfxUInt32Item) )
- {
- String aName = Exchange::GetFormatName(
- ((const SfxUInt32Item*)pItem)->GetValue() );
- rReq.SetReturnValue( SfxStringItem( nSlot, aName ) );
- }
- }
- break;
-#endif
-
//
// sonstiges
//
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index d9c19f02058a..022eabdc11cf 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -268,7 +268,7 @@ void ScEditShell::Execute( SfxRequest& rReq )
}
break;
- case FID_PASTE_CONTENTS:
+ case SID_PASTE_SPECIAL:
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pViewData->GetDialogParent() );
@@ -714,7 +714,7 @@ IMPL_LINK( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
SfxBindings& rBindings = pViewData->GetBindings();
rBindings.Invalidate( SID_PASTE );
- rBindings.Invalidate( FID_PASTE_CONTENTS );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
}
return 0;
@@ -742,7 +742,7 @@ void __EXPORT ScEditShell::GetClipState( SfxItemSet& rSet )
switch (nWhich)
{
case SID_PASTE:
- case FID_PASTE_CONTENTS:
+ case SID_PASTE_SPECIAL:
if( !bPastePossible )
rSet.DisableItem( nWhich );
break;
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index f8cf331bc8cf..a19760e4c277 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -422,7 +422,7 @@ void ScTabView::SelectionChanged()
rBindings.Invalidate( SID_CUT );
rBindings.Invalidate( SID_COPY );
rBindings.Invalidate( SID_PASTE );
- rBindings.Invalidate( FID_PASTE_CONTENTS );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
rBindings.Invalidate( FID_INS_ROW );
rBindings.Invalidate( FID_INS_COLUMN );
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 4b5d59b80284..3065aa2fd4e1 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -465,7 +465,7 @@ BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut, BOOL bApi, BOOL bI
if (!bValidRanges)
break;
- pDoc->CopyToClip(aClipParam, pDocClip.get(), false, &rMark, false, bIncludeObjects);
+ pDoc->CopyToClip(aClipParam, pDocClip.get(), &rMark, false, false, bIncludeObjects);
ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
if ( pChangeTrack )
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index 0f3a1c812802..578f6c1fe733 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -155,7 +155,7 @@ void ScViewFunc::PasteRTF( SCCOL nStartCol, SCROW nStartRow,
{
ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
pRedoDoc->InitUndo( pDoc, nTab, nTab );
- pDoc->CopyToDocument( nStartCol,nStartRow,nTab, nStartCol,nEndRow,nTab, IDF_ALL, FALSE, pRedoDoc );
+ pDoc->CopyToDocument( nStartCol,nStartRow,nTab, nStartCol,nEndRow,nTab, IDF_ALL|IDF_NOCAPTIONS, FALSE, pRedoDoc );
ScMarkData aDestMark;
aDestMark.SelectOneTable( nTab );