convert users of XDocumentInfo to XDocumentProperties
Change-Id: I10f395f90d554d0ec26fe9f2654ae839e21c7ee5
This commit is contained in:
parent
fe3303b3dc
commit
117fdb9898
@ -76,7 +76,8 @@ namespace basic
|
||||
|
||||
@param _rxDocumentModel
|
||||
denotes the document model whose BasicManager is to be retrieved. Must not be <NULL/>.
|
||||
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 <em>must</em> support the XStorageBasedDocument interface, since we
|
||||
must be able to retrieve the document's storage. If this interface is <em>not</em>
|
||||
|
@ -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() )
|
||||
{
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include <com/sun/star/frame/XDesktop.hpp>
|
||||
#include <com/sun/star/container/XEnumerationAccess.hpp>
|
||||
#include <com/sun/star/container/XEnumeration.hpp>
|
||||
#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
|
||||
#include <com/sun/star/document/XScriptInvocationContext.hpp>
|
||||
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
|
||||
#include <com/sun/star/frame/UICommandDescription.hpp>
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <basic/sbmeth.hxx>
|
||||
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
||||
#include <com/sun/star/document/XDocumentProperties.hpp>
|
||||
#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
|
||||
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
|
||||
#include <com/sun/star/lang/XUnoTunnel.hpp>
|
||||
#include <com/sun/star/script/ModuleType.hpp>
|
||||
@ -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<document::XDocumentPropertiesSupplier> 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();
|
||||
|
@ -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
|
||||
|
@ -31,9 +31,6 @@ module com { module sun { module star { module document {
|
||||
<p>
|
||||
A temporary interface to get access to documents substorages.
|
||||
</p>
|
||||
|
||||
@see DocumentInfo
|
||||
@see StandaloneDocumentInfo
|
||||
*/
|
||||
interface XDocumentSubStorageSupplier: com::sun::star::uno::XInterface
|
||||
{
|
||||
|
@ -51,7 +51,8 @@ service DocumentDefinition
|
||||
the <code>execute</code> method is the model of the loaded document.</li>
|
||||
<li><strong>preview</strong>: retrieves an image showing a preview of the sub document.</li>
|
||||
<li><strong>getDocumentInfo</strong>: retrieves the document information, as
|
||||
<type scope="com::sun::star::document">XDocumentInfo</type> instance, of the sub document.</li>
|
||||
<type scope="com::sun::star::document">XDocumentProperties</type>
|
||||
instance, of the sub document.</li>
|
||||
<li><strong>delete</strong>: deletes the sub document from the database document.</li>
|
||||
<li><strong>close</strong>: closes the sub document, if it had previously been opened
|
||||
using either the <code>open</code> or <code>openDesign</code> command. The return value
|
||||
|
@ -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);
|
||||
|
@ -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) ;
|
||||
}
|
||||
}) ;
|
||||
|
||||
|
@ -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) ;
|
||||
|
@ -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) ;
|
||||
|
||||
|
@ -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) ;
|
||||
|
@ -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) ;
|
||||
}
|
||||
}) ;
|
||||
|
||||
|
@ -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) ;
|
||||
|
@ -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) ;
|
||||
}
|
||||
}) ;
|
||||
|
||||
|
@ -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) ;
|
||||
|
@ -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) ;
|
||||
}
|
||||
} );
|
||||
|
||||
|
@ -1367,7 +1367,7 @@ sal_Bool ImplSdPPTImport::Import()
|
||||
|
||||
delete pStbMgr;
|
||||
|
||||
// read DocumentInfo
|
||||
// read DocumentProperties
|
||||
uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
|
||||
mpDoc->GetObjectShell()->GetModel(), uno::UNO_QUERY_THROW);
|
||||
uno::Reference<document::XDocumentProperties> xDocProps
|
||||
|
@ -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(
|
||||
|
@ -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 );
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include <com/sun/star/configuration/theDefaultProvider.hpp>
|
||||
#include <com/sun/star/container/XContainerQuery.hpp>
|
||||
#include <com/sun/star/document/XTypeDetection.hpp>
|
||||
#include <com/sun/star/document/XStandaloneDocumentInfo.hpp>
|
||||
#include <com/sun/star/document/DocumentProperties.hpp>
|
||||
#include <com/sun/star/io/TempFile.hpp>
|
||||
#include <com/sun/star/sdbc/XResultSet.hpp>
|
||||
#include <com/sun/star/sdbc/XRow.hpp>
|
||||
@ -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<XDocumentProperties> 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<PropertyValue>());
|
||||
m_xDocProps->setTitle(aTitle );
|
||||
m_xDocProps->storeToMedium(rURL, Sequence<PropertyValue>());
|
||||
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<PropertyValue>());
|
||||
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() )
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include <com/sun/star/beans/XPropertyContainer.hpp>
|
||||
#include <com/sun/star/beans/PropertyAttribute.hpp>
|
||||
#include <com/sun/star/document/XExporter.hpp>
|
||||
#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
|
||||
#include <com/sun/star/document/XDocumentInfo.hpp>
|
||||
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
||||
#include <com/sun/star/document/XDocumentProperties.hpp>
|
||||
#include <com/sun/star/task/InteractionHandler.hpp>
|
||||
#include <com/sun/star/util/DateTime.hpp>
|
||||
#include <com/sun/star/util/URLTransformer.hpp>
|
||||
@ -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<document::XDocumentInfoSupplier> xDIS(
|
||||
uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
|
||||
aModelData.GetModel(), uno::UNO_QUERY_THROW);
|
||||
uno::Reference<util::XCloneable> xCloneable(
|
||||
xDIS->getDocumentInfo(), uno::UNO_QUERY_THROW);
|
||||
uno::Reference<document::XDocumentInfo> xOldDocInfo(
|
||||
xDPS->getDocumentProperties(), uno::UNO_QUERY_THROW);
|
||||
uno::Reference<document::XDocumentProperties> 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<document::XDocumentPropertiesSupplier> const
|
||||
xModelDocPropsSupplier(xModel, uno::UNO_QUERY_THROW);
|
||||
uno::Reference<document::XDocumentProperties> 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() )
|
||||
|
@ -20,12 +20,11 @@
|
||||
|
||||
#include <com/sun/star/uno/Reference.hxx>
|
||||
|
||||
#include <com/sun/star/document/DocumentProperties.hpp>
|
||||
#include <com/sun/star/document/XDocumentProperties.hpp>
|
||||
#include <com/sun/star/document/UpdateDocMode.hpp>
|
||||
#include <com/sun/star/frame/XLayoutManager.hpp>
|
||||
#include <com/sun/star/embed/ElementModes.hpp>
|
||||
#include <com/sun/star/document/XStandaloneDocumentInfo.hpp>
|
||||
#include <com/sun/star/beans/XFastPropertySet.hpp>
|
||||
#include <vcl/msgbox.hxx>
|
||||
#include <svl/style.hxx>
|
||||
#include <vcl/wrkwin.hxx>
|
||||
@ -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<document::XDocumentProperties> const
|
||||
xTemplateDocProps( document::DocumentProperties::create(
|
||||
::comphelper::getProcessComponentContext()));
|
||||
xTemplateDocProps->loadFromMedium(aTemplURL,
|
||||
Sequence<beans::PropertyValue>());
|
||||
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
|
||||
|
@ -110,7 +110,6 @@ using ::basic::BasicManagerRepository;
|
||||
|
||||
DBG_NAME(SfxObjectShell)
|
||||
|
||||
#define DocumentInfo
|
||||
#include "sfxslots.hxx"
|
||||
|
||||
namespace {
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <com/sun/star/ucb/XContentAccess.hpp>
|
||||
#include <com/sun/star/util/DateTime.hpp>
|
||||
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||
#include <com/sun/star/document/DocumentProperties.hpp>
|
||||
#include <comphelper/processfactory.hxx>
|
||||
#include <tools/debug.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
@ -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<PropertyValue>());
|
||||
|
||||
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;
|
||||
|
@ -21,7 +21,7 @@
|
||||
#define SVTOOLS_SOURCE_CONTNR_CONTENTENUMERATION_HXX
|
||||
|
||||
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
|
||||
#include <com/sun/star/document/XStandaloneDocumentInfo.hpp>
|
||||
#include <com/sun/star/document/XDocumentProperties.hpp>
|
||||
#include <salhelper/thread.hxx>
|
||||
#include <ucbhelper/content.hxx>
|
||||
#include <rtl/ustring.hxx>
|
||||
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
|
@ -106,7 +106,6 @@
|
||||
|
||||
#include "ww8toolbar.hxx"
|
||||
#include <osl/file.hxx>
|
||||
#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
|
||||
|
||||
#include <breakit.hxx>
|
||||
|
||||
@ -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<document::XDocumentPropertiesSupplier> xDPS(
|
||||
mpDocShell->GetModel(), uno::UNO_QUERY_THROW);
|
||||
uno::Reference<document::XDocumentProperties> 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<document::XDocumentPropertiesSupplier> const
|
||||
xDocPropSupp(mpDocShell->GetModel(), uno::UNO_QUERY_THROW);
|
||||
uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW );
|
||||
|
||||
rtl::OUString sCreatedFrom = xDocProps->getTemplateURL();
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "vbavariables.hxx"
|
||||
#include <com/sun/star/text/XBookmarksSupplier.hpp>
|
||||
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
||||
#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
|
||||
#include <com/sun/star/document/XDocumentProperties.hpp>
|
||||
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
|
||||
#include <com/sun/star/drawing/XControlShape.hpp>
|
||||
@ -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<document::XDocumentPropertiesSupplier> 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<document::XDocumentPropertiesSupplier> const xDocPropSupp(
|
||||
getModel(), uno::UNO_QUERY_THROW );
|
||||
uno::Reference< document::XDocumentProperties > xDocProps( xDocPropSupp->getDocumentProperties(), uno::UNO_QUERY_THROW );
|
||||
xDocProps->setTemplateURL( aURL );
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "vbadocumentproperties.hxx"
|
||||
#include <cppuhelper/implbase1.hxx>
|
||||
#include <cppuhelper/implbase3.hxx>
|
||||
#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
|
||||
#include <com/sun/star/document/XDocumentProperties.hpp>
|
||||
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
||||
#include <com/sun/star/beans/NamedValue.hpp>
|
||||
#include <com/sun/star/beans/XPropertyContainer.hpp>
|
||||
@ -73,17 +73,22 @@ class PropertGetSetHelper
|
||||
{
|
||||
protected:
|
||||
uno::Reference< frame::XModel > m_xModel;
|
||||
uno::Reference< beans::XPropertySet > mxProps;
|
||||
uno::Reference<document::XDocumentProperties> 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<document::XDocumentPropertiesSupplier> 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<beans::XPropertySet>(
|
||||
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<OUString> 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)
|
||||
|
@ -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 )
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <com/sun/star/frame/XLayoutManager.hpp>
|
||||
#include <com/sun/star/frame/XDesktop.hpp>
|
||||
#include <com/sun/star/container/XEnumerationAccess.hpp>
|
||||
#include <com/sun/star/document/XDocumentInfoSupplier.hpp>
|
||||
#include <com/sun/star/document/XDocumentProperties.hpp>
|
||||
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
||||
#include <com/sun/star/document/XEmbeddedScripts.hpp>
|
||||
|
Loading…
x
Reference in New Issue
Block a user