1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
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>
35 #include <xmloff/ProgressBarHelper.hxx>
36 #include "XMLSectionExport.hxx"
37 #include "XMLLineNumberingExport.hxx"
38 #include "txtexppr.hxx"
39 #include <xmloff/txtprmap.hxx>
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
;
49 void XMLTextParagraphExport::exportStyleAttributes(
50 const css::uno::Reference
< css::style::XStyle
> & rStyle
)
52 Reference
< XPropertySet
> xPropSet( rStyle
, UNO_QUERY
);
53 Reference
< XPropertySetInfo
> xPropSetInfo(
54 xPropSet
->getPropertySetInfo());
55 if( xPropSetInfo
->hasPropertyByName( gsCategory
) )
57 sal_Int16 nCategory
= 0;
58 xPropSet
->getPropertyValue( gsCategory
) >>= nCategory
;
59 enum XMLTokenEnum eValue
= XML_TOKEN_INVALID
;
64 case ParagraphStyleCategory::TEXT
:
67 case ParagraphStyleCategory::CHAPTER
:
70 case ParagraphStyleCategory::LIST
:
73 case ParagraphStyleCategory::INDEX
:
76 case ParagraphStyleCategory::EXTRA
:
79 case ParagraphStyleCategory::HTML
:
84 if( eValue
!= XML_TOKEN_INVALID
)
85 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_CLASS
, eValue
);
87 if( xPropSetInfo
->hasPropertyByName( gsPageDescName
) )
89 Reference
< XPropertyState
> xPropState( xPropSet
, uno::UNO_QUERY
);
90 if( PropertyState_DIRECT_VALUE
==
91 xPropState
->getPropertyState( gsPageDescName
) )
94 xPropSet
->getPropertyValue( gsPageDescName
) >>= sName
;
95 // fix for #i5551# if( sName.getLength() > 0 )
96 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
98 GetExport().EncodeStyleName( sName
) );
103 ProgressBarHelper
*pProgress
= GetExport().GetProgressBarHelper();
104 pProgress
->SetValue( pProgress
->GetValue()+2 );
108 void XMLTextParagraphExport::exportNumStyles( bool bUsed
)
110 SvxXMLNumRuleExport
aNumRuleExport( GetExport() );
111 aNumRuleExport
.exportStyles(bUsed
, !IsBlockMode());
114 void XMLTextParagraphExport::exportTextStyles( bool bUsed
, bool bProg
)
116 bool bOldProg
= m_bProgress
;
119 Reference
< lang::XMultiServiceFactory
> xFactory (GetExport().GetModel(), UNO_QUERY
);
122 Reference
< XPropertySet
> xPropSet (xFactory
->createInstance ( "com.sun.star.text.Defaults" ), UNO_QUERY
);
125 exportDefaultStyle( xPropSet
, GetXMLToken(XML_PARAGRAPH
), GetParaPropMapper());
129 GetXMLToken(XML_TABLE
),
130 new XMLTextExportPropertySetMapper(
131 new XMLTextPropertySetMapper(
132 TextPropMap::TABLE_DEFAULTS
, true ),
137 GetXMLToken(XML_TABLE_ROW
),
138 new XMLTextExportPropertySetMapper(
139 new XMLTextPropertySetMapper(
140 TextPropMap::TABLE_ROW_DEFAULTS
, true ),
144 exportStyleFamily( "ParagraphStyles", GetXMLToken(XML_PARAGRAPH
), GetParaPropMapper(),
145 bUsed
, XmlStyleFamily::TEXT_PARAGRAPH
);
146 exportStyleFamily( "CharacterStyles", GetXMLToken(XML_TEXT
), GetTextPropMapper(),
147 bUsed
, XmlStyleFamily::TEXT_TEXT
);
148 // get shape export to make sure the frame family is added correctly.
149 GetExport().GetShapeExport();
150 exportStyleFamily( "FrameStyles", XML_STYLE_FAMILY_SD_GRAPHICS_NAME
, m_xFramePropMapper
,
151 bUsed
, XmlStyleFamily::TEXT_FRAME
);
152 exportNumStyles( bUsed
);
155 exportTextFootnoteConfiguration();
156 XMLSectionExport::ExportBibliographyConfiguration(GetExport());
157 XMLLineNumberingExport
aLineNumberingExport(GetExport());
158 aLineNumberingExport
.Export();
161 m_bProgress
= bOldProg
;
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */