Line data Source code
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 :
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/style/XStyle.hpp>
26 : #include <xmloff/xmltoken.hxx>
27 : #include <xmloff/xmlnmspe.hxx>
28 : #include <xmloff/families.hxx>
29 : #include <xmloff/txtparae.hxx>
30 : #include <xmloff/xmlnume.hxx>
31 : #include <xmloff/xmlexp.hxx>
32 : #include "XMLSectionExport.hxx"
33 : #include "XMLLineNumberingExport.hxx"
34 : #include "txtexppr.hxx"
35 : #include <xmloff/txtprmap.hxx>
36 :
37 :
38 : using namespace ::com::sun::star;
39 : using namespace ::com::sun::star::uno;
40 : using namespace ::com::sun::star::style;
41 : using namespace ::com::sun::star::container;
42 : using namespace ::com::sun::star::beans;
43 : using namespace ::xmloff::token;
44 :
45 0 : void XMLTextParagraphExport::exportStyleAttributes(
46 : const ::com::sun::star::uno::Reference<
47 : ::com::sun::star::style::XStyle > & rStyle )
48 : {
49 0 : OUString sName;
50 0 : Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
51 : Reference< XPropertySetInfo > xPropSetInfo(
52 0 : xPropSet->getPropertySetInfo());
53 0 : if( xPropSetInfo->hasPropertyByName( sCategory ) )
54 : {
55 0 : sal_Int16 nCategory = 0;
56 0 : xPropSet->getPropertyValue( sCategory ) >>= nCategory;
57 0 : enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
58 0 : if( -1 != nCategory )
59 : {
60 0 : switch( nCategory )
61 : {
62 : case ParagraphStyleCategory::TEXT:
63 0 : eValue = XML_TEXT;
64 0 : break;
65 : case ParagraphStyleCategory::CHAPTER:
66 0 : eValue = XML_CHAPTER;
67 0 : break;
68 : case ParagraphStyleCategory::LIST:
69 0 : eValue = XML_LIST;
70 0 : break;
71 : case ParagraphStyleCategory::INDEX:
72 0 : eValue = XML_INDEX;
73 0 : break;
74 : case ParagraphStyleCategory::EXTRA:
75 0 : eValue = XML_EXTRA;
76 0 : break;
77 : case ParagraphStyleCategory::HTML:
78 0 : eValue = XML_HTML;
79 0 : break;
80 : }
81 : }
82 0 : if( eValue != XML_TOKEN_INVALID )
83 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_CLASS, eValue);
84 : }
85 0 : if( xPropSetInfo->hasPropertyByName( sPageDescName ) )
86 : {
87 0 : Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
88 0 : if( PropertyState_DIRECT_VALUE ==
89 0 : xPropState->getPropertyState( sPageDescName ) )
90 : {
91 0 : xPropSet->getPropertyValue( sPageDescName ) >>= sName;
92 : // fix for #i5551# if( sName.getLength() > 0 )
93 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
94 : XML_MASTER_PAGE_NAME,
95 0 : GetExport().EncodeStyleName( sName ) );
96 0 : }
97 : }
98 0 : if( bProgress )
99 : {
100 0 : ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
101 0 : pProgress->SetValue( pProgress->GetValue()+2 );
102 0 : }
103 0 : }
104 :
105 0 : void XMLTextParagraphExport::exportNumStyles( bool bUsed )
106 : {
107 0 : SvxXMLNumRuleExport aNumRuleExport( GetExport() );
108 0 : aNumRuleExport.exportStyles( bUsed, pListAutoPool, !IsBlockMode() );
109 0 : }
110 :
111 0 : void XMLTextParagraphExport::exportTextStyles( bool bUsed, bool bProg )
112 : {
113 0 : sal_Bool bOldProg = bProgress;
114 0 : bProgress = bProg;
115 :
116 0 : Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY);
117 0 : if (xFactory.is())
118 : {
119 0 : OUString sTextDefaults ( "com.sun.star.text.Defaults" );
120 0 : Reference < XPropertySet > xPropSet (xFactory->createInstance ( sTextDefaults ), UNO_QUERY);
121 0 : if (xPropSet.is())
122 : {
123 0 : exportDefaultStyle( xPropSet, GetXMLToken(XML_PARAGRAPH), GetParaPropMapper());
124 :
125 : exportDefaultStyle(
126 : xPropSet,
127 0 : GetXMLToken(XML_TABLE),
128 : new XMLTextExportPropertySetMapper(
129 : new XMLTextPropertySetMapper(
130 0 : TEXT_PROP_MAP_TABLE_DEFAULTS, true ),
131 0 : GetExport() ) );
132 :
133 : exportDefaultStyle(
134 : xPropSet,
135 0 : GetXMLToken(XML_TABLE_ROW),
136 : new XMLTextExportPropertySetMapper(
137 : new XMLTextPropertySetMapper(
138 0 : TEXT_PROP_MAP_TABLE_ROW_DEFAULTS, true ),
139 0 : GetExport() ) );
140 0 : }
141 : }
142 0 : exportStyleFamily( "ParagraphStyles", GetXMLToken(XML_PARAGRAPH), GetParaPropMapper(),
143 0 : bUsed, XML_STYLE_FAMILY_TEXT_PARAGRAPH, 0);
144 0 : exportStyleFamily( "CharacterStyles", GetXMLToken(XML_TEXT), GetTextPropMapper(),
145 0 : bUsed, XML_STYLE_FAMILY_TEXT_TEXT );
146 : // get shape export to make sure the frame family is added correctly.
147 0 : GetExport().GetShapeExport();
148 : exportStyleFamily( "FrameStyles", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), GetFramePropMapper(),
149 0 : bUsed, XML_STYLE_FAMILY_TEXT_FRAME, 0);
150 0 : exportNumStyles( bUsed );
151 0 : if( !IsBlockMode() )
152 : {
153 0 : exportTextFootnoteConfiguration();
154 0 : XMLSectionExport::ExportBibliographyConfiguration(GetExport());
155 0 : XMLLineNumberingExport aLineNumberingExport(GetExport());
156 0 : aLineNumberingExport.Export();
157 : }
158 :
159 0 : bProgress = bOldProg;
160 0 : }
161 :
162 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|