summaryrefslogtreecommitdiff
path: root/xmloff
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2018-08-17 19:02:55 +0200
committerTomaž Vajngerl <quikee@gmail.com>2018-08-27 16:27:17 +0200
commit9826a4e4a6aa9953d3f354fe645a23f9dae59d77 (patch)
tree25a38cbe766a092b8df736ab5c75581d77944895 /xmloff
parent3ed1bd19eb7fb7898bcca8e046e058799f836063 (diff)
tdf#101242 Support draw:display and draw:protect attributes of ODF
LibreOffice writes the properties visible, printable and locked of layers into items in the subfile settings.xml and handles them as properties of the view. ODF handles them as property of the layer. To become more ODF conform as a first step these properties are now read and written. They are used to initialize the view in case they are missing in settings.xml, which is the case for foreign documents. The ODF properties are written in addition to the items in settings.xml, so that older versions will notice no difference with such documents. SdModelTestBase is changed to handle odg as Draw document. Change-Id: I190ecc51fc6ee91ec4b96d06bb216ce517bdfcfe Reviewed-on: https://gerrit.libreoffice.org/59269 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmloff')
-rw-r--r--xmloff/source/draw/layerexp.cxx30
-rw-r--r--xmloff/source/draw/layerimp.cxx24
2 files changed, 53 insertions, 1 deletions
diff --git a/xmloff/source/draw/layerexp.cxx b/xmloff/source/draw/layerexp.cxx
index e1a3727f97f0..72f6b1d84635 100644
--- a/xmloff/source/draw/layerexp.cxx
+++ b/xmloff/source/draw/layerexp.cxx
@@ -56,9 +56,13 @@ void SdXMLayerExporter::exportLayer( SvXMLExport& rExport )
const OUString strName( "Name" );
const OUString strTitle( "Title" );
const OUString strDescription( "Description" );
+ const OUString strIsVisible( "IsVisible");
+ const OUString strIsPrintable( "IsPrintable");
+ const OUString strIsLocked( "IsLocked" );
OUString sTmp;
+
SvXMLElementExport aElem( rExport, XML_NAMESPACE_DRAW, XML_LAYER_SET, true, true );
for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
@@ -70,6 +74,32 @@ void SdXMLayerExporter::exportLayer( SvXMLExport& rExport )
if(!sTmp.isEmpty())
rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, sTmp );
+ bool bTmpVisible( true );
+ bool bTmpPrintable( true );
+ xLayer->getPropertyValue( strIsVisible) >>= bTmpVisible;
+ xLayer->getPropertyValue( strIsPrintable) >>= bTmpPrintable;
+ // only write non-default values, default is "always"
+ if ( bTmpVisible )
+ {
+ if ( !bTmpPrintable )
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY, OUString("screen") );
+ }
+ else
+ {
+ if ( bTmpPrintable)
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY, OUString("printer") );
+ else
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY, OUString("none") );
+ }
+
+ bool bTmpLocked( false );
+ xLayer->getPropertyValue( strIsLocked ) >>= bTmpLocked;
+ // only write non-default value, default is "false"
+ if ( bTmpLocked )
+ {
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_PROTECTED, OUString("true") );
+ }
+
SvXMLElementExport aEle( rExport, XML_NAMESPACE_DRAW, XML_LAYER, true, true );
// title property (as <svg:title> element)
diff --git a/xmloff/source/draw/layerimp.cxx b/xmloff/source/draw/layerimp.cxx
index 3ffde05a447d..13071e600246 100644
--- a/xmloff/source/draw/layerimp.cxx
+++ b/xmloff/source/draw/layerimp.cxx
@@ -60,6 +60,8 @@ private:
OUString msName;
OUStringBuffer sDescriptionBuffer;
OUStringBuffer sTitleBuffer;
+ OUString msDisplay;
+ OUString msProtected;
};
SdXMLLayerContext::SdXMLLayerContext( SvXMLImport& rImport, sal_uInt16 nPrefix, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, const Reference< XNameAccess >& xLayerManager )
@@ -77,7 +79,14 @@ SdXMLLayerContext::SdXMLLayerContext( SvXMLImport& rImport, sal_uInt16 nPrefix,
if( IsXMLToken( aLocalName, XML_NAME ) )
{
msName = sValue;
- break; // no more attributes needed
+ }
+ else if ( IsXMLToken( aLocalName, XML_DISPLAY))
+ {
+ msDisplay = sValue;
+ }
+ else if ( IsXMLToken( aLocalName, XML_PROTECTED))
+ {
+ msProtected = sValue;
}
}
}
@@ -127,6 +136,19 @@ void SdXMLLayerContext::EndElement()
{
xLayer->setPropertyValue("Title", Any( sTitleBuffer.makeStringAndClear() ) );
xLayer->setPropertyValue("Description", Any( sDescriptionBuffer.makeStringAndClear() ) );
+ bool bIsVisible( true );
+ bool bIsPrintable( true );
+ if ( !msDisplay.isEmpty() )
+ {
+ bIsVisible = (msDisplay == "always") || (msDisplay == "screen");
+ bIsPrintable = (msDisplay == "always") || (msDisplay == "printer");
+ }
+ xLayer->setPropertyValue("IsVisible", Any( bIsVisible ) );
+ xLayer->setPropertyValue("IsPrintable", Any( bIsPrintable ) );
+ bool bIsLocked( false );
+ if ( !msProtected.isEmpty() )
+ bIsLocked = (msProtected == "true");
+ xLayer->setPropertyValue("IsLocked", Any( bIsLocked ) );
}
}
catch( Exception& )