1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SC_SHEETDATA_HXX 29 #define SC_SHEETDATA_HXX 30 31 #include <xmloff/maptype.hxx> 32 #include <editeng/editdata.hxx> 33 #include <vector> 34 #include <hash_set> 35 36 #include "address.hxx" 37 38 class ScAddress; 39 class SvXMLNamespaceMap; 40 41 42 struct ScStreamEntry 43 { 44 sal_Int32 mnStartOffset; 45 sal_Int32 mnEndOffset; 46 47 ScStreamEntry() : 48 mnStartOffset(-1), 49 mnEndOffset(-1) 50 { 51 } 52 53 ScStreamEntry( sal_Int32 nStart, sal_Int32 nEnd ) : 54 mnStartOffset(nStart), 55 mnEndOffset(nEnd) 56 { 57 } 58 }; 59 60 struct ScCellStyleEntry 61 { 62 rtl::OUString maName; 63 ScAddress maCellPos; 64 65 ScCellStyleEntry( const rtl::OUString& rName, const ScAddress& rPos ) : 66 maName(rName), 67 maCellPos(rPos) 68 { 69 } 70 }; 71 72 struct ScNoteStyleEntry 73 { 74 rtl::OUString maStyleName; 75 rtl::OUString maTextStyle; 76 ScAddress maCellPos; 77 78 ScNoteStyleEntry( const rtl::OUString& rStyle, const rtl::OUString& rText, const ScAddress& rPos ) : 79 maStyleName(rStyle), 80 maTextStyle(rText), 81 maCellPos(rPos) 82 { 83 } 84 }; 85 86 struct ScTextStyleEntry 87 { 88 rtl::OUString maName; 89 ScAddress maCellPos; 90 ESelection maSelection; 91 92 ScTextStyleEntry( const rtl::OUString& rName, const ScAddress& rPos, const ESelection& rSel ) : 93 maName(rName), 94 maCellPos(rPos), 95 maSelection(rSel) 96 { 97 } 98 }; 99 100 struct ScLoadedNamespaceEntry 101 { 102 rtl::OUString maPrefix; 103 rtl::OUString maName; 104 sal_uInt16 mnKey; 105 106 ScLoadedNamespaceEntry( const rtl::OUString& rPrefix, const rtl::OUString& rName, sal_uInt16 nKey ) : 107 maPrefix(rPrefix), 108 maName(rName), 109 mnKey(nKey) 110 { 111 } 112 }; 113 114 class ScSheetSaveData 115 { 116 std::hash_set<rtl::OUString, rtl::OUStringHash> maInitialPrefixes; 117 std::vector<ScLoadedNamespaceEntry> maLoadedNamespaces; 118 119 std::vector<ScCellStyleEntry> maCellStyles; 120 std::vector<ScCellStyleEntry> maColumnStyles; 121 std::vector<ScCellStyleEntry> maRowStyles; 122 std::vector<ScCellStyleEntry> maTableStyles; 123 std::vector<ScNoteStyleEntry> maNoteStyles; 124 std::vector<ScTextStyleEntry> maNoteParaStyles; 125 std::vector<ScTextStyleEntry> maNoteTextStyles; 126 std::vector<ScTextStyleEntry> maTextStyles; 127 std::vector<bool> maBlocked; 128 std::vector<ScStreamEntry> maStreamEntries; 129 std::vector<ScStreamEntry> maSaveEntries; 130 sal_Int32 mnStartTab; 131 sal_Int32 mnStartOffset; 132 133 ScNoteStyleEntry maPreviousNote; 134 135 bool mbInSupportedSave; 136 137 public: 138 ScSheetSaveData(); 139 ~ScSheetSaveData(); 140 141 void AddCellStyle( const rtl::OUString& rName, const ScAddress& rCellPos ); 142 void AddColumnStyle( const rtl::OUString& rName, const ScAddress& rCellPos ); 143 void AddRowStyle( const rtl::OUString& rName, const ScAddress& rCellPos ); 144 void AddTableStyle( const rtl::OUString& rName, const ScAddress& rCellPos ); 145 146 void HandleNoteStyles( const rtl::OUString& rStyleName, const rtl::OUString& rTextName, const ScAddress& rCellPos ); 147 void AddNoteContentStyle( sal_uInt16 nFamily, const rtl::OUString& rName, const ScAddress& rCellPos, const ESelection& rSelection ); 148 149 void AddTextStyle( const rtl::OUString& rName, const ScAddress& rCellPos, const ESelection& rSelection ); 150 151 void BlockSheet( sal_Int32 nTab ); 152 bool IsSheetBlocked( sal_Int32 nTab ) const; 153 154 void AddStreamPos( sal_Int32 nTab, sal_Int32 nStartOffset, sal_Int32 nEndOffset ); 155 void GetStreamPos( sal_Int32 nTab, sal_Int32& rStartOffset, sal_Int32& rEndOffset ) const; 156 bool HasStreamPos( sal_Int32 nTab ) const; 157 158 void StartStreamPos( sal_Int32 nTab, sal_Int32 nStartOffset ); 159 void EndStreamPos( sal_Int32 nEndOffset ); 160 161 bool HasStartPos() const { return mnStartTab >= 0; } 162 163 void ResetSaveEntries(); 164 void AddSavePos( sal_Int32 nTab, sal_Int32 nStartOffset, sal_Int32 nEndOffset ); 165 void UseSaveEntries(); 166 167 void StoreInitialNamespaces( const SvXMLNamespaceMap& rNamespaces ); 168 void StoreLoadedNamespaces( const SvXMLNamespaceMap& rNamespaces ); 169 bool AddLoadedNamespaces( SvXMLNamespaceMap& rNamespaces ) const; 170 171 const std::vector<ScCellStyleEntry>& GetCellStyles() const { return maCellStyles; } 172 const std::vector<ScCellStyleEntry>& GetColumnStyles() const { return maColumnStyles; } 173 const std::vector<ScCellStyleEntry>& GetRowStyles() const { return maRowStyles; } 174 const std::vector<ScCellStyleEntry>& GetTableStyles() const { return maTableStyles; } 175 const std::vector<ScNoteStyleEntry>& GetNoteStyles() const { return maNoteStyles; } 176 const std::vector<ScTextStyleEntry>& GetNoteParaStyles() const { return maNoteParaStyles; } 177 const std::vector<ScTextStyleEntry>& GetNoteTextStyles() const { return maNoteTextStyles; } 178 const std::vector<ScTextStyleEntry>& GetTextStyles() const { return maTextStyles; } 179 180 bool IsInSupportedSave() const; 181 void SetInSupportedSave( bool bSet ); 182 }; 183 184 #endif 185 186