Hi all,
I've started on
https://bugs.documentfoundation.org/show_bug.cgi?id=101242. My current
work is in the attachment.
Problem: Although I remove the config-items IsVisible, IsPrintable,
IsLocked from the settings.xml of a file, the values from draw:display
and draw:locked of the <draw:layer> element are not used. It seems to
me, that somewhere the read values are overwritten with a default.
Where and when are the values from settings.xml transformed to
properties of the layers of a newly opened draw document?
Any other hint, where to look?
Besides that, it would be nice, if you could tell me, if my approach is
correct so far.
Kind regards
Regina
diff --git a/xmloff/source/draw/layerexp.cxx b/xmloff/source/draw/layerexp.cxx
index e1a3727f97f0..ec880e24f211 100644
--- a/xmloff/source/draw/layerexp.cxx
+++ b/xmloff/source/draw/layerexp.cxx
@@ -56,6 +56,9 @@ void SdXMLayerExporter::exportLayer( SvXMLExport& rExport )
const OUString strName( "Name" );
const OUString strTitle( "Title" );
const OUString strDescription( "Description" );
+ const OUString strIsLocked( "IsLocked" );
+ const OUString strIsVisible( "IsVisible" );
+ const OUString strIsPrintable( "IsPrintable" );
OUString sTmp;
@@ -70,6 +73,40 @@ void SdXMLayerExporter::exportLayer( SvXMLExport& rExport )
if(!sTmp.isEmpty())
rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_NAME, sTmp );
+ bool bIsLocked;
+ xLayer->getPropertyValue( strIsLocked ) >>= bIsLocked;
+ if ( bIsLocked )
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_PROTECTED, "true" );
+ else
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_PROTECTED, "false" );
+
+ bool bIsVisible;
+ xLayer->getPropertyValue( strIsVisible ) >>= bIsVisible;
+ bool bIsPrintable;
+ xLayer->getPropertyValue( strIsPrintable ) >>= bIsPrintable;
+ if ( bIsVisible )
+ {
+ if ( bIsPrintable )
+ {
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY, "always" );
+ }
+ else
+ {
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY, "screen" );
+ }
+ }
+ else
+ {
+ if ( bIsPrintable )
+ {
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY, "printer" );
+ }
+ else
+ {
+ rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_DISPLAY, "none" );
+ }
+ }
+
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 bc28f6c83226..77b7dabe4b43 100644
--- a/xmloff/source/draw/layerimp.cxx
+++ b/xmloff/source/draw/layerimp.cxx
@@ -58,6 +58,8 @@ public:
private:
css::uno::Reference< css::container::XNameAccess > mxLayerManager;
OUString msName;
+ OUString mseDisplay; // always, none, printer, screen
+ OUString msbProtected; // false, true
OUStringBuffer sDescriptionBuffer;
OUStringBuffer sTitleBuffer;
};
@@ -77,7 +79,14 @@ SdXMLLayerContext::SdXMLLayerContext( SvXMLImport& rImport, sal_uInt16 nPrefix,
if( IsXMLToken( aLocalName, XML_NAME ) )
{
msName = sValue;
- break; // no more attributes needed
+ }
+ if( IsXMLToken( aLocalName, XML_PROTECTED ) )
+ {
+ msbProtected = sValue;
+ }
+ if( IsXMLToken( aLocalName, XML_DISPLAY ) )
+ {
+ mseDisplay = sValue;
}
}
}
@@ -127,6 +136,27 @@ void SdXMLLayerContext::EndElement()
{
xLayer->setPropertyValue("Title", Any( sTitleBuffer.makeStringAndClear() ) );
xLayer->setPropertyValue("Description", Any( sDescriptionBuffer.makeStringAndClear() )
);
+ xLayer->setPropertyValue("IsLocked",(msbProtected == "true") ? Any(true) : Any(false)
);
+ if( mseDisplay == "always" )
+ {
+ xLayer->setPropertyValue("IsVisible", Any(true) );
+ xLayer->setPropertyValue("IsPrintable", Any(true) );
+ }
+ else if( mseDisplay == "screen" )
+ {
+ xLayer->setPropertyValue("IsVisible", Any(true) );
+ xLayer->setPropertyValue("IsPrintable",Any(false) );
+ }
+ else if( mseDisplay == "printer" )
+ {
+ xLayer->setPropertyValue("IsVisible", Any(false) );
+ xLayer->setPropertyValue("IsPrintable", Any(true) );
+ }
+ else // "none"
+ {
+ xLayer->setPropertyValue("IsVisible", Any(false) );
+ xLayer->setPropertyValue("IsPrintable", Any(false) );
+ }
}
}
catch( Exception& )
Context
- Need code pointer for import of <draw:layer> attributes · Regina Henschel
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.