14#include <com/sun/star/container/XIndexReplace.hpp>
15#include <com/sun/star/container/XNamed.hpp>
16#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
17#include <com/sun/star/util/MeasureUnit.hpp>
18#include <com/sun/star/xml/sax/Writer.hpp>
45 :
public ::cppu::WeakImplHelper<container::XNamed,container::XIndexReplace>
74 virtual OUString SAL_CALL
getName()
override
85 virtual void SAL_CALL
setName(OUString
const& rName)
override
95 return ::cppu::UnoType<uno::Sequence<beans::PropertyValue>>
::get();
112 throw lang::IndexOutOfBoundsException();
121 OUString
const* pCharStyleName(
nullptr);
127 assert(pCharStyleName);
129 uno::Sequence<beans::PropertyValue>
const ret(
131 *pNumFormat, *pCharStyleName, &dummy,
""));
137 sal_Int32 nIndex,
uno::Any const& rElement)
override
140 throw lang::IndexOutOfBoundsException();
141 uno::Sequence<beans::PropertyValue>
props;
142 if (!(rElement >>=
props))
143 throw lang::IllegalArgumentException(
"invalid type",
148 OUString charStyleName;
152 nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
161class StoredChapterNumberingExport
165 StoredChapterNumberingExport(
166 uno::Reference<uno::XComponentContext>
const& xContext,
167 OUString
const& rFileName,
168 uno::Reference<xml::sax::XDocumentHandler>
const& xHandler)
169 :
SvXMLExport(xContext,
"sw::StoredChapterNumberingExport", rFileName,
170 util::MeasureUnit::
CM, xHandler)
184 virtual void ExportAutoStyles_()
override {}
185 virtual void ExportMasterStyles_()
override {}
186 virtual void ExportContent_()
override {}
189 uno::Reference<container::XIndexReplace>
const& xRule)
191 uno::Reference<container::XNamed>
const xNamed(xRule, uno::UNO_QUERY);
192 OUString
const name(xNamed->getName());
193 bool bEncoded(
false);
194 AddAttribute( XML_NAMESPACE_STYLE, XML_NAME,
195 EncodeStyleName(name, &bEncoded) );
198 AddAttribute(XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, name);
202 XML_OUTLINE_STYLE,
true,
true );
207 std::set<OUString>
const& rCharStyles,
208 std::vector<uno::Reference<container::XIndexReplace>>
const& rRules)
210 GetDocHandler()->startDocument();
212 AddAttribute(XML_NAMESPACE_NONE,
213 GetNamespaceMap_().GetAttrNameByKey(XML_NAMESPACE_OFFICE),
214 GetNamespaceMap_().GetNameByKey(XML_NAMESPACE_OFFICE));
215 AddAttribute(XML_NAMESPACE_NONE,
216 GetNamespaceMap_().GetAttrNameByKey (XML_NAMESPACE_TEXT),
217 GetNamespaceMap_().GetNameByKey(XML_NAMESPACE_TEXT));
218 AddAttribute(XML_NAMESPACE_NONE,
219 GetNamespaceMap_().GetAttrNameByKey(XML_NAMESPACE_STYLE),
220 GetNamespaceMap_().GetNameByKey(XML_NAMESPACE_STYLE));
221 AddAttribute(XML_NAMESPACE_NONE,
222 GetNamespaceMap_().GetAttrNameByKey(XML_NAMESPACE_FO),
223 GetNamespaceMap_().GetNameByKey(XML_NAMESPACE_FO));
224 AddAttribute(XML_NAMESPACE_NONE,
225 GetNamespaceMap_().GetAttrNameByKey(XML_NAMESPACE_SVG),
226 GetNamespaceMap_().GetNameByKey(XML_NAMESPACE_SVG));
231 XML_NAMESPACE_OFFICE, XML_STYLES,
true,
true);
234 for (
const auto& rCharStyle : rCharStyles)
236 AddAttribute( XML_NAMESPACE_STYLE, XML_FAMILY, XML_TEXT );
237 bool bEncoded(
false);
238 AddAttribute( XML_NAMESPACE_STYLE, XML_NAME,
239 EncodeStyleName(rCharStyle, &bEncoded) );
242 AddAttribute(XML_NAMESPACE_STYLE, XML_DISPLAY_NAME, rCharStyle);
246 XML_NAMESPACE_STYLE, XML_STYLE,
true,
true);
251 for (
const auto& rRule : rRules)
253 ExportRule(numRuleExport, rRule);
257 GetDocHandler()->endDocument();
267class StoredChapterNumberingDummyStyleContext
271 StoredChapterNumberingDummyStyleContext(
272 SvXMLImport & rImport,
273 uno::Reference<xml::sax::XFastAttributeList>
const& xAttrList)
277 OUString displayName;
281 if (aIter.getToken() == (XML_NAMESPACE_STYLE | XML_FAMILY))
284 nFamily = XmlStyleFamily::TEXT_TEXT;
286 name = aIter.toString();
288 displayName = aIter.toString();
290 SAL_WARN(
"xmloff",
"unknown value for style:family=" << aIter.toString());
295 if (nFamily != XmlStyleFamily::DATA_STYLE && !
name.isEmpty() && !displayName.isEmpty())
297 rImport.AddStyleDisplayName(nFamily, name, displayName);
302class StoredChapterNumberingImport;
304class StoredChapterNumberingRootContext
310 std::vector<rtl::Reference<SvxXMLListStyleContext>> m_Contexts;
313 StoredChapterNumberingRootContext(
316 , m_rNumRules(rNumRules)
321 virtual void SAL_CALL endFastElement(sal_Int32 )
override
324 for (
auto iter = m_Contexts.begin(); iter != m_Contexts.end(); ++iter)
326 uno::Reference<container::XIndexReplace>
const xRule(
328 iter - m_Contexts.begin()));
329 (*iter)->FillUnoNumRule(xRule);
331 uno::Reference<container::XNamed>
const xNamed(xRule, uno::UNO_QUERY);
332 xNamed->setName((*iter)->GetDisplayName());
336 virtual css::uno::Reference<XFastContextHandler> SAL_CALL createFastChildContext(
338 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList )
override
342 return new StoredChapterNumberingDummyStyleContext(GetImport(), xAttrList);
344 else if (Element ==
XML_ELEMENT(TEXT, XML_OUTLINE_STYLE))
351 m_Contexts.emplace_back(pContext);
360class StoredChapterNumberingImport
367 StoredChapterNumberingImport(
368 uno::Reference<uno::XComponentContext>
const& xContext,
371 , m_rNumRules(rNumRules)
376 const css::uno::Reference< css::xml::sax::XFastAttributeList > & )
override
379 return new StoredChapterNumberingRootContext(m_rNumRules, *
this);
387 SvStream & rStream, OUString
const& rFileName)
389 uno::Reference<uno::XComponentContext>
const xContext(
390 ::comphelper::getProcessComponentContext());
392 uno::Reference<io::XOutputStream>
const xOutStream(
393 new ::utl::OOutputStreamWrapper(rStream));
395 uno::Reference<xml::sax::XWriter>
const xWriter(
396 xml::sax::Writer::create(xContext));
398 xWriter->setOutputStream(xOutStream);
404 std::set<OUString> charStyles;
405 std::vector<uno::Reference<container::XIndexReplace>> numRules;
410 for (
size_t j = 0; j <
MAXLEVEL; ++j)
413 OUString
const* pCharStyleName(
nullptr);
414 pRule->GetNumFormat(j, pDummy, pCharStyleName);
415 if (pCharStyleName && !pCharStyleName->isEmpty())
417 charStyles.insert(*pCharStyleName);
426 exp->ExportRules(charStyles, numRules);
428 catch (uno::Exception
const&)
435 SvStream & rStream, OUString
const& rFileName)
437 uno::Reference<uno::XComponentContext>
const xContext(
438 ::comphelper::getProcessComponentContext());
440 uno::Reference<io::XInputStream>
const xInStream(
441 new ::utl::OInputStreamWrapper(rStream));
445 xml::sax::InputSource
const source(xInStream,
"",
"", rFileName);
449 xImport->parseStream(source);
451 catch (uno::Exception
const&)
void exportLevelStyles(const css::uno::Reference< css::container::XIndexReplace > &xNumRule, bool bOutline=false)
const SwNumRulesWithName * GetRules(sal_uInt16 nIdx) const
void CreateEmptyNumRule(sal_uInt16 nIdx)
void GetNumFormat(size_t, SwNumFormat const *&, OUString const *&) const
void SetName(const OUString &rSet)
void SetNumFormat(size_t, SwNumFormat const &, OUString const &)
const OUString & GetName() const
static css::uno::Sequence< css::beans::PropertyValue > GetPropertiesForNumFormat(const SwNumFormat &rFormat, OUString const &rCharFormatName, OUString const *pHeadingStyleName, OUString const &referer)
static void SetPropertiesToNumFormat(SwNumFormat &aFormat, OUString &rCharStyleName, OUString *const pBulletFontName, OUString *const pHeadingStyleName, OUString *const pParagraphStyleName, SwDoc *const pDoc, SwDocShell *const pDocShell, css::uno::Sequence< css::beans::PropertyValue > const &rProperties)
virtual void SAL_CALL setName(OUString const &rName) override
SwChapterNumRules & m_rNumRules
virtual uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
virtual uno::Type SAL_CALL getElementType() override
sal_uInt16 const m_nIndex
virtual ::sal_Bool SAL_CALL hasElements() override
SwNumRulesWithName * GetOrCreateRules()
StoredChapterNumberingRules(SwChapterNumRules &rNumRules, sal_uInt16 const nIndex)
virtual OUString SAL_CALL getName() override
virtual sal_Int32 SAL_CALL getCount() override
virtual void SAL_CALL replaceByIndex(sal_Int32 nIndex, uno::Any const &rElement) override
#define TOOLS_WARN_EXCEPTION(area, stream)
#define SAL_WARN(area, stream)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Dialog to specify the properties of date form field.
void ExportStoredChapterNumberingRules(SwChapterNumRules &rRules, SvStream &rStream, OUString const &rFileName)
void ImportStoredChapterNumberingRules(SwChapterNumRules &rRules, SvStream &rStream, OUString const &rFileName)
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
constexpr sal_uInt8 MAXLEVEL
PointerStyles const styles[]
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)