tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / xmloff / source / text / txtstyle.cxx
blobeba368134fe7322484810b0c3816ab2d61ae3bfb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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::beans;
46 using namespace ::xmloff::token;
48 void XMLTextParagraphExport::exportStyleAttributes(
49 const css::uno::Reference< css::style::XStyle > & rStyle )
51 Reference< XPropertySet > xPropSet( rStyle, UNO_QUERY );
52 Reference< XPropertySetInfo > xPropSetInfo(
53 xPropSet->getPropertySetInfo());
54 if( xPropSetInfo->hasPropertyByName( gsCategory ) )
56 sal_Int16 nCategory = 0;
57 xPropSet->getPropertyValue( gsCategory ) >>= nCategory;
58 enum XMLTokenEnum eValue = XML_TOKEN_INVALID;
59 if( -1 != nCategory )
61 switch( nCategory )
63 case ParagraphStyleCategory::TEXT:
64 eValue = XML_TEXT;
65 break;
66 case ParagraphStyleCategory::CHAPTER:
67 eValue = XML_CHAPTER;
68 break;
69 case ParagraphStyleCategory::LIST:
70 eValue = XML_LIST;
71 break;
72 case ParagraphStyleCategory::INDEX:
73 eValue = XML_INDEX;
74 break;
75 case ParagraphStyleCategory::EXTRA:
76 eValue = XML_EXTRA;
77 break;
78 case ParagraphStyleCategory::HTML:
79 eValue = XML_HTML;
80 break;
83 if( eValue != XML_TOKEN_INVALID )
84 GetExport().AddAttribute( XML_NAMESPACE_STYLE, XML_CLASS, eValue);
86 if( xPropSetInfo->hasPropertyByName( gsPageDescName ) )
88 Reference< XPropertyState > xPropState( xPropSet, uno::UNO_QUERY );
89 if( PropertyState_DIRECT_VALUE ==
90 xPropState->getPropertyState( gsPageDescName ) )
92 OUString sName;
93 xPropSet->getPropertyValue( gsPageDescName ) >>= sName;
94 // fix for #i5551# if( sName.getLength() > 0 )
95 GetExport().AddAttribute( XML_NAMESPACE_STYLE,
96 XML_MASTER_PAGE_NAME,
97 GetExport().EncodeStyleName( sName ) );
100 if( m_bProgress )
102 ProgressBarHelper *pProgress = GetExport().GetProgressBarHelper();
103 pProgress->SetValue( pProgress->GetValue()+2 );
107 void XMLTextParagraphExport::exportNumStyles( bool bUsed )
109 SvxXMLNumRuleExport aNumRuleExport( GetExport() );
110 aNumRuleExport.exportStyles(bUsed, !IsBlockMode());
113 void XMLTextParagraphExport::exportTextStyles( bool bUsed, bool bProg )
115 bool bOldProg = m_bProgress;
116 m_bProgress = bProg;
118 Reference < lang::XMultiServiceFactory > xFactory (GetExport().GetModel(), UNO_QUERY);
119 if (xFactory.is())
121 Reference < XPropertySet > xPropSet (xFactory->createInstance ( u"com.sun.star.text.Defaults"_ustr ), UNO_QUERY);
122 if (xPropSet.is())
124 exportDefaultStyle( xPropSet, GetXMLToken(XML_PARAGRAPH), GetParaPropMapper());
126 exportDefaultStyle(
127 xPropSet,
128 GetXMLToken(XML_TABLE),
129 new XMLTextExportPropertySetMapper(
130 new XMLTextPropertySetMapper(
131 TextPropMap::TABLE_DEFAULTS, true ),
132 GetExport() ) );
134 exportDefaultStyle(
135 xPropSet,
136 GetXMLToken(XML_TABLE_ROW),
137 new XMLTextExportPropertySetMapper(
138 new XMLTextPropertySetMapper(
139 TextPropMap::TABLE_ROW_DEFAULTS, true ),
140 GetExport() ) );
143 exportStyleFamily( u"ParagraphStyles"_ustr, GetXMLToken(XML_PARAGRAPH), GetParaPropMapper(),
144 bUsed, XmlStyleFamily::TEXT_PARAGRAPH);
145 exportStyleFamily( u"CharacterStyles"_ustr, GetXMLToken(XML_TEXT), GetTextPropMapper(),
146 bUsed, XmlStyleFamily::TEXT_TEXT );
147 // get shape export to make sure the frame family is added correctly.
148 GetExport().GetShapeExport();
149 exportStyleFamily( u"FrameStyles"_ustr, XML_STYLE_FAMILY_SD_GRAPHICS_NAME, m_xFramePropMapper,
150 bUsed, XmlStyleFamily::TEXT_FRAME);
151 exportNumStyles( bUsed );
152 if( !IsBlockMode() )
154 exportTextFootnoteConfiguration();
155 XMLSectionExport::ExportBibliographyConfiguration(GetExport());
156 XMLLineNumberingExport aLineNumberingExport(GetExport());
157 aLineNumberingExport.Export();
160 m_bProgress = bOldProg;
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */