LibreOffice Module xmloff (master)  1
xmlstyle.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_XMLOFF_XMLSTYLE_HXX
21 #define INCLUDED_XMLOFF_XMLSTYLE_HXX
22 
23 #include <rtl/ref.hxx>
24 #include <sal/config.h>
25 #include <xmloff/dllapi.h>
26 #include <sal/types.h>
27 #include <xmloff/xmlictxt.hxx>
28 #include <xmloff/families.hxx>
29 #include <memory>
30 
33 class SvXMLTokenMap;
34 
35 namespace com::sun::star {
36 namespace container { class XNameContainer; }
37 namespace style { class XAutoStyleFamily; }
38 }
39 
41 {
56  XML_TOK_STYLE_DEFAULT_PAGE_LAYOUT //text grid enhancement
57 };
58 
60 {
61  OUString maName;
62  OUString maDisplayName;
63  OUString maAutoName;
64  OUString maParentName;// Will be moved to XMLPropStyle soon!!!!
65  OUString maFollow; // Will be moved to XMLPropStyle soon!!!!
66  bool mbHidden;
67 
69 
70  bool mbValid : 1; // Set this to false in CreateAndInsert
71  // if the style shouldn't be processed
72  // by Finish() or si somehow invalid.
73  bool mbNew : 1; // Set this to false in CreateAnsInsert
74  // if the style is already existing.
75  bool mbDefaultStyle : 1;
76 
77 protected:
78 
79  virtual void SetAttribute( sal_uInt16 nPrefixKey,
80  const OUString& rLocalName,
81  const OUString& rValue );
82 
83  void SetFamily( XmlStyleFamily nSet ) { mnFamily = nSet; }
84  void SetAutoName( const OUString& rName ) { maAutoName = rName; }
85 
86 public:
87 
90  bool bDefaultStyle = false );
91 
92  virtual ~SvXMLStyleContext() override;
93 
94  virtual void SAL_CALL startFastElement(
95  sal_Int32 nElement,
96  const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override;
97 
98  const OUString& GetName() const { return maName; }
99  const OUString& GetDisplayName() const { return maDisplayName.getLength() ? maDisplayName : maName; }
100  const OUString& GetAutoName() const { return maAutoName; }
101  const OUString& GetParentName() const { return maParentName; }
102  const OUString& GetFollow() const { return maFollow; }
103 
104  XmlStyleFamily GetFamily() const { return mnFamily; }
105 
106  bool IsValid() const { return mbValid; }
107  void SetValid( bool b ) { mbValid = b; }
108 
109  bool IsNew() const { return mbNew; }
110  void SetNew( bool b ) { mbNew = b; }
111 
112  bool IsHidden() const { return mbHidden; }
113 
114  // This method is called for every default style
115  virtual void SetDefaults();
116 
117  // This method is called for every style. It must create it and insert
118  // it into the document.
119  virtual void CreateAndInsert( bool bOverwrite );
120 
121  // This method is called for every style. It must create it and insert
122  // it into the document if this hasn't happened already in CreateAndInsert().
123  virtual void CreateAndInsertLate( bool bOverwrite );
124 
125  // This method is called for every style after all styles have been
126  // inserted into the document.
127  virtual void Finish( bool bOverwrite );
128 
129  bool IsDefaultStyle() const { return mbDefaultStyle; }
130 
139  virtual bool IsTransient() const;
140 };
141 
143 {
144  std::unique_ptr<SvXMLStylesContext_Impl> mpImpl;
145 
146 
147  css::uno::Reference< css::container::XNameContainer > mxParaStyles;
148 
149  css::uno::Reference< css::container::XNameContainer > mxTextStyles;
150 
151  css::uno::Reference< css::style::XAutoStyleFamily > mxParaAutoStyles;
152 
153  css::uno::Reference< css::style::XAutoStyleFamily > mxTextAutoStyles;
154 
160 
161  SvXMLStylesContext(SvXMLStylesContext const &) = delete;
162  SvXMLStylesContext& operator =(SvXMLStylesContext const &) = delete;
163 
164 protected:
165 
166  sal_uInt32 GetStyleCount() const;
167  SvXMLStyleContext *GetStyle( sal_uInt32 i );
168  const SvXMLStyleContext *GetStyle( sal_uInt32 i ) const;
169 
170  virtual SvXMLStyleContext *CreateStyleChildContext(
171  sal_Int32 nElement,
172  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList );
173 
174  virtual SvXMLStyleContext *CreateStyleStyleChildContext( XmlStyleFamily nFamily,
175  sal_Int32 nElement,
176  const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
177 
178  virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
179  XmlStyleFamily nFamily, sal_Int32 nElement,
180  const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
181 
182  virtual bool InsertStyleFamily( XmlStyleFamily nFamily ) const;
183 
184 public:
185 
187  bool bAutomatic = false );
188 
189  virtual ~SvXMLStylesContext() override;
190 
191  virtual void SAL_CALL startFastElement( sal_Int32 /*nElement*/,
192  const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override {}
193 
194  // Create child element.
195  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
196  sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
197 
198  // This allows to add an SvXMLStyleContext to this context from extern
199  void AddStyle(SvXMLStyleContext& rNew);
200 
201  const SvXMLStyleContext *FindStyleChildContext(
202  XmlStyleFamily nFamily,
203  const OUString& rName,
204  bool bCreateIndex = false ) const;
205  static XmlStyleFamily GetFamily( const OUString& rFamily );
206  virtual rtl::Reference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
207  XmlStyleFamily nFamily ) const;
208 
209  virtual css::uno::Reference< css::container::XNameContainer >
210  GetStylesContainer( XmlStyleFamily nFamily ) const;
211  virtual OUString GetServiceName( XmlStyleFamily nFamily ) const;
212 
213  css::uno::Reference< css::style::XAutoStyleFamily >
214  GetAutoStyles( XmlStyleFamily nFamily ) const;
215  void CopyAutoStylesToDoc();
216  void CopyStylesToDoc( bool bOverwrite, bool bFinish = true );
217  void FinishStyles( bool bOverwrite );
218 
219  // This method must be called to release the references to all styles
220  // that are stored in the context.
221  void dispose();
222  bool IsAutomaticStyle() const;
223 };
224 
225 #endif // INCLUDED_XMLOFF_XMLSTYLE_HXX
226 
227 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maAutoName
Definition: xmlstyle.hxx:63
css::uno::Reference< css::style::XAutoStyleFamily > mxTextAutoStyles
Definition: xmlstyle.hxx:153
XmlStyleFamily GetFamily() const
Definition: xmlstyle.hxx:104
OUString maParentName
Definition: xmlstyle.hxx:64
rtl::Reference< SvXMLImportPropertyMapper > mxParaImpPropMapper
Definition: xmlstyle.hxx:155
void SetNew(bool b)
Definition: xmlstyle.hxx:110
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:71
css::uno::Reference< css::container::XNameContainer > mxParaStyles
Definition: xmlstyle.hxx:147
bool IsNew() const
Definition: xmlstyle.hxx:109
bool IsDefaultStyle() const
Definition: xmlstyle.hxx:129
exports com.sun.star. container
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
XmlStyleFamily
Definition: families.hxx:47
bool IsValid() const
Definition: xmlstyle.hxx:106
const OUString & GetAutoName() const
Definition: xmlstyle.hxx:100
OUString maDisplayName
Definition: xmlstyle.hxx:62
bool IsHidden() const
Definition: xmlstyle.hxx:112
const OUString & GetDisplayName() const
Definition: xmlstyle.hxx:99
void SetFamily(XmlStyleFamily nSet)
Definition: xmlstyle.hxx:83
rtl::Reference< SvXMLImportPropertyMapper > mxChartImpPropMapper
Definition: xmlstyle.hxx:158
std::unique_ptr< SvXMLStylesContext_Impl > mpImpl
Definition: xmlstyle.hxx:144
exports com.sun.star. style
void SetValid(bool b)
Definition: xmlstyle.hxx:107
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
XMLStyleStylesElemTokens
Definition: xmlstyle.hxx:40
const OUString & GetParentName() const
Definition: xmlstyle.hxx:101
rtl::Reference< SvXMLImportPropertyMapper > mxTextImpPropMapper
Definition: xmlstyle.hxx:156
const OUString & GetName() const
Definition: xmlstyle.hxx:98
OUString maName
Definition: xmlstyle.hxx:61
XmlStyleFamily mnFamily
Definition: xmlstyle.hxx:68
OUString maFollow
Definition: xmlstyle.hxx:65
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:128
virtual void SAL_CALL startFastElement(sal_Int32, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
Definition: xmlstyle.hxx:191
void SetAutoName(const OUString &rName)
Definition: xmlstyle.hxx:84
const OUString & GetFollow() const
Definition: xmlstyle.hxx:102
css::uno::Reference< css::style::XAutoStyleFamily > mxParaAutoStyles
Definition: xmlstyle.hxx:151
css::uno::Reference< css::container::XNameContainer > mxTextStyles
Definition: xmlstyle.hxx:149
void dispose()
rtl::Reference< SvXMLImportPropertyMapper > mxPageImpPropMapper
Definition: xmlstyle.hxx:159
rtl::Reference< SvXMLImportPropertyMapper > mxShapeImpPropMapper
Definition: xmlstyle.hxx:157
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
bool mbValid