summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2022-11-22 14:07:12 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2022-11-29 09:39:22 +0100
commitdaab698b346e5e40b67f1e15c796c4e399ccaf8a (patch)
tree7483cd08e13613e9ff27086cf17d94bbb658e8d1 /xmloff
parent7830ecc2e4e5dd264517c6554078fa807ff1fceb (diff)
sd: replace hardcoded table styles with xml file
Including a new set of default styles, provided by Rafael Lima. Some ui tests had to be modified, because the new borders are thicker. If you intend to edit the xml file, please keep in mind the following requirements: 1) There should be a table template called "default". It's applied to newly inserted tables. 2) There should be a cell style called "default". It's used for new table styles. 3) Please make all cell styles inherit from "default" (directly or indirectly), unless you intend to specify font names in them. "default" has its font names filled programmatically based on officecfg/registry/data/org/openoffice/VCL.xcu. 4) Whenever possible please use <style:table-cell-properties> for cell properties, instead of the incorrect <style:paragraph-properties> and <loext:graphic-properties> we currently use for export. See tdf#72238 and tdf#72239. Change-Id: I73dd4492fefb65b1870238aec7dc64f8076f6e95 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141825 Tested-by: Jenkins Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/draw/sdxmlimp.cxx21
-rw-r--r--xmloff/source/table/XMLTableImport.cxx8
2 files changed, 24 insertions, 5 deletions
diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx
index 6ffc7140531e..6e556ac84a31 100644
--- a/xmloff/source/draw/sdxmlimp.cxx
+++ b/xmloff/source/draw/sdxmlimp.cxx
@@ -333,6 +333,9 @@ void SAL_CALL SdXMLImport::setTargetDocument( const uno::Reference< lang::XCompo
if(xFamSup.is())
mxDocStyleFamilies = xFamSup->getStyleFamilies();
+ if (!mbLoadDoc)
+ return;
+
// prepare access to master pages
uno::Reference < drawing::XMasterPagesSupplier > xMasterPagesSupplier(GetModel(), uno::UNO_QUERY);
if(xMasterPagesSupplier.is())
@@ -372,6 +375,16 @@ void SAL_CALL SdXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen
{
SvXMLImport::initialize( aArguments );
+ OUString const sOrganizerMode("OrganizerMode");
+ bool bStyleOnly(false);
+
+ css::beans::PropertyValue aPropValue;
+ if (aArguments.hasElements() && (aArguments[0] >>= aPropValue) && aPropValue.Name == sOrganizerMode)
+ {
+ aPropValue.Value >>= bStyleOnly;
+ mbLoadDoc = !bStyleOnly;
+ }
+
uno::Reference< beans::XPropertySet > xInfoSet( getImportInfo() );
if( !xInfoSet.is() )
return;
@@ -384,11 +397,8 @@ void SAL_CALL SdXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen
if( xInfoSetInfo->hasPropertyByName( gsPreview ) )
xInfoSet->getPropertyValue( gsPreview ) >>= mbPreview;
- OUString const sOrganizerMode(
- "OrganizerMode");
if (xInfoSetInfo->hasPropertyByName(sOrganizerMode))
{
- bool bStyleOnly(false);
if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly)
{
mbLoadDoc = !bStyleOnly;
@@ -419,6 +429,11 @@ SvXMLImportContext *SdXMLImport::CreateFastContext( sal_Int32 nElement,
pContext = new SdXMLFlatDocContext_Impl( *this, xDPS->getDocumentProperties());
}
break;
+ case XML_ELEMENT( OFFICE, XML_STYLES ):
+ // internal xml file for built in styles
+ if (!mbLoadDoc)
+ pContext = CreateStylesContext();
+ break;
}
return pContext;
}
diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx
index 86b19e768e16..afc86cf4000c 100644
--- a/xmloff/source/table/XMLTableImport.cxx
+++ b/xmloff/source/table/XMLTableImport.cxx
@@ -285,12 +285,16 @@ void XMLTableImport::addTableTemplate( const OUString& rsStyleName, XMLTableTemp
{
auto xPtr = std::make_shared<XMLTableTemplate>();
xPtr->swap( xTableTemplate );
- maTableTemplates[rsStyleName] = xPtr;
+ maTableTemplates.emplace_back(rsStyleName, xPtr);
}
void XMLTableImport::insertTabletemplate(const OUString& rsStyleName, bool bOverwrite)
{
- XMLTableTemplateMap::iterator it = maTableTemplates.find(rsStyleName);
+ // FIXME: All templates will be inserted eventually, but
+ // instead of simply iterating them, like in finishStyles(),
+ // we search here by name again and again.
+ auto it = std::find_if(maTableTemplates.begin(), maTableTemplates.end(),
+ [&rsStyleName](const auto& item) { return rsStyleName == item.first; });
if (it == maTableTemplates.end())
return;