1*38d50f7bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*38d50f7bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*38d50f7bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*38d50f7bSAndrew Rist * distributed with this work for additional information 6*38d50f7bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*38d50f7bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*38d50f7bSAndrew Rist * "License"); you may not use this file except in compliance 9*38d50f7bSAndrew Rist * with the License. You may obtain a copy of the License at 10*38d50f7bSAndrew Rist * 11*38d50f7bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*38d50f7bSAndrew Rist * 13*38d50f7bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*38d50f7bSAndrew Rist * software distributed under the License is distributed on an 15*38d50f7bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*38d50f7bSAndrew Rist * KIND, either express or implied. See the License for the 17*38d50f7bSAndrew Rist * specific language governing permissions and limitations 18*38d50f7bSAndrew Rist * under the License. 19*38d50f7bSAndrew Rist * 20*38d50f7bSAndrew Rist *************************************************************/ 21*38d50f7bSAndrew Rist 22*38d50f7bSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SC_XMLSTYLI_HXX 25cdf0e10cSrcweir #define SC_XMLSTYLI_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <rtl/ustring.hxx> 28cdf0e10cSrcweir #include <vector> 29cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 30cdf0e10cSrcweir #include <xmloff/xmlictxt.hxx> 31cdf0e10cSrcweir #include <xmloff/maptype.hxx> 32cdf0e10cSrcweir #include <xmloff/prstylei.hxx> 33cdf0e10cSrcweir #include <xmloff/xmlimppr.hxx> 34cdf0e10cSrcweir #include <xmloff/XMLTextMasterPageContext.hxx> 35cdf0e10cSrcweir #include <xmloff/XMLTextMasterStylesContext.hxx> 36cdf0e10cSrcweir #include <xmloff/txtstyli.hxx> 37cdf0e10cSrcweir #include <com/sun/star/sheet/ConditionOperator.hpp> 38cdf0e10cSrcweir #include "xmlimprt.hxx" 39cdf0e10cSrcweir 40cdf0e10cSrcweir class ScSheetSaveData; 41cdf0e10cSrcweir 42cdf0e10cSrcweir class ScXMLCellImportPropertyMapper : public SvXMLImportPropertyMapper 43cdf0e10cSrcweir { 44cdf0e10cSrcweir protected: 45cdf0e10cSrcweir 46cdf0e10cSrcweir public: 47cdf0e10cSrcweir 48cdf0e10cSrcweir ScXMLCellImportPropertyMapper( 49cdf0e10cSrcweir const UniReference< XMLPropertySetMapper >& rMapper, 50cdf0e10cSrcweir SvXMLImport& rImport); 51cdf0e10cSrcweir virtual ~ScXMLCellImportPropertyMapper(); 52cdf0e10cSrcweir 53cdf0e10cSrcweir /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */ 54cdf0e10cSrcweir /* virtual sal_Bool handleSpecialItem( 55cdf0e10cSrcweir XMLPropertyState& rProperty, 56cdf0e10cSrcweir ::std::vector< XMLPropertyState >& rProperties, 57cdf0e10cSrcweir const ::rtl::OUString& rValue, 58cdf0e10cSrcweir const SvXMLUnitConverter& rUnitConverter, 59cdf0e10cSrcweir const SvXMLNamespaceMap& rNamespaceMap ) const;*/ 60cdf0e10cSrcweir 61cdf0e10cSrcweir /** this method is called for every item that has the MID_FLAG_NO_ITEM_IMPORT flag set */ 62cdf0e10cSrcweir /* virtual sal_Bool handleNoItem( 63cdf0e10cSrcweir sal_Int32 nIndex, 64cdf0e10cSrcweir ::std::vector< XMLPropertyState >& rProperties, 65cdf0e10cSrcweir const ::rtl::OUString& rValue, 66cdf0e10cSrcweir const SvXMLUnitConverter& rUnitConverter, 67cdf0e10cSrcweir const SvXMLNamespaceMap& rNamespaceMap ) const;*/ 68cdf0e10cSrcweir 69cdf0e10cSrcweir /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */ 70cdf0e10cSrcweir virtual void finished( 71cdf0e10cSrcweir ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const; 72cdf0e10cSrcweir }; 73cdf0e10cSrcweir 74cdf0e10cSrcweir class ScXMLRowImportPropertyMapper : public SvXMLImportPropertyMapper 75cdf0e10cSrcweir { 76cdf0e10cSrcweir protected: 77cdf0e10cSrcweir 78cdf0e10cSrcweir public: 79cdf0e10cSrcweir 80cdf0e10cSrcweir ScXMLRowImportPropertyMapper( 81cdf0e10cSrcweir const UniReference< XMLPropertySetMapper >& rMapper, 82cdf0e10cSrcweir SvXMLImport& rImport); 83cdf0e10cSrcweir virtual ~ScXMLRowImportPropertyMapper(); 84cdf0e10cSrcweir 85cdf0e10cSrcweir /** This method is called when all attributes have been processed. It may be used to remove items that are incomplete */ 86cdf0e10cSrcweir virtual void finished( 87cdf0e10cSrcweir ::std::vector< XMLPropertyState >& rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const; 88cdf0e10cSrcweir }; 89cdf0e10cSrcweir struct ScXMLMapContent; 90cdf0e10cSrcweir 91cdf0e10cSrcweir class XMLTableStyleContext : public XMLPropStyleContext 92cdf0e10cSrcweir { 93cdf0e10cSrcweir ::rtl::OUString sDataStyleName; 94cdf0e10cSrcweir rtl::OUString sPageStyle; 95cdf0e10cSrcweir const rtl::OUString sNumberFormat; 96cdf0e10cSrcweir SvXMLStylesContext* pStyles; 97cdf0e10cSrcweir std::vector<ScXMLMapContent> aMaps; 98cdf0e10cSrcweir com::sun::star::uno::Any aConditionalFormat; 99cdf0e10cSrcweir sal_Int32 nNumberFormat; 100cdf0e10cSrcweir sal_Int32 nLastSheet; 101cdf0e10cSrcweir sal_Bool bConditionalFormatCreated; 102cdf0e10cSrcweir sal_Bool bParentSet; 103cdf0e10cSrcweir GetScImport() const104cdf0e10cSrcweir const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()105cdf0e10cSrcweir ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 106cdf0e10cSrcweir 107cdf0e10cSrcweir void SetOperator( 108cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps, 109cdf0e10cSrcweir ::com::sun::star::sheet::ConditionOperator eOp ) const; 110cdf0e10cSrcweir 111cdf0e10cSrcweir void SetBaseCellAddress( 112cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps, 113cdf0e10cSrcweir const ::rtl::OUString& rBaseCell ) const; 114cdf0e10cSrcweir 115cdf0e10cSrcweir void SetStyle( 116cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps, 117cdf0e10cSrcweir const ::rtl::OUString& rApplyStyle ) const; 118cdf0e10cSrcweir 119cdf0e10cSrcweir void SetFormula( 120cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProps, 121cdf0e10cSrcweir sal_Int32 nFormulaIdx, const ::rtl::OUString& rFormula, 122cdf0e10cSrcweir const ::rtl::OUString& rFormulaNmsp, ::formula::FormulaGrammar::Grammar eGrammar, bool bHasNmsp ) const; 123cdf0e10cSrcweir 124cdf0e10cSrcweir void GetConditionalFormat( 125cdf0e10cSrcweir ::com::sun::star::uno::Any& aAny, const rtl::OUString& sCondition, 126cdf0e10cSrcweir const rtl::OUString& sApplyStyle, const rtl::OUString& sBaseCell) const; 127cdf0e10cSrcweir protected: 128cdf0e10cSrcweir 129cdf0e10cSrcweir virtual void SetAttribute( sal_uInt16 nPrefixKey, 130cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 131cdf0e10cSrcweir const ::rtl::OUString& rValue ); 132cdf0e10cSrcweir 133cdf0e10cSrcweir public: 134cdf0e10cSrcweir 135cdf0e10cSrcweir TYPEINFO(); 136cdf0e10cSrcweir 137cdf0e10cSrcweir XMLTableStyleContext( ScXMLImport& rImport, sal_uInt16 nPrfx, 138cdf0e10cSrcweir const ::rtl::OUString& rLName, 139cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 140cdf0e10cSrcweir SvXMLStylesContext& rStyles, sal_uInt16 nFamily, sal_Bool bDefaultStyle = sal_False ); 141cdf0e10cSrcweir virtual ~XMLTableStyleContext(); 142cdf0e10cSrcweir 143cdf0e10cSrcweir virtual SvXMLImportContext *CreateChildContext( 144cdf0e10cSrcweir sal_uInt16 nPrefix, 145cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 146cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); 147cdf0e10cSrcweir 148cdf0e10cSrcweir virtual void FillPropertySet(const ::com::sun::star::uno::Reference< 149cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet > & rPropSet ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir virtual void SetDefaults(); 152cdf0e10cSrcweir 153cdf0e10cSrcweir void AddProperty(sal_Int16 nContextID, const com::sun::star::uno::Any& aValue); 154cdf0e10cSrcweir XMLPropertyState* FindProperty(const sal_Int16 nContextID); 155cdf0e10cSrcweir 156cdf0e10cSrcweir sal_Int32 GetNumberFormat();// { return nNumberFormat; } 157cdf0e10cSrcweir GetLastSheet() const158cdf0e10cSrcweir sal_Int32 GetLastSheet() const { return nLastSheet; } SetLastSheet(sal_Int32 nNew)159cdf0e10cSrcweir void SetLastSheet(sal_Int32 nNew) { nLastSheet = nNew; } 160cdf0e10cSrcweir 161cdf0e10cSrcweir private: 162cdf0e10cSrcweir using XMLPropStyleContext::SetStyle; 163cdf0e10cSrcweir }; 164cdf0e10cSrcweir 165cdf0e10cSrcweir class XMLTableStylesContext : public SvXMLStylesContext 166cdf0e10cSrcweir { 167cdf0e10cSrcweir ::com::sun::star::uno::Reference < 168cdf0e10cSrcweir ::com::sun::star::container::XNameContainer > xCellStyles; 169cdf0e10cSrcweir ::com::sun::star::uno::Reference < 170cdf0e10cSrcweir ::com::sun::star::container::XNameContainer > xColumnStyles; 171cdf0e10cSrcweir ::com::sun::star::uno::Reference < 172cdf0e10cSrcweir ::com::sun::star::container::XNameContainer > xRowStyles; 173cdf0e10cSrcweir ::com::sun::star::uno::Reference < 174cdf0e10cSrcweir ::com::sun::star::container::XNameContainer > xTableStyles; 175cdf0e10cSrcweir const ::rtl::OUString sCellStyleServiceName; 176cdf0e10cSrcweir const ::rtl::OUString sColumnStyleServiceName; 177cdf0e10cSrcweir const ::rtl::OUString sRowStyleServiceName; 178cdf0e10cSrcweir const ::rtl::OUString sTableStyleServiceName; 179cdf0e10cSrcweir sal_Int32 nNumberFormatIndex; 180cdf0e10cSrcweir sal_Int32 nConditionalFormatIndex; 181cdf0e10cSrcweir sal_Int32 nCellStyleIndex; 182cdf0e10cSrcweir sal_Int32 nMasterPageNameIndex; 183cdf0e10cSrcweir sal_Bool bAutoStyles; 184cdf0e10cSrcweir 185cdf0e10cSrcweir UniReference < SvXMLImportPropertyMapper > xCellImpPropMapper; 186cdf0e10cSrcweir UniReference < SvXMLImportPropertyMapper > xColumnImpPropMapper; 187cdf0e10cSrcweir UniReference < SvXMLImportPropertyMapper > xRowImpPropMapper; 188cdf0e10cSrcweir UniReference < SvXMLImportPropertyMapper > xTableImpPropMapper; 189cdf0e10cSrcweir GetScImport() const190cdf0e10cSrcweir const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()191cdf0e10cSrcweir ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 192cdf0e10cSrcweir 193cdf0e10cSrcweir protected: 194cdf0e10cSrcweir 195cdf0e10cSrcweir // Create a style context. 196cdf0e10cSrcweir virtual SvXMLStyleContext *CreateStyleStyleChildContext( 197cdf0e10cSrcweir sal_uInt16 nFamily, 198cdf0e10cSrcweir sal_uInt16 nPrefix, 199cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 200cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); 201cdf0e10cSrcweir 202cdf0e10cSrcweir virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext( 203cdf0e10cSrcweir sal_uInt16 nFamily, sal_uInt16 nPrefix, 204cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 205cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 206cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); 207cdf0e10cSrcweir 208cdf0e10cSrcweir // virtual SvXMLImportPropertyMapper *GetImpPropMapper(); 209cdf0e10cSrcweir 210cdf0e10cSrcweir public: 211cdf0e10cSrcweir 212cdf0e10cSrcweir XMLTableStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx , 213cdf0e10cSrcweir const ::rtl::OUString& rLName , 214cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 215cdf0e10cSrcweir const sal_Bool bAutoStyles ); 216cdf0e10cSrcweir virtual ~XMLTableStylesContext(); 217cdf0e10cSrcweir 218cdf0e10cSrcweir // Create child element. 219cdf0e10cSrcweir /* virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, 220cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 221cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 222cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList );*/ 223cdf0e10cSrcweir 224cdf0e10cSrcweir virtual void EndElement(); 225cdf0e10cSrcweir 226cdf0e10cSrcweir virtual UniReference < SvXMLImportPropertyMapper > GetImportPropertyMapper( 227cdf0e10cSrcweir sal_uInt16 nFamily ) const; 228cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference < 229cdf0e10cSrcweir ::com::sun::star::container::XNameContainer > 230cdf0e10cSrcweir GetStylesContainer( sal_uInt16 nFamily ) const; 231cdf0e10cSrcweir virtual ::rtl::OUString GetServiceName( sal_uInt16 nFamily ) const; 232cdf0e10cSrcweir 233cdf0e10cSrcweir sal_Int32 GetIndex(const sal_Int16 nContextID); 234cdf0e10cSrcweir }; 235cdf0e10cSrcweir 236cdf0e10cSrcweir class ScXMLMasterStylesContext : public SvXMLStylesContext 237cdf0e10cSrcweir { 238cdf0e10cSrcweir protected: 239cdf0e10cSrcweir virtual SvXMLStyleContext *CreateStyleChildContext( sal_uInt16 nPrefix, 240cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 241cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 242cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); 243cdf0e10cSrcweir 244cdf0e10cSrcweir virtual SvXMLStyleContext *CreateStyleStyleChildContext( sal_uInt16 nFamily, 245cdf0e10cSrcweir sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, 246cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 247cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); 248cdf0e10cSrcweir 249cdf0e10cSrcweir virtual sal_Bool InsertStyleFamily( sal_uInt16 nFamily ) const; 250cdf0e10cSrcweir 251cdf0e10cSrcweir public: 252cdf0e10cSrcweir TYPEINFO(); 253cdf0e10cSrcweir 254cdf0e10cSrcweir ScXMLMasterStylesContext( SvXMLImport& rImport, sal_uInt16 nPrfx, 255cdf0e10cSrcweir const ::rtl::OUString& rLName, 256cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 257cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList); 258cdf0e10cSrcweir 259cdf0e10cSrcweir virtual ~ScXMLMasterStylesContext(); 260cdf0e10cSrcweir virtual void EndElement(); 261cdf0e10cSrcweir }; 262cdf0e10cSrcweir 263cdf0e10cSrcweir namespace com { namespace sun { namespace star { 264cdf0e10cSrcweir namespace style { class XStyle; } 265cdf0e10cSrcweir } } } 266cdf0e10cSrcweir 267cdf0e10cSrcweir class ScMasterPageContext : public XMLTextMasterPageContext 268cdf0e10cSrcweir { 269cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet; 270cdf0e10cSrcweir const rtl::OUString sEmpty; 271cdf0e10cSrcweir sal_Bool bContainsRightHeader; 272cdf0e10cSrcweir sal_Bool bContainsRightFooter; 273cdf0e10cSrcweir 274cdf0e10cSrcweir void ClearContent(const rtl::OUString& rContent); 275cdf0e10cSrcweir public: 276cdf0e10cSrcweir 277cdf0e10cSrcweir TYPEINFO(); 278cdf0e10cSrcweir 279cdf0e10cSrcweir ScMasterPageContext( SvXMLImport& rImport, sal_uInt16 nPrfx, 280cdf0e10cSrcweir const ::rtl::OUString& rLName, 281cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 282cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 283cdf0e10cSrcweir sal_Bool bOverwrite ); 284cdf0e10cSrcweir virtual ~ScMasterPageContext(); 285cdf0e10cSrcweir 286cdf0e10cSrcweir virtual SvXMLImportContext *CreateChildContext( 287cdf0e10cSrcweir sal_uInt16 nPrefix, 288cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 289cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ); 290cdf0e10cSrcweir 291cdf0e10cSrcweir virtual SvXMLImportContext *CreateHeaderFooterContext( 292cdf0e10cSrcweir sal_uInt16 nPrefix, 293cdf0e10cSrcweir const ::rtl::OUString& rLocalName, 294cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 295cdf0e10cSrcweir const sal_Bool bFooter, 296cdf0e10cSrcweir const sal_Bool bLeft ); 297cdf0e10cSrcweir 298cdf0e10cSrcweir virtual void Finish( sal_Bool bOverwrite ); 299cdf0e10cSrcweir }; 300cdf0e10cSrcweir 301cdf0e10cSrcweir class ScCellTextStyleContext : public XMLTextStyleContext 302cdf0e10cSrcweir { 303cdf0e10cSrcweir sal_Int32 nLastSheet; 304cdf0e10cSrcweir GetScImport() const305cdf0e10cSrcweir const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } GetScImport()306cdf0e10cSrcweir ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } 307cdf0e10cSrcweir 308cdf0e10cSrcweir public: 309cdf0e10cSrcweir ScCellTextStyleContext( SvXMLImport& rImport, sal_uInt16 nPrfx, 310cdf0e10cSrcweir const ::rtl::OUString& rLName, 311cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 312cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > & xAttrList, 313cdf0e10cSrcweir SvXMLStylesContext& rStyles, sal_uInt16 nFamily, 314cdf0e10cSrcweir sal_Bool bDefaultStyle = sal_False ); 315cdf0e10cSrcweir virtual ~ScCellTextStyleContext(); 316cdf0e10cSrcweir 317cdf0e10cSrcweir // overload FillPropertySet to store style information 318cdf0e10cSrcweir virtual void FillPropertySet( 319cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 320cdf0e10cSrcweir ::com::sun::star::beans::XPropertySet > & rPropSet ); 321cdf0e10cSrcweir }; 322cdf0e10cSrcweir 323cdf0e10cSrcweir 324cdf0e10cSrcweir #endif 325cdf0e10cSrcweir 326