summaryrefslogtreecommitdiff
path: root/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment
diff options
context:
space:
mode:
Diffstat (limited to 'odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment')
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java88
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java4
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx12
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx60
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx44
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx82
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.uno.xml24
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java92
8 files changed, 203 insertions, 203 deletions
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java
index 24eb92a3109c..623a19102774 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java
@@ -29,7 +29,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
package OfficeDev.samples.Filter;
@@ -88,7 +88,7 @@ public class AsciiReplaceFilter
{
//______________________________
// const
-
+
// the supported service names, the first one being the service name of the component itself
public static final String[] m_serviceNames = { "com.sun.star.comp.ansifilter.AsciiReplaceFilter" , "com.sun.star.document.ImportFilter", "com.sun.star.document.ExportFilter" };
@@ -354,12 +354,12 @@ public class AsciiReplaceFilter
bImport = m_bImport;
xText = m_xDocument;
}
-
+
measure("options analyzed");
-
+
if (aOptions.isValid()==false)
return false;
-
+
// start real filtering
boolean bState = false;
if (bImport)
@@ -424,32 +424,32 @@ public class AsciiReplaceFilter
FilterOptions aOptions )
{
measure("implts_import {");
-
+
com.sun.star.text.XSimpleText xText = (com.sun.star.text.XSimpleText)UnoRuntime.queryInterface(
com.sun.star.text.XSimpleText.class,
xTarget.getText());
-
+
measure("cast XSimpleText");
-
+
boolean bBreaked = false;
-
+
try
{
StringBuffer sBuffer = new StringBuffer(100000);
byte[][] lData = new byte[1][];
int nRead = aOptions.m_xInput.readBytes( lData, 4096 );
-
+
measure("read first bytes");
-
+
while (nRead>0 && !bBreaked)
{
// copy data from stream to temp. buffer
sBuffer.append( new String(lData[0]) );
measure("buffer append ["+nRead+"]");
-
+
nRead = aOptions.m_xInput.readBytes( lData, 2048 );
measure("read next bytes");
-
+
// check for cancelled filter proc on every loop!
synchronized(this)
{
@@ -461,11 +461,11 @@ public class AsciiReplaceFilter
}
measure("break check");
}
-
+
// Make some replacements inside the buffer.
String sText = implts_replace( sBuffer, aOptions );
measure("replace");
-
+
// copy current buffer to the document model.
// Create a new paragraph for every line inside original file.
// May not all data could be readed - but that doesn't matter here.
@@ -474,27 +474,27 @@ public class AsciiReplaceFilter
int nStart = 0;
int nEnd = -1;
int nLength = sText.length();
-
+
com.sun.star.text.XTextRange xCursor = (com.sun.star.text.XTextRange)UnoRuntime.queryInterface(
com.sun.star.text.XTextRange.class,
xText.createTextCursor());
-
+
while (true)
{
nEnd = sText.indexOf('\n',nStart);
-
+
if (nEnd==-1 && nStart<nLength)
nEnd = nLength;
-
+
if (nEnd==-1)
break;
-
+
String sLine = sText.substring(nStart,nEnd);
nStart = nEnd+1;
-
+
xText.insertString(xCursor,sLine,false);
xText.insertControlCharacter(xCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,false);
-
+
// check for cancelled filter proc on every loop!
synchronized(this)
{
@@ -506,9 +506,9 @@ public class AsciiReplaceFilter
}
measure("break check");
}
-
+
measure("set on model");
-
+
// with refreshing the document we are on the safe-side, otherwise the first time the filter is used the document is not fully shown (flaw!).
com.sun.star.util.XRefreshable xRefresh = (com.sun.star.util.XRefreshable)UnoRuntime.queryInterface(
com.sun.star.util.XRefreshable.class,
@@ -526,11 +526,11 @@ public class AsciiReplaceFilter
catch(com.sun.star.io.BufferSizeExceededException exExceed ) { bBreaked = true; }
catch(com.sun.star.io.NotConnectedException exConnect ) { bBreaked = true; }
catch(com.sun.star.io.IOException exIO ) { bBreaked = true; }
-
+
measure("} implts_import");
-
+
return !bBreaked;
}
@@ -556,22 +556,22 @@ public class AsciiReplaceFilter
FilterOptions aOptions)
{
measure("implts_export {");
-
+
com.sun.star.text.XTextRange xText = (com.sun.star.text.XSimpleText)UnoRuntime.queryInterface(
com.sun.star.text.XSimpleText.class,
xSource.getText());
-
+
measure("cast XTextRange");
-
+
boolean bBreaked = false;
-
+
try
{
StringBuffer sBuffer = new StringBuffer(xText.getString());
String sText = implts_replace(sBuffer,aOptions);
-
+
measure("get text from model");
-
+
// Normaly this function isn't realy cancelable
// But we following operation can be very expensive. So
// this place is the last one to stop it.
@@ -583,12 +583,12 @@ public class AsciiReplaceFilter
return false;
}
}
-
+
aOptions.m_xOutput.writeBytes(sText.getBytes());
aOptions.m_xOutput.flush();
-
+
measure("written to file");
-
+
// If we created used stream - we must close it too.
if (aOptions.m_bStreamOwner==true)
{
@@ -599,12 +599,12 @@ public class AsciiReplaceFilter
catch(com.sun.star.io.BufferSizeExceededException exExceed ) { bBreaked = true; }
catch(com.sun.star.io.NotConnectedException exConnect ) { bBreaked = true; }
catch(com.sun.star.io.IOException exIO ) { bBreaked = true; }
-
+
measure("} implts_export");
-
+
return !bBreaked;
}
-
+
/**
* helper function to convert the used StringBuffer into a Strig value.
* And we use this chance to have a look on optional filter options
@@ -626,7 +626,7 @@ public class AsciiReplaceFilter
nEnd = nStart+nLength;
}
}
-
+
// convert buffer into return format [string]
// and convert to lower or upper case if required.
String sResult = rBuffer.toString();
@@ -637,11 +637,11 @@ public class AsciiReplaceFilter
else
sResult = sResult.toUpperCase();
}
-
+
return sResult;
}
-
-
+
+
//______________________________
// interface XServiceInfo
/**
@@ -672,7 +672,7 @@ public class AsciiReplaceFilter
sService.equals( m_serviceNames[2] )
);
}
-
+
/**
* Return the real class name of the component
*
@@ -730,4 +730,4 @@ public class AsciiReplaceFilter
_AsciiReplaceFilter.m_serviceNames,
xRegistryKey );
}
-}
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java
index 013f93a304f5..3c72f8f6e46e 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java
@@ -2,7 +2,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -29,7 +29,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
package OfficeDev.samples.Filter;
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx
index c6f5f9629453..bf62c3999bf4 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx
@@ -3,7 +3,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -30,7 +30,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
#include <stdio.h>
@@ -66,9 +66,9 @@ sal_Bool SAL_CALL component_writeInfo(
try
{
Reference< XRegistryKey > xNewKey(
- reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( FilterDetect_getImplementationName() ) );
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( FilterDetect_getImplementationName() ) );
xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
-
+
const Sequence< OUString > & rSNL = FilterDetect_getSupportedServiceNames();
const OUString * pArray = rSNL.getConstArray();
for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
@@ -89,7 +89,7 @@ void * SAL_CALL component_getFactory(
const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
{
void * pRet = 0;
-
+
OUString implName = OUString::createFromAscii( pImplName );
if ( pServiceManager && implName.equals(FilterDetect_getImplementationName()) )
{
@@ -97,7 +97,7 @@ void * SAL_CALL component_getFactory(
reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
OUString::createFromAscii( pImplName ),
FilterDetect_createInstance, FilterDetect_getSupportedServiceNames() ) );
-
+
if (xFactory.is())
{
xFactory->acquire();
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx
index e6bbe85cb2c7..b9fbd7c6af70 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx
@@ -3,7 +3,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -30,7 +30,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
#include "filterdetect.hxx"
@@ -72,7 +72,7 @@ using namespace com::sun::star::container;
using namespace com::sun::star::ucb;
-OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
+OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
throw( RuntimeException )
{
// type name to return
@@ -82,7 +82,7 @@ OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
// stream of the document to be detected
Reference< XInputStream > xInStream;
for ( sal_Int32 i = 0 ; i < aArguments.getLength(); i++)
- {
+ {
OUString aName = aArguments[i].Name;
if (aName.equalsAscii("TypeName" ) )
aArguments[i].Value >>= sOriginalTypeName;
@@ -92,7 +92,7 @@ OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
aArguments[i].Value >>= xInStream;
}
- if (!xInStream.is())
+ if (!xInStream.is())
{
// open the stream if it was not suplied by the framework
Reference< XSimpleFileAccess > xSFI(mxMSF->createInstance(
@@ -100,7 +100,7 @@ OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
if (sURL.getLength() > 0 && xSFI.is())
{
try
- {
+ {
xInStream = xSFI->openFileRead( sURL);
}
catch( Exception& )
@@ -116,17 +116,17 @@ OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
// flatxml starts with an office:document element. this element
// conatains a clas="..." attribut by which we can deduct the
// type of document that is to be loaded
- //
+ //
// WARNING:
// parsing the plain text of the document is an easy way to do this
- // but not the purest solution, since namespaces and other xml details
+ // but not the purest solution, since namespaces and other xml details
// may lead to another syntactic expression of the same document.
// this example works for the way the office serializes it's XML stream
// but might need extension for other data sources...
static OString aDocToken("office:document");
// static OString aClassToken("office:class=\"");
static OString aMimeTypeToken("office:mimetype=\"");
-
+
sal_Int32 nHeadSize = 4096;
Sequence< sal_Int8 > aHeadData(nHeadSize);
@@ -138,9 +138,9 @@ OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
long bytestRead = xInStream->readBytes(aHeadData, nHeadSize);
OString aHead = OString((const sal_Char *)aHeadData.getConstArray(), bytestRead).toAsciiLowerCase();
-
+
// check for document element of flatxml format
- if (aHead.indexOf(aDocToken) >= 0)
+ if (aHead.indexOf(aDocToken) >= 0)
{
// read document class
sal_Int32 n = aHead.indexOf(aMimeTypeToken);
@@ -150,26 +150,26 @@ OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
OString aMimeType = aHead.copy(n, aHead.indexOf('\"', n) - n);
// return type for class found
if (aMimeType.equals("application/x-vnd.oasis.opendocument.text") ||
- aMimeType.equals("application/vnd.oasis.opendocument.text"))
+ aMimeType.equals("application/vnd.oasis.opendocument.text"))
sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_writer");
else if (aMimeType.equals("application/x-vnd.oasis.opendocument.text-master") ||
- aMimeType.equals("application/vnd.oasis.opendocument.text-master"))
- sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_master");
+ aMimeType.equals("application/vnd.oasis.opendocument.text-master"))
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_master");
else if (aMimeType.equals("application/x-vnd.oasis.openoffice.text-global") ||
- aMimeType.equals("application/vnd.oasis.openoffice.text-global"))
- sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_master");
+ aMimeType.equals("application/vnd.oasis.openoffice.text-global"))
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_master");
else if (aMimeType.equals("application/x-vnd.oasis.opendocument.spreadsheet") ||
- aMimeType.equals("application/vnd.oasis.opendocument.spreadsheet"))
- sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_calc");
+ aMimeType.equals("application/vnd.oasis.opendocument.spreadsheet"))
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_calc");
else if (aMimeType.equals("application/x-vnd.oasis.opendocument.drawing") ||
- aMimeType.equals("application/vnd.oasis.opendocument.drawing"))
- sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_draw");
+ aMimeType.equals("application/vnd.oasis.opendocument.drawing"))
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_draw");
else if (aMimeType.equals("application/x-vnd.oasis.opendocument.presentation") ||
- aMimeType.equals("application/vnd.oasis.opendocument.presentation"))
+ aMimeType.equals("application/vnd.oasis.opendocument.presentation"))
sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_impress");
else if (aMimeType.equals("application/x-vnd.oasis.opendocument.presentation") ||
aMimeType.equals("application/vnd.oasis.opendocument.presentation"))
- sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_impress");
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_impress");
}
}
return sTypeName;
@@ -177,7 +177,7 @@ OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
// XInitialization
-void SAL_CALL FilterDetect::initialize( const Sequence< Any >& aArguments )
+void SAL_CALL FilterDetect::initialize( const Sequence< Any >& aArguments )
throw (Exception, RuntimeException)
{
Sequence < PropertyValue > aAnySeq;
@@ -187,10 +187,10 @@ void SAL_CALL FilterDetect::initialize( const Sequence< Any >& aArguments )
const PropertyValue * pValue = aAnySeq.getConstArray();
nLength = aAnySeq.getLength();
for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
+ {
if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "Type" ) ) )
{
- pValue[i].Value >>= msFilterName;
+ pValue[i].Value >>= msFilterName;
}
else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "UserData" ) ) )
{
@@ -212,13 +212,13 @@ OUString FilterDetect_getImplementationName ()
#define SERVICE_NAME1 "com.sun.star.document.ExtendedTypeDetection"
-sal_Bool SAL_CALL FilterDetect_supportsService( const OUString& ServiceName )
+sal_Bool SAL_CALL FilterDetect_supportsService( const OUString& ServiceName )
throw (RuntimeException)
{
return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME1 ) );
}
-Sequence< OUString > SAL_CALL FilterDetect_getSupportedServiceNames( )
+Sequence< OUString > SAL_CALL FilterDetect_getSupportedServiceNames( )
throw (RuntimeException)
{
Sequence < OUString > aRet(2);
@@ -236,19 +236,19 @@ Reference< XInterface > SAL_CALL FilterDetect_createInstance( const Reference< X
}
// XServiceInfo
-OUString SAL_CALL FilterDetect::getImplementationName( )
+OUString SAL_CALL FilterDetect::getImplementationName( )
throw (RuntimeException)
{
return FilterDetect_getImplementationName();
}
-sal_Bool SAL_CALL FilterDetect::supportsService( const OUString& rServiceName )
+sal_Bool SAL_CALL FilterDetect::supportsService( const OUString& rServiceName )
throw (RuntimeException)
{
return FilterDetect_supportsService( rServiceName );
}
-Sequence< OUString > SAL_CALL FilterDetect::getSupportedServiceNames( )
+Sequence< OUString > SAL_CALL FilterDetect::getSupportedServiceNames( )
throw (RuntimeException)
{
return FilterDetect_getSupportedServiceNames();
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx
index 210d59cf56e5..e3da3d5cec0c 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx
@@ -3,7 +3,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -30,7 +30,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
#ifndef _FILTERDETECT_HXX
@@ -47,7 +47,7 @@
#include <cppuhelper/implbase3.hxx>
-enum FilterType
+enum FilterType
{
FILTER_IMPORT,
FILTER_EXPORT
@@ -66,36 +66,36 @@ protected:
::rtl::OUString msFilterName;
::com::sun::star::uno::Sequence< ::rtl::OUString > msUserData;
::rtl::OUString msTemplateName;
-
- sal_Bool SAL_CALL exportImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+
+ sal_Bool SAL_CALL exportImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (::com::sun::star::uno::RuntimeException);
-
- sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+
+ sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (::com::sun::star::uno::RuntimeException);
-
+
public:
FilterDetect( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
: mxMSF( rxMSF ) {}
-
+
virtual ~FilterDetect() {}
-
+
//XExtendedFilterDetection
- virtual ::rtl::OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& lDescriptor )
+ virtual ::rtl::OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& lDescriptor )
throw( com::sun::star::uno::RuntimeException );
-
+
// XInitialization
-
- virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
-
+
// XServiceInfo
- virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
throw (::com::sun::star::uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
throw (::com::sun::star::uno::RuntimeException);
-
- virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException);
};
@@ -103,10 +103,10 @@ public:
::rtl::OUString FilterDetect_getImplementationName()
throw ( ::com::sun::star::uno::RuntimeException );
-sal_Bool SAL_CALL FilterDetect_supportsService( const ::rtl::OUString& ServiceName )
+sal_Bool SAL_CALL FilterDetect_supportsService( const ::rtl::OUString& ServiceName )
throw ( ::com::sun::star::uno::RuntimeException );
-::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL FilterDetect_getSupportedServiceNames( )
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL FilterDetect_getSupportedServiceNames( )
throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx
index 6935eb351f55..34ae11cdbfe9 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx
@@ -3,7 +3,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -30,7 +30,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
#include <cppuhelper/factory.hxx>
@@ -88,47 +88,47 @@ private:
public:
// ctor...
- XFlatXml( const Reference< XMultiServiceFactory > &r )
+ XFlatXml( const Reference< XMultiServiceFactory > &r )
: m_rServiceFactory(r)
, m_bPrettyPrint(sal_True)
{}
// XImportFilter
virtual sal_Bool SAL_CALL importer(
- const Sequence<PropertyValue>& aSourceData,
- const Reference<XDocumentHandler>& xHandler,
- const Sequence<OUString>& msUserData)
+ const Sequence<PropertyValue>& aSourceData,
+ const Reference<XDocumentHandler>& xHandler,
+ const Sequence<OUString>& msUserData)
throw(RuntimeException);
// XExportFilter
virtual sal_Bool SAL_CALL exporter(
- const Sequence<PropertyValue>& aSourceData,
- const Sequence<OUString>& msUserData)
+ const Sequence<PropertyValue>& aSourceData,
+ const Sequence<OUString>& msUserData)
throw(RuntimeException);
// XDocumentHandler
- virtual void SAL_CALL startDocument()
+ virtual void SAL_CALL startDocument()
throw (SAXException,RuntimeException);
- virtual void SAL_CALL endDocument()
+ virtual void SAL_CALL endDocument()
throw (SAXException, RuntimeException);
- virtual void SAL_CALL startElement(const OUString& str, const Reference<XAttributeList>& attriblist)
+ virtual void SAL_CALL startElement(const OUString& str, const Reference<XAttributeList>& attriblist)
throw (SAXException,RuntimeException);
- virtual void SAL_CALL endElement(const OUString& str)
+ virtual void SAL_CALL endElement(const OUString& str)
throw (SAXException, RuntimeException);
- virtual void SAL_CALL characters(const OUString& str)
+ virtual void SAL_CALL characters(const OUString& str)
throw (SAXException, RuntimeException);
- virtual void SAL_CALL ignorableWhitespace(const OUString& str)
+ virtual void SAL_CALL ignorableWhitespace(const OUString& str)
throw (SAXException, RuntimeException);
- virtual void SAL_CALL processingInstruction(const OUString& str, const OUString& str2)
+ virtual void SAL_CALL processingInstruction(const OUString& str, const OUString& str2)
throw (com::sun::star::xml::sax::SAXException,RuntimeException);
- virtual void SAL_CALL setDocumentLocator(const Reference<XLocator>& doclocator)
- throw (SAXException,RuntimeException);
+ virtual void SAL_CALL setDocumentLocator(const Reference<XLocator>& doclocator)
+ throw (SAXException,RuntimeException);
};
sal_Bool XFlatXml::importer(
- const Sequence<PropertyValue>& aSourceData,
- const Reference<XDocumentHandler>& xHandler,
- const Sequence<OUString>& msUserData)
+ const Sequence<PropertyValue>& aSourceData,
+ const Reference<XDocumentHandler>& xHandler,
+ const Sequence<OUString>& msUserData)
throw (RuntimeException)
{
// get information from media descriptor
@@ -137,12 +137,12 @@ sal_Bool XFlatXml::importer(
// the sax parser that drives the supplied document handler
sal_Int32 nLength = aSourceData.getLength();
OUString aName, aFileName, aURL;
- Reference< XInputStream > xInputStream;
+ Reference< XInputStream > xInputStream;
for ( sal_Int32 i = 0 ; i < nLength; i++)
{
aName = aSourceData[i].Name;
if (aName.equalsAscii("InputStream"))
- aSourceData[i].Value >>= xInputStream;
+ aSourceData[i].Value >>= xInputStream;
else if ( aName.equalsAscii("FileName"))
aSourceData[i].Value >>= aFileName;
else if ( aName.equalsAscii("URL"))
@@ -158,17 +158,17 @@ sal_Bool XFlatXml::importer(
if (xSeek.is())
xSeek->seek(0);
-
+
// create SAX parser that will read the document file
// and provide events to xHandler passed to this call
- Reference < XParser > xSaxParser( m_rServiceFactory->createInstance(
+ Reference < XParser > xSaxParser( m_rServiceFactory->createInstance(
OUString::createFromAscii("com.sun.star.xml.sax.Parser")), UNO_QUERY );
OSL_ASSERT(xSaxParser.is());
if(!xSaxParser.is())return sal_False;
// let the parser try to send the sax event to the document handler
try
- {
+ {
InputSource aInput;
aInput.sSystemId = aURL;
aInput.sPublicId = aURL;
@@ -188,8 +188,8 @@ sal_Bool XFlatXml::importer(
}
sal_Bool XFlatXml::exporter(
- const Sequence<PropertyValue>& aSourceData,
- const Sequence<OUString>& msUserData)
+ const Sequence<PropertyValue>& aSourceData,
+ const Sequence<OUString>& msUserData)
throw (RuntimeException)
{
@@ -199,9 +199,9 @@ sal_Bool XFlatXml::exporter(
// from it's data-source interface
OUString aName, sURL;
Reference<XOutputStream> rOutputStream;
- sal_Int32 nLength = aSourceData.getLength();
+ sal_Int32 nLength = aSourceData.getLength();
for ( sal_Int32 i = 0 ; i < nLength; i++)
- {
+ {
aName = aSourceData[i].Name;
if ( aName.equalsAscii("OutputStream"))
aSourceData[i].Value >>= rOutputStream;
@@ -243,44 +243,44 @@ void XFlatXml::endDocument() throw (SAXException,RuntimeException){
m_rDocumentHandler->endDocument();
}
-void XFlatXml::startElement(const OUString& str, const Reference<XAttributeList>& attriblist)
+void XFlatXml::startElement(const OUString& str, const Reference<XAttributeList>& attriblist)
throw (SAXException, RuntimeException)
{
OSL_ASSERT(m_rDocumentHandler.is());
m_rDocumentHandler->startElement(str, attriblist);
}
-void XFlatXml::endElement(const OUString& str)
- throw (SAXException, RuntimeException)
+void XFlatXml::endElement(const OUString& str)
+ throw (SAXException, RuntimeException)
{
OSL_ASSERT(m_rDocumentHandler.is());
m_rDocumentHandler->endElement(str);
}
-void XFlatXml::characters(const OUString& str)
- throw (SAXException, RuntimeException)
+void XFlatXml::characters(const OUString& str)
+ throw (SAXException, RuntimeException)
{
OSL_ASSERT(m_rDocumentHandler.is());
m_rDocumentHandler->characters(str);
}
-void XFlatXml::ignorableWhitespace(const OUString& str)
+void XFlatXml::ignorableWhitespace(const OUString& str)
throw (SAXException, RuntimeException)
-{
+{
OSL_ASSERT(m_rDocumentHandler.is());
if (!m_bPrettyPrint) return;
m_rDocumentHandler->ignorableWhitespace(str);
}
-
-void XFlatXml::processingInstruction(const OUString& str, const OUString& str2)
- throw (SAXException, RuntimeException)
+
+void XFlatXml::processingInstruction(const OUString& str, const OUString& str2)
+ throw (SAXException, RuntimeException)
{
OSL_ASSERT(m_rDocumentHandler.is());
m_rDocumentHandler->processingInstruction(str, str2);
}
-void XFlatXml::setDocumentLocator(const Reference<XLocator>& doclocator)
- throw (SAXException, RuntimeException)
+void XFlatXml::setDocumentLocator(const Reference<XLocator>& doclocator)
+ throw (SAXException, RuntimeException)
{
OSL_ASSERT(m_rDocumentHandler.is());
m_rDocumentHandler->setDocumentLocator(doclocator);
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.uno.xml b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.uno.xml
index 9202844eef76..a7965afc4af0 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.uno.xml
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.uno.xml
@@ -5,12 +5,12 @@
<component-description>
<author> Aidan Butler </author>
<name>devguide.officedev.samples.filter.FlatXmlCpp</name>
-
+
<description>
This component is a sample implementation, which describes how a filter may be written that uses the XmlFilterAdaptor component. This filter opens and saves Flat Xml files.
</description>
- <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
- <language> c++ </language>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> c++ </language>
<status value="final"/>
<supported-service>devguide.officedev.samples.filter.FlatXmlCpp</supported-service>
<type>com.sun.star.lang.XSingleServiceFactory</type>
@@ -47,13 +47,13 @@
<type>com.sun.star.ucb.XSimpleFileAccess</type>
<type>com.sun.star.beans.XPropertySet</type>
</component-description>
- <project-build-dependency> cppuhelper </project-build-dependency>
- <project-build-dependency> cppu </project-build-dependency>
- <project-build-dependency> sal </project-build-dependency>
- <runtime-module-dependency> cppuhelper$(UDK_MAJOR)$(COM) </runtime-module-dependency>
- <runtime-module-dependency> salhelper$(UDK_MAJOR)$(COM) </runtime-module-dependency>
- <runtime-module-dependency> cppu$(UDK_MAJOR) </runtime-module-dependency>
- <runtime-module-dependency> reg$(UDK_MAJOR) </runtime-module-dependency>
- <runtime-module-dependency> store$(UDK_MAJOR) </runtime-module-dependency>
- <runtime-module-dependency> sal$(UDK_MAJOR) </runtime-module-dependency>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <runtime-module-dependency> cppuhelper$(UDK_MAJOR)$(COM) </runtime-module-dependency>
+ <runtime-module-dependency> salhelper$(UDK_MAJOR)$(COM) </runtime-module-dependency>
+ <runtime-module-dependency> cppu$(UDK_MAJOR) </runtime-module-dependency>
+ <runtime-module-dependency> reg$(UDK_MAJOR) </runtime-module-dependency>
+ <runtime-module-dependency> store$(UDK_MAJOR) </runtime-module-dependency>
+ <runtime-module-dependency> sal$(UDK_MAJOR) </runtime-module-dependency>
</module-description>
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java
index cf95e1637c08..e801227ed4be 100644
--- a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java
@@ -2,7 +2,7 @@
*
* The Contents of this file are made available subject to the terms of
* the BSD license.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
* All rights reserved.
*
@@ -29,7 +29,7 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*************************************************************************/
import java.io.*;
@@ -50,8 +50,8 @@ import com.sun.star.io.XActiveDataSource;
-public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
- XServiceInfo, XDocumentHandler, XTypeProvider
+public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
+ XServiceInfo, XDocumentHandler, XTypeProvider
{
/*
@@ -66,15 +66,15 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
static private final String[] __supportedServiceNames = {
"devguide.officedev.samples.filter.FlatXmlJava"
};
-
+
public FlatXml(XMultiServiceFactory f) {
m_xServiceFactory = f;
}
-
+
// --- XTypeProvider ---
public byte[] getImplementationId() {
return Integer.toString(this.hashCode()).getBytes();
- }
+ }
// --- XServiceName ---
public String getServiceName() {
@@ -91,10 +91,10 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
public String getImplementationName() {
return( this.getClass().getName() );
}
- public String[] getSupportedServiceNames() {
+ public String[] getSupportedServiceNames() {
return( __supportedServiceNames );
}
-
+
public com.sun.star.uno.Type[] getTypes() {
Type[] typeReturn = {};
try {
@@ -103,7 +103,7 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
new Type( XExportFilter.class ),
new Type( XImportFilter.class ),
new Type( XServiceName.class ),
- new Type( XServiceInfo.class )
+ new Type( XServiceInfo.class )
};
} catch( java.lang.Exception exception ) {
return null;
@@ -111,19 +111,19 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
return( typeReturn );
}
- public boolean importer(PropertyValue[] aSourceData, XDocumentHandler xDocHandler, String[] msUserData)
- throws com.sun.star.uno.RuntimeException, com.sun.star.lang.IllegalArgumentException
- {
+ public boolean importer(PropertyValue[] aSourceData, XDocumentHandler xDocHandler, String[] msUserData)
+ throws com.sun.star.uno.RuntimeException, com.sun.star.lang.IllegalArgumentException
+ {
String sName = null;
String sFileName = null;
- String sURL = null;
- com.sun.star.io.XInputStream xin = null;
+ String sURL = null;
+ com.sun.star.io.XInputStream xin = null;
try {
-
+
for (int i = 0 ; i < aSourceData.length; i++)
{
- sName = aSourceData[i].Name;
+ sName = aSourceData[i].Name;
if (sName.equals("InputStream"))
xin = (XInputStream)AnyConverter.toObject(XInputStream.class, aSourceData[i].Value);
if (sName.equals("URL"))
@@ -131,48 +131,48 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
if (sName.equals("FileName"))
sFileName=(String)AnyConverter.toObject(String.class, aSourceData[i].Value);
}
-
+
Object tmpObj=m_xServiceFactory.createInstance("com.sun.star.xml.sax.Parser");
if (tmpObj == null) return false;
-
+
XParser xParser = (XParser)UnoRuntime.queryInterface(XParser.class , tmpObj);
if (xParser == null) return false;
-
+
InputSource aInput = new InputSource();
aInput.sSystemId = sURL;
aInput.aInputStream =xin;
xParser.setDocumentHandler ( xDocHandler );
- xParser.parseStream ( aInput );
+ xParser.parseStream ( aInput );
} catch (com.sun.star.uno.Exception e){
- e.printStackTrace();
+ e.printStackTrace();
return false;
}
-
+
// done...
return true;
}
- public boolean exporter(PropertyValue[] aSourceData, String[] msUserData)
+ public boolean exporter(PropertyValue[] aSourceData, String[] msUserData)
throws com.sun.star.uno.RuntimeException, com.sun.star.lang.IllegalArgumentException
{
try {
String sURL = null;
String sName = null;
XOutputStream xos = null;
-
- // get interesting values from sourceData
+
+ // get interesting values from sourceData
for (int i = 0 ; i < aSourceData.length; i++)
{
- sName = aSourceData[i].Name;
+ sName = aSourceData[i].Name;
if (sName.equals("OutputStream"))
xos = (XOutputStream)AnyConverter.toObject(XOutputStream.class, aSourceData[i].Value);
if (sName.equals("URL"))
sURL=(String)AnyConverter.toObject(String.class, aSourceData[i].Value);
}
-
+
// prepare the XML writer
Object tmpObj = null;
- if (m_xHandler == null)
+ if (m_xHandler == null)
{
tmpObj = m_xServiceFactory.createInstance("com.sun.star.xml.sax.Writer");
if (tmpObj != null)
@@ -181,10 +181,10 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
if (m_xHandler == null)
return false;
- // Connect the provided output stream to the writer
+ // Connect the provided output stream to the writer
XActiveDataSource xADSource = (XActiveDataSource)UnoRuntime.queryInterface(
XActiveDataSource.class, m_xHandler);
-
+
if (xADSource != null && xos != null)
xADSource.setOutputStream(xos);
else
@@ -192,23 +192,23 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
} catch (com.sun.star.uno.Exception e){
return false;
}
-
+
// done ...
return true;
}
-
- public void startDocument ()
+
+ public void startDocument ()
throws com.sun.star.xml.sax.SAXException
{
m_xHandler.startDocument();
}
-
+
public void endDocument()
throws com.sun.star.xml.sax.SAXException
{
m_xHandler.endDocument();
}
-
+
public void startElement (String str, com.sun.star.xml.sax.XAttributeList xattribs)
throws com.sun.star.xml.sax.SAXException
{
@@ -226,12 +226,12 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
{
m_xHandler.characters(str);
}
-
+
public void ignorableWhitespace(String str)
throws com.sun.star.xml.sax.SAXException
{
if (!m_bPrettyPrint) return;
- else m_xHandler.ignorableWhitespace(str);
+ else m_xHandler.ignorableWhitespace(str);
}
public void processingInstruction(String aTarget, String aData)
@@ -245,12 +245,12 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
{
m_xHandler.setDocumentLocator(xLocator);
}
-
- // ------------------------------------------------------------
+
+ // ------------------------------------------------------------
// component management
-
+
public static XSingleServiceFactory __getServiceFactory(String implName,
- XMultiServiceFactory multiFactory, XRegistryKey regKey)
+ XMultiServiceFactory multiFactory, XRegistryKey regKey)
{
XSingleServiceFactory xSingleServiceFactory = null;
if (implName.equals(__implName) ) {
@@ -260,14 +260,14 @@ public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
} catch (java.lang.ClassNotFoundException e) {
return null;
}
- }
+ }
return xSingleServiceFactory;
}
-
- public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
+
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
{
return FactoryHelper.writeRegistryServiceInfo(__implName,
__serviceName, regKey);
}
-
+
}