From 117fdb9898dcc379b4f83437e858c57fd1d11911 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 21 Nov 2012 22:21:40 +0100 Subject: convert users of XDocumentInfo to XDocumentProperties Change-Id: I10f395f90d554d0ec26fe9f2654ae839e21c7ee5 --- basic/inc/basic/basicmanagerrepository.hxx | 3 +- comphelper/source/misc/documentinfo.cxx | 2 +- cui/source/customize/cfgutil.cxx | 1 - filter/source/msfilter/msvbahelper.cxx | 15 +- odk/pack/copying/idl_chapter_refs.txt | 16 +- .../star/document/XDocumentSubStorageSupplier.idl | 3 - offapi/com/sun/star/sdb/DocumentDefinition.idl | 3 +- qadevOOo/tests/java/mod/_sc/XMLMetaExporter.java | 12 +- qadevOOo/tests/java/mod/_sc/XMLMetaImporter.java | 22 +- qadevOOo/tests/java/mod/_sm/XMLMetaExporter.java | 14 +- qadevOOo/tests/java/mod/_sm/XMLMetaImporter.java | 37 ++-- qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java | 13 +- qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java | 22 +- .../java/mod/_xmloff/Draw/XMLMetaExporter.java | 12 +- .../java/mod/_xmloff/Draw/XMLMetaImporter.java | 23 +-- .../java/mod/_xmloff/Impress/XMLMetaExporter.java | 14 +- .../java/mod/_xmloff/Impress/XMLMetaImporter.java | 23 +-- sd/source/filter/ppt/pptin.cxx | 2 +- sfx2/inc/guisaveas.hxx | 5 +- sfx2/source/appl/appopen.cxx | 2 +- sfx2/source/doc/doctemplates.cxx | 56 ++---- sfx2/source/doc/guisaveas.cxx | 74 ++++--- sfx2/source/doc/objcont.cxx | 32 ++- sfx2/source/doc/objxtor.cxx | 1 - svtools/source/contnr/contentenumeration.cxx | 25 +-- svtools/source/contnr/contentenumeration.hxx | 7 +- sw/source/filter/html/swhtml.cxx | 2 +- sw/source/filter/ww8/ww8par.cxx | 7 +- sw/source/ui/vba/vbadocument.cxx | 9 +- sw/source/ui/vba/vbadocumentproperties.cxx | 222 ++++++++++++++++++--- swext/mediawiki/src/com/sun/star/wiki/Helper.java | 38 +--- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 1 - 32 files changed, 416 insertions(+), 302 deletions(-) diff --git a/basic/inc/basic/basicmanagerrepository.hxx b/basic/inc/basic/basicmanagerrepository.hxx index 490457e21a84..411aeadb8545 100644 --- a/basic/inc/basic/basicmanagerrepository.hxx +++ b/basic/inc/basic/basicmanagerrepository.hxx @@ -76,7 +76,8 @@ namespace basic @param _rxDocumentModel denotes the document model whose BasicManager is to be retrieved. Must not be . - The document should support the XDocumentInfoSupplier interface, for retrieving + The document should support the XDocumentPropertiesSupplier + interface, for retrieving its title, which is needed in some error conditions. Also it must support the XStorageBasedDocument interface, since we must be able to retrieve the document's storage. If this interface is not diff --git a/comphelper/source/misc/documentinfo.cxx b/comphelper/source/misc/documentinfo.cxx index 9a9994592ed7..0ada1a74f536 100644 --- a/comphelper/source/misc/documentinfo.cxx +++ b/comphelper/source/misc/documentinfo.cxx @@ -112,7 +112,7 @@ namespace comphelper { return sTitle; } - // 3. try the UNO DocumentInfo + // 3. try the UNO XDocumentProperties Reference< XDocumentPropertiesSupplier > xDPS( _rxDocument, UNO_QUERY ); if ( xDPS.is() ) { diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx index 410cd1090a2c..4043252a4967 100644 --- a/cui/source/customize/cfgutil.cxx +++ b/cui/source/customize/cfgutil.cxx @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index be76c32806a6..cdfa730bdbeb 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -127,11 +126,13 @@ SfxObjectShell* findShellForUrl( const rtl::OUString& sMacroURLOrPath ) if ( sMacroURLOrPath.endsWithIgnoreAsciiCaseAsciiL( ".dot", 4 ) ) { - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( xModel, uno::UNO_QUERY ); - if( xDocInfoSupp.is() ) + uno::Reference const + xDocPropSupp(xModel, uno::UNO_QUERY); + if (xDocPropSupp.is()) { - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); + uno::Reference< document::XDocumentProperties > const + xDocProps(xDocPropSupp->getDocumentProperties(), + uno::UNO_QUERY_THROW); rtl::OUString sCurrName = xDocProps->getTemplateName(); if( sMacroURLOrPath.lastIndexOf( sCurrName ) >= 0 ) { @@ -391,8 +392,8 @@ MacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUString& if ( xPrjNameCache.is() ) { // is this document created from a template? - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( pShell->GetModel(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); + uno::Reference< document::XDocumentPropertiesSupplier > const + xDocPropSupp(pShell->GetModel(), uno::UNO_QUERY_THROW); uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); rtl::OUString sCreatedFrom = xDocProps->getTemplateURL(); diff --git a/odk/pack/copying/idl_chapter_refs.txt b/odk/pack/copying/idl_chapter_refs.txt index 58d93cce9c1b..852ede042e0f 100644 --- a/odk/pack/copying/idl_chapter_refs.txt +++ b/odk/pack/copying/idl_chapter_refs.txt @@ -2088,7 +2088,7 @@ com.sun.star.document.OfficeDocument com.sun.star.lang.XMultiServiceFactory com.sun.star.container.XChild com.sun.star.document.XEventsSupplier -com.sun.star.document.XDocumentInfoSupplier +com.sun.star.document.XDocumentPropertiesSupplier TOPIC: LINK:Documentation/DevGuide/GUI/The_Example_Listings @@ -6599,12 +6599,12 @@ com.sun.star.document.ImportFilter com.sun.star.document.ExportFilter TOPIC: -LINK:Documentation/DevGuide/OfficeDev/Component/Models#XDocumentInfoSupplier -DESCR:OfficeDev - Component - Models - XDocumentInfoSupplier +LINK:Documentation/DevGuide/OfficeDev/Component/Models#XDocumentPropertiesSupplier +DESCR:OfficeDev - Component - Models - XDocumentPropertiesSupplier REF: -com.sun.star.document.XDocumentInfoSupplier +com.sun.star.document.XDocumentPropertiesSupplier TOPIC: -com.sun.star.document.XDocumentInfoSupplier +com.sun.star.document.XDocumentPropertiesSupplier LINK:Documentation/DevGuide/FirstSteps/Struct DESCR:FirstSteps - Struct @@ -7024,10 +7024,10 @@ com.sun.star.lang.XComponent LINK:Documentation/DevGuide/Text/Settings#General_Document_Information DESCR:Text - Settings - General Document Information REF: -com.sun.star.document.DocumentInfo -com.sun.star.document.XDocumentInfoSupplier +com.sun.star.document.DocumentProperties +com.sun.star.document.XDocumentPropertiesSupplier TOPIC: -com.sun.star.document.XDocumentInfoSupplier +com.sun.star.document.XDocumentPropertiesSupplier LINK:Documentation/DevGuide/Text/Sorting_Text DESCR:Text - Sorting Text diff --git a/offapi/com/sun/star/document/XDocumentSubStorageSupplier.idl b/offapi/com/sun/star/document/XDocumentSubStorageSupplier.idl index 48cddc357914..ce2d7ef56927 100644 --- a/offapi/com/sun/star/document/XDocumentSubStorageSupplier.idl +++ b/offapi/com/sun/star/document/XDocumentSubStorageSupplier.idl @@ -31,9 +31,6 @@ module com { module sun { module star { module document {

A temporary interface to get access to documents substorages.

- - @see DocumentInfo - @see StandaloneDocumentInfo */ interface XDocumentSubStorageSupplier: com::sun::star::uno::XInterface { diff --git a/offapi/com/sun/star/sdb/DocumentDefinition.idl b/offapi/com/sun/star/sdb/DocumentDefinition.idl index 1dafb93a9930..3a7220070aba 100644 --- a/offapi/com/sun/star/sdb/DocumentDefinition.idl +++ b/offapi/com/sun/star/sdb/DocumentDefinition.idl @@ -51,7 +51,8 @@ service DocumentDefinition the execute method is the model of the loaded document.
  • preview: retrieves an image showing a preview of the sub document.
  • getDocumentInfo: retrieves the document information, as - XDocumentInfo instance, of the sub document.
  • + XDocumentProperties + instance, of the sub document.
  • delete: deletes the sub document from the database document.
  • close: closes the sub document, if it had previously been opened using either the open or openDesign command. The return value diff --git a/qadevOOo/tests/java/mod/_sc/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_sc/XMLMetaExporter.java index 2fde6b2a544d..9732359bf501 100644 --- a/qadevOOo/tests/java/mod/_sc/XMLMetaExporter.java +++ b/qadevOOo/tests/java/mod/_sc/XMLMetaExporter.java @@ -28,7 +28,8 @@ import util.SOfficeFactory; import util.XMLTools; import com.sun.star.beans.XPropertySet; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.document.XExporter; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; @@ -133,11 +134,10 @@ public class XMLMetaExporter extends TestCase { xEx.setSourceDocument(xSheetDoc); // Obtaining and changing property values - XDocumentInfoSupplier infoSup = UnoRuntime.queryInterface (XDocumentInfoSupplier.class, - xSheetDoc) ; - XPropertySet docInfo = UnoRuntime.queryInterface - (XPropertySet.class, infoSup.getDocumentInfo()) ; - docInfo.setPropertyValue("Title", "TestDocument"); + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xSheetDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + xDocProps.setTitle("TestDocument"); log.println("fill sheet 1 with contnet..."); util.CalcTools.fillCalcSheetWithContent(xSheetDoc,1, 3, 3, 50, 50); diff --git a/qadevOOo/tests/java/mod/_sc/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_sc/XMLMetaImporter.java index f5df59c92d24..c494520f53cc 100644 --- a/qadevOOo/tests/java/mod/_sc/XMLMetaImporter.java +++ b/qadevOOo/tests/java/mod/_sc/XMLMetaImporter.java @@ -27,7 +27,8 @@ import lib.TestParameters; import util.SOfficeFactory; import com.sun.star.beans.XPropertySet; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.document.XImporter; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; @@ -160,24 +161,17 @@ public class XMLMetaImporter extends TestCase { tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; - XDocumentInfoSupplier infoSup = UnoRuntime.queryInterface(XDocumentInfoSupplier.class, xSheetDoc) ; - final XPropertySet docInfo = UnoRuntime.queryInterface - (XPropertySet.class, infoSup.getDocumentInfo()) ; + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xSheetDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); final PrintWriter logF = log ; tEnv.addObjRelation("XDocumentHandler.ImportChecker", new ifc.xml.sax._XDocumentHandler.ImportChecker() { public boolean checkImport() { - try { - String title = (String) docInfo.getPropertyValue - ("Title") ; - logF.println("Title returned = '" + title + "'") ; - return impTitle.equals(title) ; - } catch (com.sun.star.uno.Exception e) { - logF.println("Exception occurred while checking filter :") ; - e.printStackTrace(logF) ; - return false ; - } + String title = xDocProps.getTitle(); + logF.println("Title returned = '" + title + "'") ; + return impTitle.equals(title) ; } }) ; diff --git a/qadevOOo/tests/java/mod/_sm/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_sm/XMLMetaExporter.java index 9c961854c6e4..2c7535cdb13c 100644 --- a/qadevOOo/tests/java/mod/_sm/XMLMetaExporter.java +++ b/qadevOOo/tests/java/mod/_sm/XMLMetaExporter.java @@ -27,8 +27,9 @@ import lib.TestParameters; import util.SOfficeFactory; import util.XMLTools; -import com.sun.star.document.XDocumentInfo; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.beans.XPropertyContainer; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.document.XExporter; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; @@ -126,10 +127,11 @@ public class XMLMetaExporter extends TestCase { xEx.setSourceDocument(xMathDoc); // setting a new name and value for user info field - XDocumentInfoSupplier xDocInfoSup = UnoRuntime.queryInterface(XDocumentInfoSupplier.class, xMathDoc) ; - XDocumentInfo xDocInfo = xDocInfoSup.getDocumentInfo() ; - xDocInfo.setUserFieldName((short) 0, expName) ; - xDocInfo.setUserFieldValue((short) 0, expValue) ; + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xMathDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + XPropertyContainer xProps = xDocProps.getUserDefinedProperties(); + xProps.addProperty(expName, (short)0, expValue); } catch (com.sun.star.uno.Exception e) { e.printStackTrace(log) ; throw new StatusException("Can't create component.", e) ; diff --git a/qadevOOo/tests/java/mod/_sm/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_sm/XMLMetaImporter.java index bde9b09712cb..ebd31ebca4e2 100644 --- a/qadevOOo/tests/java/mod/_sm/XMLMetaImporter.java +++ b/qadevOOo/tests/java/mod/_sm/XMLMetaImporter.java @@ -27,8 +27,10 @@ import lib.TestParameters; import util.SOfficeFactory; import com.sun.star.beans.XPropertySet; -import com.sun.star.document.XDocumentInfo; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.beans.Property; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.UnoRuntime; @@ -114,13 +116,9 @@ public class XMLMetaImporter extends TestCase { final String impValue = "XMLMetaImporter_Value" ; final String impTitle = "XMLMetaImporter Title" ; - final XDocumentInfoSupplier xDocInfoSup ; try { oObj = (XInterface)xMSF.createInstance( "com.sun.star.comp.Math.XMLMetaImporter"); - - xDocInfoSup = UnoRuntime.queryInterface - (XDocumentInfoSupplier.class, xMathDoc) ; } catch (com.sun.star.uno.Exception e) { e.printStackTrace(log); throw new StatusException("Unexpected exception", e); @@ -156,20 +154,29 @@ public class XMLMetaImporter extends TestCase { new ifc.xml.sax._XDocumentHandler.ImportChecker() { public boolean checkImport() { try { - XDocumentInfo xDocInfo = xDocInfoSup.getDocumentInfo() ; - XPropertySet xDocInfoProp = UnoRuntime.queryInterface - (XPropertySet.class, xDocInfo) ; - boolean result = false ; - for (short i = 0; i < xDocInfo.getUserFieldCount(); i++) { - String gName = xDocInfo.getUserFieldName(i) ; - String gValue = xDocInfo.getUserFieldValue(i) ; + XDocumentPropertiesSupplier xPropSup = + UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xMathDoc); + final XDocumentProperties xDocProps = + xPropSup.getDocumentProperties(); + + XPropertySet xUDProps = UnoRuntime.queryInterface( + XPropertySet.class, + xDocProps.getUserDefinedProperties()); + XPropertySetInfo xInfo = + xUDProps.getPropertySetInfo(); + Property[] props = xInfo.getProperties(); + boolean result = false; + for (int i = 0; i < props.length; i++) { + String gName = props[i].Name; + String gValue = (String) + xUDProps.getPropertyValue(gName); logF.println("Field '" + gName + "' = '" + gValue + "'") ; if (impName.equals(gName) && impValue.equals(gValue)) result = true ; } - String gTitle = (String) xDocInfoProp.getPropertyValue - ("Title"); + String gTitle = xDocProps.getTitle(); logF.println("Title returned : '" + gTitle + "'"); result &= impTitle.equals(gTitle) ; diff --git a/qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java index dadcd90ddbd5..1de4f4baee13 100644 --- a/qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java +++ b/qadevOOo/tests/java/mod/_sw/XMLMetaExporter.java @@ -28,7 +28,8 @@ import util.SOfficeFactory; import util.XMLTools; import com.sun.star.beans.XPropertySet; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.document.XExporter; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.text.XTextDocument; @@ -129,12 +130,10 @@ public class XMLMetaExporter extends TestCase { xEx.setSourceDocument(xTextDoc); //set some meta data - XDocumentInfoSupplier infoSup = UnoRuntime.queryInterface - (XDocumentInfoSupplier.class, xTextDoc) ; - XPropertySet docInfo = UnoRuntime.queryInterface - (XPropertySet.class, infoSup.getDocumentInfo()) ; - docInfo.setPropertyValue("Title", TITLE); - + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xTextDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + xDocProps.setTitle(TITLE); } catch (com.sun.star.uno.Exception e) { e.printStackTrace(log) ; throw new StatusException("Can't create component.", e) ; diff --git a/qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java index c234003caf8c..7e071d8e504d 100644 --- a/qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java +++ b/qadevOOo/tests/java/mod/_sw/XMLMetaImporter.java @@ -27,7 +27,8 @@ import lib.TestParameters; import util.SOfficeFactory; import com.sun.star.beans.XPropertySet; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.text.XTextDocument; import com.sun.star.uno.UnoRuntime; @@ -153,24 +154,17 @@ public class XMLMetaImporter extends TestCase { tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; - XDocumentInfoSupplier infoSup = UnoRuntime.queryInterface - (XDocumentInfoSupplier.class, xTextDoc) ; - final XPropertySet docInfo = UnoRuntime.queryInterface - (XPropertySet.class, infoSup.getDocumentInfo()) ; + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xTextDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); final PrintWriter logF = log ; tEnv.addObjRelation("XDocumentHandler.ImportChecker", new ifc.xml.sax._XDocumentHandler.ImportChecker() { public boolean checkImport() { - try { - String title = (String) docInfo.getPropertyValue("Title") ; - logF.println("Title returned = '" + title + "'") ; - return impTitle.equals(title) ; - } catch (com.sun.star.uno.Exception e) { - logF.println("Exception occurred while checking filter :") ; - e.printStackTrace(logF) ; - return false ; - } + String title = xDocProps.getTitle(); + logF.println("Title returned = '" + title + "'") ; + return impTitle.equals(title) ; } }) ; diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaExporter.java index 01b61cb665f7..af8a5b7e83b0 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaExporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaExporter.java @@ -28,7 +28,8 @@ import util.SOfficeFactory; import util.XMLTools; import com.sun.star.beans.XPropertySet; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.document.XExporter; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; @@ -128,11 +129,10 @@ public class XMLMetaExporter extends TestCase { xEx.setSourceDocument(xDrawDoc); //set some meta data - XDocumentInfoSupplier infoSup = UnoRuntime.queryInterface(XDocumentInfoSupplier.class, - xDrawDoc) ; - XPropertySet docInfo = UnoRuntime.queryInterface - (XPropertySet.class, infoSup.getDocumentInfo()) ; - docInfo.setPropertyValue("Title", TITLE); + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xDrawDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + xDocProps.setTitle(TITLE); } catch (com.sun.star.uno.Exception e) { e.printStackTrace(log) ; diff --git a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaImporter.java index 1fbfb34922c8..afbfad4dfd94 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaImporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Draw/XMLMetaImporter.java @@ -27,7 +27,8 @@ import lib.TestParameters; import util.SOfficeFactory; import com.sun.star.beans.XPropertySet; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.UnoRuntime; @@ -152,25 +153,17 @@ public class XMLMetaImporter extends TestCase { tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; //set some meta data - XDocumentInfoSupplier infoSup = UnoRuntime.queryInterface - (XDocumentInfoSupplier.class, xDrawDoc); - final XPropertySet docInfo = UnoRuntime.queryInterface - (XPropertySet.class, infoSup.getDocumentInfo()); + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xDrawDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); final PrintWriter logF = log ; tEnv.addObjRelation("XDocumentHandler.ImportChecker", new ifc.xml.sax._XDocumentHandler.ImportChecker() { public boolean checkImport() { - try { - String title = (String) docInfo.getPropertyValue - ("Title") ; - logF.println("Title returned = '" + title + "'") ; - return impTitle.equals(title) ; - } catch (com.sun.star.uno.Exception e) { - logF.println("Exception occurred while checking filter :") ; - e.printStackTrace(logF) ; - return false ; - } + String title = xDocProps.getTitle(); + logF.println("Title returned = '" + title + "'") ; + return impTitle.equals(title) ; } }) ; diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java index 1ab04a13492c..5a21079cd266 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaExporter.java @@ -28,7 +28,8 @@ import util.SOfficeFactory; import util.XMLTools; import com.sun.star.beans.XPropertySet; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.document.XExporter; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; @@ -128,12 +129,11 @@ public class XMLMetaExporter extends TestCase { XExporter xEx = UnoRuntime.queryInterface(XExporter.class,oObj); xEx.setSourceDocument(xImpressDoc); - //change title name - XDocumentInfoSupplier infoSup = UnoRuntime.queryInterface - (XDocumentInfoSupplier.class, xImpressDoc) ; - XPropertySet docInfo = UnoRuntime.queryInterface - (XPropertySet.class, infoSup.getDocumentInfo()) ; - docInfo.setPropertyValue("Title", NAME); + // change title name + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xImpressDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); + xDocProps.setTitle(NAME); } catch (com.sun.star.uno.Exception e) { e.printStackTrace(log) ; diff --git a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java index b504d262572a..6dbd37f6c12d 100644 --- a/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java +++ b/qadevOOo/tests/java/mod/_xmloff/Impress/XMLMetaImporter.java @@ -27,7 +27,8 @@ import lib.TestParameters; import util.SOfficeFactory; import com.sun.star.beans.XPropertySet; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.UnoRuntime; @@ -151,25 +152,17 @@ public class XMLMetaImporter extends TestCase { tEnv.addObjRelation("XDocumentHandler.XMLData", xml) ; - XDocumentInfoSupplier infoSup = UnoRuntime.queryInterface - (XDocumentInfoSupplier.class, xImpressDoc) ; - final XPropertySet docInfo = UnoRuntime.queryInterface - (XPropertySet.class, infoSup.getDocumentInfo()) ; + XDocumentPropertiesSupplier xPropSup = UnoRuntime.queryInterface + (XDocumentPropertiesSupplier.class, xImpressDoc); + final XDocumentProperties xDocProps = xPropSup.getDocumentProperties(); final PrintWriter logF = log ; tEnv.addObjRelation("XDocumentHandler.ImportChecker", new ifc.xml.sax._XDocumentHandler.ImportChecker() { public boolean checkImport() { - try { - String title = (String) - docInfo.getPropertyValue("Title") ; - logF.println("Title returned = '" + title + "'") ; - return impTitle.equals(title) ; - } catch (com.sun.star.uno.Exception e) { - logF.println("Exception occurred while checking filter :") ; - e.printStackTrace(logF) ; - return false ; - } + String title = xDocProps.getTitle(); + logF.println("Title returned = '" + title + "'") ; + return impTitle.equals(title) ; } } ); diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx index acda309c46da..2ed3aeb6c15c 100644 --- a/sd/source/filter/ppt/pptin.cxx +++ b/sd/source/filter/ppt/pptin.cxx @@ -1367,7 +1367,7 @@ sal_Bool ImplSdPPTImport::Import() delete pStbMgr; - // read DocumentInfo + // read DocumentProperties uno::Reference xDPS( mpDoc->GetObjectShell()->GetModel(), uno::UNO_QUERY_THROW); uno::Reference xDocProps diff --git a/sfx2/inc/guisaveas.hxx b/sfx2/inc/guisaveas.hxx index 689c237a9b52..514508745d79 100644 --- a/sfx2/inc/guisaveas.hxx +++ b/sfx2/inc/guisaveas.hxx @@ -35,7 +35,7 @@ namespace com { namespace sun { namespace star { namespace document { - class XDocumentInfo; + class XDocumentProperties; } } } } @@ -75,7 +75,8 @@ public: static void SetDocInfoState( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel, - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentInfo>& i_xOldDocInfo, + const ::com::sun::star::uno::Reference< + ::com::sun::star::document::XDocumentProperties>& i_xOldDocInfo, sal_Bool bNoModify ); static sal_Bool WarnUnacceptableFormat( diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index 348f1c11f172..6c764b8a2dc8 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -223,7 +223,7 @@ void SetTemplate_Impl( const String &rFileName, const String &rLongName, SfxObjectShell *pDoc) { - // write TemplateName to DocumentInfo of document + // write TemplateName to DocumentProperties of document // TemplateDate stays as default (=current date) pDoc->ResetFromTemplate( rLongName, rFileName ); } diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index 92b91947e841..a724dea9f236 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -42,7 +42,7 @@ #include #include #include -#include +#include #include #include #include @@ -75,7 +75,6 @@ #define TEMPLATE_IMPLEMENTATION_NAME "com.sun.star.comp.sfx2.DocumentTemplates" #define SERVICENAME_TYPEDETECTION "com.sun.star.document.TypeDetection" -#define SERVICENAME_DOCINFO "com.sun.star.document.StandaloneDocumentInfo" #define TEMPLATE_ROOT_URL "vnd.sun.star.hier:/templates" #define TITLE "Title" @@ -177,7 +176,7 @@ class SfxDocTplService_Impl { uno::Reference< XMultiServiceFactory > mxFactory; uno::Reference< XCommandEnvironment > maCmdEnv; - uno::Reference< XStandaloneDocumentInfo > mxInfo; + uno::Reference m_xDocProps; uno::Reference< XTypeDetection > mxType; ::osl::Mutex maMutex; @@ -441,16 +440,15 @@ void SfxDocTplService_Impl::init_Impl() if ( bIsInitialized ) { - OUString aService( SERVICENAME_DOCINFO ); try { - mxInfo = uno::Reference< XStandaloneDocumentInfo > ( - mxFactory->createInstance( aService ), UNO_QUERY ); - } catch (uno::RuntimeException &) { - OSL_FAIL("SfxDocTplService_Impl::init_Impl: " - "cannot create DocumentProperties service"); + m_xDocProps.set(document::DocumentProperties::create( + ::comphelper::getProcessComponentContext())); + } catch (uno::RuntimeException const& e) { + SAL_WARN("sfx.doc", "SfxDocTplService_Impl::init_Impl: " + "cannot create DocumentProperties service:" << e.Message); } - aService = OUString( SERVICENAME_TYPEDETECTION ); + OUString const aService = OUString( SERVICENAME_TYPEDETECTION ); mxType = uno::Reference< XTypeDetection > ( mxFactory->createInstance( aService ), UNO_QUERY ); getDirList(); @@ -643,24 +641,20 @@ sal_Bool SfxDocTplService_Impl::needsUpdate() // ----------------------------------------------------------------------- sal_Bool SfxDocTplService_Impl::setTitleForURL( const OUString& rURL, const OUString& aTitle ) { - sal_Bool bResult = sal_False; - if ( mxInfo.is() ) + if (m_xDocProps.is()) { try { - mxInfo->loadFromURL( rURL ); - uno::Reference< XPropertySet > xPropSet( mxInfo, UNO_QUERY_THROW ); - OUString aPropName( TITLE ); - xPropSet->setPropertyValue( aPropName, uno::makeAny( aTitle ) ); - mxInfo->storeIntoURL( rURL ); - bResult = sal_True; + m_xDocProps->loadFromMedium(rURL, Sequence()); + m_xDocProps->setTitle(aTitle ); + m_xDocProps->storeToMedium(rURL, Sequence()); + return true; } catch ( Exception& ) { } } - - return bResult; + return false; } // ----------------------------------------------------------------------- @@ -668,32 +662,16 @@ sal_Bool SfxDocTplService_Impl::getTitleFromURL( const OUString& rURL, OUString& { bDocHasTitle = sal_False; - if ( mxInfo.is() ) + if (m_xDocProps.is()) { try { - mxInfo->loadFromURL( rURL ); + m_xDocProps->loadFromMedium(rURL, Sequence()); + aTitle = m_xDocProps->getTitle(); } catch ( Exception& ) { } - - try - { - uno::Reference< XPropertySet > aPropSet( mxInfo, UNO_QUERY ); - if ( aPropSet.is() ) - { - OUString aPropName( TITLE ); - Any aValue = aPropSet->getPropertyValue( aPropName ); - aValue >>= aTitle; - - aPropName = OUString( "MIMEType" ); - aValue = aPropSet->getPropertyValue( aPropName ); - aValue >>= aType; - } - } - catch ( UnknownPropertyException& ) {} - catch ( Exception& ) {} } if ( aType.isEmpty() && mxType.is() ) diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index f90432f12006..c6af31615da8 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -29,8 +29,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -1579,11 +1579,11 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& // so the document info can be updated // on export document info must be preserved - uno::Reference xDIS( + uno::Reference xDPS( aModelData.GetModel(), uno::UNO_QUERY_THROW); uno::Reference xCloneable( - xDIS->getDocumentInfo(), uno::UNO_QUERY_THROW); - uno::Reference xOldDocInfo( + xDPS->getDocumentProperties(), uno::UNO_QUERY_THROW); + uno::Reference xOldDocProps( xCloneable->createClone(), uno::UNO_QUERY_THROW); // use dispatch API to show document info dialog @@ -1605,13 +1605,16 @@ sal_Bool SfxStoringHelper::GUIStoreModel( const uno::Reference< frame::XModel >& catch( const uno::Exception& ) { if ( ( nStoreMode & EXPORT_REQUESTED ) ) - SetDocInfoState( aModelData.GetModel(), xOldDocInfo, sal_True ); - + { + SetDocInfoState(aModelData.GetModel(), xOldDocProps, sal_True); + } throw; } if ( ( nStoreMode & EXPORT_REQUESTED ) ) - SetDocInfoState( aModelData.GetModel(), xOldDocInfo, sal_True ); + { + SetDocInfoState(aModelData.GetModel(), xOldDocProps, sal_True); + } } else { @@ -1665,16 +1668,15 @@ sal_Bool SfxStoringHelper::CheckFilterOptionsAppearence( // static void SfxStoringHelper::SetDocInfoState( const uno::Reference< frame::XModel >& xModel, - const uno::Reference< document::XDocumentInfo >& i_xOldDocInfo, + const uno::Reference< document::XDocumentProperties>& i_xOldDocProps, sal_Bool bNoModify ) { - uno::Reference< document::XDocumentInfoSupplier > xModelDocInfoSupplier( xModel, uno::UNO_QUERY ); - if ( !xModelDocInfoSupplier.is() ) - throw uno::RuntimeException(); // TODO: - - uno::Reference< document::XDocumentInfo > xDocInfoToFill = xModelDocInfoSupplier->getDocumentInfo(); - uno::Reference< beans::XPropertySet > xPropSet( i_xOldDocInfo, - uno::UNO_QUERY_THROW ); + uno::Reference const + xModelDocPropsSupplier(xModel, uno::UNO_QUERY_THROW); + uno::Reference const xDocPropsToFill = + xModelDocPropsSupplier->getDocumentProperties(); + uno::Reference< beans::XPropertySet > const xPropSet( + i_xOldDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW); uno::Reference< util::XModifiable > xModifiable( xModel, uno::UNO_QUERY ); if ( bNoModify && !xModifiable.is() ) @@ -1684,7 +1686,8 @@ void SfxStoringHelper::SetDocInfoState( try { - uno::Reference< beans::XPropertySet > xSet( xDocInfoToFill, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > const xSet( + xDocPropsToFill->getUserDefinedProperties(), uno::UNO_QUERY); uno::Reference< beans::XPropertyContainer > xContainer( xSet, uno::UNO_QUERY ); uno::Reference< beans::XPropertySetInfo > xSetInfo = xSet->getPropertySetInfo(); uno::Sequence< beans::Property > lProps = xSetInfo->getProperties(); @@ -1695,8 +1698,12 @@ void SfxStoringHelper::SetDocInfoState( { uno::Any aValue = xPropSet->getPropertyValue( pProps[i].Name ); if ( pProps[i].Attributes & ::com::sun::star::beans::PropertyAttribute::REMOVABLE ) + try + { // QUESTION: DefaultValue?! xContainer->addProperty( pProps[i].Name, pProps[i].Attributes, aValue ); + } + catch (beans::PropertyExistException const&) {} try { // it is possible that the propertysets from XML and binary files differ; we shouldn't break then @@ -1705,17 +1712,30 @@ void SfxStoringHelper::SetDocInfoState( catch ( const uno::Exception& ) {} } - sal_Int16 nCount = i_xOldDocInfo->getUserFieldCount(); - sal_Int16 nSupportedCount = xDocInfoToFill->getUserFieldCount(); - for ( sal_Int16 nInd = 0; nInd < nCount && nInd < nSupportedCount; nInd++ ) - { - ::rtl::OUString aPropName = i_xOldDocInfo->getUserFieldName( nInd ); - xDocInfoToFill->setUserFieldName( nInd, aPropName ); - ::rtl::OUString aPropVal = i_xOldDocInfo->getUserFieldValue( nInd ); - xDocInfoToFill->setUserFieldValue( nInd, aPropVal ); - } + // sigh... have to set these manually i'm afraid... wonder why + // SfxObjectShell doesn't handle this internally, should be easier + xDocPropsToFill->setAuthor(i_xOldDocProps->getAuthor()); + xDocPropsToFill->setGenerator(i_xOldDocProps->getGenerator()); + xDocPropsToFill->setCreationDate(i_xOldDocProps->getCreationDate()); + xDocPropsToFill->setTitle(i_xOldDocProps->getTitle()); + xDocPropsToFill->setSubject(i_xOldDocProps->getSubject()); + xDocPropsToFill->setDescription(i_xOldDocProps->getDescription()); + xDocPropsToFill->setKeywords(i_xOldDocProps->getKeywords()); + xDocPropsToFill->setModifiedBy(i_xOldDocProps->getModifiedBy()); + xDocPropsToFill->setModificationDate(i_xOldDocProps->getModificationDate()); + xDocPropsToFill->setPrintedBy(i_xOldDocProps->getPrintedBy()); + xDocPropsToFill->setPrintDate(i_xOldDocProps->getPrintDate()); + xDocPropsToFill->setAutoloadURL(i_xOldDocProps->getAutoloadURL()); + xDocPropsToFill->setAutoloadSecs(i_xOldDocProps->getAutoloadSecs()); + xDocPropsToFill->setDefaultTarget(i_xOldDocProps->getDefaultTarget()); + xDocPropsToFill->setEditingCycles(i_xOldDocProps->getEditingCycles()); + xDocPropsToFill->setEditingDuration(i_xOldDocProps->getEditingDuration()); + // other attributes e.g. DocumentStatistics are not editable from dialog + } + catch (const uno::Exception& e) + { + SAL_INFO("sfx.doc", "SetDocInfoState: caught exception: " << e.Message); } - catch ( const uno::Exception& ) {} // set the modified flag back if required if ( bNoModify && bIsModified != xModifiable->isModified() ) diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index c96162e454d1..8511f63354e9 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -20,12 +20,11 @@ #include +#include #include #include #include #include -#include -#include #include #include #include @@ -893,29 +892,22 @@ void SfxObjectShell::UpdateFromTemplate_Impl( ) // should the document checked against changes in the template ? if ( IsQueryLoadTemplate() ) { - // load document info of template - sal_Bool bOK = sal_False; + // load document properties of template + bool bOK = false; util::DateTime aTemplDate; try { - Reference < document::XStandaloneDocumentInfo > xDocInfo ( - ::comphelper::getProcessServiceFactory()->createInstance( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.document.StandaloneDocumentInfo") ) ), - UNO_QUERY_THROW ); - Reference < beans::XFastPropertySet > xSet( xDocInfo, - UNO_QUERY_THROW ); - xDocInfo->loadFromURL( aTemplURL ); - Any aAny = xSet->getFastPropertyValue( WID_DATE_MODIFIED ); - ::com::sun::star::util::DateTime aTmp; - if ( aAny >>= aTemplDate ) - { - // get modify date from document info - bOK = sal_True; - } + Reference const + xTemplateDocProps( document::DocumentProperties::create( + ::comphelper::getProcessComponentContext())); + xTemplateDocProps->loadFromMedium(aTemplURL, + Sequence()); + aTemplDate = xTemplateDocProps->getModificationDate(); + bOK = true; } - catch (const Exception&) + catch (const Exception& e) { + SAL_INFO("sfx.doc", "caught exception" << e.Message); } // if modify date was read successfully diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index deee41ba3368..08b2743acc7f 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -110,7 +110,6 @@ using ::basic::BasicManagerRepository; DBG_NAME(SfxObjectShell) -#define DocumentInfo #include "sfxslots.hxx" namespace { diff --git a/svtools/source/contnr/contentenumeration.cxx b/svtools/source/contnr/contentenumeration.cxx index c317a233abdc..766221a5badc 100644 --- a/svtools/source/contnr/contentenumeration.cxx +++ b/svtools/source/contnr/contentenumeration.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +72,8 @@ namespace svt using ::com::sun::star::ucb::XContentAccess; using ::com::sun::star::ucb::XCommandEnvironment; using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::beans::PropertyValue; + using ::com::sun::star::document::DocumentProperties; using ::rtl::OUString; using ::ucbhelper::ResultSetInclude; using ::ucbhelper::INCLUDE_FOLDERS_AND_DOCUMENTS; @@ -379,26 +382,20 @@ namespace svt try { ::osl::MutexGuard aGuard( m_aMutex ); - if( !m_xDocInfo.is() ) + if (!m_xDocProps.is()) { - m_xDocInfo = m_xDocInfo.query( - ::comphelper::getProcessServiceFactory()->createInstance( - String( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.StandaloneDocumentInfo") ) - ) - ); + m_xDocProps.set(DocumentProperties::create( + ::comphelper::getProcessComponentContext())); } - DBG_ASSERT( m_xDocInfo.is(), "FileViewContentEnumerator::implGetDocTitle: no DocumentProperties service!" ); - if ( !m_xDocInfo.is() ) + assert(m_xDocProps.is()); + if (!m_xDocProps.is()) return sal_False; - m_xDocInfo->loadFromURL( _rTargetURL ); - Reference< XPropertySet > xPropSet( m_xDocInfo, UNO_QUERY ); + m_xDocProps->loadFromMedium(_rTargetURL, Sequence()); - Any aAny = xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" )) ); - - OUString sTitle; - if ( ( aAny >>= sTitle ) && !sTitle.isEmpty() ) + OUString const sTitle(m_xDocProps->getTitle()); + if (!sTitle.isEmpty()) { _rRet = sTitle; bRet = sal_True; diff --git a/svtools/source/contnr/contentenumeration.hxx b/svtools/source/contnr/contentenumeration.hxx index 8188bde91f59..775f2a661f25 100644 --- a/svtools/source/contnr/contentenumeration.hxx +++ b/svtools/source/contnr/contentenumeration.hxx @@ -21,7 +21,7 @@ #define SVTOOLS_SOURCE_CONTNR_CONTENTENUMERATION_HXX #include -#include +#include #include #include #include @@ -198,8 +198,9 @@ namespace svt IEnumerationResultHandler* m_pResultHandler; bool m_bCancelled; - mutable ::com::sun::star::uno::Reference< ::com::sun::star::document::XStandaloneDocumentInfo > - m_xDocInfo; + mutable ::com::sun::star::uno::Reference< + ::com::sun::star::document::XDocumentProperties> + m_xDocProps; ::com::sun::star::uno::Sequence< ::rtl::OUString > m_rBlackList; diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 4c2d5e346871..b9eb5347036f 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -845,7 +845,7 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( sal_False ).nNode.GetIndex() ) } } - // und noch die DocumentInfo aufbereiten + // adjust AutoLoad in DocumentProperties if( IsNewDoc() ) { SwDocShell *pDocShell(pDoc->GetDocShell()); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 0bd27b23050a..ef163cd62132 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -106,7 +106,6 @@ #include "ww8toolbar.hxx" #include -#include #include @@ -1453,7 +1452,7 @@ void SwWW8ImplReader::Read_Tab(sal_uInt16 , const sal_uInt8* pData, short nLen) void SwWW8ImplReader::ImportDop() { - // correct the LastPrinted date in DocumentInfo + // correct the LastPrinted date in DocumentProperties uno::Reference xDPS( mpDocShell->GetModel(), uno::UNO_QUERY_THROW); uno::Reference xDocuProps( @@ -4561,8 +4560,8 @@ sal_uLong SwWW8ImplReader::CoreLoad(WW8Glossary *pGloss, const SwPosition &rPos) if (mbNewDoc && pStg && !pGloss) /*meaningless for a glossary, cmc*/ { mpDocShell->SetIsTemplate( pWwFib->fDot ); // point at tgc record - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( mpDocShell->GetModel(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); + uno::Reference const + xDocPropSupp(mpDocShell->GetModel(), uno::UNO_QUERY_THROW); uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); rtl::OUString sCreatedFrom = xDocProps->getTemplateURL(); diff --git a/sw/source/ui/vba/vbadocument.cxx b/sw/source/ui/vba/vbadocument.cxx index 604521849ef4..395f684fe4b0 100644 --- a/sw/source/ui/vba/vbadocument.cxx +++ b/sw/source/ui/vba/vbadocument.cxx @@ -33,7 +33,6 @@ #include "vbavariables.hxx" #include #include -#include #include #include #include @@ -260,8 +259,8 @@ uno::Any SAL_CALL SwVbaDocument::getAttachedTemplate() throw (uno::RuntimeException) { uno::Reference< word::XTemplate > xTemplate; - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( getModel(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); + uno::Reference const xDocPropSupp( + getModel(), uno::UNO_QUERY_THROW); uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); rtl::OUString sTemplateUrl = xDocProps->getTemplateURL(); @@ -287,8 +286,8 @@ SwVbaDocument::setAttachedTemplate( const css::uno::Any& _attachedtemplate ) thr osl::FileBase::getFileURLFromSystemPath( sTemplate, aURL ); uno::Reference< word::XTemplate > xTemplate; - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( getModel(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); + uno::Reference const xDocPropSupp( + getModel(), uno::UNO_QUERY_THROW ); uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); xDocProps->setTemplateURL( aURL ); } diff --git a/sw/source/ui/vba/vbadocumentproperties.cxx b/sw/source/ui/vba/vbadocumentproperties.cxx index 8cd8b4b48844..80a06f2bbd2b 100644 --- a/sw/source/ui/vba/vbadocumentproperties.cxx +++ b/sw/source/ui/vba/vbadocumentproperties.cxx @@ -28,7 +28,7 @@ #include "vbadocumentproperties.hxx" #include #include -#include +#include #include #include #include @@ -73,17 +73,22 @@ class PropertGetSetHelper { protected: uno::Reference< frame::XModel > m_xModel; - uno::Reference< beans::XPropertySet > mxProps; + uno::Reference m_xDocProps; public: PropertGetSetHelper( const uno::Reference< frame::XModel >& xModel ):m_xModel( xModel ) { - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( m_xModel, uno::UNO_QUERY_THROW ); - mxProps.set( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); + uno::Reference const + xDocPropSupp(m_xModel, uno::UNO_QUERY_THROW); + m_xDocProps.set(xDocPropSupp->getDocumentProperties(), + uno::UNO_SET_THROW); } virtual ~PropertGetSetHelper() {} virtual uno::Any getPropertyValue( const rtl::OUString& rPropName ) = 0; virtual void setPropertyValue( const rtl::OUString& rPropName, const uno::Any& aValue ) = 0; - virtual uno::Reference< beans::XPropertySet > getUnoProperties() { return mxProps; } + virtual uno::Reference< beans::XPropertySet > getUserDefinedProperties() { + return uno::Reference( + m_xDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW); + } }; @@ -97,15 +102,174 @@ public: { if ( rPropName == "EditingDuration" ) { - sal_Int32 nSecs = 0; - mxProps->getPropertyValue( rPropName ) >>= nSecs; + sal_Int32 const nSecs = m_xDocProps->getEditingDuration(); return uno::makeAny( nSecs/60 ); // minutes } - return mxProps->getPropertyValue( rPropName ); + else if ("Title" == rPropName) + { + return uno::makeAny(m_xDocProps->getTitle()); + } + else if ("Subject" == rPropName) + { + return uno::makeAny(m_xDocProps->getSubject()); + } + else if ("Author" == rPropName) + { + return uno::makeAny(m_xDocProps->getAuthor()); + } + else if ("Keywords" == rPropName) + { + return uno::makeAny(m_xDocProps->getKeywords()); + } + else if ("Description" == rPropName) + { + return uno::makeAny(m_xDocProps->getDescription()); + } + else if ("Template" == rPropName) + { + return uno::makeAny(m_xDocProps->getTemplateName()); + } + else if ("ModifiedBy" == rPropName) + { + return uno::makeAny(m_xDocProps->getModifiedBy()); + } + else if ("Generator" == rPropName) + { + return uno::makeAny(m_xDocProps->getGenerator()); + } + else if ("PrintDate" == rPropName) + { + return uno::makeAny(m_xDocProps->getPrintDate()); + } + else if ("CreationDate" == rPropName) + { + return uno::makeAny(m_xDocProps->getCreationDate()); + } + else if ("ModifyDate" == rPropName) + { + return uno::makeAny(m_xDocProps->getModificationDate()); + } + else if ("AutoloadURL" == rPropName) + { + return uno::makeAny(m_xDocProps->getAutoloadURL()); + } + else + { + // fall back to user-defined properties + return getUserDefinedProperties()->getPropertyValue(rPropName); + } } virtual void setPropertyValue( const rtl::OUString& rPropName, const uno::Any& aValue ) { - mxProps->setPropertyValue( rPropName, aValue ); + if ("EditingDuration" == rPropName) + { + sal_Int32 nMins = 0; + if (aValue >>= nMins) + { + m_xDocProps->setEditingDuration(nMins * 60); // convert minutes + } + } + else if ("Title" == rPropName) + { + OUString str; + if (aValue >>= str) + { + m_xDocProps->setTitle(str); + } + } + else if ("Subject" == rPropName) + { + OUString str; + if (aValue >>= str) + { + m_xDocProps->setSubject(str); + } + } + else if ("Author" == rPropName) + { + OUString str; + if (aValue >>= str) + { + m_xDocProps->setAuthor(str); + } + } + else if ("Keywords" == rPropName) + { + uno::Sequence keywords; + if (aValue >>= keywords) + { + m_xDocProps->setKeywords(keywords); + } + } + else if ("Description" == rPropName) + { + OUString str; + if (aValue >>= str) + { + m_xDocProps->setDescription(str); + } + } + else if ("Template" == rPropName) + { + OUString str; + if (aValue >>= str) + { + m_xDocProps->setTemplateName(str); + } + } + else if ("ModifiedBy" == rPropName) + { + OUString str; + if (aValue >>= str) + { + m_xDocProps->setModifiedBy(str); + } + } + else if ("Generator" == rPropName) + { + OUString str; + if (aValue >>= str) + { + return m_xDocProps->setGenerator(str); + } + } + else if ("PrintDate" == rPropName) + { + util::DateTime dt; + if (aValue >>= dt) + { + m_xDocProps->setPrintDate(dt); + } + } + else if ("CreationDate" == rPropName) + { + util::DateTime dt; + if (aValue >>= dt) + { + m_xDocProps->setCreationDate(dt); + } + } + else if ("ModifyDate" == rPropName) + { + util::DateTime dt; + if (aValue >>= dt) + { + m_xDocProps->setModificationDate(dt); + } + } + else if ("AutoloadURL" == rPropName) + { + OUString str; + if (aValue >>= str) + { + m_xDocProps->setAutoloadURL(str); + } + } + else + { + // fall back to user-defined properties + getUserDefinedProperties()->setPropertyValue(rPropName, aValue); + } } }; @@ -114,11 +278,18 @@ class CustomPropertyGetSetHelper : public BuiltinPropertyGetSetHelper public: CustomPropertyGetSetHelper( const uno::Reference< frame::XModel >& xModel ) :BuiltinPropertyGetSetHelper( xModel ) { - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( mxProps, uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentProperties > xDocProp( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); - mxProps.set( xDocProp->getUserDefinedProperties(), uno::UNO_QUERY_THROW ); + } + virtual uno::Any getPropertyValue( const rtl::OUString& rPropName ) + { + return getUserDefinedProperties()->getPropertyValue(rPropName); + } + virtual void setPropertyValue( + const rtl::OUString& rPropName, const uno::Any& rValue) + { + return getUserDefinedProperties()->setPropertyValue(rPropName, rValue); } }; + class StatisticPropertyGetSetHelper : public PropertGetSetHelper { SwDocShell* mpDocShell; @@ -131,7 +302,6 @@ public: } virtual uno::Any getPropertyValue( const rtl::OUString& rPropName ) { - uno::Sequence< beans::NamedValue > stats; try { // Characters, ParagraphCount & WordCount are available from @@ -156,8 +326,8 @@ public: } else { - mxModelProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParagraphCount") ) ) >>= stats; - mxProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentStatistic") ) ) >>= stats; + uno::Sequence< beans::NamedValue > const stats( + m_xDocProps->getDocumentStatistics()); sal_Int32 nLen = stats.getLength(); bool bFound = false; @@ -177,9 +347,8 @@ public: virtual void setPropertyValue( const rtl::OUString& rPropName, const uno::Any& aValue ) { - - uno::Sequence< beans::NamedValue > stats; - mxProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentStatistic") ) ) >>= stats; + uno::Sequence< beans::NamedValue > stats( + m_xDocProps->getDocumentStatistics()); sal_Int32 nLen = stats.getLength(); for ( sal_Int32 index = 0; index < nLen; ++index ) @@ -187,7 +356,7 @@ public: if ( rPropName.equals( stats[ index ].Name ) ) { stats[ index ].Value = aValue; - mxProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentStatistic") ), uno::makeAny( stats ) ); + m_xDocProps->setDocumentStatistics(stats); break; } } @@ -225,12 +394,11 @@ public: if ( mpPropGetSetHelper.get() ) mpPropGetSetHelper->setPropertyValue( msOOOPropName, rValue ); } - uno::Reference< beans::XPropertySet > getUnoProperties() + uno::Reference< beans::XPropertySet > getUserDefinedProperties() { - uno::Reference< beans::XPropertySet > xProps; if ( mpPropGetSetHelper.get() ) - return mpPropGetSetHelper->getUnoProperties(); + return mpPropGetSetHelper->getUserDefinedProperties(); return xProps; } }; @@ -376,7 +544,8 @@ SwVbaCustomDocumentProperty::setType( ::sal_Int8 /*Type*/ ) throw (script::Basic void SAL_CALL SwVbaCustomDocumentProperty::Delete( ) throw (script::BasicErrorException, uno::RuntimeException) { - uno::Reference< beans::XPropertyContainer > xContainer( mPropInfo.getUnoProperties(), uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertyContainer > xContainer( + mPropInfo.getUserDefinedProperties(), uno::UNO_QUERY_THROW); xContainer->removeProperty( getName() ); } @@ -512,7 +681,6 @@ protected: uno::Reference< XHelperInterface > m_xParent; uno::Reference< uno::XComponentContext > m_xContext; uno::Reference< frame::XModel > m_xModel; - uno::Reference< document::XDocumentInfo > m_xOOOBuiltIns; DocProps mDocProps; DocPropsByName mNamedDocProps; @@ -643,11 +811,9 @@ public: CustomPropertiesImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel ) { // suck in the document( custom ) properties - uno::Reference< document::XDocumentInfoSupplier > xDocInfoSupp( m_xModel, uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentPropertiesSupplier > xDocPropSupp( xDocInfoSupp->getDocumentInfo(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XDocumentProperties > xDocProp( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW ); - mxUserDefinedProp.set( xDocProp->getUserDefinedProperties(), uno::UNO_QUERY_THROW ); mpPropGetSetHelper.reset( new CustomPropertyGetSetHelper( m_xModel ) ); + mxUserDefinedProp.set(mpPropGetSetHelper->getUserDefinedProperties(), + uno::UNO_SET_THROW); }; // XIndexAccess virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java index c9a45959d975..9601579aa798 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java +++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java @@ -32,7 +32,8 @@ import com.sun.star.container.XContainerQuery; import com.sun.star.container.XEnumeration; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; -import com.sun.star.document.XDocumentInfoSupplier; +import com.sun.star.document.XDocumentPropertiesSupplier; +import com.sun.star.document.XDocumentProperties; import com.sun.star.frame.XModel; import com.sun.star.frame.XModuleManager; import com.sun.star.io.XInputStream; @@ -462,37 +463,18 @@ public class Helper protected static String GetDocTitle( XModel xDoc ) { - String sTitle = ""; - XDocumentInfoSupplier xDocInfoSup = ( XDocumentInfoSupplier ) UnoRuntime.queryInterface( XDocumentInfoSupplier.class, xDoc ); - XPropertySet xPropSet = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, xDocInfoSup.getDocumentInfo() ); - try - { - sTitle = ( String ) xPropSet.getPropertyValue( "Title" ); - } catch ( Exception ex ) - { - ex.printStackTrace(); - } - return sTitle; + XDocumentPropertiesSupplier xDocPropSup = + UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xDoc); + XDocumentProperties xDocProps = xDocPropSup.getDocumentProperties(); + return xDocProps.getTitle(); } protected static void SetDocTitle( XModel xDoc, String sTitle ) { - XDocumentInfoSupplier xDocInfoSup = ( XDocumentInfoSupplier ) UnoRuntime.queryInterface( XDocumentInfoSupplier.class, xDoc ); - if ( xDocInfoSup != null ) - { - XPropertySet xPropSet = ( XPropertySet ) UnoRuntime.queryInterface( XPropertySet.class, xDocInfoSup.getDocumentInfo() ); - if ( xPropSet != null ) - { - try - { - xPropSet.setPropertyValue( "Title", sTitle ); - } - catch ( Exception ex ) - { - ex.printStackTrace(); - } - } - } + XDocumentPropertiesSupplier xDocPropSup = + UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xDoc); + XDocumentProperties xDocProps = xDocPropSup.getDocumentProperties(); + xDocProps.setTitle(sTitle); } protected static String GetDocServiceName( XComponentContext xContext, XModel xModel ) diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index abdbe10c0fca..d64cf1aa3a5d 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include -- cgit