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 {
42  OUString maName;
43  OUString maDisplayName;
44  OUString maAutoName;
45  OUString maParentName;// Will be moved to XMLPropStyle soon!!!!
46  OUString maFollow; // Will be moved to XMLPropStyle soon!!!!
47  bool mbHidden;
48 
50 
51  bool mbValid : 1; // Set this to false in CreateAndInsert
52  // if the style shouldn't be processed
53  // by Finish() or si somehow invalid.
54  bool mbNew : 1; // Set this to false in CreateAnsInsert
55  // if the style is already existing.
56  bool mbDefaultStyle : 1;
57 
58 protected:
59 
60  virtual void SetAttribute( sal_Int32 nElement, const OUString& rValue );
61 
62  void SetFamily( XmlStyleFamily nSet ) { mnFamily = nSet; }
63  void SetAutoName( const OUString& rName ) { maAutoName = rName; }
64 
65 public:
66 
69  bool bDefaultStyle = false );
70 
71  virtual ~SvXMLStyleContext() override;
72 
73  virtual void SAL_CALL startFastElement(
74  sal_Int32 nElement,
75  const css::uno::Reference< css::xml::sax::XFastAttributeList >& ) override;
76 
77  const OUString& GetName() const { return maName; }
78  const OUString& GetDisplayName() const { return maDisplayName.getLength() ? maDisplayName : maName; }
79  const OUString& GetAutoName() const { return maAutoName; }
80  const OUString& GetParentName() const { return maParentName; }
81  const OUString& GetFollow() const { return maFollow; }
82 
83  XmlStyleFamily GetFamily() const { return mnFamily; }
84 
85  bool IsValid() const { return mbValid; }
86  void SetValid( bool b ) { mbValid = b; }
87 
88  bool IsNew() const { return mbNew; }
89  void SetNew( bool b ) { mbNew = b; }
90 
91  bool IsHidden() const { return mbHidden; }
92 
93  // This method is called for every default style
94  virtual void SetDefaults();
95 
96  // This method is called for every style. It must create it and insert
97  // it into the document.
98  virtual void CreateAndInsert( bool bOverwrite );
99 
100  // This method is called for every style. It must create it and insert
101  // it into the document if this hasn't happened already in CreateAndInsert().
102  virtual void CreateAndInsertLate( bool bOverwrite );
103 
104  // This method is called for every style after all styles have been
105  // inserted into the document.
106  virtual void Finish( bool bOverwrite );
107 
108  bool IsDefaultStyle() const { return mbDefaultStyle; }
109 
118  virtual bool IsTransient() const;
119 };
120 
122 {
123  std::unique_ptr<SvXMLStylesContext_Impl> mpImpl;
124 
125 
126  css::uno::Reference< css::container::XNameContainer > mxParaStyles;
127 
128  css::uno::Reference< css::container::XNameContainer > mxTextStyles;
129 
130  css::uno::Reference< css::style::XAutoStyleFamily > mxParaAutoStyles;
131 
132  css::uno::Reference< css::style::XAutoStyleFamily > mxTextAutoStyles;
133 
139 
140  SvXMLStylesContext(SvXMLStylesContext const &) = delete;
141  SvXMLStylesContext& operator =(SvXMLStylesContext const &) = delete;
142 
143 protected:
144 
145  sal_uInt32 GetStyleCount() const;
146  SvXMLStyleContext *GetStyle( sal_uInt32 i );
147  const SvXMLStyleContext *GetStyle( sal_uInt32 i ) const;
148 
149  virtual SvXMLStyleContext *CreateStyleChildContext(
150  sal_Int32 nElement,
151  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList );
152 
153  virtual SvXMLStyleContext *CreateStyleStyleChildContext( XmlStyleFamily nFamily,
154  sal_Int32 nElement,
155  const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
156 
157  virtual SvXMLStyleContext *CreateDefaultStyleStyleChildContext(
158  XmlStyleFamily nFamily, sal_Int32 nElement,
159  const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
160 
161  virtual bool InsertStyleFamily( XmlStyleFamily nFamily ) const;
162 
163 public:
164 
166  bool bAutomatic = false );
167 
168  virtual ~SvXMLStylesContext() override;
169 
170  // Create child element.
171  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
172  sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
173 
174  // This allows to add an SvXMLStyleContext to this context from extern
175  void AddStyle(SvXMLStyleContext& rNew);
176 
177  const SvXMLStyleContext *FindStyleChildContext(
178  XmlStyleFamily nFamily,
179  const OUString& rName,
180  bool bCreateIndex = false ) const;
181  static XmlStyleFamily GetFamily( std::u16string_view rFamily );
182  virtual rtl::Reference < SvXMLImportPropertyMapper > GetImportPropertyMapper(
183  XmlStyleFamily nFamily ) const;
184 
185  virtual css::uno::Reference< css::container::XNameContainer >
186  GetStylesContainer( XmlStyleFamily nFamily ) const;
187  virtual OUString GetServiceName( XmlStyleFamily nFamily ) const;
188 
189  css::uno::Reference< css::style::XAutoStyleFamily >
190  GetAutoStyles( XmlStyleFamily nFamily ) const;
191  void CopyAutoStylesToDoc();
192  void CopyStylesToDoc( bool bOverwrite, bool bFinish = true );
193  void FinishStyles( bool bOverwrite );
194 
195  // This method must be called to release the references to all styles
196  // that are stored in the context.
197  void dispose();
198  bool IsAutomaticStyle() const;
199 };
200 
201 #endif // INCLUDED_XMLOFF_XMLSTYLE_HXX
202 
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString maAutoName
Definition: xmlstyle.hxx:44
css::uno::Reference< css::style::XAutoStyleFamily > mxTextAutoStyles
Definition: xmlstyle.hxx:132
XmlStyleFamily GetFamily() const
Definition: xmlstyle.hxx:83
OUString maParentName
Definition: xmlstyle.hxx:45
rtl::Reference< SvXMLImportPropertyMapper > mxParaImpPropMapper
Definition: xmlstyle.hxx:134
void SetNew(bool b)
Definition: xmlstyle.hxx:89
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:45
css::uno::Reference< css::container::XNameContainer > mxParaStyles
Definition: xmlstyle.hxx:126
bool IsNew() const
Definition: xmlstyle.hxx:88
bool IsDefaultStyle() const
Definition: xmlstyle.hxx:108
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:85
const OUString & GetAutoName() const
Definition: xmlstyle.hxx:79
OUString maDisplayName
Definition: xmlstyle.hxx:43
bool IsHidden() const
Definition: xmlstyle.hxx:91
const OUString & GetDisplayName() const
Definition: xmlstyle.hxx:78
void SetFamily(XmlStyleFamily nSet)
Definition: xmlstyle.hxx:62
rtl::Reference< SvXMLImportPropertyMapper > mxChartImpPropMapper
Definition: xmlstyle.hxx:137
std::unique_ptr< SvXMLStylesContext_Impl > mpImpl
Definition: xmlstyle.hxx:123
exports com.sun.star. style
void SetValid(bool b)
Definition: xmlstyle.hxx:86
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:44
const OUString & GetParentName() const
Definition: xmlstyle.hxx:80
rtl::Reference< SvXMLImportPropertyMapper > mxTextImpPropMapper
Definition: xmlstyle.hxx:135
const OUString & GetName() const
Definition: xmlstyle.hxx:77
OUString maName
Definition: xmlstyle.hxx:42
XmlStyleFamily mnFamily
Definition: xmlstyle.hxx:49
OUString maFollow
Definition: xmlstyle.hxx:46
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:59
void SetAutoName(const OUString &rName)
Definition: xmlstyle.hxx:63
const OUString & GetFollow() const
Definition: xmlstyle.hxx:81
css::uno::Reference< css::style::XAutoStyleFamily > mxParaAutoStyles
Definition: xmlstyle.hxx:130
css::uno::Reference< css::container::XNameContainer > mxTextStyles
Definition: xmlstyle.hxx:128
void dispose()
rtl::Reference< SvXMLImportPropertyMapper > mxPageImpPropMapper
Definition: xmlstyle.hxx:138
rtl::Reference< SvXMLImportPropertyMapper > mxShapeImpPropMapper
Definition: xmlstyle.hxx:136
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
bool mbValid