Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <com/sun/star/style/ParagraphStyleCategory.hpp>
31 : : #include <com/sun/star/beans/XPropertySet.hpp>
32 : : #include <com/sun/star/beans/XPropertySetInfo.hpp>
33 : : #include <com/sun/star/beans/XPropertyState.hpp>
34 : : #include <com/sun/star/style/XStyle.hpp>
35 : : #include <xmloff/xmltoken.hxx>
36 : : #include "xmloff/xmlnmspe.hxx"
37 : : #include <xmloff/families.hxx>
38 : : #include <xmloff/txtparae.hxx>
39 : : #include <xmloff/xmlnume.hxx>
40 : : #include <xmloff/xmlexp.hxx>
41 : : #include "XMLSectionExport.hxx"
42 : : #include "XMLLineNumberingExport.hxx"
43 : : #include "txtexppr.hxx"
44 : : #include <xmloff/txtprmap.hxx>
45 : :
46 : : using ::rtl::OUString;
47 : : using ::rtl::OUStringBuffer;
48 : :
49 : : using namespace ::com::sun::star;
50 : : using namespace ::com::sun::star::uno;
51 : : using namespace ::com::sun::star::style;
52 : : using namespace ::com::sun::star::container;
53 : : using namespace ::com::sun::star::beans;
54 : : using namespace ::xmloff::token;
55 : :
56 : 156 : void XMLTextParagraphExport::exportStyleAttributes(
57 : : const ::com::sun::star::uno::Reference<
58 : : ::com::sun::star::style::XStyle > & rStyle )
59 : : {
60 : 156 : OUString sName;
61 : 156 : Any aAny;
62 [ + - ]: 156 : Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
63 : : Reference< XPropertySetInfo > xPropSetInfo(
64 [ + - ][ + - ]: 156 : xPropSet->getPropertySetInfo());
65 [ + - ][ + - ]: 156 : if( xPropSetInfo->hasPropertyByName( sCategory ) )
[ + + ]
66 : : {
67 : 139 : sal_Int16 nCategory = 0;
68 [ + - ][ + - ]: 139 : xPropSet->getPropertyValue( sCategory ) >>= nCategory;
69 : 139 : enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
70 [ + + ]: 139 : if( -1 != nCategory )
71 : : {
72 [ + - + + : 130 : switch( nCategory )
+ - - ]
73 : : {
74 : : case ParagraphStyleCategory::TEXT:
75 : 59 : eValue = XML_TEXT;
76 : 59 : break;
77 : : case ParagraphStyleCategory::CHAPTER:
78 : 0 : eValue = XML_CHAPTER;
79 : 0 : break;
80 : : case ParagraphStyleCategory::LIST:
81 : 19 : eValue = XML_LIST;
82 : 19 : break;
83 : : case ParagraphStyleCategory::INDEX:
84 : 33 : eValue = XML_INDEX;
85 : 33 : break;
86 : : case ParagraphStyleCategory::EXTRA:
87 : 19 : eValue = XML_EXTRA;
88 : 19 : break;
89 : : case ParagraphStyleCategory::HTML:
90 : 0 : eValue = XML_HTML;
91 : 130 : break;
92 : : }
93 : : }
94 [ + + ]: 139 : if( eValue != XML_TOKEN_INVALID )
95 [ + - ]: 139 : GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_CLASS, eValue);
96 : : }
97 [ + - ][ + - ]: 156 : if( xPropSetInfo->hasPropertyByName( sPageDescName ) )
[ + + ]
98 : : {
99 [ + - ]: 139 : Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
100 [ - + ]: 139 : if( PropertyState_DIRECT_VALUE ==
101 [ + - ][ + - ]: 139 : xPropState->getPropertyState( sPageDescName ) )
102 : : {
103 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( sPageDescName ) >>= sName;
104 : : // fix for #i5551# if( sName.getLength() > 0 )
105 : 0 : GetExport().AddAttribute( XML_NAMESPACE_STYLE,
106 : : XML_MASTER_PAGE_NAME,
107 [ # # # # ]: 0 : GetExport().EncodeStyleName( sName ) );
108 : 139 : }
109 : : }
110 [ + - ]: 156 : if( bProgress )
111 : : {
112 [ + - ]: 156 : ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
113 [ + - ]: 156 : pProgress->SetValue( pProgress->GetValue()+2 );
114 : 156 : }
115 : 156 : }
116 : :
117 : 21 : void XMLTextParagraphExport::exportNumStyles( sal_Bool bUsed )
118 : : {
119 [ + - ]: 21 : SvxXMLNumRuleExport aNumRuleExport( GetExport() );
120 [ + - ][ + - ]: 21 : aNumRuleExport.exportStyles( bUsed, pListAutoPool, !IsBlockMode() );
121 : 21 : }
122 : :
123 : 21 : void XMLTextParagraphExport::exportTextStyles( sal_Bool bUsed, sal_Bool bProg )
124 : : {
125 : 21 : sal_Bool bOldProg = bProgress;
126 : 21 : bProgress = bProg;
127 : :
128 [ + - ]: 21 : Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY);
129 [ + - ]: 21 : if (xFactory.is())
130 : : {
131 [ + - ]: 21 : OUString sTextDefaults ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.Defaults" ) );
132 [ + - ][ + - ]: 21 : Reference < XPropertySet > xPropSet (xFactory->createInstance ( sTextDefaults ), UNO_QUERY);
[ + - ]
133 [ + - ]: 21 : if (xPropSet.is())
134 : : {
135 [ + - ][ + - ]: 21 : exportDefaultStyle( xPropSet, GetXMLToken(XML_PARAGRAPH), GetParaPropMapper());
[ + - ][ + - ]
136 : :
137 : : exportDefaultStyle(
138 : : xPropSet,
139 [ + - ]: 21 : GetXMLToken(XML_TABLE),
140 : : new XMLTextExportPropertySetMapper(
141 : : new XMLTextPropertySetMapper(
142 [ + - ]: 21 : TEXT_PROP_MAP_TABLE_DEFAULTS ),
143 [ + - ][ + - ]: 63 : GetExport() ) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
144 : :
145 : : exportDefaultStyle(
146 : : xPropSet,
147 [ + - ]: 21 : GetXMLToken(XML_TABLE_ROW),
148 : : new XMLTextExportPropertySetMapper(
149 : : new XMLTextPropertySetMapper(
150 [ + - ]: 21 : TEXT_PROP_MAP_TABLE_ROW_DEFAULTS ),
151 [ + - ][ + - ]: 63 : GetExport() ) );
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
152 : 21 : }
153 : : }
154 [ + - ]: 21 : exportStyleFamily( "ParagraphStyles", GetXMLToken(XML_PARAGRAPH), GetParaPropMapper(),
155 [ + - ][ + - ]: 42 : bUsed, XML_STYLE_FAMILY_TEXT_PARAGRAPH, 0);
[ + - ]
156 [ + - ]: 21 : exportStyleFamily( "CharacterStyles", GetXMLToken(XML_TEXT), GetTextPropMapper(),
157 [ + - ][ + - ]: 42 : bUsed, XML_STYLE_FAMILY_TEXT_TEXT );
[ + - ]
158 : : // get shape export to make sure the the frame family is added correctly.
159 [ + - ][ + - ]: 21 : GetExport().GetShapeExport();
160 : : exportStyleFamily( "FrameStyles", OUString(RTL_CONSTASCII_USTRINGPARAM(XML_STYLE_FAMILY_SD_GRAPHICS_NAME)), GetFramePropMapper(),
161 [ + - ][ + - ]: 21 : bUsed, XML_STYLE_FAMILY_TEXT_FRAME, 0);
[ + - ][ + - ]
162 [ + - ]: 21 : exportNumStyles( bUsed );
163 [ + + ]: 21 : if( !IsBlockMode() )
164 : : {
165 [ + - ]: 19 : exportTextFootnoteConfiguration();
166 [ + - ]: 19 : XMLSectionExport::ExportBibliographyConfiguration(GetExport());
167 [ + - ]: 19 : XMLLineNumberingExport aLineNumberingExport(GetExport());
168 [ + - ]: 19 : aLineNumberingExport.Export();
169 : : }
170 : :
171 : 21 : bProgress = bOldProg;
172 : 21 : }
173 : :
174 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|