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 .
21 #include <com/sun/star/style/ParagraphStyleCategory.hpp>
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/beans/XPropertySetInfo.hpp>
24 #include <com/sun/star/beans/XPropertyState.hpp>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/style/XStyle.hpp>
27 #include <xmloff/xmltoken.hxx>
28 #include <xmloff/xmlnmspe.hxx>
29 #include <xmloff/families.hxx>
30 #include <xmloff/txtparae.hxx>
31 #include <xmloff/xmlnume.hxx>
32 #include <xmloff/xmlexp.hxx>
33 #include "XMLSectionExport.hxx"
34 #include "XMLLineNumberingExport.hxx"
35 #include "txtexppr.hxx"
36 #include <xmloff/txtprmap.hxx>
39 using namespace ::com::sun::star
;
40 using namespace ::com::sun::star::uno
;
41 using namespace ::com::sun::star::style
;
42 using namespace ::com::sun::star::container
;
43 using namespace ::com::sun::star::beans
;
44 using namespace ::xmloff::token
;
46 void XMLTextParagraphExport::exportStyleAttributes(
47 const ::com::sun::star::uno::Reference
<
48 ::com::sun::star::style::XStyle
> & rStyle
)
51 Reference
< XPropertySet
> xPropSet( rStyle
, UNO_QUERY
);
52 Reference
< XPropertySetInfo
> xPropSetInfo(
53 xPropSet
->getPropertySetInfo());
54 if( xPropSetInfo
->hasPropertyByName( sCategory
) )
56 sal_Int16 nCategory
= 0;
57 xPropSet
->getPropertyValue( sCategory
) >>= nCategory
;
58 enum XMLTokenEnum eValue
= XML_TOKEN_INVALID
;
63 case ParagraphStyleCategory::TEXT
:
66 case ParagraphStyleCategory::CHAPTER
:
69 case ParagraphStyleCategory::LIST
:
72 case ParagraphStyleCategory::INDEX
:
75 case ParagraphStyleCategory::EXTRA
:
78 case ParagraphStyleCategory::HTML
:
83 if( eValue
!= XML_TOKEN_INVALID
)
84 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_CLASS
, eValue
);
86 if( xPropSetInfo
->hasPropertyByName( sPageDescName
) )
88 Reference
< XPropertyState
> xPropState( xPropSet
, uno::UNO_QUERY
);
89 if( PropertyState_DIRECT_VALUE
==
90 xPropState
->getPropertyState( sPageDescName
) )
92 xPropSet
->getPropertyValue( sPageDescName
) >>= sName
;
93 // fix for #i5551# if( sName.getLength() > 0 )
94 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
96 GetExport().EncodeStyleName( sName
) );
101 ProgressBarHelper
*pProgress
= GetExport().GetProgressBarHelper();
102 pProgress
->SetValue( pProgress
->GetValue()+2 );
106 void XMLTextParagraphExport::exportNumStyles( bool bUsed
)
108 SvxXMLNumRuleExport
aNumRuleExport( GetExport() );
109 aNumRuleExport
.exportStyles( bUsed
, pListAutoPool
, !IsBlockMode() );
112 void XMLTextParagraphExport::exportTextStyles( bool bUsed
, bool bProg
)
114 bool bOldProg
= bProgress
;
117 Reference
< lang::XMultiServiceFactory
> xFactory (GetExport().GetModel(), UNO_QUERY
);
120 OUString
sTextDefaults ( "com.sun.star.text.Defaults" );
121 Reference
< XPropertySet
> xPropSet (xFactory
->createInstance ( sTextDefaults
), UNO_QUERY
);
124 exportDefaultStyle( xPropSet
, GetXMLToken(XML_PARAGRAPH
), GetParaPropMapper());
128 GetXMLToken(XML_TABLE
),
129 new XMLTextExportPropertySetMapper(
130 new XMLTextPropertySetMapper(
131 TextPropMap::TABLE_DEFAULTS
, true ),
136 GetXMLToken(XML_TABLE_ROW
),
137 new XMLTextExportPropertySetMapper(
138 new XMLTextPropertySetMapper(
139 TextPropMap::TABLE_ROW_DEFAULTS
, true ),
143 exportStyleFamily( "ParagraphStyles", GetXMLToken(XML_PARAGRAPH
), GetParaPropMapper(),
144 bUsed
, XML_STYLE_FAMILY_TEXT_PARAGRAPH
, 0);
145 exportStyleFamily( "CharacterStyles", GetXMLToken(XML_TEXT
), GetTextPropMapper(),
146 bUsed
, XML_STYLE_FAMILY_TEXT_TEXT
);
147 // get shape export to make sure the frame family is added correctly.
148 GetExport().GetShapeExport();
149 exportStyleFamily( "FrameStyles", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME
), GetFramePropMapper(),
150 bUsed
, XML_STYLE_FAMILY_TEXT_FRAME
, 0);
151 exportNumStyles( bUsed
);
154 exportTextFootnoteConfiguration();
155 XMLSectionExport::ExportBibliographyConfiguration(GetExport());
156 XMLLineNumberingExport
aLineNumberingExport(GetExport());
157 aLineNumberingExport
.Export();
160 bProgress
= bOldProg
;
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */