LibreOffice Module xmloff (master)  1
txtstyle.cxx
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 #include <sal/config.h>
21 
22 #include <com/sun/star/frame/XModel.hpp>
23 #include <com/sun/star/style/ParagraphStyleCategory.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/beans/XPropertySetInfo.hpp>
26 #include <com/sun/star/beans/XPropertyState.hpp>
27 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include <com/sun/star/style/XStyle.hpp>
29 #include <xmloff/xmltoken.hxx>
30 #include <xmloff/xmlnamespace.hxx>
31 #include <xmloff/families.hxx>
32 #include <xmloff/txtparae.hxx>
33 #include <xmloff/xmlnume.hxx>
34 #include <xmloff/xmlexp.hxx>
36 #include "XMLSectionExport.hxx"
38 #include "txtexppr.hxx"
39 #include <xmloff/txtprmap.hxx>
40 
41 
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::style;
45 using namespace ::com::sun::star::container;
46 using namespace ::com::sun::star::beans;
47 using namespace ::xmloff::token;
48 
50  const css::uno::Reference< css::style::XStyle > & rStyle )
51 {
52  OUString sName;
53  Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
54  Reference< XPropertySetInfo > xPropSetInfo(
55  xPropSet->getPropertySetInfo());
56  if( xPropSetInfo->hasPropertyByName( gsCategory ) )
57  {
58  sal_Int16 nCategory = 0;
59  xPropSet->getPropertyValue( gsCategory ) >>= nCategory;
60  enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
61  if( -1 != nCategory )
62  {
63  switch( nCategory )
64  {
65  case ParagraphStyleCategory::TEXT:
66  eValue = XML_TEXT;
67  break;
68  case ParagraphStyleCategory::CHAPTER:
69  eValue = XML_CHAPTER;
70  break;
71  case ParagraphStyleCategory::LIST:
72  eValue = XML_LIST;
73  break;
74  case ParagraphStyleCategory::INDEX:
75  eValue = XML_INDEX;
76  break;
77  case ParagraphStyleCategory::EXTRA:
78  eValue = XML_EXTRA;
79  break;
80  case ParagraphStyleCategory::HTML:
81  eValue = XML_HTML;
82  break;
83  }
84  }
85  if( eValue != XML_TOKEN_INVALID )
87  }
88  if( xPropSetInfo->hasPropertyByName( gsPageDescName ) )
89  {
90  Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
91  if( PropertyState_DIRECT_VALUE ==
92  xPropState->getPropertyState( gsPageDescName ) )
93  {
94  xPropSet->getPropertyValue( gsPageDescName ) >>= sName;
95  // fix for #i5551# if( sName.getLength() > 0 )
98  GetExport().EncodeStyleName( sName ) );
99  }
100  }
101  if( bProgress )
102  {
104  pProgress->SetValue( pProgress->GetValue()+2 );
105  }
106 }
107 
109 {
110  SvxXMLNumRuleExport aNumRuleExport( GetExport() );
111  aNumRuleExport.exportStyles( bUsed, &maListAutoPool, !IsBlockMode() );
112 }
113 
114 void XMLTextParagraphExport::exportTextStyles( bool bUsed, bool bProg )
115 {
116  bool bOldProg = bProgress;
117  bProgress = bProg;
118 
119  Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY);
120  if (xFactory.is())
121  {
122  Reference < XPropertySet > xPropSet (xFactory->createInstance ( "com.sun.star.text.Defaults" ), UNO_QUERY);
123  if (xPropSet.is())
124  {
126 
128  xPropSet,
133  GetExport() ) );
134 
136  xPropSet,
141  GetExport() ) );
142  }
143  }
147  bUsed, XmlStyleFamily::TEXT_TEXT );
148  // get shape export to make sure the frame family is added correctly.
152  exportNumStyles( bUsed );
153  if( !IsBlockMode() )
154  {
157  XMLLineNumberingExport aLineNumberingExport(GetExport());
158  aLineNumberingExport.Export();
159  }
160 
161  bProgress = bOldProg;
162 }
163 
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl::Reference< SvXMLExportPropertyMapper > xFramePropMapper
Definition: txtparae.hxx:85
virtual void exportStyleAttributes(const css::uno::Reference< css::style::XStyle > &rStyle) override
Definition: txtstyle.cxx:49
rtl::Reference< XMLShapeExport > const & GetShapeExport()
Definition: xmlexp.hxx:568
void exportDefaultStyle(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const OUString &rXMLFamily, const rtl::Reference< SvXMLExportPropertyMapper > &rPropMapper)
Definition: styleexp.cxx:385
static constexpr OUStringLiteral gsPageDescName
Definition: txtparae.hxx:142
const rtl::Reference< SvXMLExportPropertyMapper > & GetParaPropMapper() const
Definition: txtparae.hxx:161
SvXMLExport & GetExport()
Definition: styleexp.hxx:59
void exportStyleFamily(const OUString &rFamily, const OUString &rXMLFamily, const rtl::Reference< SvXMLExportPropertyMapper > &rPropMapper, bool bUsed, XmlStyleFamily nFamily, const OUString *pPrefix=nullptr)
Definition: styleexp.cxx:421
bool IsBlockMode() const
Definition: txtparae.hxx:502
ProgressBarHelper * GetProgressBarHelper()
Definition: xmlexp.cxx:1961
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
Definition: xmlexp.cxx:909
const char * sName
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:49
#define XML_STYLE_FAMILY_SD_GRAPHICS_NAME
Definition: families.hxx:36
XMLTextListAutoStylePool maListAutoPool
Definition: txtparae.hxx:93
void exportNumStyles(bool bUsed)
Definition: txtstyle.cxx:108
const rtl::Reference< SvXMLExportPropertyMapper > & GetTextPropMapper() const
Definition: txtparae.hxx:166
void exportStyles(bool bUsed, XMLTextListAutoStylePool *pPool, bool bExportChapterNumbering)
Definition: xmlnume.cxx:777
export and its child elements
sal_Int32 GetValue() const
void exportTextFootnoteConfiguration()
export footnote and endnote configuration elements
Definition: txtftne.cxx:201
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3378
Handling of tokens in XML:
void exportTextStyles(bool bUsed, bool bProg)
Definition: txtstyle.cxx:114
void SetValue(sal_Int32 nValue)
static constexpr OUStringLiteral gsCategory
Definition: txtparae.hxx:135
Reference< XSingleServiceFactory > xFactory
constexpr sal_uInt16 XML_NAMESPACE_STYLE
static void ExportBibliographyConfiguration(SvXMLExport &rExport)
Export the configuration element for bibliography indices.