diff options
383 files changed, 15921 insertions, 7508 deletions
diff --git a/basic/source/app/app.cxx b/basic/source/app/app.cxx index 31385f2f6e9e..4cc2765604fd 100644 --- a/basic/source/app/app.cxx +++ b/basic/source/app/app.cxx @@ -1401,19 +1401,10 @@ long BasicFrame::Command( short nID, BOOL bChecked ) // InitMenu(GetMenuBar()->GetPopupMenu( RID_APPRUN )); break; case RID_FILEPRINT: -#ifndef UNX if( pWork ) pPrn->Print( pWork->GetText(), pWork->pDataEdit->GetText(), this ); -#else - InfoBox( this, SttResId( IDS_NOPRINTERERROR ) ).Execute(); -#endif break; case RID_FILESETUP: -#ifndef UNX - pPrn->Setup(); -#else - InfoBox( this, SttResId( IDS_NOPRINTERERROR ) ).Execute(); -#endif break; case RID_QUIT: if( Close() ) aBasicApp.Quit(); diff --git a/basic/source/app/makefile.mk b/basic/source/app/makefile.mk index 13c3b4a8b507..3a52f402b329 100644 --- a/basic/source/app/makefile.mk +++ b/basic/source/app/makefile.mk @@ -61,6 +61,7 @@ OBJFILES = \ EXCEPTIONSFILES = \ $(OBJ)$/app.obj \ + $(OBJ)$/printer.obj \ $(OBJ)$/process.obj .IF "$(GUI)" == "WNT" diff --git a/basic/source/app/printer.cxx b/basic/source/app/printer.cxx index 6f173fd53ffa..61879d628d39 100644 --- a/basic/source/app/printer.cxx +++ b/basic/source/app/printer.cxx @@ -64,35 +64,32 @@ public: void ChangeMessage( short ); }; -BasicPrinter::BasicPrinter() : Printer() +BasicPrinter::BasicPrinter() : mpPrinter( new Printer() ) { nPage = 0; nLine = 9999; - SetMapMode( MapMode( MAP_POINT ) ); - Size s( GetOutputSize() ); + mpPrinter->SetMapMode( MapMode( MAP_POINT ) ); + Size s( mpPrinter->GetOutputSize() ); // Use 10 point font Font aFont( FAMILY_MODERN, Size( 0, 10 ) ); aFont.SetPitch( PITCH_FIXED ); - SetFont( aFont ); + mpPrinter->SetFont( aFont ); // Output: 6 Lines/Inch = 12 Point nLines = (short) s.Height() / 12; nYoff = 12; - SetStartPrintHdl( LINK( this, BasicPrinter, StartPrintHdl ) ); - SetEndPrintHdl( LINK( this, BasicPrinter, EndPrintHdl ) ); - SetPrintPageHdl( LINK( this, BasicPrinter, PrintPageHdl ) ); } void BasicPrinter::Header() { - if( nPage ) EndPage(); + if( nPage ) mpListener->EndPage(); nPage++; - StartPage(); + mpListener->StartPage(); String aHdr; String aPage( SttResId( IDS_PAGE ) ); aPage.Append( String::CreateFromInt32(nPage) ); aHdr = aFile.Copy( 0, 80 - aPage.Len() ); aHdr.Expand( 80 - aPage.Len(), ' ' ); aHdr += aPage; - DrawText( Point( 0, 0 ), aHdr ); + mpPrinter->DrawText( Point( 0, 0 ), aHdr ); nLine = 2; } @@ -100,98 +97,29 @@ void BasicPrinter::Print( const String& rFile, const String& rText, BasicFrame * { nPage = 0; nLine = 9999; aFile = rFile; - // Setup dialog - SttResId aResId( IDD_PRINT_DIALOG ); - pDlg = new PrintingDialog - ( aBasicApp.pFrame, this, aResId, aFile ); - // Set position of dialog - Size s1 = aBasicApp.pFrame->GetSizePixel(); - Size s2 = pDlg->GetSizePixel(); - pDlg->SetPosPixel( Point( (s1.Width() - s2.Width() ) / 2, - (s1.Height()- s2.Height() ) / 2 ) ); // Disable PRINT-Menu MenuBar* pBar = pFrame->GetMenuBar(); Menu* pFileMenu = pBar->GetPopupMenu( RID_APPFILE ); pFileMenu->EnableItem( RID_FILEPRINT, FALSE ); - pDlg->ChangeMessage( 1 ); - pDlg->Show(); - StartJob( rFile ); - StartPage(); + mpListener.reset( new vcl::OldStylePrintAdaptor( mpPrinter ) ); + mpListener->StartPage(); xub_StrLen nDone=0; while( nDone < rText.Len() ) { if( nLine >= nLines ) Header(); xub_StrLen nLineEnd = std::min( rText.Search( '\n', nDone ), rText.Search( '\r', nDone ) ); - DrawText( Point( 0, nLine * nYoff ), rText, nDone, nLineEnd-nDone-1 ); + mpPrinter->DrawText( Point( 0, nLine * nYoff ), rText, nDone, nLineEnd-nDone-1 ); nDone = nLineEnd; if( nDone <= rText.Len() && rText.GetChar(nDone) == '\r' ) nDone++; if( nDone <= rText.Len() && rText.GetChar(nDone) == '\n' ) nDone++; nLine++; - Application::Reschedule(); } - EndPage(); - EndJob(); + mpListener->EndPage(); + + Printer::PrintJob( mpListener, mpPrinter->GetJobSetup() ); nPage = 1; - while( IsPrinting() ) Application::Reschedule(); - delete pDlg; pDlg = NULL; pFileMenu->EnableItem( RID_FILEPRINT, TRUE ); } -IMPL_LINK_INLINE_START( BasicPrinter, StartPrintHdl, Printer *, pPrinter ) -{ - (void) pPrinter; /* avoid warning about unused parameter */ - if( pDlg != NULL ) - pDlg->Show(); - return 0; -} -IMPL_LINK_INLINE_END( BasicPrinter, StartPrintHdl, Printer *, pPrinter ) - -IMPL_LINK_INLINE_START( BasicPrinter, EndPrintHdl, Printer *, pPrinter ) -{ - (void) pPrinter; /* avoid warning about unused parameter */ - if( pDlg != NULL) - pDlg->Hide(); - return 0; -} -IMPL_LINK_INLINE_END( BasicPrinter, EndPrintHdl, Printer *, pPrinter ) - -IMPL_LINK_INLINE_START( BasicPrinter, PrintPageHdl, Printer *, pPrinter ) -{ - (void) pPrinter; /* avoid warning about unused parameter */ - if( pDlg != NULL) - pDlg->ChangeMessage( nPage ); - return 0; -} -IMPL_LINK_INLINE_END( BasicPrinter, PrintPageHdl, Printer *, pPrinter ) - -IMPL_LINK_INLINE( BasicPrinter, Abort , void *, EMPTYARG, -{ - AbortJob(); - return 0L; -} -) - -///////////////////////////////////////////////////////////////////////// - -PrintingDialog::PrintingDialog - ( Window* pParent, BasicPrinter* pPrn, ResId& rId, String& rName ) -: ModelessDialog( pParent, rId ) -, aName ( rName ) -, aText ( this, ResId( RID_TEXT, *rId.GetResMgr() ) ) -, aCancel( this, ResId( RID_CANCEL, *rId.GetResMgr() ) ) -{ - FreeResource(); - aCancel.SetClickHdl( LINK( pPrn, BasicPrinter, Abort ) ); -} - -void PrintingDialog::ChangeMessage( short nPage ) -{ - String aMsg( SttResId( IDS_PRINTMSG ) ); - aMsg += aName; - aMsg += CUniString("\n"); - aMsg += String( SttResId( IDS_PAGE ) ); - aMsg += String::CreateFromInt32( nPage ); - aText.SetText( aMsg ); -} diff --git a/basic/source/app/printer.hxx b/basic/source/app/printer.hxx index d6db8154c57f..26b89b5278fe 100644 --- a/basic/source/app/printer.hxx +++ b/basic/source/app/printer.hxx @@ -31,31 +31,25 @@ #ifndef _BASICPRN_HXX #define _BASICPRN_HXX -#ifndef _PRINT_HXX //autogen -#include <vcl/print.hxx> -#endif +#include "vcl/print.hxx" +#include "vcl/oldprintadaptor.hxx" -class PrintingDialog; +class BasicPrinter +{ + boost::shared_ptr<Printer> mpPrinter; + boost::shared_ptr<vcl::OldStylePrintAdaptor> mpListener; -class BasicPrinter : public Printer { short nLine; // aktuelle Zeile short nPage; // aktuelle Seite short nLines; // Zeilen pro Seite short nYoff; // Zeilenabstand in Points String aFile; // Dateiname - PrintingDialog* pDlg; // Druck-Dialog + void Header(); // Seitenkopf drucken + void StartPage(); public: BasicPrinter(); void Print( const String& rFile, const String& rText, BasicFrame *pFrame ); - DECL_LINK( Abort, void * ); - DECL_LINK( StartPrintHdl, Printer * ); - DECL_LINK( EndPrintHdl, Printer * ); - DECL_LINK( PrintPageHdl, Printer * ); -#if defined( PM20 ) - // StarView-Bug, bald wieder zu entfernen: - virtual void SetPageQueueSize( USHORT ) {} -#endif }; #endif diff --git a/basic/source/runtime/basrdll.cxx b/basic/source/runtime/basrdll.cxx index aa3fda6a7116..a13569ee0a9f 100644 --- a/basic/source/runtime/basrdll.cxx +++ b/basic/source/runtime/basrdll.cxx @@ -32,9 +32,7 @@ #include "precompiled_basic.hxx" #include <tools/shl.hxx> #include <vcl/svapp.hxx> -#ifndef _SOLAR_HRC #include <svl/solar.hrc> -#endif #include <tools/debug.hxx> #include <vcl/msgbox.hxx> diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java index 7fcfba0cf0a3..06f7da701f14 100644 --- a/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/NativeInputStreamHelper.java @@ -1,4 +1,33 @@ -/* +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StorageFileAccess.java,v $ + * $Revision: 1.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + /* * NativeInputStreamHelper.java * * Created on 9. September 2004, 11:51 diff --git a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java index 50697e07c6aa..5778c9ab830c 100644 --- a/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java +++ b/connectivity/com/sun/star/sdbcx/comp/hsqldb/StorageNativeInputStream.java @@ -1,3 +1,32 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StorageFileAccess.java,v $ + * $Revision: 1.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ /* * StorageNativeInputStream.java * diff --git a/connectivity/inc/connectivity/BlobHelper.hxx b/connectivity/inc/connectivity/BlobHelper.hxx new file mode 100644 index 000000000000..2fb832823bd2 --- /dev/null +++ b/connectivity/inc/connectivity/BlobHelper.hxx @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FValue.cxx,v $ + * $Revision: 1.34 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CONNECTIVITY_BLOBHELPER_HXX_ +#define _CONNECTIVITY_BLOBHELPER_HXX_ + +#include "connectivity/dbtoolsdllapi.hxx" +#include <com/sun/star/sdbc/XBlob.hpp> +#include <cppuhelper/implbase1.hxx> + +namespace connectivity +{ + class OOO_DLLPUBLIC_DBTOOLS BlobHelper : public ::cppu::WeakImplHelper1< com::sun::star::sdbc::XBlob > + { + ::com::sun::star::uno::Sequence< sal_Int8 > m_aValue; + public: + BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val); + private: + virtual ::sal_Int64 SAL_CALL length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getBytes( ::sal_Int64 pos, ::sal_Int32 length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int64 SAL_CALL position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& pattern, ::sal_Int64 start ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual ::sal_Int64 SAL_CALL positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& pattern, ::sal_Int64 start ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + }; +} + +#endif //_CONNECTIVITY_BLOBHELPER_HXX_ + diff --git a/connectivity/inc/connectivity/dbmetadata.hxx b/connectivity/inc/connectivity/dbmetadata.hxx index 1ee1718247ae..4cfab247c10f 100644 --- a/connectivity/inc/connectivity/dbmetadata.hxx +++ b/connectivity/inc/connectivity/dbmetadata.hxx @@ -121,6 +121,17 @@ namespace dbtools */ bool supportsSubqueriesInFrom() const; + /** checks whether the database supports primary keys + + Since there's no dedicated API to ask a database for this, a heuristics needs to be applied. + First, the <code>PrimaryKeySupport<code> settings of the data source is examined. If it is <TRUE/> + or <FALSE/>, then value is returned. If it is <NULL/>, then the database meta data are examined + for support of core SQL grammar, and the result is returned. The assumption is that a database/driver + which supports core SQL grammar usually also supports primary keys, and vice versa. At least, experience + shows this is true most of the time. + */ + bool supportsPrimaryKeys() const; + /** determines whether names in the database should be restricted to SQL-92 identifiers Effectively, this method checks the EnableSQL92Check property of the data source settings, diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx index 493dc2a3802f..32ef3bcb7da1 100644 --- a/connectivity/inc/connectivity/dbtools.hxx +++ b/connectivity/inc/connectivity/dbtools.hxx @@ -37,6 +37,7 @@ #include <comphelper/stl_types.hxx> #include <unotools/sharedunocomponent.hxx> #include "connectivity/dbtoolsdllapi.hxx" +#include "connectivity/FValue.hxx" namespace com { namespace sun { namespace star { @@ -593,6 +594,20 @@ namespace dbtools sal_Int32 sqlType, sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + /** call the appropiate set method for the specific sql type @see com::sun::star::sdbc::DataType + @param _xParams the parameters where to set the value + @param parameterIndex the index of the parameter, 1 based + @param x the value to set + @param sqlType the corresponding sql type @see com::sun::star::sdbc::DataType + @param scale the scale of the sql type can be 0 + */ + OOO_DLLPUBLIC_DBTOOLS + void setObjectWithInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _xParameters, + sal_Int32 parameterIndex, + const ::connectivity::ORowSetValue& x, + sal_Int32 sqlType, + sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + /** implements <method scope="com.sun.star.sdb">XParameters::setObject</method> <p>The object which is to be set is analyzed, and in case it is a simlpe scalar type for which there diff --git a/connectivity/inc/connectivity/sqliterator.hxx b/connectivity/inc/connectivity/sqliterator.hxx index ddbf3e24af3c..e8e4c8e6a6f2 100644 --- a/connectivity/inc/connectivity/sqliterator.hxx +++ b/connectivity/inc/connectivity/sqliterator.hxx @@ -279,6 +279,9 @@ namespace connectivity // return true when the tableNode is a rule like catalog_name, schema_name or table_name sal_Bool isTableNode(const OSQLParseNode* _pTableNode) const; + + // tries to find the correct type of the function + sal_Int32 getFunctionReturnType(const OSQLParseNode* _pNode ); private: /** traverses the list of table names, and filles _rTables */ diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx index 0adcae01d966..cc1b27cf4f57 100644 --- a/connectivity/inc/connectivity/sqlnode.hxx +++ b/connectivity/inc/connectivity/sqlnode.hxx @@ -225,6 +225,10 @@ namespace connectivity as, op_column_commalist, table_primary_as_range_column, + datetime_primary, + concatenation, + char_factor, + bit_value_fct, rule_count, // letzter_wert UNKNOWN_RULE // ID indicating that a node is no rule with a matching Rule-enum value (see getKnownRuleID) }; diff --git a/connectivity/qa/connectivity/GeneralTest.java b/connectivity/qa/connectivity/GeneralTest.java index 18b6cf267a43..da894ba2cbdb 100644 --- a/connectivity/qa/connectivity/GeneralTest.java +++ b/connectivity/qa/connectivity/GeneralTest.java @@ -30,21 +30,13 @@ package complex.connectivity; import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.XCloseable; import com.sun.star.sdbc.*; -import com.sun.star.sdb.*; -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; import com.sun.star.lang.XMultiServiceFactory; import complexlib.ComplexTestCase; -import java.io.PrintWriter; -import util.utils; -import java.util.*; -import java.io.*; //import complex.connectivity.DBaseStringFunctions; public class GeneralTest extends ComplexTestCase { @@ -63,7 +55,7 @@ public class GeneralTest extends ComplexTestCase { public void test() throws com.sun.star.uno.Exception,com.sun.star.beans.UnknownPropertyException { try { - XDriverManager driverManager = (XDriverManager)UnoRuntime.queryInterface(XDriverManager.class,((XMultiServiceFactory)param.getMSF()).createInstance("com.sun.star.sdbc.DriverManager")); + XDriverManager driverManager = UnoRuntime.queryInterface( XDriverManager.class, ((XMultiServiceFactory)param.getMSF()).createInstance( "com.sun.star.sdbc.DriverManager" ) ); String databaseURL = "sdbc:calc:singin' in the rain" ; XConnection catalogConnection = driverManager.getConnection(databaseURL); failed(); diff --git a/connectivity/qa/connectivity/tools/AbstractDatabase.java b/connectivity/qa/connectivity/tools/AbstractDatabase.java index d3150cd8aa07..4807860740ad 100755 --- a/connectivity/qa/connectivity/tools/AbstractDatabase.java +++ b/connectivity/qa/connectivity/tools/AbstractDatabase.java @@ -38,10 +38,10 @@ import com.sun.star.sdb.XDocumentDataSource; import com.sun.star.sdb.XOfficeDatabaseDocument; import com.sun.star.sdbc.SQLException; import com.sun.star.sdbc.XCloseable; -import com.sun.star.sdbc.XConnection; import com.sun.star.sdbc.XStatement; import com.sun.star.uno.UnoRuntime; import com.sun.star.util.CloseVetoException; +import connectivity.tools.sdb.Connection; import java.io.File; /** @@ -60,7 +60,7 @@ public abstract class AbstractDatabase implements DatabaseAccess // the data source belonging to the database document protected DataSource m_dataSource; // the default connection - protected XConnection m_connection; + protected Connection m_connection; public AbstractDatabase(final XMultiServiceFactory orb) throws Exception { @@ -80,12 +80,10 @@ public abstract class AbstractDatabase implements DatabaseAccess * the ownership of the connection, so you don't need to (and should not) dispose/close it. * */ - public XConnection defaultConnection() throws SQLException + public Connection defaultConnection() throws SQLException { - if (m_connection == null) - { - m_connection = m_databaseDocument.getDataSource().getConnection("", ""); - } + if ( m_connection == null ) + m_connection = new Connection( m_databaseDocument.getDataSource().getConnection("", "") ); return m_connection; } @@ -104,8 +102,7 @@ public abstract class AbstractDatabase implements DatabaseAccess { if (m_databaseDocument != null) { - final XStorable storeDoc = (XStorable) UnoRuntime.queryInterface(XStorable.class, - m_databaseDocument); + final XStorable storeDoc = UnoRuntime.queryInterface(XStorable.class, m_databaseDocument); storeDoc.store(); } } @@ -118,8 +115,8 @@ public abstract class AbstractDatabase implements DatabaseAccess public void close() { // close connection - final XCloseable closeConn = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, - m_connection); + final XCloseable closeConn = UnoRuntime.queryInterface( XCloseable.class, + m_connection != null ? m_connection.getXConnection() : null ); if (closeConn != null) { try @@ -133,8 +130,7 @@ public abstract class AbstractDatabase implements DatabaseAccess m_connection = null; // close document - final com.sun.star.util.XCloseable closeDoc = (com.sun.star.util.XCloseable) UnoRuntime.queryInterface( - com.sun.star.util.XCloseable.class, m_databaseDocument); + final com.sun.star.util.XCloseable closeDoc = UnoRuntime.queryInterface( com.sun.star.util.XCloseable.class, m_databaseDocument ); if (closeDoc != null) { try @@ -178,7 +174,7 @@ public abstract class AbstractDatabase implements DatabaseAccess */ public XModel getModel() { - return (XModel) UnoRuntime.queryInterface(XModel.class, m_databaseDocument); + return UnoRuntime.queryInterface( XModel.class, m_databaseDocument ); } public XMultiServiceFactory getORB() @@ -191,10 +187,9 @@ public abstract class AbstractDatabase implements DatabaseAccess { m_databaseDocumentFile = _docURL; - final XNameAccess dbContext = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, - m_orb.createInstance("com.sun.star.sdb.DatabaseContext")); - final XDocumentDataSource dataSource = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, - dbContext.getByName(_docURL)); + final XNameAccess dbContext = UnoRuntime.queryInterface( XNameAccess.class, + m_orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) ); + final XDocumentDataSource dataSource = UnoRuntime.queryInterface( XDocumentDataSource.class, dbContext.getByName( _docURL ) ); m_databaseDocument = dataSource.getDatabaseDocument(); m_dataSource = new DataSource(m_orb, m_databaseDocument.getDataSource()); diff --git a/connectivity/qa/connectivity/tools/CRMDatabase.java b/connectivity/qa/connectivity/tools/CRMDatabase.java new file mode 100644 index 000000000000..7a6cb7e8c034 --- /dev/null +++ b/connectivity/qa/connectivity/tools/CRMDatabase.java @@ -0,0 +1,295 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: CRMDatabase.java,v $ + * $Revision: 1.6.2.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package connectivity.tools; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.PropertyState; +import com.sun.star.container.ElementExistException; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.frame.XController; +import com.sun.star.frame.XModel; +import com.sun.star.io.IOException; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XSingleSelectQueryComposer; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XRefreshable; +import connectivity.tools.sdb.Connection; + +/** implements a small Customer Relationship Management database + * + * Not finished, by far. Feel free to add features as you need them. + */ +public class CRMDatabase +{ + private static final String INTEGER = "INTEGER"; + private static final String VARCHAR50 = "VARCHAR(50)"; + private final XMultiServiceFactory m_orb; + private final HsqlDatabase m_database; + private final DataSource m_dataSource; + private final Connection m_connection; + + /** constructs the CRM database + */ + public CRMDatabase( XMultiServiceFactory _orb, boolean _withUI ) throws Exception + { + m_orb = _orb; + + m_database = new HsqlDatabase( m_orb ); + m_dataSource = m_database.getDataSource(); + + if ( _withUI ) + { + final XComponentLoader loader = UnoRuntime.queryInterface( XComponentLoader.class, + m_orb.createInstance( "com.sun.star.frame.Desktop" ) ); + PropertyValue[] loadArgs = new PropertyValue[] { + new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE ) + }; + loader.loadComponentFromURL( m_database.getDocumentURL(), "_blank", 0, loadArgs ); + getDocumentUI().connect(); + m_connection = new Connection( getDocumentUI().getActiveConnection() ); + } + else + { + m_connection = m_database.defaultConnection(); + } + + createTables(); + createQueries(); + } + + /** + * creates a CRMDatabase from an existing document, given by URL + * @param _orb + * @param _existingDocumentURL + * @throws Exceptio + */ + public CRMDatabase( XMultiServiceFactory _orb, final String _existingDocumentURL ) throws Exception + { + m_orb = _orb; + + m_database = new HsqlDatabase( m_orb, _existingDocumentURL ); + m_dataSource = m_database.getDataSource(); + m_connection = m_database.defaultConnection(); + } + + // -------------------------------------------------------------------------------------------------------- + /** returns the database document underlying the CRM database + */ + public final HsqlDatabase getDatabase() + { + return m_database; + } + + // -------------------------------------------------------------------------------------------------------- + /** returns the default connection to the database + */ + public final Connection getConnection() + { + return m_connection; + } + + // -------------------------------------------------------------------------------------------------------- + public void saveAndClose() throws SQLException, IOException + { + XDatabaseDocumentUI ui = getDocumentUI(); + if ( ui != null ) + ui.closeSubComponents(); + m_database.store(); + m_database.closeAndDelete(); + } + + // -------------------------------------------------------------------------------------------------------- + public XDatabaseDocumentUI getDocumentUI() + { + XModel docModel = UnoRuntime.queryInterface( XModel.class, m_database.getDatabaseDocument() ); + return UnoRuntime.queryInterface( XDatabaseDocumentUI.class, docModel.getCurrentController() ); + } + + // -------------------------------------------------------------------------------------------------------- + public XController loadSubComponent( final int _objectType, final String _name ) throws IllegalArgumentException, SQLException, NoSuchElementException + { + XDatabaseDocumentUI docUI = getDocumentUI(); + if ( !docUI.isConnected() ) + docUI.connect(); + + XComponent subComponent = docUI.loadComponent( _objectType, _name, false ); + XController controller = UnoRuntime.queryInterface( XController.class, subComponent ); + if ( controller != null ) + return controller; + XModel document = UnoRuntime.queryInterface( XModel.class, subComponent ); + return document.getCurrentController(); + } + + // -------------------------------------------------------------------------------------------------------- + private void createTables() throws SQLException + { + HsqlTableDescriptor table = new HsqlTableDescriptor( "categories", + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ), + new HsqlColumnDescriptor( "Name",VARCHAR50), + new HsqlColumnDescriptor( "Description", "VARCHAR(1024)" ), + new HsqlColumnDescriptor( "Image", "LONGVARBINARY" ) } ); + m_database.createTable( table, true ); + + m_database.executeSQL( "INSERT INTO \"categories\" ( \"ID\", \"Name\" ) VALUES ( 1, 'Food' )" ); + m_database.executeSQL( "INSERT INTO \"categories\" ( \"ID\", \"Name\" ) VALUES ( 2, 'Furniture' )" ); + + table = new HsqlTableDescriptor( "products", + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ), + new HsqlColumnDescriptor( "Name",VARCHAR50), + new HsqlColumnDescriptor( "CategoryID",INTEGER, HsqlColumnDescriptor.REQUIRED, "categories", "ID" ) } ); + m_database.createTable( table, true ); + + m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 1, 'Oranges', 1 )" ); + m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 2, 'Apples', 1 )" ); + m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 3, 'Pears', 1 )" ); + m_database.executeSQL( "INSERT INTO \"products\" VALUES ( 4, 'Strawberries', 1 )" ); + + table = new HsqlTableDescriptor( "customers", + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ), + new HsqlColumnDescriptor( "Name",VARCHAR50), + new HsqlColumnDescriptor( "Address",VARCHAR50), + new HsqlColumnDescriptor( "City",VARCHAR50), + new HsqlColumnDescriptor( "Postal",VARCHAR50), + new HsqlColumnDescriptor( "Comment","LONGVARCHAR")} ); + m_database.createTable( table, true ); + + m_database.executeSQL( "INSERT INTO \"customers\" VALUES(1,'Food, Inc.','Down Under','Melbourne','509','Prefered') " ); + m_database.executeSQL( "INSERT INTO \"customers\" VALUES(2,'Simply Delicious','Down Under','Melbourne','518',null) " ); + m_database.executeSQL( "INSERT INTO \"customers\" VALUES(3,'Pure Health','10 Fish St.','San Francisco','94107',null) " ); + m_database.executeSQL( "INSERT INTO \"customers\" VALUES(4,'Milk And More','Arlington Road 21','Dublin','31021','Good one.') " ); + + table = new HsqlTableDescriptor( "orders", + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "ID",INTEGER, HsqlColumnDescriptor.PRIMARY ), + new HsqlColumnDescriptor( "CustomerID",INTEGER, HsqlColumnDescriptor.REQUIRED, "customers", "ID" ), + new HsqlColumnDescriptor( "OrderDate", "DATE" ), + new HsqlColumnDescriptor( "ShipDate", "DATE" ) } ); + m_database.createTable( table, true ); + + m_database.executeSQL( "INSERT INTO \"orders\" (\"ID\", \"CustomerID\", \"OrderDate\") VALUES(1, 1, {D '2009-01-01'})" ); + m_database.executeSQL( "INSERT INTO \"orders\" VALUES(2, 2, {D '2009-01-01'}, {D '2009-01-23'})" ); + + table = new HsqlTableDescriptor( "orders_details", + new HsqlColumnDescriptor[] { + new HsqlColumnDescriptor( "OrderID",INTEGER, HsqlColumnDescriptor.PRIMARY, "orders", "ID" ), + new HsqlColumnDescriptor( "ProductID",INTEGER, HsqlColumnDescriptor.PRIMARY, "products", "ID" ), + new HsqlColumnDescriptor( "Quantity",INTEGER) } ); + m_database.createTable( table, true ); + + m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(1, 1, 100)" ); + m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(1, 2, 100)" ); + m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 2, 2000)" ); + m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 3, 2000)" ); + m_database.executeSQL( "INSERT INTO \"orders_details\" VALUES(2, 4, 2000)" ); + + // since we created the tables by directly executing the SQL statements, we need to refresh + // the tables container + m_connection.refreshTables(); + } + + // -------------------------------------------------------------------------------------------------------- + private void validateUnparseable() + { + // The "unparseable" query should be indeed be unparseable by OOo (though a valid HSQL query) + XSingleSelectQueryComposer composer; + QueryDefinition unparseableQuery; + try + { + final XMultiServiceFactory factory = UnoRuntime.queryInterface( + XMultiServiceFactory.class, m_database.defaultConnection().getXConnection() ); + composer = UnoRuntime.queryInterface( + XSingleSelectQueryComposer.class, factory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) ); + unparseableQuery = m_dataSource.getQueryDefinition( "unparseable" ); + } + catch( Exception e ) + { + throw new RuntimeException( "caught an unexpected exception: " + e.getMessage() ); + } + + boolean caughtExpected = false; + try + { + composer.setQuery( unparseableQuery.getCommand() ); + } + catch (WrappedTargetException e) { } + catch( SQLException e ) + { + caughtExpected = true; + } + + if ( !caughtExpected ) + throw new RuntimeException( "Somebody improved the parser! This is bad :), since we need an unparsable query here!" ); + } + + // -------------------------------------------------------------------------------------------------------- + private void createQueries() throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException + { + m_database.getDataSource().createQuery( + "all orders", + "SELECT \"orders\".\"ID\" AS \"Order No.\", " + + "\"customers\".\"Name\" AS \"Customer Name\", " + + "\"orders\".\"OrderDate\" AS \"Order Date\", " + + "\"orders\".\"ShipDate\" AS \"Ship Date\", " + + "\"orders_details\".\"Quantity\", " + + "\"products\".\"Name\" AS \"Product Name\" " + + "FROM \"orders_details\" AS \"orders_details\", " + + "\"orders\" AS \"orders\", " + + "\"products\" AS \"products\", " + + "\"customers\" AS \"customers\" " + + "WHERE ( \"orders_details\".\"OrderID\" = \"orders\".\"ID\" " + + "AND \"orders_details\".\"ProductID\" = \"products\".\"ID\" " + + "AND \"orders\".\"CustomerID\" = \"customers\".\"ID\" )" + ); + + m_database.getDataSource().createQuery( + "unshipped orders", + "SELECT * " + + "FROM \"all orders\"" + + "WHERE ( \"ShipDate\" IS NULL )" + ); + + m_database.getDataSource().createQuery( "parseable", "SELECT * FROM \"customers\"" ); + m_database.getDataSource().createQuery( "parseable native", "SELECT * FROM INFORMATION_SCHEMA.SYSTEM_VIEWS", false ); + m_database.getDataSource().createQuery( "unparseable", + "SELECT CAST( \"ID\" AS VARCHAR(3) ) AS \"ID_VARCHAR\" FROM \"products\"", false ); + + validateUnparseable(); + } +} diff --git a/connectivity/qa/connectivity/tools/DataSource.java b/connectivity/qa/connectivity/tools/DataSource.java index 1ed8f7f98af7..23d0d142128a 100644 --- a/connectivity/qa/connectivity/tools/DataSource.java +++ b/connectivity/qa/connectivity/tools/DataSource.java @@ -39,10 +39,8 @@ import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.beans.XPropertySet; import com.sun.star.sdb.XQueryDefinitionsSupplier; import com.sun.star.sdbc.XDataSource; -import com.sun.star.sdbcx.XTablesSupplier; import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; -import com.sun.star.util.XRefreshable; import java.util.logging.Level; import java.util.logging.Logger; @@ -57,11 +55,10 @@ public class DataSource { m_orb = _orb; - final XNameAccess dbContext = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, - _orb.createInstance("com.sun.star.sdb.DatabaseContext")); + final XNameAccess dbContext = UnoRuntime.queryInterface( + XNameAccess.class, _orb.createInstance( "com.sun.star.sdb.DatabaseContext" ) ); - m_dataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class, - dbContext.getByName(_registeredName)); + m_dataSource = UnoRuntime.queryInterface( XDataSource.class, dbContext.getByName( _registeredName ) ); } public DataSource(final XMultiServiceFactory _orb,final XDataSource _dataSource) @@ -86,13 +83,11 @@ public class DataSource */ public void createQuery(final String _name, final String _sqlCommand, final boolean _escapeProcessing) throws ElementExistException, WrappedTargetException, com.sun.star.lang.IllegalArgumentException { - final XSingleServiceFactory queryDefsFac = (XSingleServiceFactory) UnoRuntime.queryInterface( - XSingleServiceFactory.class, getQueryDefinitions()); + final XSingleServiceFactory queryDefsFac = UnoRuntime.queryInterface( XSingleServiceFactory.class, getQueryDefinitions() ); XPropertySet queryDef = null; try { - queryDef = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, queryDefsFac.createInstance()); + queryDef = UnoRuntime.queryInterface( XPropertySet.class, queryDefsFac.createInstance() ); queryDef.setPropertyValue("Command", _sqlCommand); queryDef.setPropertyValue("EscapeProcessing", Boolean.valueOf(_escapeProcessing)); } @@ -101,8 +96,7 @@ public class DataSource e.printStackTrace(System.err); } - final XNameContainer queryDefsContainer = (XNameContainer) UnoRuntime.queryInterface( - XNameContainer.class, getQueryDefinitions()); + final XNameContainer queryDefsContainer = UnoRuntime.queryInterface( XNameContainer.class, getQueryDefinitions() ); queryDefsContainer.insertByName(_name, queryDef); } @@ -113,8 +107,7 @@ public class DataSource final XNameAccess allDefs = getQueryDefinitions(); try { - return new QueryDefinition( - (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, allDefs.getByName(_name))); + return new QueryDefinition( UnoRuntime.queryInterface( XPropertySet.class, allDefs.getByName( _name) ) ); } catch (WrappedTargetException e) { @@ -126,25 +119,11 @@ public class DataSource */ public XNameAccess getQueryDefinitions() { - final XQueryDefinitionsSupplier suppQueries = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface( + final XQueryDefinitionsSupplier suppQueries = UnoRuntime.queryInterface( XQueryDefinitionsSupplier.class, m_dataSource); return suppQueries.getQueryDefinitions(); } - /** refreshs the table container of a given connection - * - * This is usually necessary if you created tables by directly executing SQL statements, - * bypassing the SDBCX layer. - */ - public void refreshTables(final com.sun.star.sdbc.XConnection _connection) - { - final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface( - XTablesSupplier.class, _connection); - final XRefreshable refreshTables = (XRefreshable) UnoRuntime.queryInterface( - XRefreshable.class, suppTables.getTables()); - refreshTables.refresh(); - } - /** returns the name of the data source * * If a data source is registered at the database context, the name is the registration @@ -157,8 +136,7 @@ public class DataSource String name = null; try { - final XPropertySet dataSourceProps = (XPropertySet) UnoRuntime.queryInterface( - XPropertySet.class, m_dataSource); + final XPropertySet dataSourceProps = UnoRuntime.queryInterface( XPropertySet.class, m_dataSource ); name = (String) dataSourceProps.getPropertyValue("Name"); } catch (Exception ex) diff --git a/connectivity/qa/connectivity/tools/DatabaseAccess.java b/connectivity/qa/connectivity/tools/DatabaseAccess.java index bc39bb099087..78608063e64c 100755 --- a/connectivity/qa/connectivity/tools/DatabaseAccess.java +++ b/connectivity/qa/connectivity/tools/DatabaseAccess.java @@ -34,7 +34,7 @@ import com.sun.star.io.IOException; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdb.XOfficeDatabaseDocument; import com.sun.star.sdbc.SQLException; -import com.sun.star.sdbc.XConnection; +import connectivity.tools.sdb.Connection; /** * @@ -42,7 +42,7 @@ import com.sun.star.sdbc.XConnection; */ public interface DatabaseAccess { - XConnection defaultConnection() throws SQLException; + Connection defaultConnection() throws SQLException; void executeSQL(final String statementString) throws SQLException; diff --git a/connectivity/qa/connectivity/tools/HsqlDatabase.java b/connectivity/qa/connectivity/tools/HsqlDatabase.java index 593a5ad95981..896eed1525e9 100644 --- a/connectivity/qa/connectivity/tools/HsqlDatabase.java +++ b/connectivity/qa/connectivity/tools/HsqlDatabase.java @@ -30,6 +30,7 @@ package connectivity.tools; import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.PropertyState; import com.sun.star.beans.XPropertySet; import com.sun.star.container.ElementExistException; import com.sun.star.frame.XStorable; @@ -83,9 +84,9 @@ public class HsqlDatabase extends AbstractDatabase dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb"); final XStorable storable = (XStorable) UnoRuntime.queryInterface(XStorable.class, m_databaseDocument); - storable.storeAsURL(m_databaseDocumentFile, new PropertyValue[] - { - }); + storable.storeAsURL( m_databaseDocumentFile, new PropertyValue[] + { new PropertyValue( "PickListEntry", 0, false, PropertyState.DIRECT_VALUE ) + } ); } /** drops the table with a given name @@ -208,10 +209,8 @@ public class HsqlDatabase extends AbstractDatabase public void createTableInSDBCX(final HsqlTableDescriptor _tableDesc) throws SQLException, ElementExistException { final XPropertySet sdbcxDescriptor = _tableDesc.createSdbcxDescriptor(defaultConnection()); - final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface( - XTablesSupplier.class, defaultConnection()); - final XAppend appendTable = (XAppend) UnoRuntime.queryInterface( - XAppend.class, suppTables.getTables()); + final XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, defaultConnection().getXConnection() ); + final XAppend appendTable = UnoRuntime.queryInterface( XAppend.class, suppTables.getTables() ); appendTable.appendByDescriptor(sdbcxDescriptor); } } diff --git a/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java b/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java index ec6c472309d5..2c4f9d6e6466 100644 --- a/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java +++ b/connectivity/qa/connectivity/tools/HsqlTableDescriptor.java @@ -33,11 +33,11 @@ package connectivity.tools; import com.sun.star.beans.XPropertySet; import com.sun.star.container.XNameAccess; import com.sun.star.sdbc.ColumnValue; -import com.sun.star.sdbc.XConnection; import com.sun.star.sdbcx.XColumnsSupplier; import com.sun.star.sdbcx.XDataDescriptorFactory; import com.sun.star.sdbcx.XTablesSupplier; import com.sun.star.uno.UnoRuntime; +import connectivity.tools.sdb.Connection; /** is a very simply descriptor of a HSQL table, to be used with a HsqlDatabase.createTable method */ @@ -67,12 +67,10 @@ public class HsqlTableDescriptor return m_columns; } - public XPropertySet createSdbcxDescriptor( XConnection _forConnection ) + public XPropertySet createSdbcxDescriptor( Connection _forConnection ) { - XTablesSupplier suppTables = (XTablesSupplier)UnoRuntime.queryInterface( - XTablesSupplier.class, _forConnection ); - XDataDescriptorFactory tableDescFac = (XDataDescriptorFactory)UnoRuntime.queryInterface( - XDataDescriptorFactory.class, suppTables.getTables() ); + XTablesSupplier suppTables = UnoRuntime.queryInterface( XTablesSupplier.class, _forConnection.getXConnection() ); + XDataDescriptorFactory tableDescFac = UnoRuntime.queryInterface( XDataDescriptorFactory.class, suppTables.getTables() ); XPropertySet tableDesc = tableDescFac.createDataDescriptor(); try @@ -81,12 +79,10 @@ public class HsqlTableDescriptor } catch ( Exception e ) { e.printStackTrace( System.err ); } - XColumnsSupplier suppDescCols = (XColumnsSupplier)UnoRuntime.queryInterface( - XColumnsSupplier.class, tableDesc ); + XColumnsSupplier suppDescCols = UnoRuntime.queryInterface( XColumnsSupplier.class, tableDesc ); XNameAccess descColumns = suppDescCols.getColumns(); - XDataDescriptorFactory columnDescFac = (XDataDescriptorFactory)UnoRuntime.queryInterface( - XDataDescriptorFactory.class, descColumns ); + XDataDescriptorFactory columnDescFac = UnoRuntime.queryInterface( XDataDescriptorFactory.class, descColumns ); HsqlColumnDescriptor[] myColumns = getColumns(); for ( int i = 0; i < myColumns.length; ++i ) diff --git a/connectivity/qa/connectivity/tools/makefile.mk b/connectivity/qa/connectivity/tools/makefile.mk index 589a85ea385f..32aa94c77312 100644 --- a/connectivity/qa/connectivity/tools/makefile.mk +++ b/connectivity/qa/connectivity/tools/makefile.mk @@ -29,10 +29,10 @@ # #************************************************************************* -PRJ = ..$/..$/.. +PRJ = ../../.. TARGET = ConnectivityTools PRJNAME = connectivity -PACKAGE = connectivity$/tools +PACKAGE = connectivity/tools # --- Settings ----------------------------------------------------- .INCLUDE: settings.mk @@ -46,14 +46,8 @@ all: #----- compile .java files ----------------------------------------- JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunnerLight.jar -# Do not use $/ with the $(FIND) command as for W32-4nt this leads to a backslash -# in a posix command. In this special case use / instead of $/ -.IF "$(GUI)"=="OS2" -JAVAFILES := $(shell @ls ./*.java) -.ELSE -JAVAFILES := $(shell @$(FIND) ./*.java) -.ENDIF -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) +JAVAFILES := $(shell @$(FIND) . -name "*.java") +JAVACLASSFILES := $(foreach,i,$(JAVAFILES) $(CLASSDIR)/$(PACKAGE)/$(i:d)$(i:b).class) #----- make a jar from compiled files ------------------------------ diff --git a/connectivity/qa/connectivity/tools/sdb/Connection.java b/connectivity/qa/connectivity/tools/sdb/Connection.java new file mode 100644 index 000000000000..aac120fb1e73 --- /dev/null +++ b/connectivity/qa/connectivity/tools/sdb/Connection.java @@ -0,0 +1,93 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package connectivity.tools.sdb; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.XSingleSelectQueryComposer; +import com.sun.star.sdbc.SQLException; +import com.sun.star.sdbc.XConnection; +import com.sun.star.sdbc.XDatabaseMetaData; +import com.sun.star.sdbc.XPreparedStatement; +import com.sun.star.sdbc.XResultSet; +import com.sun.star.sdbc.XStatement; +import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XRefreshable; + +/** + * is a convenience wrapper around a SDB-level connection object + */ +public class Connection +{ + private final XConnection m_connection; + + public Connection( final XConnection _connection ) + { + m_connection = _connection; + } + + public XConnection getXConnection() + { + return m_connection; + } + + public boolean execute( final String _sql ) throws SQLException + { + XStatement statement = createStatement(); + return statement.execute( _sql ); + } + + public XResultSet executeQuery( final String _sql ) throws SQLException + { + XStatement statement = createStatement(); + return statement.executeQuery( _sql ); + } + + public int executeUpdate( final String _sql ) throws SQLException + { + XStatement statement = createStatement(); + return statement.executeUpdate( _sql ); + } + + public void refreshTables() + { + final XTablesSupplier suppTables = UnoRuntime.queryInterface(XTablesSupplier.class, m_connection); + final XRefreshable refresh = UnoRuntime.queryInterface( XRefreshable.class, suppTables.getTables() ); + refresh.refresh(); + } + + public XSingleSelectQueryComposer createSingleSelectQueryComposer() throws Exception + { + final XMultiServiceFactory connectionFactory = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_connection ); + return UnoRuntime.queryInterface( + XSingleSelectQueryComposer.class, connectionFactory.createInstance( "com.sun.star.sdb.SingleSelectQueryComposer" ) ); + } + + public + XStatement createStatement() throws SQLException + { + return m_connection.createStatement(); + } + + public + XPreparedStatement prepareStatement( String _sql ) throws SQLException + { + return m_connection.prepareStatement( _sql ); + } + + public + XDatabaseMetaData getMetaData() throws SQLException + { + return m_connection.getMetaData(); + } + + public + void close() throws SQLException + { + m_connection.close(); + } +} diff --git a/connectivity/source/commontools/BlobHelper.cxx b/connectivity/source/commontools/BlobHelper.cxx new file mode 100644 index 000000000000..5859db9036ac --- /dev/null +++ b/connectivity/source/commontools/BlobHelper.cxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: FValue.cxx,v $ + * $Revision: 1.34 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_connectivity.hxx" +#include "connectivity/BlobHelper.hxx" +#include <comphelper/seqstream.hxx> +#include "connectivity/dbexception.hxx" + +using namespace connectivity; +using namespace dbtools; +using namespace ::com::sun::star::sdbc; +using namespace ::com::sun::star::uno; + +BlobHelper::BlobHelper(const ::com::sun::star::uno::Sequence< sal_Int8 >& _val) : m_aValue(_val) +{ +} +// ----------------------------------------------------------------------------- +::sal_Int64 SAL_CALL BlobHelper::length( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return m_aValue.getLength(); +} +// ----------------------------------------------------------------------------- +::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL BlobHelper::getBytes( ::sal_Int64 pos, ::sal_Int32 _length ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + if ( sal_Int32(pos + _length) > m_aValue.getLength() ) + throw ::com::sun::star::sdbc::SQLException(); + return ::com::sun::star::uno::Sequence< ::sal_Int8 >(m_aValue.getConstArray() + sal_Int32(pos),_length); +} +// ----------------------------------------------------------------------------- +::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL BlobHelper::getBinaryStream( ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + return new ::comphelper::SequenceInputStream(m_aValue); +} +// ----------------------------------------------------------------------------- +::sal_Int64 SAL_CALL BlobHelper::position( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XBlob::position", *this ); + return 0; +} +// ----------------------------------------------------------------------------- +::sal_Int64 SAL_CALL BlobHelper::positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*pattern*/, ::sal_Int64 /*start*/ ) throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +{ + ::dbtools::throwFeatureNotImplementedException( "XBlob::positionOfBlob", *this ); + return 0; +} diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index f7943fc4cf45..f171af5ec530 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -257,6 +257,7 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType) case DataType::BLOB: case DataType::CLOB: case DataType::OBJECT: + case DataType::OTHER: (*this) = getAny(); break; default: @@ -847,6 +848,7 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const case DataType::BLOB: case DataType::CLOB: case DataType::OBJECT: + case DataType::OTHER: bRet = false; break; default: @@ -913,6 +915,7 @@ Any ORowSetValue::makeAny() const case DataType::BLOB: case DataType::CLOB: case DataType::OBJECT: + case DataType::OTHER: rValue = getAny(); break; case DataType::BIT: @@ -1019,6 +1022,19 @@ Any ORowSetValue::makeAny() const else aRet = ::rtl::OUString::valueOf((sal_Int64)*this); break; + case DataType::CLOB: + { + Any aValue( getAny() ); + Reference< XClob > xClob; + if ( aValue >>= xClob ) + { + if ( xClob.is() ) + { + aRet = xClob->getSubString(1,(sal_Int32)xClob->length() ); + } + } + } + break; } } return aRet; @@ -1090,6 +1106,9 @@ sal_Bool ORowSetValue::getBool() const case DataType::INTEGER: bRet = m_bSigned ? (m_aValue.m_nInt32 != 0) : (*static_cast<sal_Int64*>(m_aValue.m_pValue) != sal_Int64(0)); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return bRet; @@ -1131,6 +1150,8 @@ sal_Int8 ORowSetValue::getInt8() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getInt8() for this type is not allowed!"); break; case DataType::BIT: @@ -1155,6 +1176,9 @@ sal_Int8 ORowSetValue::getInt8() const else nRet = static_cast<sal_Int8>(*static_cast<sal_Int64*>(m_aValue.m_pValue)); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1196,6 +1220,8 @@ sal_Int16 ORowSetValue::getInt16() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getInt16() for this type is not allowed!"); break; case DataType::BIT: @@ -1220,6 +1246,9 @@ sal_Int16 ORowSetValue::getInt16() const else nRet = static_cast<sal_Int16>(*static_cast<sal_Int64*>(m_aValue.m_pValue)); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1261,6 +1290,8 @@ sal_Int32 ORowSetValue::getInt32() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getInt32() for this type is not allowed!"); break; case DataType::BIT: @@ -1285,6 +1316,9 @@ sal_Int32 ORowSetValue::getInt32() const else nRet = static_cast<sal_Int32>(*static_cast<sal_Int64*>(m_aValue.m_pValue)); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1326,6 +1360,8 @@ sal_Int64 ORowSetValue::getLong() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getInt32() for this type is not allowed!"); break; case DataType::BIT: @@ -1350,6 +1386,9 @@ sal_Int64 ORowSetValue::getLong() const else nRet = *(sal_Int64*)m_aValue.m_pValue; break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1395,6 +1434,8 @@ float ORowSetValue::getFloat() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getDouble() for this type is not allowed!"); break; case DataType::BIT: @@ -1419,6 +1460,9 @@ float ORowSetValue::getFloat() const else nRet = float(*(sal_Int64*)m_aValue.m_pValue); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1466,6 +1510,8 @@ double ORowSetValue::getDouble() const case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"getDouble() for this type is not allowed!"); break; case DataType::BIT: @@ -1490,6 +1536,9 @@ double ORowSetValue::getDouble() const else nRet = double(*(sal_Int64*)m_aValue.m_pValue); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return nRet; @@ -1551,6 +1600,8 @@ void ORowSetValue::setFromDouble(const double& _rVal,sal_Int32 _nDatatype) case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: + case DataType::CLOB: OSL_ASSERT(!"setFromDouble() for this type is not allowed!"); break; case DataType::BIT: @@ -1595,12 +1646,39 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const case DataType::BLOB: { Reference<XInputStream> xStream; - Any aValue = getAny(); + const Any aValue = makeAny(); if(aValue.hasValue()) { - aValue >>= xStream; + Reference<XBlob> xBlob(aValue,UNO_QUERY); + if ( xBlob.is() ) + xStream = xBlob->getBinaryStream(); + else + { + Reference<XClob> xClob(aValue,UNO_QUERY); + if ( xClob.is() ) + xStream = xClob->getCharacterStream(); + } if(xStream.is()) - xStream->readBytes(aSeq,xStream->available()); + { + const sal_uInt32 nBytesToRead = 65535; + sal_uInt32 nRead; + + do + { + ::com::sun::star::uno::Sequence< sal_Int8 > aReadSeq; + + nRead = xStream->readSomeBytes( aReadSeq, nBytesToRead ); + + if( nRead ) + { + const sal_uInt32 nOldLength = aSeq.getLength(); + aSeq.realloc( nOldLength + nRead ); + rtl_copyMemory( aSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() ); + } + } + while( nBytesToRead == nRead ); + xStream->closeInput(); + } } } break; @@ -1658,6 +1736,9 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const aValue.Year = pDateTime->Year; } break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return aValue; @@ -1696,6 +1777,10 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const break; case DataType::TIME: aValue = *static_cast< ::com::sun::star::util::Time*>(m_aValue.m_pValue); + break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return aValue; @@ -1743,6 +1828,9 @@ Sequence<sal_Int8> ORowSetValue::getSequence() const case DataType::TIMESTAMP: aValue = *static_cast< ::com::sun::star::util::DateTime*>(m_aValue.m_pValue); break; + default: + OSL_ENSURE(0,"Illegal conversion!"); + break; } } return aValue; @@ -1833,6 +1921,9 @@ namespace detail virtual Sequence< sal_Int8 > getBytes() const = 0; virtual Reference< XInputStream > getBinaryStream() const = 0; virtual Reference< XInputStream > getCharacterStream() const = 0; + virtual Reference< XBlob > getBlob() const = 0; + virtual Reference< XClob > getClob() const = 0; + virtual Any getObject() const = 0; virtual sal_Bool wasNull() const = 0; virtual ~IValueSource() { } @@ -1862,6 +1953,9 @@ namespace detail virtual Sequence< sal_Int8 > getBytes() const { return m_xRow->getBytes( m_nPos ); }; virtual Reference< XInputStream > getBinaryStream() const { return m_xRow->getBinaryStream( m_nPos ); }; virtual Reference< XInputStream > getCharacterStream() const { return m_xRow->getCharacterStream( m_nPos ); }; + virtual Reference< XBlob > getBlob() const { return m_xRow->getBlob( m_nPos ); }; + virtual Reference< XClob > getClob() const { return m_xRow->getClob( m_nPos ); }; + virtual Any getObject() const { return m_xRow->getObject( m_nPos, NULL ); }; virtual sal_Bool wasNull() const { return m_xRow->wasNull( ); }; private: @@ -1892,6 +1986,9 @@ namespace detail virtual Sequence< sal_Int8 > getBytes() const { return m_xColumn->getBytes(); }; virtual Reference< XInputStream > getBinaryStream() const { return m_xColumn->getBinaryStream(); }; virtual Reference< XInputStream > getCharacterStream() const { return m_xColumn->getCharacterStream(); }; + virtual Reference< XBlob > getBlob() const { return m_xColumn->getBlob(); }; + virtual Reference< XClob > getClob() const { return m_xColumn->getClob(); }; + virtual Any getObject() const { return m_xColumn->getObject( NULL ); }; virtual sal_Bool wasNull() const { return m_xColumn->wasNull( ); }; private: @@ -1987,13 +2084,17 @@ void ORowSetValue::impl_fill( const sal_Int32 _nType, sal_Bool _bNullable, const (*this) = _rValueSource.getLong(); break; case DataType::CLOB: - (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getCharacterStream()); + (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getClob()); setTypeKind(DataType::CLOB); break; case DataType::BLOB: - (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getBinaryStream()); + (*this) = ::com::sun::star::uno::makeAny(_rValueSource.getBlob()); setTypeKind(DataType::BLOB); break; + case DataType::OTHER: + (*this) = _rValueSource.getObject(); + setTypeKind(DataType::OTHER); + break; default: OSL_ENSURE( false, "ORowSetValue::fill: unsupported type!" ); bReadData = false; @@ -2139,6 +2240,29 @@ void ORowSetValue::fill(const Any& _rValue) break; } + case TypeClass_INTERFACE: + { + Reference< XClob > xClob; + if ( _rValue >>= xClob ) + { + (*this) = _rValue; + setTypeKind(DataType::CLOB); + } + else + { + Reference< XBlob > xBlob; + if ( _rValue >>= xBlob ) + { + (*this) = _rValue; + setTypeKind(DataType::BLOB); + } + else + { + (*this) = _rValue; + } + } + } + break; default: OSL_ENSURE(0,"Unknown type"); diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx index c5b65a9d113b..d30161da497c 100644 --- a/connectivity/source/commontools/dbmetadata.cxx +++ b/connectivity/source/commontools/dbmetadata.cxx @@ -257,6 +257,27 @@ namespace dbtools } //-------------------------------------------------------------------- + bool DatabaseMetaData::supportsPrimaryKeys() const + { + lcl_checkConnected( *m_pImpl ); + + bool doesSupportPrimaryKeys = false; + try + { + Any setting; + if ( !( lcl_getConnectionSetting( "PrimaryKeySupport", *m_pImpl, setting ) ) + || !( setting >>= doesSupportPrimaryKeys ) + ) + doesSupportPrimaryKeys = m_pImpl->xConnectionMetaData->supportsCoreSQLGrammar(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return doesSupportPrimaryKeys; + } + + //-------------------------------------------------------------------- const ::rtl::OUString& DatabaseMetaData::getIdentifierQuoteString() const { return lcl_getConnectionStringSetting( *m_pImpl, m_pImpl->sCachedIdentifierQuoteString, &XDatabaseMetaData::getIdentifierQuoteString ); diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 02e6e420142f..f00cfe14a9e5 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -213,6 +213,7 @@ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType, case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: nFormat = _xTypes->getStandardFormat(NumberFormat::TEXT, _rLocale); break; case DataType::DATE: @@ -234,10 +235,10 @@ sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType, case DataType::STRUCT: case DataType::ARRAY: case DataType::BLOB: - case DataType::CLOB: case DataType::REF: default: - nFormat = NumberFormat::UNDEFINED; + nFormat = _xTypes->getStandardFormat(NumberFormat::UNDEFINED, _rLocale); + //nFormat = NumberFormat::UNDEFINED; } return nFormat; } @@ -1850,9 +1851,20 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams, sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, - sal_Int32 /*scale*/) throw(SQLException, RuntimeException) + sal_Int32 scale) throw(SQLException, RuntimeException) +{ + ORowSetValue aVal; + aVal.fill(x); + setObjectWithInfo(_xParams,parameterIndex,aVal,sqlType,scale); +} +// ----------------------------------------------------------------------------- +void setObjectWithInfo(const Reference<XParameters>& _xParams, + sal_Int32 parameterIndex, + const ::connectivity::ORowSetValue& _rValue, + sal_Int32 sqlType, + sal_Int32 scale) throw(SQLException, RuntimeException) { - if(!x.hasValue()) + if ( _rValue.isNull() ) _xParams->setNull(parameterIndex,sqlType); else { @@ -1860,65 +1872,62 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams, { case DataType::DECIMAL: case DataType::NUMERIC: - _xParams->setObjectWithInfo(parameterIndex,x,sqlType,0); + _xParams->setObjectWithInfo(parameterIndex,_rValue.makeAny(),sqlType,scale); break; case DataType::CHAR: case DataType::VARCHAR: - //case DataType::DECIMAL: - //case DataType::NUMERIC: case DataType::LONGVARCHAR: - _xParams->setString(parameterIndex,::comphelper::getString(x)); + _xParams->setString(parameterIndex,_rValue); break; - case DataType::BIGINT: + case DataType::CLOB: { - sal_Int64 nValue = 0; - if(x >>= nValue) + Any x(_rValue.makeAny()); + ::rtl::OUString sValue; + if ( x >>= sValue ) + _xParams->setString(parameterIndex,sValue); + else { - _xParams->setLong(parameterIndex,nValue); - break; + Reference< XClob > xClob; + if(x >>= xClob) + _xParams->setClob(parameterIndex,xClob); + else + { + Reference< ::com::sun::star::io::XInputStream > xStream; + if(x >>= xStream) + _xParams->setCharacterStream(parameterIndex,xStream,xStream->available()); + } } } break; + case DataType::BIGINT: + if ( _rValue.isSigned() ) + _xParams->setLong(parameterIndex,_rValue); + else + _xParams->setString(parameterIndex,_rValue); + break; case DataType::FLOAT: + _xParams->setFloat(parameterIndex,_rValue); + break; case DataType::REAL: - { - float nValue = 0; - if(x >>= nValue) - { - _xParams->setFloat(parameterIndex,nValue); - break; - } - } - // run through if we couldn't set a float value case DataType::DOUBLE: - _xParams->setDouble(parameterIndex,::comphelper::getDouble(x)); + _xParams->setDouble(parameterIndex,_rValue); break; case DataType::DATE: - { - ::com::sun::star::util::Date aValue; - if(x >>= aValue) - _xParams->setDate(parameterIndex,aValue); - } + _xParams->setDate(parameterIndex,_rValue); break; case DataType::TIME: - { - ::com::sun::star::util::Time aValue; - if(x >>= aValue) - _xParams->setTime(parameterIndex,aValue); - } + _xParams->setTime(parameterIndex,_rValue); break; case DataType::TIMESTAMP: - { - ::com::sun::star::util::DateTime aValue; - if(x >>= aValue) - _xParams->setTimestamp(parameterIndex,aValue); - } + _xParams->setTimestamp(parameterIndex,_rValue); break; case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: { + Any x(_rValue.makeAny()); Sequence< sal_Int8> aBytes; if(x >>= aBytes) _xParams->setBytes(parameterIndex,aBytes); @@ -1944,16 +1953,25 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams, break; case DataType::BIT: case DataType::BOOLEAN: - _xParams->setBoolean(parameterIndex,::cppu::any2bool(x)); + _xParams->setBoolean(parameterIndex,_rValue); break; case DataType::TINYINT: - _xParams->setByte(parameterIndex,(sal_Int8)::comphelper::getINT32(x)); + if ( _rValue.isSigned() ) + _xParams->setByte(parameterIndex,_rValue); + else + _xParams->setShort(parameterIndex,_rValue); break; case DataType::SMALLINT: - _xParams->setShort(parameterIndex,(sal_Int16)::comphelper::getINT32(x)); + if ( _rValue.isSigned() ) + _xParams->setShort(parameterIndex,_rValue); + else + _xParams->setInt(parameterIndex,_rValue); break; case DataType::INTEGER: - _xParams->setInt(parameterIndex,::comphelper::getINT32(x)); + if ( _rValue.isSigned() ) + _xParams->setInt(parameterIndex,_rValue); + else + _xParams->setLong(parameterIndex,_rValue); break; default: { diff --git a/connectivity/source/commontools/makefile.mk b/connectivity/source/commontools/makefile.mk index cb5a4ad3f7aa..1cc6cf494919 100644 --- a/connectivity/source/commontools/makefile.mk +++ b/connectivity/source/commontools/makefile.mk @@ -89,6 +89,7 @@ EXCEPTIONSFILES=\ $(SLO)$/ParamterSubstitution.obj \ $(SLO)$/DriversConfig.obj \ $(SLO)$/formattedcolumnvalue.obj \ + $(SLO)$/BlobHelper.obj \ $(SLO)$/warningscontainer.obj SLOFILES=\ diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index 45e937235dd1..f5d22e2937aa 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -148,9 +148,10 @@ namespace dbtools sal_Int32 nType = DataType::OTHER; _rxField->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) >>= nType; - if ( ( DataType::CHAR == nType ) - || ( DataType::VARCHAR == nType ) + if ( ( DataType::CHAR == nType ) + || ( DataType::VARCHAR == nType ) || ( DataType::LONGVARCHAR == nType ) + || ( DataType::CLOB == nType ) ) { // yes -> force a quoted text and try again ::rtl::OUString sQuoted( _rStatement ); diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx index 1c53614bba04..438f3bc473cc 100644 --- a/connectivity/source/drivers/ado/AResultSet.cxx +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -334,11 +334,9 @@ Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw } // ------------------------------------------------------------------------- -Any SAL_CALL OResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) +Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) { - - ::dbtools::throwFeatureNotImplementedException( "XRow::getObject", *this ); - return Any(); + return getValue(columnIndex).makeAny(); } // ------------------------------------------------------------------------- @@ -786,14 +784,24 @@ void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::s } // ------------------------------------------------------------------------- -void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateBinaryStream", *this ); + if(!x.is()) + ::dbtools::throwFunctionSequenceException(*this); + + Sequence<sal_Int8> aSeq; + x->readBytes(aSeq,length); + updateBytes(columnIndex,aSeq); } // ------------------------------------------------------------------------- -void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this ); + if(!x.is()) + ::dbtools::throwFunctionSequenceException(*this); + + Sequence<sal_Int8> aSeq; + x->readBytes(aSeq,length); + updateBytes(columnIndex,aSeq); } // ------------------------------------------------------------------------- void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx index 09596da61bd6..b1b8235da3d8 100644 --- a/connectivity/source/drivers/ado/Aolevariant.cxx +++ b/connectivity/source/drivers/ado/Aolevariant.cxx @@ -39,8 +39,17 @@ #include "diagnose_ex.h" #include "resource/sharedresources.hxx" #include "resource/ado_res.hrc" - +#include "com/sun/star/bridge/oleautomation/Date.hpp" +#include "com/sun/star/bridge/oleautomation/Currency.hpp" +#include "com/sun/star/bridge/oleautomation/SCode.hpp" +#include "com/sun/star/bridge/oleautomation/Decimal.hpp" + +using namespace com::sun::star::beans; +using namespace com::sun::star::uno; +using namespace com::sun::star::bridge::oleautomation; using namespace connectivity::ado; +using ::rtl::OUString; + OLEString::OLEString() :m_sStr(NULL) { @@ -698,6 +707,88 @@ SAFEARRAY* OLEVariant::getUI1SAFEARRAYPtr() const return V_ARRAY(&varDest); } // ----------------------------------------------------------------------------- +::com::sun::star::uno::Any OLEVariant::makeAny() const +{ + ::com::sun::star::uno::Any aValue; + switch (V_VT(this)) + { + case VT_EMPTY: + case VT_NULL: + aValue.setValue(NULL, Type()); + break; + case VT_I2: + aValue.setValue( & iVal, getCppuType( (sal_Int16*)0)); + break; + case VT_I4: + aValue.setValue( & lVal, getCppuType( (sal_Int32*)0)); + break; + case VT_R4: + aValue.setValue( & fltVal, getCppuType( (float*)0)); + break; + case VT_R8: + aValue.setValue(& dblVal, getCppuType( (double*)0)); + break; + case VT_CY: + { + Currency cy(cyVal.int64); + aValue <<= cy; + break; + } + case VT_DATE: + { + aValue <<= (::com::sun::star::util::Date)*this; + break; + } + case VT_BSTR: + { + OUString b(reinterpret_cast<const sal_Unicode*>(bstrVal)); + aValue.setValue( &b, getCppuType( &b)); + break; + } + case VT_BOOL: + { + sal_Bool b= boolVal == VARIANT_TRUE; + aValue.setValue( &b, getCppuType( &b)); + break; + } + case VT_I1: + aValue.setValue( & cVal, getCppuType((sal_Int8*)0)); + break; + case VT_UI1: // there is no unsigned char in UNO + aValue.setValue( & bVal, getCppuType( (sal_Int8*)0)); + break; + case VT_UI2: + aValue.setValue( & uiVal, getCppuType( (sal_uInt16*)0)); + break; + case VT_UI4: + aValue.setValue( & ulVal, getCppuType( (sal_uInt32*)0)); + break; + case VT_INT: + aValue.setValue( & intVal, getCppuType( (sal_Int32*)0)); + break; + case VT_UINT: + aValue.setValue( & uintVal, getCppuType( (sal_uInt32*)0)); + break; + case VT_VOID: + aValue.setValue( NULL, Type()); + break; + case VT_DECIMAL: + { + Decimal dec; + dec.Scale = decVal.scale; + dec.Sign = decVal.sign; + dec.LowValue = decVal.Lo32; + dec.MiddleValue = decVal.Mid32; + dec.HighValue = decVal.Hi32; + aValue <<= dec; + break; + } + + default: + break; + } + return aValue; +} // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/ado.xcu b/connectivity/source/drivers/ado/ado.xcu index 236d38bd7ff7..8a106c70283f 100755 --- a/connectivity/source/drivers/ado/ado.xcu +++ b/connectivity/source/drivers/ado/ado.xcu @@ -115,6 +115,11 @@ <value>true</value> </prop> </node> + <node oor:name="PrimaryKeySupport" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> <node oor:name="MetaData"> <node oor:name="SupportsTableCreation" oor:op="replace"> diff --git a/connectivity/source/drivers/ado/adoimp.cxx b/connectivity/source/drivers/ado/adoimp.cxx index 188303a1ba50..e3412babfdf6 100644 --- a/connectivity/source/drivers/ado/adoimp.cxx +++ b/connectivity/source/drivers/ado/adoimp.cxx @@ -157,8 +157,10 @@ DataTypeEnum ADOS::MapJdbc2ADOType(sal_Int32 _nType,sal_Int32 _nJetEngine) case DataType::BIT: return adBoolean; break; case DataType::BINARY: return adBinary; break; case DataType::VARCHAR: return adVarWChar; break; + case DataType::CLOB: case DataType::LONGVARCHAR: return adLongVarWChar; break; case DataType::VARBINARY: return adVarBinary; break; + case DataType::BLOB: case DataType::LONGVARBINARY: return adLongVarBinary; break; case DataType::CHAR: return adWChar; break; case DataType::TINYINT: return isJetEngine(_nJetEngine) ? adUnsignedTinyInt : adTinyInt;break; diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx index 07cdf95d7b44..6e583644e3b9 100644 --- a/connectivity/source/drivers/file/FStatement.cxx +++ b/connectivity/source/drivers/file/FStatement.cxx @@ -497,13 +497,16 @@ void OStatement_Base::construct(const ::rtl::OUString& sql) throw(SQLException, // SELECT statement without columns -> error m_pConnection->throwGenericSQLException(STR_QUERY_NO_COLUMN,*this); - if ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_CREATE_TABLE ) - // CREATE TABLE is not supported at all - m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); - - if ( ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_ODBC_CALL ) || ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_UNKNOWN ) ) - // ODBC call or unknown statement type -> error - m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); + switch(m_aSQLIterator.getStatementType()) + { + case SQL_STATEMENT_CREATE_TABLE: + case SQL_STATEMENT_ODBC_CALL: + case SQL_STATEMENT_UNKNOWN: + m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this); + break; + default: + break; + } // at this moment we support only one table per select statement Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xTabs.begin()->second,UNO_QUERY); diff --git a/connectivity/source/drivers/jdbc/Boolean.cxx b/connectivity/source/drivers/jdbc/Boolean.cxx index cac868d4792f..d778487655d5 100644 --- a/connectivity/source/drivers/jdbc/Boolean.cxx +++ b/connectivity/source/drivers/jdbc/Boolean.cxx @@ -40,17 +40,19 @@ jclass java_lang_Boolean::theClass = 0; java_lang_Boolean::~java_lang_Boolean() {} - -jclass java_lang_Boolean::getMyClass() const +jclass java_lang_Boolean::st_getMyClass() { // die Klasse muss nur einmal geholt werden, daher statisch if( !theClass ) - { theClass = findMyClass("java/lang/Boolean"); - } return theClass; } +jclass java_lang_Boolean::getMyClass() const +{ + return st_getMyClass(); +} + java_lang_Boolean::java_lang_Boolean( sal_Bool _par0 ): java_lang_Object( NULL, (jobject)NULL ) { SDBThreadAttach t; diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx index 8cea582940d3..e6209a90f236 100644 --- a/connectivity/source/drivers/jdbc/CallableStatement.cxx +++ b/connectivity/source/drivers/jdbc/CallableStatement.cxx @@ -227,9 +227,8 @@ void SAL_CALL java_sql_CallableStatement::registerOutParameter( sal_Int32 parame static jmethodID mID(NULL); obtainMethodId(t.pEnv, cMethodName,cSignature, mID); // Parameter konvertieren - jstring str = convertwchar_tToJavaString(t.pEnv,typeName); - t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str); - t.pEnv->DeleteLocalRef(str); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,typeName)); + t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str.get()); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); } } @@ -336,23 +335,22 @@ void java_sql_CallableStatement::createStatement(JNIEnv* /*_pEnv*/) // Java-Call absetzen jobject out = NULL; // Parameter konvertieren - jstring str = convertwchar_tToJavaString(t.pEnv,m_sSqlStatement); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,m_sSqlStatement)); static jmethodID mID(NULL); if ( !mID ) mID = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature ); if( mID ){ - out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str ,m_nResultSetType,m_nResultSetConcurrency); + out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str.get() ,m_nResultSetType,m_nResultSetConcurrency); } //mID else { static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/CallableStatement;"; static jmethodID mID2 = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,"Unknown method id!"); if( mID2 ){ - out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, str ); + out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, str.get() ); } //mID } - t.pEnv->DeleteLocalRef(str); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); if ( out ) diff --git a/connectivity/source/drivers/jdbc/Clob.cxx b/connectivity/source/drivers/jdbc/Clob.cxx index 632504448e06..ef64ca7b05e9 100644 --- a/connectivity/source/drivers/jdbc/Clob.cxx +++ b/connectivity/source/drivers/jdbc/Clob.cxx @@ -34,6 +34,8 @@ #include "java/tools.hxx" #include "java/io/Reader.hxx" #include <connectivity/dbexception.hxx> +#include <rtl/logfile.hxx> + using namespace connectivity; //************************************************************** //************ Class: java.sql.Clob @@ -61,6 +63,7 @@ jclass java_sql_Clob::getMyClass() const sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::length" ); jlong out(0); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); @@ -79,6 +82,7 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx ::rtl::OUString SAL_CALL java_sql_Clob::getSubString( sal_Int64 pos, sal_Int32 subStringLength ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::getSubString" ); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); ::rtl::OUString aStr; { @@ -98,6 +102,7 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Clob::getCharacterStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::getCharacterStream" ); SDBThreadAttach t; static jmethodID mID(NULL); jobject out = callObjectMethod(t.pEnv,"getCharacterStream","()Ljava/io/Reader;", mID); @@ -108,6 +113,7 @@ sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLEx sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sal_Int32 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::position" ); jlong out(0); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); @@ -130,6 +136,7 @@ sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sa sal_Int64 SAL_CALL java_sql_Clob::positionOfClob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& /*pattern*/, sal_Int64 /*start*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::positionOfClob" ); ::dbtools::throwFeatureNotImplementedException( "XClob::positionOfClob", *this ); // this was put here in CWS warnings01. The previous implementation was defective, as it did ignore // the pattern parameter. Since the effort for proper implementation is rather high - we would need diff --git a/connectivity/source/drivers/jdbc/InputStream.cxx b/connectivity/source/drivers/jdbc/InputStream.cxx index 522c1f67973e..dd2b0566b33f 100644 --- a/connectivity/source/drivers/jdbc/InputStream.cxx +++ b/connectivity/source/drivers/jdbc/InputStream.cxx @@ -84,8 +84,9 @@ void SAL_CALL java_io_InputStream::closeInput( ) throw(::com::sun::star::io::No // ----------------------------------------------------- sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException) { - if ( aData.getLength() < nBytesToRead ) - throw ::com::sun::star::io::BufferSizeExceededException(); + if (nBytesToRead < 0) + throw ::com::sun::star::io::BufferSizeExceededException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), *this ); + jint out(0); SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); @@ -102,7 +103,8 @@ sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequen if(out > 0) { jboolean p = sal_False; - memcpy(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out); + aData.realloc ( out ); + rtl_copyMemory(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out); } t.pEnv->DeleteLocalRef((jbyteArray)pByteArray); } //t.pEnv diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx index 96325511807f..9e967a65b85d 100644 --- a/connectivity/source/drivers/jdbc/JConnection.cxx +++ b/connectivity/source/drivers/jdbc/JConnection.cxx @@ -56,6 +56,7 @@ #include <rtl/ustrbuf.hxx> #include <jni.h> #include "resource/common_res.hrc" +#include <unotools/confignode.hxx> #include <list> #include <memory> @@ -553,10 +554,9 @@ Reference< XPreparedStatement > SAL_CALL java_sql_Connection::prepareCall( const static jmethodID mID(NULL); obtainMethodId(t.pEnv, cMethodName,cSignature, mID); // Parameter konvertieren - jstring str = convertwchar_tToJavaString(t.pEnv,sql); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,sql)); - jobject out = t.pEnv->CallObjectMethod( object, mID, str ); - t.pEnv->DeleteLocalRef(str); + jobject out = t.pEnv->CallObjectMethod( object, mID, str.get() ); aStr = JavaString2String(t.pEnv, (jstring)out ); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); } //t.pEnv @@ -767,7 +767,20 @@ void java_sql_Connection::loadDriverFromProperties( const ::rtl::OUString& _sDri enableAutoRetrievingEnabled( bAutoRetrievingEnabled ); setAutoRetrievingStatement( sGeneratedValueStatement ); } - +// ----------------------------------------------------------------------------- +::rtl::OUString java_sql_Connection::impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass) +{ + static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/JDBC/DriverClassPaths")); + ::utl::OConfigurationTreeRoot aNamesRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory( + m_pDriver->getContext().getLegacyServiceFactory(), s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY); + ::rtl::OUString sURL; + if ( aNamesRoot.isValid() && aNamesRoot.hasByName( _sDriverClass ) ) + { + ::utl::OConfigurationNode aRegisterObj = aNamesRoot.openNode( _sDriverClass ); + OSL_VERIFY( aRegisterObj.getNodeValue( "Path" ) >>= sURL ); + } + return sURL; +} // ----------------------------------------------------------------------------- sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyValue >& info) @@ -790,6 +803,8 @@ sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url, ::comphelper::NamedValueCollection aSettings( info ); sDriverClass = aSettings.getOrDefault( "JavaDriverClass", sDriverClass ); sDriverClassPath = aSettings.getOrDefault( "JavaDriverClassPath", sDriverClassPath); + if ( !sDriverClassPath.getLength() ) + sDriverClassPath = impl_getJavaDriverClassPath_nothrow(sDriverClass); bAutoRetrievingEnabled = aSettings.getOrDefault( "IsAutoRetrievingEnabled", bAutoRetrievingEnabled ); sGeneratedValueStatement = aSettings.getOrDefault( "AutoRetrievingStatement", sGeneratedValueStatement ); m_bParameterSubstitution = aSettings.getOrDefault( "ParameterNameSubstitution", m_bParameterSubstitution ); @@ -810,8 +825,8 @@ sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url, static const char * cSignature = "(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;"; static const char * cMethodName = "connect"; // Java-Call absetzen - jmethodID mID = NULL; - if ( !mID )
+ static jmethodID mID = NULL; + if ( !mID ) mID = t.pEnv->GetMethodID( m_Driver_theClass, cMethodName, cSignature ); if ( mID ) { diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx index 6f4e78550dc0..73829b46ec64 100644 --- a/connectivity/source/drivers/jdbc/Object.cxx +++ b/connectivity/source/drivers/jdbc/Object.cxx @@ -43,7 +43,7 @@ #include <vos/mutex.hxx> #include <osl/thread.h> #include <com/sun/star/uno/Sequence.hxx> - +#include "java/LocalRef.hxx" #include "resource/jdbc_log.hrc" #include <rtl/logfile.hxx> #include <comphelper/logging.hxx> @@ -395,10 +395,9 @@ void java_lang_Object::callVoidMethodWithStringArg( const char* _pMethodName, jm OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" ); obtainMethodId(t.pEnv, _pMethodName,"(Ljava/lang/String;)V", _inout_MethodID); - jstring str = convertwchar_tToJavaString(t.pEnv,_nArgument); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument)); // call method - t.pEnv->CallVoidMethod( object, _inout_MethodID , str); - t.pEnv->DeleteLocalRef(str); + t.pEnv->CallVoidMethod( object, _inout_MethodID , str.get()); ThrowSQLException( t.pEnv, NULL ); } // ------------------------------------------------------------------------- @@ -417,10 +416,9 @@ sal_Int32 java_lang_Object::callIntMethodWithStringArg( const char* _pMethodName // *this // ); - jstring str = convertwchar_tToJavaString(t.pEnv,_nArgument); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument)); // call method - jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str); - t.pEnv->DeleteLocalRef(str); + jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str.get()); ThrowSQLException( t.pEnv, NULL ); return (sal_Int32)out; } diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx index dbf7241885da..ae43b40b3a0b 100644 --- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx +++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx @@ -45,7 +45,7 @@ #include "resource/jdbc_log.hrc" #include "resource/common_res.hrc" #include "resource/sharedresources.hxx" - +#include "java/LocalRef.hxx" #include <string.h> using namespace connectivity; @@ -138,10 +138,9 @@ void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, c // Java-Call absetzen static jmethodID mID(NULL); obtainMethodId(t.pEnv, cMethodName,cSignature, mID); - jstring str = convertwchar_tToJavaString(t.pEnv,x); - t.pEnv->CallVoidMethod( object, mID, parameterIndex,str); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x)); + t.pEnv->CallVoidMethod( object, mID, parameterIndex,str.get()); // und aufraeumen - t.pEnv->DeleteLocalRef(str); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); } //t.pEnv } diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx index 677985ac6a90..df90a68799bc 100644 --- a/connectivity/source/drivers/jdbc/ResultSet.cxx +++ b/connectivity/source/drivers/jdbc/ResultSet.cxx @@ -30,10 +30,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_connectivity.hxx" +#include "java/lang/String.hxx" +#include "java/lang/Boolean.hxx" #include "java/sql/ResultSet.hxx" #include "java/math/BigDecimal.hxx" #include "java/sql/JStatement.hxx" #include "java/sql/SQLWarning.hxx" +#include "java/sql/Timestamp.hxx" #include "java/sql/Array.hxx" #include "java/sql/Ref.hxx" #include "java/sql/Clob.hxx" @@ -54,6 +57,7 @@ #include "connectivity/dbexception.hxx" #include "resource/common_res.hrc" #include "resource/sharedresources.hxx" +#include "java/LocalRef.hxx" #include <rtl/logfile.hxx> #include <string.h> @@ -324,6 +328,7 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getObject" ); jobject out(0); + Any aRet; SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!"); { jvalue args[2]; @@ -341,15 +346,43 @@ Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Referen obtainMethodId(t.pEnv, cMethodName,cSignature, mID); } - out = t.pEnv->CallObjectMethodA( object, mID, args); - t.pEnv->DeleteLocalRef((jstring)args[1].l); - ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); - // und aufraeumen - + out = t.pEnv->CallObjectMethodA( object, mID, args); + t.pEnv->DeleteLocalRef((jstring)args[1].l); + ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); + // und aufraeumen + if ( out ) + { + if ( t.pEnv->IsInstanceOf(out,java_lang_String::st_getMyClass()) ) + { + java_lang_String aVal(t.pEnv,out); + aRet <<= (::rtl::OUString)aVal; + } + else if ( t.pEnv->IsInstanceOf(out,java_lang_Boolean::st_getMyClass()) ) + { + java_lang_Boolean aVal(t.pEnv,out); + static jmethodID methodID = NULL; + aRet <<= aVal.callBooleanMethod("booleanValue",methodID); + } + else if ( t.pEnv->IsInstanceOf(out,java_sql_Date::st_getMyClass()) ) + { + java_sql_Date aVal(t.pEnv,out); + aRet <<= (::com::sun::star::util::Date)aVal; + } + else if ( t.pEnv->IsInstanceOf(out,java_sql_Time::st_getMyClass()) ) + { + java_sql_Time aVal(t.pEnv,out); + aRet <<= (::com::sun::star::util::Time)aVal; + } + else if ( t.pEnv->IsInstanceOf(out,java_sql_Timestamp::st_getMyClass()) ) + { + java_sql_Timestamp aVal(t.pEnv,out); + aRet <<= (::com::sun::star::util::DateTime)aVal; + } + else + t.pEnv->DeleteLocalRef(out); + } } //t.pEnv - // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!! - ::dbtools::throwFunctionNotSupportedException( "XRow::getObject", *this ); - return out==0 ? Any() : Any();//new java_lang_Object( t.pEnv, out ); + return aRet; } // ------------------------------------------------------------------------- @@ -689,9 +722,8 @@ void SAL_CALL java_sql_ResultSet::updateString( sal_Int32 columnIndex, const ::r { // Parameter konvertieren - jstring str = convertwchar_tToJavaString(t.pEnv,x); - t.pEnv->CallVoidMethod( object, mID,columnIndex,str); - t.pEnv->DeleteLocalRef(str); + jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x)); + t.pEnv->CallVoidMethod( object, mID,columnIndex,str.get()); ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); } } @@ -754,16 +786,68 @@ void SAL_CALL java_sql_ResultSet::updateTimestamp( sal_Int32 columnIndex, const } // ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 /*columnIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBinaryStream" ); - ::dbtools::throwFeatureNotImplementedException( "XParameters::updateBinaryStream", *this ); + try + { + SDBThreadAttach t; + { + + // temporaere Variable initialisieren + // Java-Call absetzen + static jmethodID mID(NULL); + if ( !mID ) + { + static const char * cSignature = "(ILjava/io/InputStream;I)V"; + static const char * cMethodName = "updateBinaryStream"; + obtainMethodId(t.pEnv, cMethodName,cSignature, mID); + } + + { + // Parameter konvertieren + jobject obj = createByteInputStream(x,length); + t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length); + ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); + } + } + } + catch(Exception) + { + ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateBinaryStream", *this ); + } } // ------------------------------------------------------------------------- -void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 /*columnIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) +void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateCharacterStream" ); - ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this ); + try + { + SDBThreadAttach t; + { + + // temporaere Variable initialisieren + // Java-Call absetzen + static jmethodID mID(NULL); + if ( !mID ) + { + static const char * cSignature = "(ILjava/io/Reader;I)V"; + static const char * cMethodName = "updateCharacterStream"; + obtainMethodId(t.pEnv, cMethodName,cSignature, mID); + } + + { + // Parameter konvertieren + jobject obj = createCharArrayReader(x,length); + t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length); + ThrowLoggedSQLException( m_aLogger, t.pEnv, *this ); + } + } + } + catch(Exception) + { + ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this ); + } } // ------------------------------------------------------------------------- void SAL_CALL java_sql_ResultSet::updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx index 8c30f7a14efc..065ffe11d3e7 100644 --- a/connectivity/source/drivers/jdbc/Timestamp.cxx +++ b/connectivity/source/drivers/jdbc/Timestamp.cxx @@ -71,6 +71,10 @@ java_sql_Date::~java_sql_Date() jclass java_sql_Date::getMyClass() const { + return st_getMyClass(); +} +jclass java_sql_Date::st_getMyClass() +{ // die Klasse muss nur einmal geholt werden, daher statisch if( !theClass ) theClass = findMyClass("java/sql/Date"); @@ -94,12 +98,15 @@ java_sql_Time::~java_sql_Time() jclass java_sql_Time::getMyClass() const { + return st_getMyClass(); +} +jclass java_sql_Time::st_getMyClass() +{ // die Klasse muss nur einmal geholt werden, daher statisch if( !theClass ) theClass = findMyClass("java/sql/Time"); return theClass; } - java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_util_Date( NULL, (jobject)NULL ) { SDBThreadAttach t; @@ -140,12 +147,15 @@ java_sql_Timestamp::~java_sql_Timestamp() jclass java_sql_Timestamp::getMyClass() const { + return st_getMyClass(); +} +jclass java_sql_Timestamp::st_getMyClass() +{ // die Klasse muss nur einmal geholt werden, daher statisch if( !theClass ) theClass = findMyClass("java/sql/Timestamp"); return theClass; } - java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _rOut) :java_util_Date( NULL, (jobject)NULL ) { diff --git a/connectivity/source/drivers/jdbc/jdbc.xcu b/connectivity/source/drivers/jdbc/jdbc.xcu index ae1bbad227e7..f5ac8f20db5c 100755 --- a/connectivity/source/drivers/jdbc/jdbc.xcu +++ b/connectivity/source/drivers/jdbc/jdbc.xcu @@ -145,6 +145,11 @@ <value>true</value> </prop> </node> + <node oor:name="PrimaryKeySupport" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> <node oor:name="MetaData"> <node oor:name="SupportsTableCreation" oor:op="replace"> diff --git a/connectivity/source/drivers/jdbc/makefile.mk b/connectivity/source/drivers/jdbc/makefile.mk index 831a6755af91..fb37a3077743 100644 --- a/connectivity/source/drivers/jdbc/makefile.mk +++ b/connectivity/source/drivers/jdbc/makefile.mk @@ -95,6 +95,7 @@ SHL1STDLIBS=\ $(SALLIB) \ $(JVMACCESSLIB) \ $(DBTOOLSLIB) \ + $(UNOTOOLSLIB) \ $(JVMFWKLIB) \ $(COMPHELPERLIB) diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx index daaed46acdd9..f77c45d66fc8 100644 --- a/connectivity/source/drivers/jdbc/tools.cxx +++ b/connectivity/source/drivers/jdbc/tools.cxx @@ -218,5 +218,58 @@ sal_Bool connectivity::isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear) return bRet; } - - +// ----------------------------------------------------------------------------- +jobject connectivity::createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length) +{ + SDBThreadAttach t; + if( !t.pEnv || !x.is() ) + return NULL; + // Java-Call fuer den Konstruktor absetzen + // temporaere Variable initialisieren + jclass clazz = java_lang_Object::findMyClass("java/io/ByteArrayInputStream"); + static jmethodID mID(NULL); + if ( !mID ) + { + static const char * cSignature = "([B)V"; + mID = t.pEnv->GetMethodID( clazz, "<init>", cSignature ); + OSL_ENSURE( mID, cSignature ); + if ( !mID ) + throw SQLException(); + } // if ( !_inout_MethodID ) + jbyteArray pByteArray = t.pEnv->NewByteArray(length); + Sequence< sal_Int8 > aData; + x->readBytes(aData,length); + jboolean p = sal_False; + rtl_copyMemory(t.pEnv->GetByteArrayElements(pByteArray,&p),aData.getArray(),aData.getLength()); + jobject out = t.pEnv->NewObject( clazz, mID,pByteArray); + t.pEnv->DeleteLocalRef((jbyteArray)pByteArray); + return out; +} +// ----------------------------------------------------------------------------- +jobject connectivity::createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length) +{ + SDBThreadAttach t; + if( !t.pEnv || !x.is() ) + return NULL; + // Java-Call fuer den Konstruktor absetzen + // temporaere Variable initialisieren + jclass clazz = java_lang_Object::findMyClass("java/io/CharArrayReader"); + static jmethodID mID(NULL); + if ( !mID ) + { + static const char * cSignature = "([C)V"; + mID = t.pEnv->GetMethodID( clazz, "<init>", cSignature ); + OSL_ENSURE( mID, cSignature ); + if ( !mID ) + throw SQLException(); + } // if ( !_inout_MethodID ) + jcharArray pCharArray = t.pEnv->NewCharArray(length); + Sequence< sal_Int8 > aData; + x->readBytes(aData,length); + jboolean p = sal_False; + rtl_copyMemory(t.pEnv->GetCharArrayElements(pCharArray,&p),aData.getArray(),aData.getLength()); + jobject out = t.pEnv->NewObject( clazz, mID,pCharArray); + t.pEnv->DeleteLocalRef((jcharArray)pCharArray); + return out; +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/odbc/odbc.xcu b/connectivity/source/drivers/odbc/odbc.xcu index cf306f10d57f..b3a9d7149650 100755 --- a/connectivity/source/drivers/odbc/odbc.xcu +++ b/connectivity/source/drivers/odbc/odbc.xcu @@ -150,6 +150,11 @@ <value>true</value> </prop> </node> + <node oor:name="PrimaryKeySupport" oor:op="replace"> + <prop oor:name="Value" oor:type="xs:boolean"> + <value>true</value> + </prop> + </node> </node> <node oor:name="MetaData"> <node oor:name="SupportsTableCreation" oor:op="replace"> diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx index b92206199c24..f923987cc04e 100644 --- a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx +++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx @@ -921,6 +921,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARCHAR,nValue,*this); break; case DataType::LONGVARCHAR: + case DataType::CLOB: OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARCHAR,nValue,*this); break; case DataType::DATE: @@ -939,6 +940,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARBINARY,nValue,*this); break; case DataType::LONGVARBINARY: + case DataType::BLOB: OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARBINARY,nValue,*this); break; case DataType::SQLNULL: @@ -959,12 +961,6 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In case DataType::ARRAY: // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); break; - case DataType::BLOB: - // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); - break; - case DataType::CLOB: - // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); - break; case DataType::REF: // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this); break; @@ -1009,6 +1005,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In bConvert = (nValue & SQL_CVT_VARCHAR) == SQL_CVT_VARCHAR; break; case DataType::LONGVARCHAR: + case DataType::CLOB: bConvert = (nValue & SQL_CVT_LONGVARCHAR) == SQL_CVT_LONGVARCHAR; break; case DataType::DATE: @@ -1027,6 +1024,7 @@ sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_In bConvert = (nValue & SQL_CVT_VARBINARY) == SQL_CVT_VARBINARY; break; case DataType::LONGVARBINARY: + case DataType::BLOB: bConvert = (nValue & SQL_CVT_LONGVARBINARY) == SQL_CVT_LONGVARBINARY; break; } diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx index 77ecceeaacdf..d084561f9372 100644 --- a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx @@ -283,7 +283,7 @@ Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 co aDate.day = 0; aDate.month = 0; aDate.year = 0; - OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_DATE,m_bWasNull,**this,&aDate,sizeof aDate); + OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_DATE : SQL_C_TYPE_DATE,m_bWasNull,**this,&aDate,sizeof aDate); return Date(aDate.day,aDate.month,aDate.year); } else @@ -434,7 +434,7 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) columnIndex = mapColumn(columnIndex); ::rtl::OUString aVal; if(columnIndex <= m_nDriverColumnCount) - aVal = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,(SWORD)SQL_C_WCHAR,m_bWasNull,**this,m_nTextEncoding); + aVal = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,impl_getColumnType_nothrow(columnIndex),m_bWasNull,**this,m_nTextEncoding); else m_bWasNull = sal_True; @@ -454,7 +454,7 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) columnIndex = mapColumn(columnIndex); TIME_STRUCT aTime={0,0,0}; if(columnIndex <= m_nDriverColumnCount) - OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_TIME,m_bWasNull,**this,&aTime,sizeof aTime); + OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME,m_bWasNull,**this,&aTime,sizeof aTime); else m_bWasNull = sal_True; return Time(0,aTime.second,aTime.minute,aTime.hour); @@ -472,7 +472,7 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) columnIndex = mapColumn(columnIndex); TIMESTAMP_STRUCT aTime={0,0,0,0,0,0,0}; if(columnIndex <= m_nDriverColumnCount) - OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_TIMESTAMP,m_bWasNull,**this,&aTime,sizeof aTime); + OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP,m_bWasNull,**this,&aTime,sizeof aTime); else m_bWasNull = sal_True; return DateTime((sal_uInt16)aTime.fraction*1000,aTime.second,aTime.minute,aTime.hour,aTime.day,aTime.month,aTime.year); @@ -1316,5 +1316,11 @@ void ODatabaseMetaDataResultSet::checkColumnCount() } // ----------------------------------------------------------------------------- - +SWORD ODatabaseMetaDataResultSet::impl_getColumnType_nothrow(sal_Int32 columnIndex) +{ + ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex); + if ( aFind == m_aODBCColumnTypes.end() ) + aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pConnection,m_aStatementHandle,*this,columnIndex))).first; + return aFind->second; +} diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx index 8d72c3271b82..03d9912e4e22 100644 --- a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx @@ -321,16 +321,6 @@ void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool setInt (parameterIndex, value); } // ------------------------------------------------------------------------- -#define PREP_BIND_PARAM(_ty,_jt) \ - OTools::bindParameter(m_pConnection, \ - m_aStatementHandle, \ - parameterIndex, \ - bindBuf, \ - getLengthBuf(parameterIndex), \ - (SWORD)_jt, \ - sal_False,m_pConnection->useOldDateFormat(),_pData,(Reference <XInterface>)*this,getOwnConnection()->getTextEncoding()) - - void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,sal_Int32 _nSize,void* _pData) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -353,6 +343,10 @@ void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType, case SQL_NUMERIC: ++nRealSize; break; + case SQL_BINARY: + case SQL_VARBINARY: + nRealSize=1; //dummy buffer, binary data isn't copied + break; default: break; } @@ -480,15 +474,17 @@ void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 s } // ------------------------------------------------------------------------- -void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException) { - ::dbtools::throwFunctionNotSupportedException( "XParameters::setClob", *this ); + if ( x.is() ) + setStream(parameterIndex, x->getCharacterStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR); } // ------------------------------------------------------------------------- -void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException) +void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException) { - ::dbtools::throwFunctionNotSupportedException( "XParameters::setBlob", *this ); + if ( x.is() ) + setStream(parameterIndex, x->getBinaryStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR); } // ------------------------------------------------------------------------- @@ -503,7 +499,12 @@ void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Re ::dbtools::throwFunctionNotSupportedException( "XParameters::setRef", *this ); } // ------------------------------------------------------------------------- - +void OPreparedStatement::setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x ) +{ + ::rtl::OString aString(::rtl::OUStringToOString(x,getOwnConnection()->getTextEncoding())); + setParameter(parameterIndex,DataType::DECIMAL,aString.getLength(),(void*)&x); +} +// ------------------------------------------------------------------------- void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException) { checkDisposed(OStatement_BASE::rBHelper.bDisposed); @@ -528,6 +529,12 @@ void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, c setNull(parameterIndex,sqlType); break; case DataType::DECIMAL: + { + ORowSetValue aValue; + aValue.fill(x); + setDecimal(parameterIndex,aValue); + } + break; case DataType::NUMERIC: { ORowSetValue aValue; @@ -568,19 +575,20 @@ void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException) { setParameter(parameterIndex,DataType::BINARY,x.getLength(),(void*)&x); + boundParams[parameterIndex-1].setSequence(x); // this assures that the sequence stays alive } // ------------------------------------------------------------------------- void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - setStream (parameterIndex, x, length, DataType::LONGVARCHAR); + setStream(parameterIndex, x, length, DataType::LONGVARCHAR); } // ------------------------------------------------------------------------- void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException) { - setStream (parameterIndex, x, length, DataType::LONGVARBINARY); + setStream(parameterIndex, x, length, DataType::LONGVARBINARY); } // ------------------------------------------------------------------------- @@ -839,10 +847,10 @@ sal_Int32 OPreparedStatement::getPrecision ( sal_Int32 sqlType) // Sets an input stream as a parameter, using the given SQL type //-------------------------------------------------------------------- -void OPreparedStatement::setStream ( +void OPreparedStatement::setStream( sal_Int32 ParameterIndex, const Reference< XInputStream>& x, - sal_Int32 length, + SQLLEN length, sal_Int32 SQLtype) throw(SQLException) { diff --git a/connectivity/source/drivers/odbcbase/OResultSet.cxx b/connectivity/source/drivers/odbcbase/OResultSet.cxx index 8c885f0924ad..fb1a08147338 100644 --- a/connectivity/source/drivers/odbcbase/OResultSet.cxx +++ b/connectivity/source/drivers/odbcbase/OResultSet.cxx @@ -223,9 +223,11 @@ SQLRETURN OResultSet::unbind(sal_Bool _bUnbindHandle) delete static_cast< double* >(reinterpret_cast< void * >(pValue->first)); break; case DataType::LONGVARCHAR: + case DataType::CLOB: delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first)); break; case DataType::LONGVARBINARY: + case DataType::BLOB: delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first)); break; case DataType::DATE: @@ -284,9 +286,11 @@ TVoidPtr OResultSet::allocBindColumn(sal_Int32 _nType,sal_Int32 _nColumnIndex) aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new double(0.0)),_nType); break; case DataType::LONGVARCHAR: + case DataType::CLOB: aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType); // dient nur zum auffinden break; case DataType::LONGVARBINARY: + case DataType::BLOB: aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType); // dient nur zum auffinden break; case DataType::DATE: @@ -1499,6 +1503,7 @@ void OResultSet::fillRow(sal_Int32 _nToColumn) case DataType::DECIMAL: case DataType::NUMERIC: case DataType::LONGVARCHAR: + case DataType::CLOB: { ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(nColumn); if ( aFind == m_aODBCColumnTypes.end() ) @@ -1514,6 +1519,7 @@ void OResultSet::fillRow(sal_Int32 _nToColumn) *pColumn = getDouble(nColumn); break; case DataType::LONGVARBINARY: + case DataType::BLOB: *pColumn = getBytes(nColumn); break; case DataType::DATE: @@ -1719,6 +1725,7 @@ void OResultSet::fillNeededData(SQLRETURN _nRet) case DataType::BINARY: case DataType::VARBINARY: case DataType::LONGVARBINARY: + case DataType::BLOB: aSeq = m_aRow[nColumnIndex]; N3SQLPutData (m_aStatementHandle, aSeq.getArray(), aSeq.getLength()); break; @@ -1730,6 +1737,7 @@ void OResultSet::fillNeededData(SQLRETURN _nRet) break; } case DataType::LONGVARCHAR: + case DataType::CLOB: { ::rtl::OUString sRet; sRet = m_aRow[nColumnIndex].getString(); diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx index 39c848f34eaf..daa6d28a0acf 100644 --- a/connectivity/source/drivers/odbcbase/OTools.cxx +++ b/connectivity/source/drivers/odbcbase/OTools.cxx @@ -135,6 +135,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType, { case SQL_CHAR: case SQL_VARCHAR: + case SQL_DECIMAL: if(_bUseWChar) { *pLen = SQL_NTS; @@ -160,7 +161,7 @@ void OTools::bindData( SQLSMALLINT _nOdbcType, *pLen = sizeof(sal_Int64); _nColumnSize = *pLen; break; - case SQL_DECIMAL: + case SQL_NUMERIC: if(_bUseWChar) { @@ -210,12 +211,9 @@ void OTools::bindData( SQLSMALLINT _nOdbcType, if(pSeq) { - // memcpy(_pData,pSeq->getConstArray(),pSeq->getLength()); - _pData = (sal_Int8*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); + _pData = (sal_Int8*)pSeq->getConstArray(); *pLen = pSeq->getLength(); } - // _pData = (sal_Int8*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray(); - // *pLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength(); } break; case SQL_LONGVARBINARY: diff --git a/connectivity/source/inc/ado/Aolevariant.hxx b/connectivity/source/inc/ado/Aolevariant.hxx index f15d78a37ed9..c9fd9807af41 100644 --- a/connectivity/source/inc/ado/Aolevariant.hxx +++ b/connectivity/source/inc/ado/Aolevariant.hxx @@ -161,6 +161,7 @@ namespace connectivity double getDate() const; CY getCurrency() const; SAFEARRAY* getUI1SAFEARRAYPtr() const; + ::com::sun::star::uno::Any makeAny() const; static VARIANT_BOOL VariantBool(sal_Bool bEinBoolean); diff --git a/connectivity/source/inc/java/lang/Boolean.hxx b/connectivity/source/inc/java/lang/Boolean.hxx index 2f33ea27bc11..7cfd1bbc4aa1 100644 --- a/connectivity/source/inc/java/lang/Boolean.hxx +++ b/connectivity/source/inc/java/lang/Boolean.hxx @@ -48,6 +48,7 @@ namespace connectivity java_lang_Boolean( JNIEnv * pEnv, jobject myObj ) : java_lang_Object( pEnv, myObj ){} java_lang_Boolean( sal_Bool _par0 ); + static jclass st_getMyClass(); }; } diff --git a/connectivity/source/inc/java/sql/Connection.hxx b/connectivity/source/inc/java/sql/Connection.hxx index 74d76d32f35a..41c18848021f 100644 --- a/connectivity/source/inc/java/sql/Connection.hxx +++ b/connectivity/source/inc/java/sql/Connection.hxx @@ -80,6 +80,11 @@ namespace connectivity const ::rtl::OUString& _sDriverClassPath, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _rSystemProperties ); + /** load driver class path from system configuration. + @param _sDriverClass + The driver class name to look for in the configuration. + */ + ::rtl::OUString impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass); protected: // statische Daten fuer die Klasse diff --git a/connectivity/source/inc/java/sql/Timestamp.hxx b/connectivity/source/inc/java/sql/Timestamp.hxx index ce6de39b5bb9..2d234e1b52a1 100644 --- a/connectivity/source/inc/java/sql/Timestamp.hxx +++ b/connectivity/source/inc/java/sql/Timestamp.hxx @@ -54,6 +54,7 @@ namespace connectivity java_sql_Date( const ::com::sun::star::util::Date& _rOut ); operator ::com::sun::star::util::Date(); + static jclass st_getMyClass(); }; @@ -73,6 +74,7 @@ namespace connectivity java_sql_Time( JNIEnv * pEnv, jobject myObj ) : java_util_Date( pEnv, myObj ){} java_sql_Time( const ::com::sun::star::util::Time& _rOut ); operator ::com::sun::star::util::Time(); + static jclass st_getMyClass(); }; //************************************************************** @@ -93,6 +95,7 @@ namespace connectivity sal_Int32 getNanos(); void setNanos(sal_Int32 n); + static jclass st_getMyClass(); }; } #endif // _CONNECTIVITY_JAVA_SQL_TIMESTAMP_HXX_ diff --git a/connectivity/source/inc/java/tools.hxx b/connectivity/source/inc/java/tools.hxx index af061d5599b7..a74865817ddb 100644 --- a/connectivity/source/inc/java/tools.hxx +++ b/connectivity/source/inc/java/tools.hxx @@ -41,6 +41,7 @@ #include <comphelper/uno3.hxx> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/util/Time.hpp> #include <com/sun/star/util/Date.hpp> #include <com/sun/star/util/DateTime.hpp> @@ -85,6 +86,9 @@ namespace connectivity <TRUE/> if an exception is occured */ sal_Bool isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear); + + jobject createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length); + jobject createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length); } #endif // _CONNECTIVITY_JAVA_TOOLS_HXX_ diff --git a/connectivity/source/inc/odbc/OBoundParam.hxx b/connectivity/source/inc/odbc/OBoundParam.hxx index c71977a94910..bc896c2361d8 100644 --- a/connectivity/source/inc/odbc/OBoundParam.hxx +++ b/connectivity/source/inc/odbc/OBoundParam.hxx @@ -119,6 +119,11 @@ namespace connectivity paramInputStreamLen = len; } + void setSequence(const ::com::sun::star::uno::Sequence< sal_Int8 >& _aSequence) + { + aSequence = _aSequence; + } + //-------------------------------------------------------------------- // getInputStream // Gets the input stream for the bound parameter @@ -191,6 +196,7 @@ namespace connectivity // data is in native format. ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> paramInputStream; + ::com::sun::star::uno::Sequence< sal_Int8 > aSequence; // When an input stream is // bound to a parameter, the // input stream is saved diff --git a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx index 6248417828ba..46b5a020d1d0 100644 --- a/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx +++ b/connectivity/source/inc/odbc/ODatabaseMetaDataResultSet.hxx @@ -100,6 +100,7 @@ namespace connectivity sal_Int32 getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); sal_Int32 getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); ::rtl::OUString getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + SWORD impl_getColumnType_nothrow(sal_Int32 column); sal_Int32 mapColumn (sal_Int32 column); diff --git a/connectivity/source/inc/odbc/OPreparedStatement.hxx b/connectivity/source/inc/odbc/OPreparedStatement.hxx index 9e6f6ca8a61f..d167c9edb9a0 100644 --- a/connectivity/source/inc/odbc/OPreparedStatement.hxx +++ b/connectivity/source/inc/odbc/OPreparedStatement.hxx @@ -89,7 +89,7 @@ namespace connectivity void FreeParams(); void putParamData (sal_Int32 index) throw(::com::sun::star::sdbc::SQLException); void setStream (sal_Int32 ParameterIndex,const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream>& x, - sal_Int32 length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException); + SQLLEN length,sal_Int32 SQLtype) throw(::com::sun::star::sdbc::SQLException); sal_Int32 getParamLength ( sal_Int32 index); sal_Int8* getLengthBuf (sal_Int32 index); sal_Int8* getDataBuf (sal_Int32 index); @@ -102,6 +102,7 @@ namespace connectivity sal_Bool isPrepared() const { return m_bPrepared;} void prepareStatement(); void checkParameterIndex(sal_Int32 _parameterIndex); + void setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x ); /** creates the driver specific resultset (factory) diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 97875dfd4de0..1680516e8dc0 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -107,7 +107,6 @@ static connectivity::OSQLInternalNode* newNode(const sal_Char* pNewValue, const connectivity::SQLNodeType eNodeType, const sal_uInt32 nNodeID = 0) { - OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID); return new connectivity::OSQLInternalNode(pNewValue, eNodeType, nNodeID); } @@ -115,7 +114,6 @@ static connectivity::OSQLInternalNode* newNode(const ::rtl::OString& _NewValue, const connectivity::SQLNodeType eNodeType, const sal_uInt32 nNodeID = 0) { - OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID); return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID); } @@ -123,7 +121,6 @@ static connectivity::OSQLInternalNode* newNode(const ::rtl::OUString& _NewValue, const connectivity::SQLNodeType eNodeType, const sal_uInt32 nNodeID = 0) { - OSL_TRACE("connectivity: Rule Number: %d,%d",eNodeType,nNodeID); return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID); } @@ -2043,7 +2040,8 @@ join_spec: | named_columns_join ; join_type: - SQL_TOKEN_INNER + /* empty */ {$$ = SQL_NEW_RULE;} + | SQL_TOKEN_INNER { $$ = SQL_NEW_RULE; $$->append($1); diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index 26086495be89..54ab874f70e1 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -952,21 +952,7 @@ bool OSQLParseTreeIterator::traverseSelectColumnNames(const OSQLParseNode* pSele if ( pColumnRef->isRule() ) { bFkt = sal_True; - if ( SQL_ISRULE(pColumnRef,num_value_exp) || SQL_ISRULE(pColumnRef,term) || SQL_ISRULE(pColumnRef,factor) ) - { - nType = DataType::DOUBLE; - } - else - { - ::rtl::OUString sFunctionName; - if ( SQL_ISRULE(pColumnRef,length_exp) ) - pColumnRef->getChild(0)->getChild(0)->parseNodeToStr( - sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); - else - pColumnRef->getChild(0)->parseNodeToStr( - sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); - nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() ); - } + nType = getFunctionReturnType(pColumnRef); } } /* @@ -1601,7 +1587,6 @@ void OSQLParseTreeIterator::impl_traverse( sal_uInt32 _nIncludeMask ) case SQL_STATEMENT_INSERT: break; default: - OSL_ENSURE( false, "OSQLParseTreeIterator::traverseAll: not yet implemented for this statement type!" ); break; } } @@ -2104,3 +2089,84 @@ void OSQLParseTreeIterator::impl_appendError( const SQLException& _rError ) m_aErrors = _rError; } // ----------------------------------------------------------------------------- +sal_Int32 OSQLParseTreeIterator::getFunctionReturnType(const OSQLParseNode* _pNode ) +{ + sal_Int32 nType = DataType::OTHER; + ::rtl::OUString sFunctionName; + if ( SQL_ISRULE(_pNode,length_exp) ) + { + _pNode->getChild(0)->getChild(0)->parseNodeToStr(sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() ); + } + else if ( SQL_ISRULE(_pNode,num_value_exp) || SQL_ISRULE(_pNode,term) || SQL_ISRULE(_pNode,factor) ) + { + nType = DataType::DOUBLE; + } + else + { + _pNode->getChild(0)->parseNodeToStr(sFunctionName, m_pImpl->m_xConnection, NULL, sal_False, sal_False ); + + // MIN and MAX have another return type, we have to check the expression itself. + // @see http://qa.openoffice.org/issues/show_bug.cgi?id=99566 + if ( SQL_ISRULE(_pNode,general_set_fct) && (SQL_ISTOKEN(_pNode->getChild(0),MIN) || SQL_ISTOKEN(_pNode->getChild(0),MAX) )) + { + const OSQLParseNode* pValueExp = _pNode->getChild(3); + if (SQL_ISRULE(pValueExp,column_ref)) + { + ::rtl::OUString sColumnName; + ::rtl::OUString aTableRange; + getColumnRange(pValueExp,sColumnName,aTableRange); + OSL_ENSURE(sColumnName.getLength(),"Columnname darf nicht leer sein"); + Reference<XPropertySet> xColumn = findColumn( sColumnName, aTableRange, true ); + + if ( xColumn.is() ) + { + xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_TYPE)) >>= nType; + } + } + else + { + if ( SQL_ISRULE(pValueExp,num_value_exp) || SQL_ISRULE(pValueExp,term) || SQL_ISRULE(pValueExp,factor) ) + { + nType = DataType::DOUBLE; + } + else if ( SQL_ISRULE(pValueExp,datetime_primary) ) + { + switch(pValueExp->getChild(0)->getTokenID() ) + { + case SQL_TOKEN_CURRENT_DATE: + nType = DataType::DATE; + break; + case SQL_TOKEN_CURRENT_TIME: + nType = DataType::TIME; + break; + case SQL_TOKEN_CURRENT_TIMESTAMP: + nType = DataType::TIMESTAMP; + break; + } + } + else if ( SQL_ISRULE(pValueExp,value_exp_primary) ) + { + nType = getFunctionReturnType(pValueExp->getChild(1)); + } + else if ( SQL_ISRULE(pValueExp,concatenation) + || SQL_ISRULE(pValueExp,char_factor) + || SQL_ISRULE(pValueExp,bit_value_fct) + || SQL_ISRULE(pValueExp,char_value_fct) + || SQL_ISRULE(pValueExp,char_substring_fct) + || SQL_ISRULE(pValueExp,fold) + || SQL_ISTOKEN(pValueExp,STRING) ) + { + nType = DataType::VARCHAR; + } + } + if ( nType == DataType::OTHER ) + nType = DataType::DOUBLE; + } + else + nType = ::connectivity::OSQLParser::getFunctionReturnType( sFunctionName, &m_rParser.getContext() ); + } + + return nType; +} + diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 8d869c2dea0a..c76dd44e3d18 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -813,8 +813,9 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - if ( !SQL_ISRULE(pReturn,char_value_exp) && !buildStringNodes(pReturn) ) - pReturn = NULL; + case DataType::CLOB: + if ( !SQL_ISRULE(pReturn,char_value_exp) && !buildStringNodes(pReturn) ) + pReturn = NULL; default: break; } @@ -829,6 +830,7 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: break; case DataType::DATE: case DataType::TIME: @@ -872,12 +874,13 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::REAL: case DataType::DOUBLE: // kill thousand seperators if any - killThousandSeparator(pReturn); + killThousandSeparator(pReturn); break; case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - pReturn = buildNode_STR_NUM(pReturn); + case DataType::CLOB: + pReturn = buildNode_STR_NUM(pReturn); break; default: m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_INT_COMPARE); @@ -893,12 +896,13 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType,OSQLParseNode*& pLiteral) case DataType::REAL: case DataType::DOUBLE: // kill thousand seperators if any - killThousandSeparator(pReturn); + killThousandSeparator(pReturn); break; case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: - pReturn = buildNode_STR_NUM(pReturn); + case DataType::CLOB: + pReturn = buildNode_STR_NUM(pReturn); break; case DataType::INTEGER: default: @@ -967,6 +971,7 @@ sal_Int16 OSQLParser::buildLikeRule(OSQLParseNode*& pAppend, OSQLParseNode*& pLi case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: if(pLiteral->isRule()) { pAppend->append(pLiteral); @@ -1228,6 +1233,7 @@ OSQLParseNode* OSQLParser::predicateTree(::rtl::OUString& rErrorMessage, const : case DataType::CHAR: case DataType::VARCHAR: case DataType::LONGVARCHAR: + case DataType::CLOB: s_pScanner->SetRule(s_pScanner->GetSTRINGRule()); break; default: @@ -1415,7 +1421,11 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: { OSQLParseNode::table_node, "table_node" }, { OSQLParseNode::as, "as" }, { OSQLParseNode::op_column_commalist, "op_column_commalist" }, - { OSQLParseNode::table_primary_as_range_column, "table_primary_as_range_column" } + { OSQLParseNode::table_primary_as_range_column, "table_primary_as_range_column" }, + { OSQLParseNode::datetime_primary, "datetime_primary" }, + { OSQLParseNode::concatenation, "concatenation" }, + { OSQLParseNode::char_factor, "char_factor" }, + { OSQLParseNode::bit_value_fct, "bit_value_fct" } }; size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] ); OSL_ENSURE( nRuleMapCount == size_t( OSQLParseNode::rule_count ), "OSQLParser::OSQLParser: added a new rule? Adjust this map!" ); diff --git a/desktop/prj/d.lst b/desktop/prj/d.lst index fe688e2c4b44..5ec84bca7d37 100644 --- a/desktop/prj/d.lst +++ b/desktop/prj/d.lst @@ -93,7 +93,7 @@ mkdir: %_DEST%\bin%_EXT%\odf4ms ..\%__SRC%\bin\*.res %_DEST%\bin%_EXT%\*.res -..\%__SRC%\misc\soffice.sh %_DEST%\bin%_EXT%\soffice +..\%__SRC%\misc\soffice.sh-expanded %_DEST%\bin%_EXT%\soffice ..\%__SRC%\misc\sbase.sh %_DEST%\bin%_EXT%\sbase ..\%__SRC%\misc\scalc.sh %_DEST%\bin%_EXT%\scalc ..\%__SRC%\misc\sdraw.sh %_DEST%\bin%_EXT%\sdraw diff --git a/desktop/scripts/makefile.mk b/desktop/scripts/makefile.mk index 52750ca0b44f..001ead351928 100644 --- a/desktop/scripts/makefile.mk +++ b/desktop/scripts/makefile.mk @@ -54,7 +54,18 @@ UNIXTEXT= \ $(MISC)$/unopkg.sh .IF "$(OS)" != "MACOSX" + +ALLTAR: $(MISC)$/soffice.sh-expanded + +$(MISC)/soffice.sh-expanded: $(MISC)/soffice.sh +.IF "$(OS)" == "LINUX" && "$(CPUNAME)" == "POWERPC" + $(SED) 's/^#@# //' $< > $@ +.ELSE + $(COPY) $< $@ +.ENDIF + UNIXTEXT+= $(MISC)$/soffice.sh + .ENDIF .INCLUDE : target.mk diff --git a/desktop/scripts/soffice.sh b/desktop/scripts/soffice.sh index 7895d3ed1cd9..0690e9647f35 100644 --- a/desktop/scripts/soffice.sh +++ b/desktop/scripts/soffice.sh @@ -43,11 +43,8 @@ export SAL_ENABLE_FILE_LOCKING # working on your system. # SAL_NOOPENGL=true; export SAL_NOOPENGL -# the following test is needed on Linux PPC with IBM j2sdk142 -if [ "`uname -s`" = "Linux" -a "`uname -m`" = "ppc" ] ; then - JITC_PROCESSOR_TYPE=6 - export JITC_PROCESSOR_TYPE -fi +# The following is needed on Linux PPC with IBM j2sdk142: +#@# export JITC_PROCESSOR_TYPE=6 # resolve installation directory sd_cwd="`pwd`" @@ -129,11 +126,13 @@ export PATH "$sd_prog/$sd_binary" "$@" & trap 'kill -9 $!' TERM wait $! +sd_ret=$? -while [ $? -eq 79 ] +while [ $sd_ret -eq 79 ] do "$sd_prog/$sd_binary" ""$BOOTSTRAPVARS"" & wait $! + sd_ret=$? done -exit +exit $sd_ret diff --git a/desktop/source/pagein/makefile.mk b/desktop/source/pagein/makefile.mk index 85cbb4d3c9fd..626412877250 100644 --- a/desktop/source/pagein/makefile.mk +++ b/desktop/source/pagein/makefile.mk @@ -81,21 +81,25 @@ $(MISC)$/$(TARGET)-calc : makefile.mk @echo Making: $@ @-echo $(DLLPRE)sc$(DFTDLLPOST) > $@ @-echo $(DLLPRE)svx$(DFTDLLPOST) >> $@ + @-echo $(DLLPRE)svxcore$(DFTDLLPOST) >> $@ $(MISC)$/$(TARGET)-draw : makefile.mk @echo Making: $@ @-echo $(DLLPRE)sd$(DFTDLLPOST) > $@ @-echo $(DLLPRE)svx$(DFTDLLPOST) >> $@ + @-echo $(DLLPRE)svxcore$(DFTDLLPOST) >> $@ $(MISC)$/$(TARGET)-impress : makefile.mk @echo Making: $@ @-echo $(DLLPRE)sd$(DFTDLLPOST) > $@ @-echo $(DLLPRE)svx$(DFTDLLPOST) >> $@ + @-echo $(DLLPRE)svxcore$(DFTDLLPOST) >> $@ $(MISC)$/$(TARGET)-writer : makefile.mk @echo Making: $@ @-echo $(DLLPRE)sw$(DFTDLLPOST) > $@ @-echo $(DLLPRE)svx$(DFTDLLPOST) >> $@ + @-echo $(DLLPRE)svxcore$(DFTDLLPOST) >> $@ # sorted in approx. reverse load order (ld.so.1) $(MISC)$/$(TARGET)-common : makefile.mk @@ -121,7 +125,7 @@ $(MISC)$/$(TARGET)-common : makefile.mk @-echo $(DLLPRE)ucb1$(DLLPOST) >> $@ @-echo configmgr2$(UNODLLPOST) >> $@ # - @-echo $(DLLPRE)dtransX11$(DFTDLLPOST) >> $@ + @-echo $(DLLPRE)dtrans$(DLLPOST) >> $@ @-echo $(DLLPRE)vclplug_gen$(DFTDLLPOST) >> $@ .IF "$(ENABLE_GTK)" != "" @-echo $(DLLPRE)vclplug_gtk$(DFTDLLPOST) >> $@ @@ -130,7 +134,6 @@ $(MISC)$/$(TARGET)-common : makefile.mk @-echo $(DLLPRE)vclplug_kde$(DFTDLLPOST) >> $@ .ENDIF # ENABLE_KDE # - @-echo $(DLLPRE)psp$(DFTDLLPOST) >> $@ @-echo $(DLLPRE)basegfx$(DFTDLLPOST) >> $@ @-echo $(DLLPRE)sot$(DFTDLLPOST) >> $@ @-echo $(DLLPRE)xcr$(DFTDLLPOST) >> $@ diff --git a/desktop/source/pkgchk/unopkg/makefile.mk b/desktop/source/pkgchk/unopkg/makefile.mk index 3562fad961d9..4a1f409f4564 100644 --- a/desktop/source/pkgchk/unopkg/makefile.mk +++ b/desktop/source/pkgchk/unopkg/makefile.mk @@ -49,6 +49,7 @@ PRJINC += ..$/..$/deployment ..$/.. CFLAGS+=-DSYSTEM_DB -I$(DB_INCLUDES) .ENDIF +.IF "$(LINK_SO)"!="" APP1TARGET = so$/unopkg APP1OBJS = $(OBJFILES) APP1STDLIBS = $(SALLIB) $(UNOPKGAPPLIB) @@ -59,6 +60,7 @@ APP1RPATH = BRAND APP1ICON = $(SOLARRESDIR)$/icons/so9_main_app.ico APP1LINKRES = $(MISC)$/$(TARGET)1.res .ENDIF +.ENDIF # "$(LINK_SO)"!="" APP2TARGET = unopkg APP2OBJS = $(OBJFILES) diff --git a/desktop/util/makefile.mk b/desktop/util/makefile.mk index 05f129b3c5fc..82cad8c095ad 100644 --- a/desktop/util/makefile.mk +++ b/desktop/util/makefile.mk @@ -79,6 +79,7 @@ RESLIB1SRSFILES= $(SRS)$/desktop.srs \ $(SRS)$/wizard.srs .IF "$(L10N_framework)"=="" +.IF "$(LINK_SO)"=="TRUE" .IF "$(GUI)" != "OS2" APP1TARGET=so$/$(TARGET) APP1NOSAL=TRUE @@ -119,12 +120,6 @@ APP1STDLIBS = \ $(VOSLIB) -.IF "$(GUI)" == "UNX" -.IF "$(OS)" == "LINUX" || "$(OS)" == "FREEBSD" -APP1STDLIBS+= -lXext -.ENDIF -.ENDIF - APP1DEPN= $(APP1RES) verinfo.rc .IF "$(GUI)" == "WNT" @@ -143,6 +138,8 @@ APP1STACK=10000000 .ENDIF # "$(GUI)" != "OS2" +.ENDIF # "$(LINK_SO)"=="TRUE" + APP5TARGET=soffice APP5NOSAL=TRUE APP5RPATH=BRAND @@ -206,6 +203,7 @@ APP5LINKRES=$(MISC)$/ooffice.res .ENDIF # OS2 .IF "$(GUI)" == "WNT" +.IF "$(LINK_SO)"=="TRUE" APP6TARGET=so$/officeloader APP6RES=$(RES)$/soloader.res APP6NOSAL=TRUE @@ -218,6 +216,7 @@ APP6OBJS = \ $(OBJ)$/officeloader.obj \ $(SOLARLIBDIR)$/pathutils-obj.obj STDLIB6=$(ADVAPI32LIB) $(SHELL32LIB) $(SHLWAPILIB) +.ENDIF # "$(LINK_SO)"=="TRUE" APP7TARGET=officeloader APP7RES=$(RES)$/ooloader.res @@ -265,7 +264,9 @@ $(APP6TARGETN) : $(MISC)$/binso_created.flg ALLTAR: $(MISC)$/$(TARGET).exe.manifest ALLTAR: $(MISC)$/$(TARGET).bin.manifest ALLTAR: $(BIN)$/$(TARGET).bin +.IF "$(LINK_SO)"=="TRUE" ALLTAR: $(BIN)$/so$/$(TARGET).bin +.ENDIF # "$(LINK_SO)"=="TRUE" .ENDIF # WNT .IF "$(GUI)" == "OS2" @@ -276,23 +277,29 @@ $(BIN)$/soffice_oo$(EXECPOST) : $(APP5TARGETN) $(COPY) $< $@ .IF "$(GUI)" != "OS2" +.IF "$(LINK_SO)"=="TRUE" $(BIN)$/so$/soffice_so$(EXECPOST) : $(APP1TARGETN) $(COPY) $< $@ -ALLTAR : $(BIN)$/so$/soffice_so$(EXECPOST) $(BIN)$/soffice_oo$(EXECPOST) - +ALLTAR : $(BIN)$/so$/soffice_so$(EXECPOST) +.ENDIF # "$(LINK_SO)"=="TRUE" +ALLTAR : $(BIN)$/soffice_oo$(EXECPOST) .ENDIF .IF "$(OS)" == "MACOSX" +.IF "$(LINK_SO)"=="TRUE" $(BIN)$/so$/soffice_mac$(EXECPOST) : $(APP1TARGETN) $(COPY) $< $@ +ALLTAR : $(BIN)$/so$/soffice_mac$(EXECPOST) +.ENDIF # "$(LINK_SO)"=="TRUE" + $(BIN)$/soffice_mac$(EXECPOST) : $(APP5TARGETN) $(COPY) $< $@ -ALLTAR : $(BIN)$/so$/soffice_mac$(EXECPOST) $(BIN)$/soffice_mac$(EXECPOST) +ALLTAR : $(BIN)$/soffice_mac$(EXECPOST) -.ENDIF +.ENDIF # "$(OS)" == "MACOSX" .IF "$(GUI)" == "WNT" diff --git a/desktop/util/verinfo.rc b/desktop/util/verinfo.rc index 8f1840afbed9..105933ff130d 100644 --- a/desktop/util/verinfo.rc +++ b/desktop/util/verinfo.rc @@ -101,42 +101,42 @@ VS_VERSION_INFO versioninfo } } -2 ICON "icons\\so9_writer_doc.ico" -3 ICON "icons\\so9_writer_tem.ico" -4 ICON "icons\\so9_calc_doc.ico" -5 ICON "icons\\so9_calc_tem.ico" -6 ICON "icons\\so9_draw_doc.ico" -7 ICON "icons\\so9_draw_tem.ico" -8 ICON "icons\\so9_impress_doc.ico" -9 ICON "icons\\so9_impress_tem.ico" -10 ICON "icons\\so9_impress_doc.ico" -11 ICON "icons\\so9_global_doc.ico" -12 ICON "icons\\so9_html_doc.ico" -13 ICON "icons\\so9_chart_doc.ico" -14 ICON "icons\\so9_base_doc.ico" -15 ICON "icons\\so9_math_doc.ico" -16 ICON "icons\\so9_empty_tem.ico" -17 ICON "icons\\so9_macro_doc.ico" +2 ICON "icons\\oasis-text.ico" +3 ICON "icons\\oasis-text-template.ico" +4 ICON "icons\\oasis-spreadsheet.ico" +5 ICON "icons\\oasis-spreadsheet-template.ico" +6 ICON "icons\\oasis-drawing.ico" +7 ICON "icons\\oasis-drawing-template.ico" +8 ICON "icons\\oasis-presentation.ico" +9 ICON "icons\\oasis-presentation-template.ico" +10 ICON "icons\\oasis-presentation-template.ico" +11 ICON "icons\\oasis-master-document.ico" +12 ICON "icons\\oasis-web-template.ico" +13 ICON "icons\\oasis-empty-document.ico" +14 ICON "icons\\oasis-database.ico" +15 ICON "icons\\oasis-formula.ico" +16 ICON "icons\\empty-template.ico" +17 ICON "icons\\empty-document.ico" 18 ICON "icons\\so8-configuration.ico" 19 ICON "icons\\so8-open.ico" -20 ICON "icons\\so8-image-doc.ico" +20 ICON "icons\\empty-document.ico" 21 ICON "icons\\so9_writer_app.ico" 22 ICON "icons\\so9_calc_app.ico" 23 ICON "icons\\so9_draw_app.ico" 24 ICON "icons\\so9_impress_app.ico" 25 ICON "icons\\so9_math_app.ico" 26 ICON "icons\\so9_base_app.ico" -27 ICON "icons\\so9_empty_doc.ico" -28 ICON "icons\\so7-writer-doc.ico" -29 ICON "icons\\so7-writer-tem.ico" -30 ICON "icons\\so7-calc-doc.ico" -31 ICON "icons\\so7-calc-tem.ico" -32 ICON "icons\\so7-draw-doc.ico" -33 ICON "icons\\so7-draw-tem.ico" -34 ICON "icons\\so7-impress-doc.ico" -35 ICON "icons\\so7-impress-tem.ico" -36 ICON "icons\\so7-master-doc.ico" -37 ICON "icons\\so7-chart-doc.ico" -38 ICON "icons\\so7-base-doc.ico" -39 ICON "icons\\so7-math-doc.ico" +27 ICON "icons\\oasis-empty-document.ico" +28 ICON "icons\\text.ico" +29 ICON "icons\\text-template.ico" +30 ICON "icons\\spreadsheet.ico" +31 ICON "icons\\spreadsheet-template.ico" +32 ICON "icons\\drawing.ico" +33 ICON "icons\\drawing-template.ico" +34 ICON "icons\\presentation.ico" +35 ICON "icons\\presentation-template.ico" +36 ICON "icons\\master-document.ico" +37 ICON "icons\\empty-document.ico" +38 ICON "icons\\database.ico" +39 ICON "icons\\formula.ico" 40 ICON "icons\\oxt-extension.ico" diff --git a/desktop/win32/source/setup/setup.cpp b/desktop/win32/source/setup/setup.cpp index fb29c13d3a1c..c51dcd105bfd 100644 --- a/desktop/win32/source/setup/setup.cpp +++ b/desktop/win32/source/setup/setup.cpp @@ -76,6 +76,7 @@ #define PARAM_PATCH TEXT( " /update " ) #define PARAM_REG_ALL_MSO_TYPES TEXT( "REGISTER_ALL_MSO_TYPES=1 " ) #define PARAM_REG_NO_MSO_TYPES TEXT( "REGISTER_NO_MSO_TYPES=1 " ) +#define PARAM_SILENTINSTALL TEXT( " /QB" ) #define PARAM_RUNNING TEXT( "ignore_running" ) #define CMDLN_REG_ALL_MSO_TYPES TEXT( "msoreg=1" ) @@ -85,6 +86,11 @@ #define ADVAPI32_DLL TEXT( "advapi32.dll" ) #define PROFILE_NAME TEXT( "setup.ini" ) +#define RUNTIME_X64_NAME TEXT( "redist\\vcredist_x64.exe" ) +#define RUNTIME_X86_NAME TEXT( "redist\\vcredist_x86.exe" ) +#define PRODUCTCODE_X86 TEXT( "{E503B4BF-F7BB-3D5F-8BC8-F694B1CFF942}" ) +#define PRODUCTCODE_X64 TEXT( "{350AA351-21FA-3270-8B7A-835434E766AD}" ) + #define MSIAPI_DllGetVersion "DllGetVersion" #define ADVAPI32API_CheckTokenMembership "CheckTokenMembership" @@ -1897,6 +1903,114 @@ boolean SetupAppX::IsPatchInstalled( TCHAR* pBaseDir, TCHAR* pFileName ) } //-------------------------------------------------------------------------- +boolean SetupAppX::InstallRuntimes( TCHAR *sProductCode, TCHAR *sRuntimePath ) +{ + INSTALLSTATE nRet = MsiQueryProductState( sProductCode ); + OutputDebugStringFormat( TEXT( "MsiQueryProductState returned <%d>\r\n" ), nRet ); + if ( nRet == INSTALLSTATE_DEFAULT ) + return true; + + Log( TEXT( " Will install runtime <%s>\r\n" ), sRuntimePath ); + OutputDebugStringFormat( TEXT( " Will install runtime <%s>\r\n" ), sRuntimePath ); + + STARTUPINFO aSUI; + PROCESS_INFORMATION aPI; + + ZeroMemory( (void*)&aPI, sizeof( PROCESS_INFORMATION ) ); + ZeroMemory( (void*)&aSUI, sizeof( STARTUPINFO ) ); + + aSUI.cb = sizeof(STARTUPINFO); + aSUI.dwFlags = STARTF_USESHOWWINDOW; + aSUI.wShowWindow = SW_SHOW; + + DWORD nCmdLineLength = lstrlen( sRuntimePath ) + lstrlen( PARAM_SILENTINSTALL ) + 2; + TCHAR *sCmdLine = new TCHAR[ nCmdLineLength ]; + + if ( FAILED( StringCchCopy( sCmdLine, nCmdLineLength, sRuntimePath ) ) || + FAILED( StringCchCat( sCmdLine, nCmdLineLength, PARAM_SILENTINSTALL ) ) ) + { + delete [] sCmdLine; + SetError( ERROR_INSTALL_FAILURE ); + return false; + } + + if ( !WIN::CreateProcess( NULL, sCmdLine, NULL, NULL, FALSE, + CREATE_DEFAULT_ERROR_MODE, NULL, NULL, + &aSUI, &aPI ) ) + { + Log( TEXT( "ERROR: Could not create process %s.\r\n" ), sCmdLine ); + SetError( WIN::GetLastError() ); + delete [] sCmdLine; + return false; + } + + DWORD nResult = WaitForProcess( aPI.hProcess ); + bool bRet = true; + + if( ERROR_SUCCESS != nResult ) + { + Log( TEXT( "ERROR: While waiting for %s.\r\n" ), sCmdLine ); + SetError( nResult ); + bRet = false; + } + else + { + GetExitCodeProcess( aPI.hProcess, &nResult ); + SetError( nResult ); + + if ( nResult != ERROR_SUCCESS ) + { + TCHAR sBuf[80]; + StringCchPrintf( sBuf, 80, TEXT("Warning: install runtime returned %u.\r\n"), nResult ); + Log( sBuf ); + } + else + Log( TEXT( " Installation of runtime completed successfully.\r\n" ) ); + } + + CloseHandle( aPI.hProcess ); + + delete [] sCmdLine; + + return bRet; +} + +//-------------------------------------------------------------------------- +boolean SetupAppX::InstallRuntimes() +{ + TCHAR *sRuntimePath = 0; + SYSTEM_INFO siSysInfo; + + GetNativeSystemInfo(&siSysInfo); + + OutputDebugStringFormat( TEXT( "found architecture<%d>\r\n" ), siSysInfo.wProcessorArchitecture ); + + if ( siSysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ) + { + if ( GetPathToFile( RUNTIME_X64_NAME, &sRuntimePath ) ) + InstallRuntimes( PRODUCTCODE_X64, sRuntimePath ); + else + Log( TEXT( "ERROR: no installer for x64 runtime libraries found!" ) ); + + if ( sRuntimePath ) + { + delete [] sRuntimePath; + sRuntimePath = 0; + } + } + + if ( GetPathToFile( RUNTIME_X86_NAME, &sRuntimePath ) ) + InstallRuntimes( PRODUCTCODE_X86, sRuntimePath ); + else + Log( TEXT( "ERROR: no installer for x86 runtime libraries found!" ) ); + + if ( sRuntimePath ) + delete [] sRuntimePath; + + return true; +} + +//-------------------------------------------------------------------------- //-------------------------------------------------------------------------- LanguageDataX::LanguageDataX( LPTSTR pData ) { diff --git a/desktop/win32/source/setup/setup.hxx b/desktop/win32/source/setup/setup.hxx index 72785cc75b31..169254db87ab 100644 --- a/desktop/win32/source/setup/setup.hxx +++ b/desktop/win32/source/setup/setup.hxx @@ -119,12 +119,13 @@ private: LPTSTR *pNext, boolean bStripQuotes = false ); boolean IsAdmin(); - boolean GetCommandLine(); boolean IsTerminalServerInstalled() const; void AddFileToPatchList( TCHAR* pPath, TCHAR* pFile ); boolean IsPatchInstalled( TCHAR* pBaseDir, TCHAR* pFileName ); + boolean InstallRuntimes( TCHAR* pProductCode, TCHAR* pFileName ); + public: SetupAppX(); ~SetupAppX(); @@ -136,6 +137,7 @@ public: virtual boolean ChooseLanguage( long& rLanguage ); virtual boolean CheckVersion(); virtual boolean CheckForUpgrade(); + virtual boolean InstallRuntimes(); virtual boolean Install( long nLanguage ); virtual UINT GetError() const; diff --git a/desktop/win32/source/setup/setup_main.cxx b/desktop/win32/source/setup/setup_main.cxx index 515363749c55..6c96bde46b12 100644 --- a/desktop/win32/source/setup/setup_main.cxx +++ b/desktop/win32/source/setup/setup_main.cxx @@ -124,6 +124,9 @@ extern "C" int __stdcall WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, int ) if ( ! pSetup->ChooseLanguage( nLanguage ) ) throw pSetup->GetError(); + if ( ! pSetup->InstallRuntimes() ) + throw pSetup->GetError(); + if ( ! pSetup->Install( nLanguage ) ) throw pSetup->GetError(); } diff --git a/desktop/win32/source/setup/setup_main.hxx b/desktop/win32/source/setup/setup_main.hxx index 67b54adc0d2a..28200fcae757 100644 --- a/desktop/win32/source/setup/setup_main.hxx +++ b/desktop/win32/source/setup/setup_main.hxx @@ -53,6 +53,7 @@ public: virtual boolean ChooseLanguage( long& rLanguage ) = 0; virtual boolean CheckVersion() = 0; virtual boolean CheckForUpgrade() = 0; + virtual boolean InstallRuntimes() = 0; virtual boolean Install( long nLanguage ) = 0; virtual UINT GetError() const = 0; diff --git a/drawinglayer/inc/drawinglayer/attribute/fillbitmapattribute.hxx b/drawinglayer/inc/drawinglayer/attribute/fillbitmapattribute.hxx index 4e316232bd81..376e1d626927 100644 --- a/drawinglayer/inc/drawinglayer/attribute/fillbitmapattribute.hxx +++ b/drawinglayer/inc/drawinglayer/attribute/fillbitmapattribute.hxx @@ -36,7 +36,7 @@ #ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLBITMAPATTRIBUTE_HXX #define INCLUDED_DRAWINGLAYER_ATTRIBUTE_FILLBITMAPATTRIBUTE_HXX -#include <vcl/bitmap.hxx> +#include <vcl/bitmapex.hxx> #include <basegfx/point/b2dpoint.hxx> #include <basegfx/vector/b2dvector.hxx> @@ -56,7 +56,7 @@ namespace drawinglayer { class FillBitmapAttribute { - Bitmap maBitmap; + BitmapEx maBitmapEx; basegfx::B2DPoint maTopLeft; basegfx::B2DVector maSize; @@ -64,11 +64,15 @@ namespace drawinglayer unsigned mbTiling : 1; public: - FillBitmapAttribute(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize, bool bTiling); + FillBitmapAttribute( + const BitmapEx& rBitmapEx, + const basegfx::B2DPoint& rTopLeft, + const basegfx::B2DVector& rSize, + bool bTiling); bool operator==(const FillBitmapAttribute& rCandidate) const; // data access - const Bitmap& getBitmap() const { return maBitmap; } + const BitmapEx& getBitmapEx() const { return maBitmapEx; } const basegfx::B2DPoint& getTopLeft() const { return maTopLeft; } const basegfx::B2DVector& getSize() const { return maSize; } bool getTiling() const { return mbTiling; } diff --git a/drawinglayer/inc/drawinglayer/attribute/fontattribute.hxx b/drawinglayer/inc/drawinglayer/attribute/fontattribute.hxx new file mode 100644 index 000000000000..d8eed659f5e7 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/attribute/fontattribute.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: strokeattribute.hxx,v $ + * + * $Revision: 1.5 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:16 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_ATTRIBUTE_FONTATTRIBUTE_HXX +#define INCLUDED_DRAWINGLAYER_ATTRIBUTE_FONTATTRIBUTE_HXX + +#include <sal/config.h> +#include <sal/types.h> +#include <tools/string.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace attribute + { + /** FontAttribute class + + This attribute class is able to hold all parameters needed/used + to completely define the parametrisation of a text portion. + */ + class FontAttribute + { + private: + /// core data + String maFamilyName; // Font Family Name + String maStyleName; // Font Style Name + sal_uInt16 mnWeight; // Font weight + + /// bitfield + unsigned mbSymbol : 1; // Symbol Font Flag + unsigned mbVertical : 1; // Vertical Text Flag + unsigned mbItalic : 1; // Italic Flag + unsigned mbOutline : 1; // Outline Flag + unsigned mbRTL : 1; // RTL Flag + unsigned mbBiDiStrong : 1; // BiDi Flag + // TODO: pair kerning and CJK kerning + + public: + /// constructor + FontAttribute( + const String& rFamilyName, + const String& rStyleName, + sal_uInt16 nWeight, + bool bSymbol = false, + bool bVertical = false, + bool bItalic = false, + bool bOutline = false, + bool bRTL = false, + bool bBiDiStrong = false) + : maFamilyName(rFamilyName), + maStyleName(rStyleName), + mnWeight(nWeight), + mbSymbol(bSymbol), + mbVertical(bVertical), + mbItalic(bItalic), + mbOutline(bOutline), + mbRTL(bRTL), + mbBiDiStrong(bBiDiStrong) + { + } + + FontAttribute() + : maFamilyName(), + maStyleName(), + mnWeight(0), + mbSymbol(false), + mbVertical(false), + mbItalic(false), + mbOutline(false), + mbRTL(false), + mbBiDiStrong(false) + { + } + + /// compare operator + bool operator==(const FontAttribute& rCompare) const; + + /// data read access + const String& getFamilyName() const { return maFamilyName; } + const String& getStyleName() const { return maStyleName; } + sal_uInt16 getWeight() const { return mnWeight; } + bool getSymbol() const { return mbSymbol; } + bool getVertical() const { return mbVertical; } + bool getItalic() const { return mbItalic; } + bool getOutline() const { return mbOutline; } + bool getRTL() const { return mbRTL; } + bool getBiDiStrong() const { return mbBiDiStrong; } + }; + } // end of namespace attribute +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_ATTRIBUTE_FONTATTRIBUTE_HXX + +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive2d/alphaprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/alphaprimitive2d.hxx index 6fdf3200543c..10288b70bd1b 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/alphaprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/alphaprimitive2d.hxx @@ -44,23 +44,52 @@ namespace drawinglayer { namespace primitive2d { + /** AlphaPrimitive2D class + + This is the basic primitive for applying freely defined transparence + to freely defined content. The basic idea is to associate a content + which is defined as a sequence of primitives and hold as child content + in the GroupPrimitive2D with an alpha channel also defined as a sequence + of primitives and hold in the Alpha member. + + The basic definition is to use the Alpha content as Alpha-Mask by + interpreting the Alpha-content not as RGB, but as Luminance alpha mask + using the common RGB_to_luminance definition as e.g. used by VCL. + + The defining geometry is the Range of the child primitive sequence, + this means the renderers will/shall use this geometric information for + rendering, not the alpha one. The alpha one should/will be clipped + accordingly. + */ class AlphaPrimitive2D : public GroupPrimitive2D { private: - Primitive2DSequence maAlpha; // transparence sequence + /// The Alpha-Mask who's RGB-Values are interpreted as Luminance + Primitive2DSequence maAlpha; public: + /** constructor + + @param rChildren + The content which is defined to have a transparency. The + range of this primitive is defined by this content + + @param rAlpha + The definition of the Alpha-channel for this primitive. It + will be interpreted as mask by interpreting as gray values + using the common RGB_to_luminance definitions + */ AlphaPrimitive2D( const Primitive2DSequence& rChildren, const Primitive2DSequence& rAlpha); - // get data + /// data read access const Primitive2DSequence& getAlpha() const { return maAlpha; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/animatedprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/animatedprimitive2d.hxx index 41ae18b30fc9..cd6133dc54d8 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/animatedprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/animatedprimitive2d.hxx @@ -38,6 +38,7 @@ #include <drawinglayer/primitive2d/groupprimitive2d.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// // predefines @@ -51,50 +52,59 @@ namespace drawinglayer { namespace primitive2d { + /** AnimatedSwitchPrimitive2D class + + This is the basic class for simple, animated primitives. The basic idea + is to have an animation definition (AnimationEntry) who's basic + functionality is to return a state value for any given animation time in + the range of [0.0 .. 1.0]. Depending on the state, the decomposition + calculates an index, which of the members of the child vector is to + be visualized. + + An example: For blinking, the Child vector should exist of two entries; + for values of [0.0 .. 0.5] the first, else the last entry will be used. + This mechanism is not limited to two entries, though. + */ class AnimatedSwitchPrimitive2D : public GroupPrimitive2D { private: - // the animation definition which allows translation of a point in time - // to an animation state [0.0 .. 1.0]. This member contains a cloned - // definition and is owned by this implementation + /** + The animation definition which allows translation of a point in time + to an animation state [0.0 .. 1.0]. This member contains a cloned + definition and is owned by this implementation. + */ animation::AnimationEntry* mpAnimationEntry; - // the last remembered decompose time, created and used by getDecomposition() for - // buffering purposes - double mfDecomposeViewTime; - - // bitfield - // flag if this is a text or graphic animation. Necessary since SdrViews need to differentiate - // between both types if they are on/off + /// bitfield + /** flag if this is a text or graphic animation. Necessary since SdrViews need to differentiate + between both types if they are on/off + */ unsigned mbIsTextAnimation : 1; - protected: - // create local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; - public: + /// constructor AnimatedSwitchPrimitive2D( const animation::AnimationEntry& rAnimationEntry, const Primitive2DSequence& rChildren, bool bIsTextAnimation); + + /// destructor - needed due to mpAnimationEntry virtual ~AnimatedSwitchPrimitive2D(); - // get data + /// data read access const animation::AnimationEntry& getAnimationEntry() const { return *mpAnimationEntry; } bool isTextAnimation() const { return mbIsTextAnimation; } bool isGraphicAnimation() const { return !isTextAnimation(); } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range - virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() - // The getDecomposition is overloaded here since the decompose is dependent of the point in time, - // so the default implementation is nut useful here, it needs to be handled locally + /** The getDecomposition is overloaded here since the decompose is dependent of the point in time, + so the default implementation is nut useful here, it needs to be handled locally + */ virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; }; } // end of namespace primitive2d @@ -106,84 +116,63 @@ namespace drawinglayer { namespace primitive2d { + /** AnimatedBlinkPrimitive2D class + + Basically the same mechanism as in AnimatedSwitchPrimitive2D, but the + decomposition is specialized in delivering the children in the + range [0.0.. 0.5] and an empty sequence else + */ class AnimatedBlinkPrimitive2D : public AnimatedSwitchPrimitive2D { protected: - // create local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; - public: + /// constructor AnimatedBlinkPrimitive2D( const animation::AnimationEntry& rAnimationEntry, const Primitive2DSequence& rChildren, bool bIsTextAnimation); - // provide unique ID + /// create local decomposition + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// -// helper class for AnimatedInterpolatePrimitive2D namespace drawinglayer { namespace primitive2d { - class BufferedMatrixDecompose - { - private: - // the matrix itself - basegfx::B2DHomMatrix maB2DHomMatrix; - - // the decomposition - basegfx::B2DVector maScale; - basegfx::B2DVector maTranslate; - double mfRotate; - double mfShearX; - - // flag if already decomposed, used by ensureDecompose() - bool mbDecomposed; + /** AnimatedInterpolatePrimitive2D class - public: - BufferedMatrixDecompose(const basegfx::B2DHomMatrix& rMatrix); - void ensureDecompose() const; - - // data access - const basegfx::B2DHomMatrix& getB2DHomMatrix() const { return maB2DHomMatrix; } - const basegfx::B2DVector& getScale() const { return maScale; } - const basegfx::B2DVector& getTranslate() const { return maTranslate; } - double getRotate() const { return mfRotate; } - double getShearX() const { return mfShearX; } - }; - } // end of anonymous namespace -} // end of namespace drawinglayer - -////////////////////////////////////////////////////////////////////////////// - -namespace drawinglayer -{ - namespace primitive2d - { + Specialized on multi-step animations based on matrix transformations. The + Child sequelce will be embedded in a matrix transformation. That transformation + will be linearly combined from the decomposed values and the animation value + to allow a smooth animation. + */ class AnimatedInterpolatePrimitive2D : public AnimatedSwitchPrimitive2D { private: - // the transformations - std::vector< BufferedMatrixDecompose > maMatrixStack; + /// the transformations + std::vector< basegfx::tools::B2DHomMatrixBufferedDecompose > maMatrixStack; protected: - // create local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; - public: + /// constructor AnimatedInterpolatePrimitive2D( const std::vector< basegfx::B2DHomMatrix >& rmMatrixStack, const animation::AnimationEntry& rAnimationEntry, const Primitive2DSequence& rChildren, bool bIsTextAnimation); - // provide unique ID + /// create local decomposition + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx index 65977cfd4241..85cf5e236d4f 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx @@ -46,35 +46,48 @@ namespace drawinglayer { namespace primitive2d { - class BackgroundColorPrimitive2D : public BasePrimitive2D + /** BackgroundColorPrimitive2D class + + This primitive is defined to fill the whole visible Viewport with + the given color (and thus decomposes to a filled polygon). This + makes it a view-depnendent primitive by definition. It only has + a valid decomposition if a valid Viewport is given in the + ViewInformation2D at decomposition time. + + It will try to buffer it's last decomposition using maLastViewport + to detect changes in the get2DDecomposition call. + */ + class BackgroundColorPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the fill color to use basegfx::BColor maBColor; - // the last used viewInformation, used from getDecomposition for buffering + /// the last used viewInformation, used from getDecomposition for buffering basegfx::B2DRange maLastViewport; protected: - // create local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// create local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor BackgroundColorPrimitive2D( const basegfx::BColor& rBColor); - // get data + /// data read access const basegfx::BColor& getBColor() const { return maBColor; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get 2d range + /// get B2Drange virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() - // Overload standard getDecomposition call to be view-dependent here + /// Overload standard getDecomposition call to be view-dependent here virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/baseprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/baseprimitive2d.hxx index b05c60394ecd..6cf45ffefe54 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/baseprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/baseprimitive2d.hxx @@ -43,16 +43,17 @@ #include <basegfx/range/b2drange.hxx> ////////////////////////////////////////////////////////////////////////////// -// defines for DeclPrimitrive2DIDBlock and ImplPrimitrive2DIDBlock -// Added to be able to simply change identification stuff later, e.g. add -// a identification string and/or ID to the interface and to the implementation -// ATM used to delclare implement getPrimitiveID() +/** defines for DeclPrimitrive2DIDBlock and ImplPrimitrive2DIDBlock + Added to be able to simply change identification stuff later, e.g. add + a identification string and/or ID to the interface and to the implementation + ATM used to delclare implement getPrimitive2DID() +*/ #define DeclPrimitrive2DIDBlock() \ - virtual sal_uInt32 getPrimitiveID() const; + virtual sal_uInt32 getPrimitive2DID() const; #define ImplPrimitrive2DIDBlock(TheClass, TheID) \ - sal_uInt32 TheClass::getPrimitiveID() const { return TheID; } + sal_uInt32 TheClass::getPrimitive2DID() const { return TheID; } ////////////////////////////////////////////////////////////////////////////// // predefines @@ -61,6 +62,13 @@ namespace drawinglayer { namespace geometry { class ViewInformation2D; }} +namespace drawinglayer { namespace primitive2d { + /// typedefs for basePrimitive2DImplBase, Primitive2DSequence and Primitive2DReference + typedef cppu::WeakComponentImplHelper1< ::com::sun::star::graphic::XPrimitive2D > BasePrimitive2DImplBase; + typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive2D > Primitive2DReference; + typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSequence; +}} + ////////////////////////////////////////////////////////////////////////////// // basePrimitive2D class @@ -68,101 +76,222 @@ namespace drawinglayer { namespace primitive2d { - // typedefs for basePrimitive2DImplBase, Primitive2DSequence and Primitive2DReference - typedef cppu::WeakComponentImplHelper1< ::com::sun::star::graphic::XPrimitive2D > BasePrimitive2DImplBase; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive2D > Primitive2DReference; - typedef ::com::sun::star::uno::Sequence< Primitive2DReference > Primitive2DSequence; - - // base class for all C++ implementations of com::sun::star::graphic::XPrimitive2D. This class - // is strongly virtual due to the lack of getPrimitiveID() implementation. This is by purpose, this - // base class shall not be incarnated and be used directly as a XPrimitive2D. + /** BasePrimitive2D class + + Baseclass for all C++ implementations of com::sun::star::graphic::XPrimitive2D + + This class is strongly virtual due to the lack of getPrimitiveID() implementation. + This is by purpose, this base class shall not be incarnated and be used directly as + a XPrimitive2D. + + Is is derived from boost::noncopyable to make clear that a primitive is a read-only + instance and copying or changing values is not intended. The idea is to hold all data + needed for visualisation of this primitive in unchangeable form. + + It is derived from comphelper::OBaseMutex to have a Mutex at hand; in a base + implementation this may not be needed, but e.g. when buffering at last decomposition + in a local member, multiple threads may try to decompose at the same time, so locking + is needed to avoid race conditions seen from the UNO object implementation. + + A method to get a simplified representation is provided by get2DDecomposition. The + default implementation returns an empty sequence. The idea is that processors + using this primitive and do not know it, may get the decomposition and process + these instead. An example is e.g. a fat line, who's decomposition may contain + the geometric representation of that line using filled polygon prmimitives. When + the renderer knows how to handle fat lines, he may proccess this primitive directly; + if not he can use the decomposition. With this functionality, renderers may operate by + knowing only a small set of primitives. + + When a primitive does not implement get2DDecomposition, it is called a 'Basic Primitive' and + belongs to the set of primitives which a processor should be able to handle. Practice + will define this minimal sets of primitives. When defined and the concept is prooved, + unique UNO APIs may be defined/implemented for these set to allow more intense work + with primitives using UNO. + + Current Basic 2D Primitives are: + + - BitmapPrimitive2D (bitmap data, evtl. with alpha) + - MetafilePrimitive2D (VCL Metafile, currently no decomposition, but planned, so may vanish) + - PointArrayPrimitive2D (single points) + - PolygonHairlinePrimitive2D (hairline curves/polygons) + - PolyPolygonColorPrimitive2D (colored polygons) + + All other implemented primitives have a defined decomposition and can thus be + decomposed downt to this small set. + + A renderer implementing support for this minimal set of primitives can completely + render primitive-based visualisations. Of course, he also has to take states into account + which are representated by GroupPrimitive2D derivations, see groupprimitive2d.hxx + + To support getting the geometric BoundRect, getB2DRange is used. The default + implementation will use the get2DDecomposition result and merge a range from the + entries. Thus, an implementation is only necessary for the Basic Primitives, but + of course speedups are possible (and are used) by implementing the method at higher-level + primitives. + + For primitive identification, getPrimitiveID is used currently in this implementations + to allow a fast switch/case processing. This needs a unique identifier mechanism which + currently uses defines (see drawinglayer_primitivetypes2d.hxx). For UNO prmitive API + it will be needed to add a unique descriptor (Name?) later to the API. + + This base implementation provides mappings from the methods from XPrimitive2D + (getDecomposition/getRange) to the appropriate methods in the C++ implementations + (get2DDecomposition/getB2DRange). The PropertyValue ViewParameters is converted to + the appropriate C++ implementation class ViewInformation2D. + + This base class does not implement any buffering; e.g. buffering the decompositon + and/or the range. These may be buffered anytime since the definition is that the primitive + is read-only and thus unchangeable. This implies that the decomposition and/or getting + the range will lead to the same result as last time, under the precondition that + the parameter ViewInformation2D is the same as the last one. This is usually the case + for view-independent primitives which are defined by not using ViewInformation2D + in their get2DDecomposition/getB2DRange implementations. + */ class BasePrimitive2D : private boost::noncopyable, protected comphelper::OBaseMutex, public BasePrimitive2DImplBase { private: - // a sequence used for buffering the last createLocalDecomposition() result. Use - // the protected access methods to change. Only implementations of getDecomposition() - // should make use. - Primitive2DSequence maLocalDecomposition; - protected: - // access methods to maLocalDecomposition. The usage of this methods may allow - // later thread-safe stuff to be added if needed. Only to be used by getDecomposition() - // implementations for buffering the last decomposition. - const Primitive2DSequence& getLocalDecomposition() const { return maLocalDecomposition; } - void setLocalDecomposition(const Primitive2DSequence& rNew) { maLocalDecomposition = rNew; } - - // method which is to be used to implement the local decomposition of a 2D primitive. The default - // implementation will just return an empty decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; - public: - // constructor + // constructor/destructor BasePrimitive2D(); + virtual ~BasePrimitive2D(); - // the ==operator is mainly needed to allow testing newly-created primitives against their last - // incarnation which buffers/holds the made decompositions. The default implementation - // uses getPrimitiveID()-calls to test if it's the same ID at last. Overloaded implementation are then - // based on this implementation + /** the ==operator is mainly needed to allow testing newly-created primitives against their last + incarnation which buffers/holds the made decompositions. The default implementation + uses getPrimitive2DID()-calls to test if it's the same ID at last. Overloaded implementation are then + based on this implementation + */ virtual bool operator==( const BasePrimitive2D& rPrimitive ) const; bool operator!=( const BasePrimitive2D& rPrimitive ) const { return !operator==(rPrimitive); } - // The default implementation will use getDecomposition results to create the range + /// The default implementation will use getDecomposition results to create the range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID for fast identifying of known primitive implementations in renderers. These use - // the the defines from primitivetypes2d.hxx to define unique IDs. - // This method is normally defined using DeclPrimitrive2DIDBlock() - virtual sal_uInt32 getPrimitiveID() const = 0; + /** provide unique ID for fast identifying of known primitive implementations in renderers. These use + the the defines from primitivetypes2d.hxx to define unique IDs. + This method is normally defined using DeclPrimitrive2DIDBlock() + */ + virtual sal_uInt32 getPrimitive2DID() const = 0; - // The getDecomposition default implementation will on demand use createLocalDecomposition() if maLocalDecomposition is empty. - // It will set maLocalDecomposition to this obtained decomposition to buffer it. - // If the decomposition is also ViewInformation2D-dependent, this method needs to be overloaded and the - // ViewInformation2D for the last decomposition need to be remembered, too, and be used in the next call to decide if - // the buffered decomposition may be reused or not. + /// The default implementation will return an empty sequence virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; // // Methods from XPrimitive2D // - // The getDecomposition implementation for UNO API will use getDecomposition from this implementation. It - // will construct a ViewInformation2D from the ViewParameters for that purpose + /** The getDecomposition implementation for UNO API will use getDecomposition from this implementation. It + will construct a ViewInformation2D from the ViewParameters for that purpose + */ virtual Primitive2DSequence SAL_CALL getDecomposition( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rViewParameters ) throw ( ::com::sun::star::uno::RuntimeException ); - // The getRange implementation for UNO API will use getRange from this implementation. It - // will construct a ViewInformation2D from the ViewParameters for that purpose + /** The getRange implementation for UNO API will use getRange from this implementation. It + will construct a ViewInformation2D from the ViewParameters for that purpose + */ virtual ::com::sun::star::geometry::RealRectangle2D SAL_CALL getRange( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rViewParameters ) throw ( ::com::sun::star::uno::RuntimeException ); }; } // end of namespace primitive2d } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// +// BufferedDecompositionPrimitive2D class + +namespace drawinglayer +{ + namespace primitive2d + { + /** BufferedDecompositionPrimitive2D class + + Baseclass for all C++ implementations of com::sun::star::graphic::XPrimitive2D + which want to buffer the decomoposition result + + Buffering the decomposition is the most-used buffering and is thus used my most + primitive implementations which support a decomposition as base class. + + The buffering is done by holding the last decomposition in the local parameter + maBuffered2DDecomposition. The default implementation of get2DDecomposition checks + if maBuffered2DDecomposition is empty. If yes, it uses create2DDecomposition + to create the content. In all cases, maBuffered2DDecomposition is returned. + + For view-dependent primitives derived from Primitive2DBufferDecomposition more needs + to be done when the decomposition depends on parts of the parameter ViewInformation2D. + This defines a standard method for processing these: + + Implement a view-dependent get2DDecomposition doing te following steps: + (a) Locally extract needed parameters from ViewInformation2D to new, local parameters + (this may be a complete local copy of ViewInformation2D) + (b) If a buffered decomposition exists, ckeck if one of the new local parameters + differs from the corresponding locally remembered (as member) ones. If yes, + clear maBuffered2DDecomposition + (d) call baseclass::get2DDecomposition which will use create2DDecomposition + to fill maBuffered2DDecomposition if it's empty + (e) copy the new local parameters to the corresponding locally remembered ones + to identify if a new decomposition is needed at the next call + (f) return maBuffered2DDecomposition + */ + class BufferedDecompositionPrimitive2D + : public BasePrimitive2D + { + private: + /// a sequence used for buffering the last create2DDecomposition() result + Primitive2DSequence maBuffered2DDecomposition; + + protected: + /** access methods to maBuffered2DDecomposition. The usage of this methods may allow + later thread-safe stuff to be added if needed. Only to be used by getDecomposition() + implementations for buffering the last decomposition. + */ + const Primitive2DSequence& getBuffered2DDecomposition() const { return maBuffered2DDecomposition; } + void setBuffered2DDecomposition(const Primitive2DSequence& rNew) { maBuffered2DDecomposition = rNew; } + + /** method which is to be used to implement the local decomposition of a 2D primitive. The default + implementation will just return an empty decomposition + */ + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + public: + // constructor/destructor + BufferedDecompositionPrimitive2D(); + + /** The getDecomposition default implementation will on demand use create2DDecomposition() if + maBuffered2DDecomposition is empty. It will set maBuffered2DDecomposition to this obtained decomposition + to buffer it. If the decomposition is also ViewInformation2D-dependent, this method needs to be + overloaded and the ViewInformation2D for the last decomposition need to be remembered, too, and + be used in the next call to decide if the buffered decomposition may be reused or not. + */ + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// // tooling namespace drawinglayer { namespace primitive2d { - // get B2DRange from a given Primitive2DReference + /// get B2DRange from a given Primitive2DReference basegfx::B2DRange getB2DRangeFromPrimitive2DReference(const Primitive2DReference& rCandidate, const geometry::ViewInformation2D& aViewInformation); - // get B2DRange from a given Primitive2DSequence + /// get B2DRange from a given Primitive2DSequence basegfx::B2DRange getB2DRangeFromPrimitive2DSequence(const Primitive2DSequence& rCandidate, const geometry::ViewInformation2D& aViewInformation); - // compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D) - // and using compare operator + /** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D) + and using compare operator + */ bool arePrimitive2DReferencesEqual(const Primitive2DReference& rA, const Primitive2DReference& rB); - // compare two Primitive2DReferences for equality, uses arePrimitive2DReferencesEqual internally + /// compare two Primitive2DReferences for equality, uses arePrimitive2DReferencesEqual internally bool arePrimitive2DSequencesEqual(const Primitive2DSequence& rA, const Primitive2DSequence& rB); - // concatenate sequence + /// concatenate sequence void appendPrimitive2DSequenceToPrimitive2DSequence(Primitive2DSequence& rDest, const Primitive2DSequence& rSource); - // concatenate single Primitive2D + /// concatenate single Primitive2D void appendPrimitive2DReferenceToPrimitive2DSequence(Primitive2DSequence& rDest, const Primitive2DReference& rSource); } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/bitmapprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/bitmapprimitive2d.hxx index d295c6ab4b89..f5de130febf9 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/bitmapprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/bitmapprimitive2d.hxx @@ -47,28 +47,41 @@ namespace drawinglayer { namespace primitive2d { + /** BitmapPrimitive2D class + + This class is the central primitive for Bitmap-based primitives. + It provides RGBA-based bitmaps, currently using a BitmapEx from VCL. + This may change in the future to any other, maybe more general base + class providing 24bit RGBA. + */ class BitmapPrimitive2D : public BasePrimitive2D { private: + /// the RGBA Bitmap-data BitmapEx maBitmapEx; + + /** the object transformation from unit coordinates, defining + size, shear, rotate and position + */ basegfx::B2DHomMatrix maTransform; public: + /// constructor BitmapPrimitive2D( const BitmapEx& rBitmapEx, const basegfx::B2DHomMatrix& rTransform); - // get data + /// data read access const BitmapEx& getBitmapEx() const { return maBitmapEx; } const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/borderlineprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/borderlineprimitive2d.hxx index 504ada20f8ac..b13528184f3b 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/borderlineprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/borderlineprimitive2d.hxx @@ -46,25 +46,41 @@ namespace drawinglayer { namespace primitive2d { - class BorderLinePrimitive2D : public BasePrimitive2D + /** BorderLinePrimitive2D class + + This is the basic primitive to build frames around objects, e.g. tables. + It defines a single or double line from Start to nd using the LeftWidth, + Distance and RightWidth definitions. + The LineStart/End overlap is defined by the Extend(Inner|Outer)(Start|End) + definitions. + */ + class BorderLinePrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the line definition basegfx::B2DPoint maStart; basegfx::B2DPoint maEnd; + + /// the widths of single/double line double mfLeftWidth; double mfDistance; double mfRightWidth; + + /// edge overlap sizes double mfExtendInnerStart; double mfExtendInnerEnd; double mfExtendOuterStart; double mfExtendOuterEnd; + + /// the line color basegfx::BColor maRGBColor; - // bitfield + /// bitfield + /// flags to influence inside/outside creation unsigned mbCreateInside : 1; unsigned mbCreateOutside : 1; - // helpers + /// local helpers double getCorrectedLeftWidth() const { return basegfx::fTools::equal(1.0, mfLeftWidth) ? 0.0 : mfLeftWidth; @@ -106,10 +122,11 @@ namespace drawinglayer } protected: - // create local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// create local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor BorderLinePrimitive2D( const basegfx::B2DPoint& rStart, const basegfx::B2DPoint& rEnd, @@ -124,7 +141,7 @@ namespace drawinglayer bool bCreateOutside, const basegfx::BColor& rRGBColor); - // get data + /// data read access const basegfx::B2DPoint& getStart() const { return maStart; } const basegfx::B2DPoint& getEnd() const { return maEnd; } double getLeftWidth() const { return mfLeftWidth; } @@ -138,10 +155,10 @@ namespace drawinglayer bool getCreateOutside() const { return mbCreateOutside; } const basegfx::BColor& getRGBColor() const { return maRGBColor; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx index 95c53347debb..b153e04ee1cb 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/chartprimitive2d.hxx @@ -46,6 +46,12 @@ namespace drawinglayer { namespace primitive2d { + /** ChartPrimitive2D class + + This is a helper primitive which decomposes to the ChartMetaFile + visualisation. It is used to allow specific renderers to do something + direct for visualising the chart. + */ class ChartPrimitive2D : public GroupPrimitive2D { private: diff --git a/drawinglayer/inc/drawinglayer/primitive2d/controlprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/controlprimitive2d.hxx index 0e69cb7bdfc0..5dd55405adf7 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/controlprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/controlprimitive2d.hxx @@ -47,63 +47,74 @@ namespace drawinglayer { namespace primitive2d { - class ControlPrimitive2D : public BasePrimitive2D + /** ControlPrimitive2D class + + Base class for ControlPrimitive handling. It decoposes to a + graphical representation (Bitmap data) of the control. This + representation is limited to a quadratic pixel maximum defined + in the applicatin settings. + */ + class ControlPrimitive2D : public BufferedDecompositionPrimitive2D { private: - // object's base data + /// object's base data basegfx::B2DHomMatrix maTransform; com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > mxControlModel; - // the created an cached awt::XControl + /// the created an cached awt::XControl com::sun::star::uno::Reference< com::sun::star::awt::XControl > mxXControl; - // the last used scaling, used from getDecomposition for buffering + /// the last used scaling, used from getDecomposition for buffering basegfx::B2DVector maLastViewScaling; - // used from getXControl() to create a local awt::XControl which is remembered in mxXControl - // and from thereon always used and returned by getXControl() + /** used from getXControl() to create a local awt::XControl which is remembered in mxXControl + and from thereon always used and returned by getXControl() + */ void createXControl(); - // single local decompositions, used from createLocalDecomposition() + /// single local decompositions, used from create2DDecomposition() Primitive2DReference createBitmapDecomposition(const geometry::ViewInformation2D& rViewInformation) const; Primitive2DReference createPlaceholderDecomposition(const geometry::ViewInformation2D& rViewInformation) const; protected: - // local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor ControlPrimitive2D( const basegfx::B2DHomMatrix& rTransform, const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& rxControlModel); - // constructor with an additional XControl as parameter to allow to hand it over at incarnation time - // if it exists. This will avoid to create a 2nd one on demand in createXControl() - // and thus double the XControls. + /** constructor with an additional XControl as parameter to allow to hand it over at incarnation time + if it exists. This will avoid to create a 2nd one on demand in createXControl() + and thus double the XControls. + */ ControlPrimitive2D( const basegfx::B2DHomMatrix& rTransform, const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& rxControlModel, const com::sun::star::uno::Reference< com::sun::star::awt::XControl >& rxXControl); - // get data + /// data read access const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } const com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& getControlModel() const { return mxControlModel; } - // mxControl access. This will on demand create the awt::XControl using createXControl() - // if it does not exist. It may already have been created or even handed over at - // incarnation + /** mxControl access. This will on demand create the awt::XControl using createXControl() + if it does not exist. It may already have been created or even handed over at + incarnation + */ const com::sun::star::uno::Reference< com::sun::star::awt::XControl >& getXControl() const; - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() - // Overload standard getDecomposition call to be view-dependent here + /// Overload standard getDecomposition call to be view-dependent here virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/discretebitmapprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/discretebitmapprimitive2d.hxx new file mode 100644 index 000000000000..04ddb73460fa --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/discretebitmapprimitive2d.hxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: bitmapprimitive2d.hxx,v $ + * + * $Revision: 1.4 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:16 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_DISCRETEBITMAPPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_DISCRETEBITMAPPRIMITIVE2D_HXX + +#include <drawinglayer/primitive2d/primitivetools2d.hxx> +#include <vcl/bitmapex.hxx> + +////////////////////////////////////////////////////////////////////////////// +// DiscreteBitmapPrimitive2D class + +namespace drawinglayer +{ + namespace primitive2d + { + /** DiscreteBitmapPrimitive2D class + + This class defines a view-dependent BitmapPrimitive which has a + logic position for the top-left position and is always to be + painted in 1:1 pixel resolution. It will never be sheared, rotated + or scaled with the view. + */ + class DiscreteBitmapPrimitive2D : public ObjectAndViewTransformationDependentPrimitive2D + { + private: + /// the RGBA Bitmap-data + BitmapEx maBitmapEx; + + /** the top-left object position */ + basegfx::B2DPoint maTopLeft; + + protected: + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + public: + /// constructor + DiscreteBitmapPrimitive2D( + const BitmapEx& rBitmapEx, + const basegfx::B2DPoint& rTopLeft); + + /// data read access + const BitmapEx& getBitmapEx() const { return maBitmapEx; } + const basegfx::B2DPoint& getTopLeft() const { return maTopLeft; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + + /// provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PRIMITIVE2D_DISCRETEBITMAPPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx index 8d5d089f5800..d287482389b5 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx @@ -103,6 +103,12 @@ #define PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 52) #define PRIMITIVE2D_ID_HITTESTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 53) #define PRIMITIVE2D_ID_INVERTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 54) +#define PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 55) +#define PRIMITIVE2D_ID_WALLPAPERBITMAPPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 56) +#define PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 57) +#define PRIMITIVE2D_ID_TEXTCHARACTERSTRIKEOUTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 58) +#define PRIMITIVE2D_ID_TEXTGEOMETRYSTRIKEOUTPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 59) +#define PRIMITIVE2D_ID_EPSPRIMITIVE2D (PRIMITIVE2D_ID_RANGE_DRAWINGLAYER| 60) ////////////////////////////////////////////////////////////////////////////// diff --git a/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx index e0da8a36c3f5..c27b6874891f 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/embedded3dprimitive2d.hxx @@ -42,52 +42,65 @@ #include <basegfx/matrix/b2dhommatrix.hxx> ////////////////////////////////////////////////////////////////////////////// -// BackgroundColorPrimitive2D class +// Embedded3DPrimitive2D class namespace drawinglayer { namespace primitive2d { - class Embedded3DPrimitive2D : public BasePrimitive2D + /** Embedded3DPrimitive2D class + + This is a helper primitive which allows embedding of single 3D + primitives to the 2D primitive logic. It will get the scene it's + involved and thus the 3D transformation. With this information it + is able to provide 2D range data for a 3D primitive. + + This primitive will not be visualized and decomposes to a yellow + 2D rectangle to visualize that this should never be visualized + */ + class Embedded3DPrimitive2D : public BufferedDecompositionPrimitive2D { private: - // the sequence of 3d primitives + /// the sequence of 3d primitives primitive3d::Primitive3DSequence mxChildren3D; - // the 2D scene object transformation + /// the 2D scene object transformation basegfx::B2DHomMatrix maObjectTransformation; - // the 3D transformations + /// the 3D transformations geometry::ViewInformation3D maViewInformation3D; - // if the embedded 3D primitives contain shadow, these parameters are needed - // to extract the shadow wich is a sequence od 2D primitives and may expand - // the 2D range. Since every single 3D object in a scene may individually - // have shadow or not, these values need to be provided and prepared. The shadow - // distance itself (a 2D transformation) is part of the 3D shadow definition + /** if the embedded 3D primitives contain shadow, these parameters are needed + to extract the shadow wich is a sequence od 2D primitives and may expand + the 2D range. Since every single 3D object in a scene may individually + have shadow or not, these values need to be provided and prepared. The shadow + distance itself (a 2D transformation) is part of the 3D shadow definition + */ basegfx::B3DVector maLightNormal; double mfShadowSlant; basegfx::B3DRange maScene3DRange; - // the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked) + /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked) Primitive2DSequence maShadowPrimitives; - // #i96669# add simple range buffering for this primitive + /// #i96669# add simple range buffering for this primitive basegfx::B2DRange maB2DRange; - // bitfield - // flag if given 3D geometry is already cheched for shadow definitions and 2d shadows - // are created in maShadowPrimitives + /// bitfield + /** flag if given 3D geometry is already cheched for shadow definitions and 2d shadows + are created in maShadowPrimitives + */ unsigned mbShadow3DChecked : 1; - // private helpers + /// private helpers bool impGetShadow3D(const geometry::ViewInformation2D& rViewInformation) const; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor Embedded3DPrimitive2D( const primitive3d::Primitive3DSequence& rxChildren3D, const basegfx::B2DHomMatrix& rObjectTransformation, @@ -96,7 +109,7 @@ namespace drawinglayer double fShadowSlant, const basegfx::B3DRange& rScene3DRange); - // get data + /// get data const primitive3d::Primitive3DSequence& getChildren3D() const { return mxChildren3D; } const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; } @@ -104,13 +117,13 @@ namespace drawinglayer double getShadowSlant() const { return mfShadowSlant; } const basegfx::B3DRange& getScene3DRange() const { return maScene3DRange; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/epsprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/epsprimitive2d.hxx new file mode 100644 index 000000000000..0ebb29e153ec --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/epsprimitive2d.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: backgroundcolorprimitive2d.hxx,v $ + * + * $Revision: 1.3 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:16 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EPSPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EPSPRIMITIVE2D_HXX + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <vcl/gfxlink.hxx> +#include <vcl/gdimtf.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + /** EpsPrimitive2D class */ + class EpsPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /// the geometry definition + basegfx::B2DHomMatrix maEpsTransform; + + /// the Eps content definition + GfxLink maGfxLink; + + /// the replacement content definition + GDIMetaFile maMetaFile; + + protected: + /// create local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + public: + /// constructor + EpsPrimitive2D( + const basegfx::B2DHomMatrix& rEpsTransform, + const GfxLink& rGfxLink, + const GDIMetaFile& rMetaFile); + + /// data read access + const basegfx::B2DHomMatrix& getEpsTransform() const { return maEpsTransform; } + const GfxLink& getGfxLink() const { return maGfxLink; } + const GDIMetaFile& getMetaFile() const { return maMetaFile; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + + /// get B2Drange + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_EPSPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive2d/fillbitmapprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/fillbitmapprimitive2d.hxx index 1811b9bfaad9..7d2b084a9356 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/fillbitmapprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/fillbitmapprimitive2d.hxx @@ -47,32 +47,49 @@ namespace drawinglayer { namespace primitive2d { - class FillBitmapPrimitive2D : public BasePrimitive2D + /** FillBitmapPrimitive2D class + + This class defines a bitmap filling for a rectangular area. The + Range is defined by the Transformation, the fill by the FillBitmapAttribute. + There, the fill consists of a Bitmap (not transparent) defining the fill data + and a Point/Vector pair defining the relative position/size [0.0 .. 1.0] + inside the area where the bitmap is positioned. A flag defines then if this + is tiled or not. + + Renderers should handle this primitive; it has a geometrically correct + decomposition, but on pixel oututs the areas where the tiled pieces are + aligned tend to show up (one overlapping or empty pixel) + */ + class FillBitmapPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the geometric definition basegfx::B2DHomMatrix maTransformation; + + /// the fill attributes attribute::FillBitmapAttribute maFillBitmap; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor FillBitmapPrimitive2D( const basegfx::B2DHomMatrix& rTransformation, const attribute::FillBitmapAttribute& rFillBitmap); - // get data + /// data read access const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } const attribute::FillBitmapAttribute& getFillBitmap() const { return maFillBitmap; } - // compare operator + /// compare operator virtual bool operator==( const BasePrimitive2D& rPrimitive ) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/fillgradientprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/fillgradientprimitive2d.hxx index ef5a52c6ddcf..0fd084c6fad0 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/fillgradientprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/fillgradientprimitive2d.hxx @@ -40,38 +40,77 @@ #include <drawinglayer/attribute/fillattribute.hxx> ////////////////////////////////////////////////////////////////////////////// -// FillbitmapPrimitive2D class +// predefines + +namespace basegfx { class B2DPolygon; } + +////////////////////////////////////////////////////////////////////////////// +// FillGradientPrimitive2D class namespace drawinglayer { namespace primitive2d { - class FillGradientPrimitive2D : public BasePrimitive2D + /** FillGradientPrimitive2D class + + This class defines a gradient filling for a rectangular area. The + Range is defined by the Transformation, the gradient by the FillGradientAttribute. + + The decomposition will deliver the decomposed gradient, e.g. for an ellipse + gradient the various ellipses in various color steps will be created. + + I have added functionality to create both versions of filled decompositions: + Those who overlap and non-overlapping ones. The overlapping version is the + default one since it works with and without AntiAliasing. The non-overlapping + version is used in the MetafilePrimitive2D decomposition when the old XOR + paint was recorded. + */ + class FillGradientPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the geometric definition basegfx::B2DRange maObjectRange; + + /// the gradient definition attribute::FillGradientAttribute maFillGradient; + /// local helpers + void generateMatricesAndColors( + std::vector< basegfx::B2DHomMatrix >& rMatrices, + std::vector< basegfx::BColor >& rColors) const; + Primitive2DSequence createOverlappingFill( + const std::vector< basegfx::B2DHomMatrix >& rMatrices, + const std::vector< basegfx::BColor >& rColors, + const basegfx::B2DPolygon& rUnitPolygon) const; + Primitive2DSequence createNonOverlappingFill( + const std::vector< basegfx::B2DHomMatrix >& rMatrices, + const std::vector< basegfx::BColor >& rColors, + const basegfx::B2DPolygon& rUnitPolygon) const; + protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local helper + Primitive2DSequence createFill(bool bOverlapping) const; + + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor FillGradientPrimitive2D( const basegfx::B2DRange& rObjectRange, const attribute::FillGradientAttribute& rFillGradient); - // get data + /// data read access const basegfx::B2DRange& getObjectRange() const { return maObjectRange; } const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx index 04410429d4a3..1df3bb103eb0 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/fillhatchprimitive2d.hxx @@ -40,41 +40,56 @@ #include <drawinglayer/attribute/fillattribute.hxx> ////////////////////////////////////////////////////////////////////////////// -// FillbitmapPrimitive2D class +// FillHatchPrimitive2D class namespace drawinglayer { namespace primitive2d { - class FillHatchPrimitive2D : public BasePrimitive2D + /** FillHatchPrimitive2D class + + This class defines a hatch filling for a rectangular area. The + Range is defined by the Transformation, the hatch by the FillHatchAttribute. + If the background is to be filled, a flag in FillHatchAttribute is set and + the BColor defines the background color. + + The decomposition will deliver the hatch lines. + */ + class FillHatchPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the geometric definition basegfx::B2DRange maObjectRange; + + /// the hatch definition attribute::FillHatchAttribute maFillHatch; + + /// hatch background color (if used) basegfx::BColor maBColor; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor FillHatchPrimitive2D( const basegfx::B2DRange& rObjectRange, const basegfx::BColor& rBColor, const attribute::FillHatchAttribute& rFillHatch); - // get data + /// data read access const basegfx::B2DRange& getObjectRange() const { return maObjectRange; } const attribute::FillHatchAttribute& getFillHatch() const { return maFillHatch; } const basegfx::BColor& getBColor() const { return maBColor; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/graphicprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/graphicprimitive2d.hxx index 4d020a3ab1c5..6d3c0ebf702a 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/graphicprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/graphicprimitive2d.hxx @@ -46,18 +46,39 @@ namespace drawinglayer { namespace primitive2d { - class GraphicPrimitive2D : public BasePrimitive2D + /** GraphicPrimitive2D class + + Primitive to hold graphics defined by GraphicObject and GraphicAttr + combination. This includes MetaFiles and diverse pixel-oriented graphic + formats. It even includes animated GIFs, Croppings and other changes + defined in GraphicAttr. + + This makes the decomposition contain a wide variety of possibilites, + too. From a simple BitmapPrimitive over AnimatedSwitchPrimitive2D, + MetafilePrimitive2D (with and without embedding in a masking when e.g. + the Metafile is bigger than the geometry) and embeddings in + TransformPrimitive2D and MaskPrimitive2D for croppings. + + The primitive geometry area is defined by Transform. + */ + class GraphicPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the geometric definition basegfx::B2DHomMatrix maTransform; + + /// the GraphicObject with all it's content possibilities GraphicObject maGraphicObject; + + /// The GraphicAttr with all it's modification possibilities GraphicAttr maGraphicAttr; protected: - // local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor(s) GraphicPrimitive2D( const basegfx::B2DHomMatrix& rTransform, const GraphicObject& rGraphicObject, @@ -66,19 +87,19 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rTransform, const GraphicObject& rGraphicObject); - // get data + /// data read access const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } const GraphicObject& getGraphicObject() const { return maGraphicObject; } const GraphicAttr& getGraphicAttr() const { return maGraphicAttr; } bool isTransparent() const; - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/gridprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/gridprimitive2d.hxx index f0aad415bfce..4ba83fc75c88 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/gridprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/gridprimitive2d.hxx @@ -48,29 +48,47 @@ namespace drawinglayer { namespace primitive2d { - class GridPrimitive2D : public BasePrimitive2D + /** GridPrimitive2D class + + This primitive is specialized to Grid visualisation. The graphic definition + (Transform) contains the whole grid area, but will of course be combined + with the visible area (Viewport) when decomposed. Also a reolution-dependent + point reduction is used to not create too much grid visualisation data. This + makes this primitive highly view-dependent and it dynamically buffers + the last decomposition dependent from the Viewport used. + */ + class GridPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// The geometry definition for the grid area basegfx::B2DHomMatrix maTransform; + + /// grid layout definitions double mfWidth; double mfHeight; double mfSmallestViewDistance; double mfSmallestSubdivisionViewDistance; sal_uInt32 mnSubdivisionsX; sal_uInt32 mnSubdivisionsY; + + /// Grid color for single-pixel grid points basegfx::BColor maBColor; + + /// The Bitmap (with alpha) for grid cross points BitmapEx maCrossMarker; - // the last used object to view transformtion and the last Viewport, - // used from getDecomposition for decide buffering + /** the last used object to view transformtion and the last Viewport, + used from getDecomposition for decide buffering + */ basegfx::B2DHomMatrix maLastObjectToViewTransformation; basegfx::B2DRange maLastViewport; protected: - // create local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// create local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor GridPrimitive2D( const basegfx::B2DHomMatrix& rTransform, double fWidth, @@ -82,7 +100,7 @@ namespace drawinglayer const basegfx::BColor& rBColor, const BitmapEx& rCrossMarker); - // get data + /// data read access const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } double getWidth() const { return mfWidth; } double getHeight() const { return mfHeight; } @@ -93,16 +111,16 @@ namespace drawinglayer const basegfx::BColor& getBColor() const { return maBColor; } const BitmapEx& getCrossMarker() const { return maCrossMarker; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get 2d range + /// get 2d range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() - // Overload standard getDecomposition call to be view-dependent here + /// Overload standard getDecomposition call to be view-dependent here virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/groupprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/groupprimitive2d.hxx index 855e65ba98f8..89b49420a3e7 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/groupprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/groupprimitive2d.hxx @@ -45,27 +45,58 @@ namespace drawinglayer { namespace primitive2d { + /** GroupPrimitive2D class + + Baseclass for all grouping 2D primitives + + The grouping primitive in it's basic form is capable of holding + a child primitive content and returns it on decomposition on default. + It is used for two main purposes, but more may apply: + + - to transport extended information, e.g. for text classification, + see e.g. TextHierarchy*Primitive2D implementations. Since they + decompose to their child content, renderers not aware/interested + in that extra information will just ignore these primitives + + - to encapsulate common geometry, e.g. the ShadowPrimitive2D implements + applying a generic shadow to a child sequence by adding the needed + offset and color stuff in the decomposition + + In most cases the decomposition is straightforward, so by default + this primitive will not buffer the result and is not derived from + BufferedDecompositionPrimitive2D, but from BasePrimitive2D. + + A renderer has to take GroupPrimitive2D derivations into account which + are used to hold a state. + + Current Basic 2D StatePrimitives are: + + - AlphaPrimitive2D (objects with freely defined transparence) + - InvertPrimitive2D (for XOR) + - MaskPrimitive2D (for masking) + - ModifiedColorPrimitive2D (for a stack of color modifications) + - TransformPrimitive2D (for a transformation stack) + */ class GroupPrimitive2D : public BasePrimitive2D { private: - // the children. Declared private since this shall never be changed at all after construction + /// the children. Declared private since this shall never be changed at all after construction Primitive2DSequence maChildren; - protected: - // local decomposition. Implementation will just return children - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; - public: - // constructor + /// constructor GroupPrimitive2D(const Primitive2DSequence& rChildren); - // data access + /// data read access const Primitive2DSequence& getChildren() const { return maChildren; } - // compare operator + /// compare operator virtual bool operator==( const BasePrimitive2D& rPrimitive ) const; - // provide unique ID + /// local decomposition. Implementation will just return children + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx index 4e8357a3eac1..a1171cb846e0 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/helplineprimitive2d.hxx @@ -47,32 +47,52 @@ namespace drawinglayer { namespace primitive2d { + /** HelplineStyle2D definition + + The available styles of Helplines + */ enum HelplineStyle2D { HELPLINESTYLE2D_POINT, HELPLINESTYLE2D_LINE }; - class HelplinePrimitive2D : public BasePrimitive2D + /** HelplinePrimitive2D class + + This primitive provides a view-dependent helpline definition. The Helpline + is defined by a line equation (Point and vector) and a style. When the style + is a line, dependent from Viewport the visible part of that Helpline is + constructed. For Point, a cross is constructed. This primitive is highly + view-dependent. + + The visualisation uses the two given colors to create a dashed line with + the given dash length. + */ + class HelplinePrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// Helpline geometry definition basegfx::B2DPoint maPosition; basegfx::B2DVector maDirection; HelplineStyle2D meStyle; + + /// Helpline style definition basegfx::BColor maRGBColA; basegfx::BColor maRGBColB; double mfDiscreteDashLength; - // the last used object to view transformtion and the last Viewport, - // used from getDecomposition for decide buffering + /** the last used object to view transformtion and the last Viewport, + used from getDecomposition for decide buffering + */ basegfx::B2DHomMatrix maLastObjectToViewTransformation; basegfx::B2DRange maLastViewport; protected: - // create local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// create local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor HelplinePrimitive2D( const basegfx::B2DPoint& rPosition, const basegfx::B2DVector& rDirection, @@ -81,7 +101,7 @@ namespace drawinglayer const basegfx::BColor& aRGBColB, double fDiscreteDashLength); - // get data + /// data read access const basegfx::B2DPoint getPosition() const { return maPosition; } const basegfx::B2DVector getDirection() const { return maDirection; } HelplineStyle2D getStyle() const { return meStyle; } @@ -89,13 +109,13 @@ namespace drawinglayer const basegfx::BColor& getRGBColB() const { return maRGBColB; } double getDiscreteDashLength() const { return mfDiscreteDashLength; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() - // Overload standard getDecomposition call to be view-dependent here + /// Overload standard getDecomposition call to be view-dependent here virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/hittestprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/hittestprimitive2d.hxx index 2bbcad315eb3..3b69c685c985 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/hittestprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/hittestprimitive2d.hxx @@ -44,30 +44,35 @@ namespace drawinglayer { namespace primitive2d { - // This primitive is used to represent geometry for non-visible objects, - // e.g. a PresObj's outline. To still be able to use primitives for HitTest - // functionality, the 2d decompositions will produce an as much as possible - // simplified line geometry encapsulated in this primtive when there is no - // line geometry. In a further enchanced version this may change to 'if neither - // filled nor lines' creation criteria. The whole primitive decomposes to nothing, - // so no one not knowing it will be influenced. Only helper processors for hit test - // (and maybe BoundRect extractors) will use it and it's children subcontent. + /** HitTestPrimitive2D class + + This primitive is used to represent geometry for non-visible objects, + e.g. a PresObj's outline. To still be able to use primitives for HitTest + functionality, the 2d decompositions will produce an as much as possible + simplified line geometry encapsulated in this primtive when there is no + line geometry. In a further enchanced version this may change to 'if neither + filled nor lines' creation criteria. The whole primitive decomposes to nothing, + so no one not knowing it will be influenced. Only helper processors for hit test + (and maybe BoundRect extractors) will use it and it's children subcontent. + */ class HitTestPrimitive2D : public GroupPrimitive2D { - protected: - // local decomposition. Implementation will return empty Primitive2DSequence - // since this is no visualisation data - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; - public: + /// constructor HitTestPrimitive2D(const Primitive2DSequence& rChildren); - // despite returning an empty decomposition since it's no visualisation data, - // range calculation is intended to use invisible replacement geometry, so - // the local implementation will return the children's range + /** despite returning an empty decomposition since it's no visualisation data, + range calculation is intended to use invisible replacement geometry, so + the local implementation will return the children's range + */ virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /** local decomposition. Implementation will return empty Primitive2DSequence + since this is no visualisation data + */ + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/invertprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/invertprimitive2d.hxx index ae7a316e03da..85f1c6510c5a 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/invertprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/invertprimitive2d.hxx @@ -44,12 +44,23 @@ namespace drawinglayer { namespace primitive2d { + /** InvertPrimitive2D class + + This is a helper class which encapsulates geometry that should be + painted XOR, e.g. old cursor visualisations. It decomposes to + it's content, so when not supporting it, the contained geometry + will be visualized normally. + Unfortunately this is still needed, but hard to support on various + systems. XOR painting needs read access to the target, so modern + graphic systems tend to not support it anymore. + */ class InvertPrimitive2D : public GroupPrimitive2D { public: + /// constructor InvertPrimitive2D(const Primitive2DSequence& rChildren); - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/markerarrayprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/markerarrayprimitive2d.hxx index 350471f4aff3..cc4c054f8bb3 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/markerarrayprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/markerarrayprimitive2d.hxx @@ -41,38 +41,55 @@ #include <vcl/bitmapex.hxx> ////////////////////////////////////////////////////////////////////////////// -// MarkerPrimitive2D class +// MarkerArrayPrimitive2D class namespace drawinglayer { namespace primitive2d { - class MarkerArrayPrimitive2D : public BasePrimitive2D + /** MarkerArrayPrimitive2D class + + This primtive defines an array of markers. Their size is defined + in pixels and independent from the view transformation which makes + this primitive highly view-dependent. It is also transformation + invariant, so that the bitmap is always visualized unscaled and + unrotated. + It is used e.g. for grid position visualisation. The given Bitmap + (with alpha) is defined to be visible centered at each of the given + positions. + It decomposes to the needed number of BitmapPrimitive2D's, so it would + be efficient to handle it directly in a renderer. + */ + class MarkerArrayPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the positions for the marker std::vector< basegfx::B2DPoint > maPositions; + + /// the marker definintion to visualize BitmapEx maMarker; protected: - // create local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// create local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor MarkerArrayPrimitive2D( const std::vector< basegfx::B2DPoint >& rPositions, const BitmapEx& rMarker); - // get data + /// data read access const std::vector< basegfx::B2DPoint >& getPositions() const { return maPositions; } const BitmapEx& getMarker() const { return maMarker; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/maskprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/maskprimitive2d.hxx index 9be17376941e..e5cb12e6e87c 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/maskprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/maskprimitive2d.hxx @@ -45,23 +45,42 @@ namespace drawinglayer { namespace primitive2d { + /** MaskPrimitive2D class + + This is the central masking primitive. It's a grouping + primitive and contains a PolyPolygon which defines the visible + area. Only visualisation parts of the Child primitive sequence + inside of the mask PolyPolygon is defined to be visible. + + This primitive should be handled by a renderer. If it is not handled, + it decomposes to it's Child content, and thus the visualisation would + contaiun no clips. + + The geometrc range of this primitive is completely defined by the Mask + PolyPolygon since by definition nothing outside of the mask is visible. + */ class MaskPrimitive2D : public GroupPrimitive2D { private: + /// the mask PolyPolygon basegfx::B2DPolyPolygon maMask; public: + /// constructor MaskPrimitive2D( const basegfx::B2DPolyPolygon& rMask, const Primitive2DSequence& rChildren); - // get data + /// data read access const basegfx::B2DPolyPolygon& getMask() const { return maMask; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// get range + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/mediaprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/mediaprimitive2d.hxx index 019fdc69bd3f..e5f884f09294 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/mediaprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/mediaprimitive2d.hxx @@ -46,38 +46,55 @@ namespace drawinglayer { namespace primitive2d { - class MediaPrimitive2D : public BasePrimitive2D + /** MediaPrimitive2D class + + This is a unified primitive for Media visualisation, e.g. animations + or sounds. It's geometry is defined by Transform. For conveinience, + it also contains a discrete border size (aka Pixels) which will be added + if used. This makes it a view-dependent primitive. It also gets a filled + background and the decomposition will try to create a graphic representation + if te content (defined by the URL), e.g. a still frome for animated stuff. + */ + class MediaPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the geometry definition basegfx::B2DHomMatrix maTransform; + + /// the content definition rtl::OUString maURL; + + /// style: background color basegfx::BColor maBackgroundColor; + + /// discrete border (in 'pixels') sal_uInt32 mnDiscreteBorder; protected: - // local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor MediaPrimitive2D( const basegfx::B2DHomMatrix& rTransform, const rtl::OUString& rURL, const basegfx::BColor& rBackgroundColor, sal_uInt32 nDiscreteBorder); - // get data + /// data read access const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } const rtl::OUString& getURL() const { return maURL; } const basegfx::BColor& getBackgroundColor() const { return maBackgroundColor; } sal_uInt32 getDiscreteBorder() const { return mnDiscreteBorder; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/metafileprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/metafileprimitive2d.hxx index 23eb5dd1b36e..0cbd7e4628cb 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/metafileprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/metafileprimitive2d.hxx @@ -47,28 +47,55 @@ namespace drawinglayer { namespace primitive2d { - class MetafilePrimitive2D : public BasePrimitive2D + /** MediaPrimitive2D class + + This is the MetaFile representing primitive. It's geometry is defined + by MetaFileTransform. The content (defined by MetaFile) will be scaled + to the geometric definiton by using PrefMapMode and PrefSize of the + Metafile. + + It has shown that this not always guarantees that all Metafile content + is inside the geometric definition, but this primitive defines that this + is the case to allow a getB2DRange implementation. If it cannot be + guaranteed that the Metafile is inside the geometric definition, it should + be embedded to a MaskPrimitive2D. + + This primitive has no decomposition yet, so when not supported by a renderer, + it will not be visualized. + + In the future, a decomposition implementation would be appreciated and would + have many advantages; Metafile would no longer have to be rendered by + sub-systems and a standard way for converting Metafiles would exist. + */ + class MetafilePrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the geometry definition basegfx::B2DHomMatrix maMetaFileTransform; + + /// the content definition GDIMetaFile maMetaFile; + protected: + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor MetafilePrimitive2D( const basegfx::B2DHomMatrix& rMetaFileTransform, const GDIMetaFile& rMetaFile); - // get data + /// data read access const basegfx::B2DHomMatrix& getTransform() const { return maMetaFileTransform; } const GDIMetaFile& getMetaFile() const { return maMetaFile; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx index 903ba89c9a5b..e93dd523e0b7 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx @@ -45,23 +45,42 @@ namespace drawinglayer { namespace primitive2d { + /** ModifiedColorPrimitive2D class + + This primitive is a grouping primitive and allows to define + how the colors of it's child content shall be modified for + visualisation. This can be (and is) used e.g. for generic shadow + visualisation by forcing all color usages of the contained + sub-content to the shadow color. + + For the possibilities of color modifications, please refer + to the basegfx::BColorModifier definitions in basegfx. For + processing there is tooling in basegfx to build a stack of + BColorModifiers to always be able to proccess the correct + colors. + + If a renderer does not handle this primitive, the content will + be visualized unchanged. + */ class ModifiedColorPrimitive2D : public GroupPrimitive2D { private: + /// The ColorModifier to use basegfx::BColorModifier maColorModifier; public: + /// constructor ModifiedColorPrimitive2D( const Primitive2DSequence& rChildren, const basegfx::BColorModifier& rColorModifier); - // get data + /// data read access const basegfx::BColorModifier& getColorModifier() const { return maColorModifier; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/pagepreviewprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/pagepreviewprimitive2d.hxx index edba5455ff0a..5eca0ac2ab13 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/pagepreviewprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/pagepreviewprimitive2d.hxx @@ -36,7 +36,7 @@ #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PAGEPREVIEWPRIMITIVE2D_HXX #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PAGEPREVIEWPRIMITIVE2D_HXX -#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <com/sun/star/drawing/XDrawPage.hpp> #include <basegfx/matrix/b2dhommatrix.hxx> @@ -46,57 +46,66 @@ namespace drawinglayer { namespace primitive2d { - // This primitive is needed to have the correct XDrawPage as ViewInformation for decomposing - // the page contents (given as childs of the GroupPrimitive2D here) if these contain e.g. - // view-dependent (in this case XDrawPage-dependent) text fields like PageNumber. If You want - // those primitives to be visualized correctly, Your renderer needs to locally correct it's - // ViewInformation2D to reference the new XDrawPage. - class PagePreviewPrimitive2D : public GroupPrimitive2D + /** PagePreviewPrimitive2D class + + This primitive is needed to have the correct XDrawPage as ViewInformation for decomposing + the page contents (given as PageContent here) if these contain e.g. + view-dependent (in this case XDrawPage-dependent) text fields like PageNumber. If You want + those primitives to be visualized correctly, Your renderer needs to locally correct it's + ViewInformation2D to reference the new XDrawPage. + */ + class PagePreviewPrimitive2D : public BufferedDecompositionPrimitive2D { private: - // the XDrawPage visualized by this primitive. When we go forward with primitives - // this will not only be used by the renderers to provide the correct decompose - // graphic attribute context, but also to completely create the page's sub-content. + /** the XDrawPage visualized by this primitive. When we go forward with primitives + this will not only be used by the renderers to provide the correct decompose + graphic attribute context, but also to completely create the page's sub-content. + */ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > mxDrawPage; - // the own geometry + /// the PageContent + Primitive2DSequence maPageContent; + + /// the own geometry basegfx::B2DHomMatrix maTransform; - // content width and height + /// content width and height double mfContentWidth; double mfContentHeight; - // bitfield - // flag to allow keeping the aspect ratio + /// bitfield + /// flag to allow keeping the aspect ratio unsigned mbKeepAspectRatio : 1; protected: - // local decomposition. Implementation will just return children - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. Implementation will just return children + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PagePreviewPrimitive2D( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage, const basegfx::B2DHomMatrix& rTransform, double fContentWidth, double fContentHeight, - const Primitive2DSequence& rChildren, + const Primitive2DSequence& rPageContent, bool bKeepAspectRatio); - // get data + /// data read access const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& getXDrawPage() const { return mxDrawPage; } + const Primitive2DSequence& getPageContent() const { return maPageContent; } const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } double getContentWidth() const { return mfContentWidth; } double getContentHeight() const { return mfContentHeight; } bool getKeepAspectRatio() const { return mbKeepAspectRatio; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // own getB2DRange + /// own getB2DRange virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/pointarrayprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/pointarrayprimitive2d.hxx index bdd4142b0584..793c96444bac 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/pointarrayprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/pointarrayprimitive2d.hxx @@ -40,37 +40,51 @@ #include <basegfx/color/bcolor.hxx> ////////////////////////////////////////////////////////////////////////////// -// MarkerPrimitive2D class +// PointArrayPrimitive2D class namespace drawinglayer { namespace primitive2d { + /** PointArrayPrimitive2D class + + This primitive defines single,discrete 'pixels' for the given + positions in the given color. This makes it view-dependent since + the logic size of a 'pixel' depends on the view transformation. + + This is one of the non-decomposable primitives, so a renderer + should proccess it (Currently it is only used for grid visualisation, + but this may change). + */ class PointArrayPrimitive2D : public BasePrimitive2D { private: + /// the array of positions std::vector< basegfx::B2DPoint > maPositions; + + /// the color to use basegfx::BColor maRGBColor; - // #i96669# add simple range buffering for this primitive - basegfx::B2DRange maB2DRange; + /// #i96669# add simple range buffering for this primitive + basegfx::B2DRange maB2DRange; public: + /// constructor PointArrayPrimitive2D( const std::vector< basegfx::B2DPoint >& rPositions, const basegfx::BColor& rRGBColor); - // get data + /// data read access const std::vector< basegfx::B2DPoint >& getPositions() const { return maPositions; } const basegfx::BColor& getRGBColor() const { return maRGBColor; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx index 48ec5e80aa09..4c6f5b49bf01 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/polygonprimitive2d.hxx @@ -49,26 +49,40 @@ namespace drawinglayer { namespace primitive2d { + /** PolygonHairlinePrimitive2D class + + This primitive defines a Hairline. Since hairlines are view-dependent, + this primitive is view-dependent, too. + + This is one of the non-decomposable primitives, so a renderer + should proccess it. + */ class PolygonHairlinePrimitive2D : public BasePrimitive2D { private: + /// the hairline geometry basegfx::B2DPolygon maPolygon; + + /// the hairline color basegfx::BColor maBColor; public: - PolygonHairlinePrimitive2D(const basegfx::B2DPolygon& rPolygon, const basegfx::BColor& rBColor); + /// constructor + PolygonHairlinePrimitive2D( + const basegfx::B2DPolygon& rPolygon, + const basegfx::BColor& rBColor); - // get data + /// data read access const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; } const basegfx::BColor& getBColor() const { return maBColor; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -81,44 +95,59 @@ namespace drawinglayer { namespace primitive2d { - class PolygonMarkerPrimitive2D : public BasePrimitive2D + /** PolygonMarkerPrimitive2D class + + This primitive defines a two-colored marker hairline which is + dashed with the given dash length. Since hairlines are view-dependent, + this primitive is view-dependent, too. + + It will be decomposed to the needed PolygonHairlinePrimitive2D if + not handled directly by a renderer. + */ + class PolygonMarkerPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the marker hairline geometry basegfx::B2DPolygon maPolygon; + + /// the two colors basegfx::BColor maRGBColorA; basegfx::BColor maRGBColorB; + + /// the dash distance in 'pixels' double mfDiscreteDashLength; - // decomposition is view-dependent, remember last InverseObjectToViewTransformation + /// decomposition is view-dependent, remember last InverseObjectToViewTransformation basegfx::B2DHomMatrix maLastInverseObjectToViewTransformation; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolygonMarkerPrimitive2D( const basegfx::B2DPolygon& rPolygon, const basegfx::BColor& rRGBColorA, const basegfx::BColor& rRGBColorB, double fDiscreteDashLength); - // get data + /// data read access const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; } const basegfx::BColor& getRGBColorA() const { return maRGBColorA; } const basegfx::BColor& getRGBColorB() const { return maRGBColorB; } double getDiscreteDashLength() const { return mfDiscreteDashLength; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // get local decomposition. Overloaded since this decomposition is view-dependent + /// get local decomposition. Overloaded since this decomposition is view-dependent virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -131,39 +160,52 @@ namespace drawinglayer { namespace primitive2d { - class PolygonStrokePrimitive2D : public BasePrimitive2D + /** PolygonStrokePrimitive2D class + + This primitive defines a line with line width, line join, line color + and stroke attributes. It will be decomposed dependent on the definition + to the needed primitives, e.g. filled PolyPolygons for fat lines. + */ + class PolygonStrokePrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the line geometry basegfx::B2DPolygon maPolygon; + + /// the line attributes like width, join and color attribute::LineAttribute maLineAttribute; + + /// the line stroking (if used) attribute::StrokeAttribute maStrokeAttribute; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolygonStrokePrimitive2D( const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, const attribute::StrokeAttribute& rStrokeAttribute); + /// constructor without stroking PolygonStrokePrimitive2D( const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute); - // get data + /// data read access basegfx::B2DPolygon getB2DPolygon() const { return maPolygon; } const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -176,17 +218,24 @@ namespace drawinglayer { namespace primitive2d { + /** PolygonWavePrimitive2D class + + This primitive defines a waveline based on a PolygonStrokePrimitive2D + where the wave is defined by wave width and wave length. + */ class PolygonWavePrimitive2D : public PolygonStrokePrimitive2D { private: + /// wave definition double mfWaveWidth; double mfWaveHeight; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolygonWavePrimitive2D( const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, @@ -194,23 +243,24 @@ namespace drawinglayer double fWaveWidth, double fWaveHeight); + /// constructor without stroking PolygonWavePrimitive2D( const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, double fWaveWidth, double fWaveHeight); - // get data + /// data read access double getWaveWidth() const { return mfWaveWidth; } double getWaveHeight() const { return mfWaveHeight; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -223,17 +273,25 @@ namespace drawinglayer { namespace primitive2d { + /** PolygonStrokeArrowPrimitive2D class + + This primitive defines a PolygonStrokePrimitive2D which is extended + eventually by start and end definitions which are normally used for + arrows. + */ class PolygonStrokeArrowPrimitive2D : public PolygonStrokePrimitive2D { private: + /// geometric definitions for line start and end attribute::LineStartEndAttribute maStart; attribute::LineStartEndAttribute maEnd; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolygonStrokeArrowPrimitive2D( const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, @@ -241,23 +299,24 @@ namespace drawinglayer const attribute::LineStartEndAttribute& rStart, const attribute::LineStartEndAttribute& rEnd); + /// constructor without stroking PolygonStrokeArrowPrimitive2D( const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, const attribute::LineStartEndAttribute& rStart, const attribute::LineStartEndAttribute& rEnd); - // get data + /// data read access const attribute::LineStartEndAttribute& getStart() const { return maStart; } const attribute::LineStartEndAttribute& getEnd() const { return maEnd; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx index 9991a3109e10..187e89f42e97 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx @@ -51,30 +51,40 @@ namespace drawinglayer { namespace primitive2d { - class PolyPolygonHairlinePrimitive2D : public BasePrimitive2D + /** PolyPolygonHairlinePrimitive2D class + + This primitive defines a multi-PolygonHairlinePrimitive2D and is + just for convenience. The definition is not different from the single + defined PolygonHairlinePrimitive2Ds. + */ + class PolyPolygonHairlinePrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the hairline geometry basegfx::B2DPolyPolygon maPolyPolygon; + + /// the hairline color basegfx::BColor maBColor; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolyPolygonHairlinePrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rBColor); - // get data + /// data read access basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; } const basegfx::BColor& getBColor() const { return maBColor; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -87,38 +97,50 @@ namespace drawinglayer { namespace primitive2d { - class PolyPolygonMarkerPrimitive2D : public BasePrimitive2D + /** PolyPolygonMarkerPrimitive2D class + + This primitive defines a multi-PolygonMarkerPrimitive2D and is + just for convenience. The definition is not different from the single + defined PolygonMarkerPrimitive2Ds. + */ + class PolyPolygonMarkerPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the marker hairline geometry basegfx::B2DPolyPolygon maPolyPolygon; + + /// the two colors basegfx::BColor maRGBColorA; basegfx::BColor maRGBColorB; + + /// the dash distance in 'pixels' double mfDiscreteDashLength; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolyPolygonMarkerPrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rRGBColorA, const basegfx::BColor& rRGBColorB, double fDiscreteDashLength); - // get data + // data read access basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; } const basegfx::BColor& getRGBColorA() const { return maRGBColorA; } const basegfx::BColor& getRGBColorB() const { return maRGBColorB; } double getDiscreteDashLength() const { return mfDiscreteDashLength; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -131,39 +153,52 @@ namespace drawinglayer { namespace primitive2d { - class PolyPolygonStrokePrimitive2D : public BasePrimitive2D + /** PolyPolygonStrokePrimitive2D class + + This primitive defines a multi-PolygonStrokePrimitive2D and is + just for convenience. The definition is not different from the single + defined PolygonStrokePrimitive2Ds. + */ + class PolyPolygonStrokePrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the line geometry basegfx::B2DPolyPolygon maPolyPolygon; + + /// the line attributes like width, join and color attribute::LineAttribute maLineAttribute; + + /// the line stroking (if used) attribute::StrokeAttribute maStrokeAttribute; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolyPolygonStrokePrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, const attribute::LineAttribute& rLineAttribute, const attribute::StrokeAttribute& rStrokeAttribute); + /// constructor without stroking PolyPolygonStrokePrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, const attribute::LineAttribute& rLineAttribute); - // get data + /// data read access basegfx::B2DPolyPolygon getB2DPolyPolygon() const { return maPolyPolygon; } const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -176,17 +211,25 @@ namespace drawinglayer { namespace primitive2d { + /** PolyPolygonStrokePrimitive2D class + + This primitive defines a multi-PolygonStrokeArrowPrimitive2D and is + just for convenience. The definition is not different from the single + defined PolygonStrokeArrowPrimitive2Ds. + */ class PolyPolygonStrokeArrowPrimitive2D : public PolyPolygonStrokePrimitive2D { private: + /// geometric definitions for line start and end attribute::LineStartEndAttribute maStart; attribute::LineStartEndAttribute maEnd; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolyPolygonStrokeArrowPrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, const attribute::LineAttribute& rLineAttribute, @@ -194,23 +237,24 @@ namespace drawinglayer const attribute::LineStartEndAttribute& rStart, const attribute::LineStartEndAttribute& rEnd); + /// constructor without stroking PolyPolygonStrokeArrowPrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, const attribute::LineAttribute& rLineAttribute, const attribute::LineStartEndAttribute& rStart, const attribute::LineStartEndAttribute& rEnd); - // get data + /// data read access const attribute::LineStartEndAttribute& getStart() const { return maStart; } const attribute::LineStartEndAttribute& getEnd() const { return maEnd; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -223,28 +267,38 @@ namespace drawinglayer { namespace primitive2d { + /** PolyPolygonColorPrimitive2D class + + This primitive defines a PolyPolygon filled with a single color. + This is one of the non-decomposable primitives, so a renderer + should proccess it. + */ class PolyPolygonColorPrimitive2D : public BasePrimitive2D { private: + /// the PolyPolygon geometry basegfx::B2DPolyPolygon maPolyPolygon; + + /// the polygon fill color basegfx::BColor maBColor; public: + /// constructor PolyPolygonColorPrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rBColor); - // get data + /// data read access const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } const basegfx::BColor& getBColor() const { return maBColor; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -257,28 +311,39 @@ namespace drawinglayer { namespace primitive2d { - class PolyPolygonGradientPrimitive2D : public PolyPolygonColorPrimitive2D + /** PolyPolygonColorPrimitive2D class + + This primitive defines a PolyPolygon filled with a gradient. The + decomosition will create a MaskPrimitive2D containing a + FillGradientPrimitive2D. + */ + class PolyPolygonGradientPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the PolyPolygon geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the gradient definition attribute::FillGradientAttribute maFillGradient; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolyPolygonGradientPrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, - const basegfx::BColor& rBColor, const attribute::FillGradientAttribute& rFillGradient); - // get data + /// data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -291,28 +356,44 @@ namespace drawinglayer { namespace primitive2d { - class PolyPolygonHatchPrimitive2D : public PolyPolygonColorPrimitive2D + /** PolyPolygonHatchPrimitive2D class + + This primitive defines a PolyPolygon filled with a hatch. The + decomosition will create a MaskPrimitive2D containing a + FillHatchPrimitive2D. + */ + class PolyPolygonHatchPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the PolyPolygon geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the hatch background color (if used) + basegfx::BColor maBackgroundColor; + + /// the hatch definition attribute::FillHatchAttribute maFillHatch; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolyPolygonHatchPrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, - const basegfx::BColor& rBColor, + const basegfx::BColor& rBackgroundColor, const attribute::FillHatchAttribute& rFillHatch); - // get data + /// data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } + const basegfx::BColor& getBackgroundColor() const { return maBackgroundColor; } const attribute::FillHatchAttribute& getFillHatch() const { return maFillHatch; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -325,28 +406,39 @@ namespace drawinglayer { namespace primitive2d { - class PolyPolygonBitmapPrimitive2D : public PolyPolygonColorPrimitive2D + /** PolyPolygonBitmapPrimitive2D class + + This primitive defines a PolyPolygon filled with bitmap data + (including alpha). The decomosition will create a MaskPrimitive2D + containing a FillBitmapPrimitive2D. + */ + class PolyPolygonBitmapPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// the PolyPolygon geometry + basegfx::B2DPolyPolygon maPolyPolygon; + + /// the bitmap fill definition (may include tiling) attribute::FillBitmapAttribute maFillBitmap; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor PolyPolygonBitmapPrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, - const basegfx::BColor& rBColor, const attribute::FillBitmapAttribute& rFillBitmap); - // get data + /// data read access + const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } const attribute::FillBitmapAttribute& getFillBitmap() const { return maFillBitmap; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx index bd561cbab21a..a095c558ba12 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/primitivetools2d.hxx @@ -37,70 +37,163 @@ #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PRIMITIVE2DTOOLS_HXX #include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> ////////////////////////////////////////////////////////////////////////////// -// tooling class for BasePrimitive2D baseed classes which are view-dependent -// regarding the size of a discrete unit. The implementation of get2DDecomposition -// guards the buffered local decomposition and ensures that a createLocalDecomposition -// implementation may use an up-to-date DiscreteUnit accessible using getDiscreteUnit() namespace drawinglayer { namespace primitive2d { - class DiscreteMetricDependentPrimitive2D : public BasePrimitive2D + /** DiscreteMetricDependentPrimitive2D class + + tooling class for BufferedDecompositionPrimitive2D baseed classes which are view-dependent + regarding the size of a discrete unit. The implementation of get2DDecomposition + guards the buffered local decomposition and ensures that a create2DDecomposition + implementation may use an up-to-date DiscreteUnit accessible using getDiscreteUnit() + */ + class DiscreteMetricDependentPrimitive2D : public BufferedDecompositionPrimitive2D { private: - // the last used fDiscreteUnit definitions for decomposition. Since this - // is checked and updated from get2DDecomposition() it will be current and - // usable in createLocalDecomposition() + /** the last used fDiscreteUnit definitions for decomposition. Since this + is checked and updated from get2DDecomposition() it will be current and + usable in create2DDecomposition() + */ double mfDiscreteUnit; public: + /// constructor DiscreteMetricDependentPrimitive2D() - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), mfDiscreteUnit(0.0) { } - // data access + /// data read access double getDiscreteUnit() const { return mfDiscreteUnit; } - // get local decomposition. Overloaded since this decomposition is view-dependent + /// get local decomposition. Overloaded since this decomposition is view-dependent virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; }; } // end of namespace primitive2d } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// -// tooling class for BasePrimitive2D baseed classes which are view-dependent -// regarding the viewport. The implementation of get2DDecomposition -// guards the buffered local decomposition and ensures that a createLocalDecomposition -// implementation may use an up-to-date Viewport accessible using getViewport() namespace drawinglayer { namespace primitive2d { - class ViewportDependentPrimitive2D : public BasePrimitive2D + /** ViewportDependentPrimitive2D class + + tooling class for BufferedDecompositionPrimitive2D baseed classes which are view-dependent + regarding the viewport. The implementation of get2DDecomposition + guards the buffered local decomposition and ensures that a create2DDecomposition + implementation may use an up-to-date Viewport accessible using getViewport() + */ + class ViewportDependentPrimitive2D : public BufferedDecompositionPrimitive2D { private: - // the last used Viewport definition for decomposition. Since this - // is checked and updated from get2DDecomposition() it will be current and - // usable in createLocalDecomposition() + /** the last used Viewport definition for decomposition. Since this + is checked and updated from get2DDecomposition() it will be current and + usable in create2DDecomposition() + */ basegfx::B2DRange maViewport; public: + /// constructor ViewportDependentPrimitive2D() - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maViewport() { } - // data access + /// data read access const basegfx::B2DRange& getViewport() const { return maViewport; } - // get local decomposition. Overloaded since this decomposition is view-dependent + /// get local decomposition. Overloaded since this decomposition is view-dependent + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + /** ViewTransformationDependentPrimitive2D class + + tooling class for BufferedDecompositionPrimitive2D based classes which are view-dependent + regarding the complete Viewtransformation. The implementation of get2DDecomposition + guards the buffered local decomposition and ensures that a create2DDecomposition + implementation may use an up-to-date ViewTransformation accessible using getViewTransformation() + */ + class ViewTransformationDependentPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /** the last used ViewTransformation definition for decomposition. Since this + is checked and updated from get2DDecomposition() it will be current and + usable in create2DDecomposition() + */ + basegfx::B2DHomMatrix maViewTransformation; + + public: + /// constructor + ViewTransformationDependentPrimitive2D() + : BufferedDecompositionPrimitive2D(), + maViewTransformation() + { + } + + /// data read access + const basegfx::B2DHomMatrix& getViewTransformation() const { return maViewTransformation; } + + /// get local decomposition. Overloaded since this decomposition is view-dependent + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + /** ObjectAndViewTransformationDependentPrimitive2D class + + tooling class for BufferedDecompositionPrimitive2D based classes which are view-dependent + and Object-Transform dependent. The implementation of get2DDecomposition + guards the buffered local decomposition and ensures that a create2DDecomposition + implementation may use an up-to-date ViewTransformation accessible using getViewTransformation() + and an object transformation via getObjectTransformation() + */ + class ObjectAndViewTransformationDependentPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /** the last used ViewTransformation and the last ObjectTransformation + definition for decomposition. Since this is checked and updated from + get2DDecomposition() it will be current and usable in create2DDecomposition() + */ + basegfx::B2DHomMatrix maViewTransformation; + basegfx::B2DHomMatrix maObjectTransformation; + + public: + /// constructor + ObjectAndViewTransformationDependentPrimitive2D() + : BufferedDecompositionPrimitive2D(), + maViewTransformation(), + maObjectTransformation() + { + } + + /// data read access + const basegfx::B2DHomMatrix& getViewTransformation() const { return maViewTransformation; } + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + + /// get local decomposition. Overloaded since this decomposition is view-dependent virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx index 8ffc9a332e5c..65d2bdf67f92 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/sceneprimitive2d.hxx @@ -49,33 +49,60 @@ namespace drawinglayer { namespace primitive2d { - class ScenePrimitive2D : public BasePrimitive2D + /** ScenePrimitive2D class + + This primitive defines a 3D scene as a 2D primitive and is the anchor point + for a 3D visualisation. The decomposition is view-dependent and will try to + re-use already rendered 3D content. + + The rendering is done using the default-3D renderer from basegfx which supports + AntiAliasing. + + The 2D primitive's geometric range is defined completely by the + ObjectTransformation combined with evtl. 2D shadows from the 3D objects. The + shadows of 3D objects are 2D polygons, projected with the 3D transformation. + + This is the class a renderer may process directly when he wants to implement + an own (e.g. system-specific) 3D renderer. + */ + class ScenePrimitive2D : public BufferedDecompositionPrimitive2D { private: - primitive3d::Primitive3DSequence mxChildren3D; // the 3d sub-primitives - attribute::SdrSceneAttribute maSdrSceneAttribute; // 3d scene attribute set - attribute::SdrLightingAttribute maSdrLightingAttribute; // lighting attribute set - basegfx::B2DHomMatrix maObjectTransformation; // object transformation for scene for 2d definition - geometry::ViewInformation3D maViewInformation3D; // scene transformation set and object transformation + /// the 3D geometry definition + primitive3d::Primitive3DSequence mxChildren3D; + + /// 3D scene attribute set + attribute::SdrSceneAttribute maSdrSceneAttribute; + + /// lighting attribute set + attribute::SdrLightingAttribute maSdrLightingAttribute; + + /// object transformation for scene for 2D definition + basegfx::B2DHomMatrix maObjectTransformation; + + /// scene transformation set and object transformation + geometry::ViewInformation3D maViewInformation3D; - // the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked) + /// the primitiveSequence for on-demand created shadow primitives (see mbShadow3DChecked) Primitive2DSequence maShadowPrimitives; - // bitfield - // flag if given 3D geometry is already cheched for shadow definitions and 2d shadows - // are created in maShadowPrimitives + /// bitfield + /** flag if given 3D geometry is already cheched for shadow definitions and 2d shadows + are created in maShadowPrimitives + */ unsigned mbShadow3DChecked : 1; - // the last used NewDiscreteSize and NewUnitVisiblePart definitions for decomposition + /// the last used NewDiscreteSize and NewUnitVisiblePart definitions for decomposition double mfOldDiscreteSizeX; double mfOldDiscreteSizeY; basegfx::B2DRange maOldUnitVisiblePart; - // the last created BitmapEx, e.g. for fast HitTest. This does not really need - // memory since BitmapEx is internally RefCounted + /** the last created BitmapEx, e.g. for fast HitTest. This does not really need + memory since BitmapEx is internally RefCounted + */ BitmapEx maOldRenderedBitmap; - // private helpers + /// private helpers bool impGetShadow3D(const geometry::ViewInformation2D& rViewInformation) const; void calculateDiscreteSizes( const geometry::ViewInformation2D& rViewInformation, @@ -84,28 +111,30 @@ namespace drawinglayer basegfx::B2DRange& rUnitVisibleRange) const; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: - // public helpers - // Geometry extractor. Shadow will be added as in createLocalDecomposition, but - // the 3D content is not converted to a bitmap visualisation but to projected 2D gemetry. This - // helper is useful e.g. for Contour extraction or HitTests. + /// public helpers + /** Geometry extractor. Shadow will be added as in create2DDecomposition, but + the 3D content is not converted to a bitmap visualisation but to projected 2D gemetry. This + helper is useful e.g. for Contour extraction or HitTests. + */ Primitive2DSequence getGeometry2D() const; Primitive2DSequence getShadow2D(const geometry::ViewInformation2D& rViewInformation) const; - // Fast HitTest which uses the last buffered BitmapEx from the last - // rendered area if available. The return value describes if the check - // could be done with the current information, so do NOT use o_rResult - // when it returns false. o_rResult will be changed on return true and - // then contains a definitive answer if content of this scene is hit or - // not. On return false, it is normally necessary to use the geometric - // HitTest (see CutFindProcessor usages). The given HitPoint - // has to be in logic coordinates in scene's ObjectCoordinateSystem. + /** Fast HitTest which uses the last buffered BitmapEx from the last + rendered area if available. The return value describes if the check + could be done with the current information, so do NOT use o_rResult + when it returns false. o_rResult will be changed on return true and + then contains a definitive answer if content of this scene is hit or + not. On return false, it is normally necessary to use the geometric + HitTest (see CutFindProcessor usages). The given HitPoint + has to be in logic coordinates in scene's ObjectCoordinateSystem. + */ bool tryToCheckLastVisualisationDirectHit(const basegfx::B2DPoint& rLogicHitPoint, bool& o_rResult) const; - // constructor/destructor + /// constructor ScenePrimitive2D( const primitive3d::Primitive3DSequence& rxChildren3D, const attribute::SdrSceneAttribute& rSdrSceneAttribute, @@ -113,23 +142,23 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rObjectTransformation, const geometry::ViewInformation3D& rViewInformation3D); - // get data + /// data ead access const primitive3d::Primitive3DSequence& getChildren3D() const { return mxChildren3D; } const attribute::SdrSceneAttribute& getSdrSceneAttribute() const { return maSdrSceneAttribute; } const attribute::SdrLightingAttribute& getSdrLightingAttribute() const { return maSdrLightingAttribute; } const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } const geometry::ViewInformation3D& getViewInformation3D() const { return maViewInformation3D; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() - // get local decomposition. Overloaded since this decomposition is view-dependent + /// get local decomposition. Overloaded since this decomposition is view-dependent virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/shadowprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/shadowprimitive2d.hxx index b749000ee566..0e3f7258441a 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/shadowprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/shadowprimitive2d.hxx @@ -46,33 +46,50 @@ namespace drawinglayer { namespace primitive2d { + /** ShadowPrimitive2D class + + This primitive defines a generic shadow geometry construction + for 2D objects. It decomposes to a TransformPrimitive2D embedded + into a ModifiedColorPrimitive2D. + + It's for primtive usage convenience, so that not everyone has + to implement the generic shadow construction by himself. + + The same geometry as sequence of primitives is used as geometry and + as shadow. Since these are RefCounted Uno-Api objects, no extra objects + are needed for the shadow itself; all the local decompositions of the + original geometry can be reused from the renderer for shadow visualisation. + */ class ShadowPrimitive2D : public GroupPrimitive2D { private: + /// the shadow transformation, normally just an offset basegfx::B2DHomMatrix maShadowTransform; - basegfx::BColor maShadowColor; - protected: - // create decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// the shadow color to which all geometry is to be forced + basegfx::BColor maShadowColor; public: + /// constructor ShadowPrimitive2D( const basegfx::B2DHomMatrix& rShadowTransform, const basegfx::BColor& rShadowColor, const Primitive2DSequence& rChildren); - // get data + /// data read access const basegfx::B2DHomMatrix& getShadowTransform() const { return maShadowTransform; } const basegfx::BColor& getShadowColor() const { return maShadowColor; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// create decomposition + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/structuretagprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/structuretagprimitive2d.hxx index 9ccb91e7bebd..c86e4c91bb86 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/structuretagprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/structuretagprimitive2d.hxx @@ -45,30 +45,34 @@ namespace drawinglayer { namespace primitive2d { - // This class is used to provode simple support for adding grouped - // pdf writer structured element information like used in sd from - // unomodel.cxx where a ViewObjectContactRedirector is used to add - // such information for diverse objects. - // This primitive encapsulates these and the VCLPdfRenderer uses it - // to apply the needed infos directly to the pdf export in a compatible - // way. - // If a renderer ignores this, it just decomposes to it's child - // content. + /** StructureTagPrimitive2D class + + This class is used to provode simple support for adding grouped + pdf writer structured element information like used in sd from + unomodel.cxx where a ViewObjectContactRedirector is used to add + such information for diverse objects. + This primitive encapsulates these and the VCLPdfRenderer uses it + to apply the needed infos directly to the pdf export in a compatible + way. + If a renderer ignores this, it just decomposes to it's child + content. + */ class StructureTagPrimitive2D : public GroupPrimitive2D { private: - // the PDF structure element this grouping represents + /// the PDF structure element this grouping represents vcl::PDFWriter::StructElement maStructureElement; public: + /// constructor StructureTagPrimitive2D( const vcl::PDFWriter::StructElement& rStructureElement, const Primitive2DSequence& rChildren); - // data access + /// data read access const vcl::PDFWriter::StructElement& getStructureElement() const { return maStructureElement; } - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx index 69023873760a..fe41c2e1824a 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx @@ -37,13 +37,14 @@ #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTDECORATEDPRIMITIVE2D_HXX #include <drawinglayer/primitive2d/textprimitive2d.hxx> +#include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// // predeclarations -namespace basegfx { - class DecomposedB2DHomMatrixContainer; -} // end of namespace basegfx +namespace basegfx { namespace tools { + class B2DHomMatrixBufferedOnDemandDecompose; +}} namespace com { namespace sun { namespace star { namespace i18n { struct Boundary; @@ -55,153 +56,102 @@ namespace drawinglayer { namespace primitive2d { - // This is used for both underline and overline - enum FontUnderline - { - FONT_UNDERLINE_NONE, - FONT_UNDERLINE_SINGLE, - FONT_UNDERLINE_DOUBLE, - FONT_UNDERLINE_DOTTED, - FONT_UNDERLINE_DASH, - FONT_UNDERLINE_LONGDASH, - FONT_UNDERLINE_DASHDOT, - FONT_UNDERLINE_DASHDOTDOT, - FONT_UNDERLINE_SMALLWAVE, - FONT_UNDERLINE_WAVE, - FONT_UNDERLINE_DOUBLEWAVE, - FONT_UNDERLINE_BOLD, - FONT_UNDERLINE_BOLDDOTTED, - FONT_UNDERLINE_BOLDDASH, - FONT_UNDERLINE_BOLDLONGDASH, - FONT_UNDERLINE_BOLDDASHDOT, - FONT_UNDERLINE_BOLDDASHDOTDOT, - FONT_UNDERLINE_BOLDWAVE - }; - - enum FontStrikeout - { - FONT_STRIKEOUT_NONE, - FONT_STRIKEOUT_SINGLE, - FONT_STRIKEOUT_DOUBLE, - FONT_STRIKEOUT_BOLD, - FONT_STRIKEOUT_SLASH, - FONT_STRIKEOUT_X - }; - - enum FontEmphasisMark - { - FONT_EMPHASISMARK_NONE, - FONT_EMPHASISMARK_DOT, - FONT_EMPHASISMARK_CIRCLE, - FONT_EMPHASISMARK_DISC, - FONT_EMPHASISMARK_ACCENT - }; - - enum FontRelief - { - FONT_RELIEF_NONE, - FONT_RELIEF_EMBOSSED, - FONT_RELIEF_ENGRAVED - }; + /** TextDecoratedPortionPrimitive2D class + This primitive expands the TextSimplePortionPrimitive2D by common + decorations used in the office. It can be decomposed and will create + a TextSimplePortionPrimitive2D and all the contained decorations (if used) + as geometry. + */ class TextDecoratedPortionPrimitive2D : public TextSimplePortionPrimitive2D { private: + /// decoration definitions basegfx::BColor maOverlineColor; basegfx::BColor maTextlineColor; - FontUnderline meFontOverline; - FontUnderline meFontUnderline; - FontStrikeout meFontStrikeout; - FontEmphasisMark meFontEmphasisMark; - FontRelief meFontRelief; + TextLine meFontOverline; + TextLine meFontUnderline; + TextStrikeout meTextStrikeout; + TextEmphasisMark meTextEmphasisMark; + TextRelief meTextRelief; - // bitfield + /// bitfield unsigned mbUnderlineAbove : 1; unsigned mbWordLineMode : 1; unsigned mbEmphasisMarkAbove : 1; unsigned mbEmphasisMarkBelow : 1; unsigned mbShadow : 1; - // helper methods - void impCreateTextLine( - std::vector< Primitive2DReference >& rTarget, - basegfx::DecomposedB2DHomMatrixContainer& rDecTrans, - const basegfx::B2DHomMatrix &rUnscaledTransform, - FontUnderline eLineStyle, - double fLineOffset, - double fLineHeight, - double fLineWidth, - const basegfx::BColor& rLineColor) const; - + /// helper methods void impCreateGeometryContent( std::vector< Primitive2DReference >& rTarget, - basegfx::DecomposedB2DHomMatrixContainer& rDecTrans, + basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose& rDecTrans, const String& rText, xub_StrLen aTextPosition, xub_StrLen aTextLength, const ::std::vector< double >& rDXArray, - const FontAttributes& rFontAttributes) const; + const attribute::FontAttribute& rFontAttribute) const; void impCorrectTextBoundary( ::com::sun::star::i18n::Boundary& rNextWordBoundary) const; void impSplitSingleWords( std::vector< Primitive2DReference >& rTarget, - basegfx::DecomposedB2DHomMatrixContainer& rDecTrans) const; + basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose& rDecTrans) const; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor TextDecoratedPortionPrimitive2D( - // TextSimplePortionPrimitive2D parameters + /// TextSimplePortionPrimitive2D parameters const basegfx::B2DHomMatrix& rNewTransform, const String& rText, xub_StrLen aTextPosition, xub_StrLen aTextLength, const ::std::vector< double >& rDXArray, - const FontAttributes& rFontAttributes, + const attribute::FontAttribute& rFontAttribute, const ::com::sun::star::lang::Locale& rLocale, const basegfx::BColor& rFontColor, - // local parameters + /// local parameters const basegfx::BColor& rOverlineColor, const basegfx::BColor& rTextlineColor, - FontUnderline eFontOverline = FONT_UNDERLINE_NONE, - FontUnderline eFontUnderline = FONT_UNDERLINE_NONE, + TextLine eFontOverline = TEXT_LINE_NONE, + TextLine eFontUnderline = TEXT_LINE_NONE, bool bUnderlineAbove = false, - FontStrikeout eFontStrikeout = FONT_STRIKEOUT_NONE, + TextStrikeout eTextStrikeout = TEXT_STRIKEOUT_NONE, bool bWordLineMode = false, - FontEmphasisMark eFontEmphasisMark = FONT_EMPHASISMARK_NONE, + TextEmphasisMark eTextEmphasisMark = TEXT_EMPHASISMARK_NONE, bool bEmphasisMarkAbove = true, bool bEmphasisMarkBelow = false, - FontRelief eFontRelief = FONT_RELIEF_NONE, + TextRelief eTextRelief = TEXT_RELIEF_NONE, bool bShadow = false); - // get data - FontUnderline getFontOverline() const { return meFontOverline; } - FontUnderline getFontUnderline() const { return meFontUnderline; } - FontStrikeout getFontStrikeout() const { return meFontStrikeout; } - FontEmphasisMark getFontEmphasisMark() const { return meFontEmphasisMark; } - FontRelief getFontRelief() const { return meFontRelief; } + /// data read access + TextLine getFontOverline() const { return meFontOverline; } + TextLine getFontUnderline() const { return meFontUnderline; } + TextStrikeout getTextStrikeout() const { return meTextStrikeout; } + TextEmphasisMark getTextEmphasisMark() const { return meTextEmphasisMark; } + TextRelief getTextRelief() const { return meTextRelief; } basegfx::BColor getOverlineColor() const { return maOverlineColor; } basegfx::BColor getTextlineColor() const { return maTextlineColor; } - bool getUnderlineAbove() const { return mbUnderlineAbove; } bool getWordLineMode() const { return mbWordLineMode; } bool getEmphasisMarkAbove() const { return mbEmphasisMarkAbove; } bool getEmphasisMarkBelow() const { return mbEmphasisMarkBelow; } bool getShadow() const { return mbShadow; } - // compare operator + /// compare operator virtual bool operator==( const BasePrimitive2D& rPrimitive ) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/texteffectprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/texteffectprimitive2d.hxx index 128b1ea5a210..77b64d16ea24 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/texteffectprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/texteffectprimitive2d.hxx @@ -36,7 +36,7 @@ #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTEFFECTPRIMITIVE2D_HXX #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTEFFECTPRIMITIVE2D_HXX -#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -45,6 +45,7 @@ namespace drawinglayer { namespace primitive2d { + /** TextEffectStyle2D definition */ enum TextEffectStyle2D { TEXTEFFECTSTYLE2D_RELIEF_EMBOSSED_DEFAULT, @@ -54,46 +55,59 @@ namespace drawinglayer TEXTEFFECTSTYLE2D_OUTLINE }; - class TextEffectPrimitive2D : public GroupPrimitive2D + /** TextEffectPrimitive2D class + + This primitive embeds text primitives (normally, as can be seen can + also be used for any other primitives) which have some TextEffect applied + and create the needed geometry and embedding on decomposition. + */ + class TextEffectPrimitive2D : public BufferedDecompositionPrimitive2D { private: - // the style to apply, the direction and the rotation center + /// the text (or other) content + Primitive2DSequence maTextContent; + + /// the style to apply, the direction and the rotation center const basegfx::B2DPoint maRotationCenter; double mfDirection; TextEffectStyle2D meTextEffectStyle2D; - // the last used object to view transformtion used from getDecomposition - // for decide buffering + /** the last used object to view transformtion used from getDecomposition + for decide buffering + */ basegfx::B2DHomMatrix maLastObjectToViewTransformation; protected: - // create local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// create local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// construcor TextEffectPrimitive2D( - const Primitive2DSequence& rChildren, + const Primitive2DSequence& rTextContent, const basegfx::B2DPoint& rRotationCenter, double fDirection, TextEffectStyle2D eTextEffectStyle2D); - // get data + /// data read access + const Primitive2DSequence& getTextContent() const { return maTextContent; } const basegfx::B2DPoint& getRotationCenter() const { return maRotationCenter; } double getDirection() const { return mfDirection; } TextEffectStyle2D getTextEffectStyle2D() const { return meTextEffectStyle2D; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // own get range implementation to solve more effective. Content is by definition displaced - // by a fixed discrete unit, thus the contained geometry needs only once be asked for it's - // own basegfx::B2DRange + /** own get range implementation to solve more effective. Content is by definition displaced + by a fixed discrete unit, thus the contained geometry needs only once be asked for it's + own basegfx::B2DRange + */ virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() - // Overload standard getDecomposition call to be view-dependent here + /// Overload standard getDecomposition call to be view-dependent here virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textenumsprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textenumsprimitive2d.hxx new file mode 100644 index 000000000000..b0e7dc8c241e --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/textenumsprimitive2d.hxx @@ -0,0 +1,119 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: wrongspellprimitive2d.hxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTENUMSPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTENUMSPRIMITIVE2D_HXX + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <vcl/vclenum.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + /** TextLine definition + + This is used for both underline and overline + */ + enum TextLine + { + TEXT_LINE_NONE, + TEXT_LINE_SINGLE, + TEXT_LINE_DOUBLE, + TEXT_LINE_DOTTED, + TEXT_LINE_DASH, + TEXT_LINE_LONGDASH, + TEXT_LINE_DASHDOT, + TEXT_LINE_DASHDOTDOT, + TEXT_LINE_SMALLWAVE, + TEXT_LINE_WAVE, + TEXT_LINE_DOUBLEWAVE, + TEXT_LINE_BOLD, + TEXT_LINE_BOLDDOTTED, + TEXT_LINE_BOLDDASH, + TEXT_LINE_BOLDLONGDASH, + TEXT_LINE_BOLDDASHDOT, + TEXT_LINE_BOLDDASHDOTDOT, + TEXT_LINE_BOLDWAVE + }; + + /** helper to convert LineStyle */ + TextLine mapFontUnderlineToTextLine(FontUnderline eLineStyle); + FontUnderline mapTextLineToFontUnderline(TextLine eLineStyle); + + /** FontStrikeout definition */ + enum TextStrikeout + { + TEXT_STRIKEOUT_NONE, + TEXT_STRIKEOUT_SINGLE, + TEXT_STRIKEOUT_DOUBLE, + TEXT_STRIKEOUT_BOLD, + TEXT_STRIKEOUT_SLASH, + TEXT_STRIKEOUT_X + }; + + /** helper to convert FontStrikeout */ + TextStrikeout mapFontStrikeoutToTextStrikeout(::FontStrikeout eFontStrikeout); + ::FontStrikeout mapTextStrikeoutToFontStrikeout(TextStrikeout eFontStrikeout); + + /** TextEmphasisMark definition */ + enum TextEmphasisMark + { + TEXT_EMPHASISMARK_NONE, + TEXT_EMPHASISMARK_DOT, + TEXT_EMPHASISMARK_CIRCLE, + TEXT_EMPHASISMARK_DISC, + TEXT_EMPHASISMARK_ACCENT + }; + + /** TextRelief definition */ + enum TextRelief + { + TEXT_RELIEF_NONE, + TEXT_RELIEF_EMBOSSED, + TEXT_RELIEF_ENGRAVED + }; + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTENUMSPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx index 1160704c0fa3..3f9c02b6e9bd 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/texthierarchyprimitive2d.hxx @@ -45,17 +45,23 @@ namespace drawinglayer { namespace primitive2d { - // text format hierarchy helper class. It decomposes to it's - // content, so all direct renderers may ignore it. If You need - // to know more about line hierarchies You may react on it and - // also need to take care that the source of data uses it. + /** TextHierarchyLinePrimitive2D class + + Text format hierarchy helper class. It decomposes to it's + content, so all direct renderers may ignore it. If You need + to know more about line hierarchies You may react on it and + also need to take care that the source of data uses it. + + This primitive encapsulates text lines. + */ class TextHierarchyLinePrimitive2D : public GroupPrimitive2D { private: public: + /// constructor TextHierarchyLinePrimitive2D(const Primitive2DSequence& rChildren); - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -67,14 +73,18 @@ namespace drawinglayer { namespace primitive2d { - // see TextHierarchyLinePrimitive2D comment + /** TextHierarchyBulletPrimitive2D class + + This primitive encapsulates text bullets. + */ class TextHierarchyBulletPrimitive2D : public GroupPrimitive2D { private: public: + /// constructor TextHierarchyBulletPrimitive2D(const Primitive2DSequence& rChildren); - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -86,14 +96,18 @@ namespace drawinglayer { namespace primitive2d { - // see TextHierarchyLinePrimitive2D comment + /** TextHierarchyParagraphPrimitive2D class + + This primitive encapsulates text paragraphs. + */ class TextHierarchyParagraphPrimitive2D : public GroupPrimitive2D { private: public: + /// constructor TextHierarchyParagraphPrimitive2D(const Primitive2DSequence& rChildren); - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -105,14 +119,18 @@ namespace drawinglayer { namespace primitive2d { - // see TextHierarchyLinePrimitive2D comment + /** TextHierarchyBlockPrimitive2D class + + This primitive encapsulates text blocks. + */ class TextHierarchyBlockPrimitive2D : public GroupPrimitive2D { private: public: + /// constructor TextHierarchyBlockPrimitive2D(const Primitive2DSequence& rChildren); - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -124,19 +142,28 @@ namespace drawinglayer { namespace primitive2d { - // type enum + /** FieldType definition */ enum FieldType { - FIELD_TYPE_COMMON, // unspecified. If more info is needed for a FieldType, - // create a new type and it's handling - FIELD_TYPE_PAGE, // uses "FIELD_SEQ_BEGIN;PageField" -> special handling - FIELD_TYPE_URL // uses URL as string -> special handling + /** unspecified. If more info is needed for a FieldType, + create a new type and it's handling + */ + FIELD_TYPE_COMMON, + + /** uses "FIELD_SEQ_BEGIN;PageField" -> special handling */ + FIELD_TYPE_PAGE, + + /** uses URL as string -> special handling */ + FIELD_TYPE_URL }; - // see TextHierarchyLinePrimitive2D comment. - // Also: This type uses a type enum to transport the encapsulated field - // type. Also added is a String which is type-dependent. E.g. for URL - // fields, it contains the URL. + /** TextHierarchyFieldPrimitive2D class + + This primitive encapsulates text fields. + Also: This type uses a type enum to transport the encapsulated field + type. Also added is a String which is type-dependent. E.g. for URL + fields, it contains the URL. + */ class TextHierarchyFieldPrimitive2D : public GroupPrimitive2D { private: @@ -144,19 +171,20 @@ namespace drawinglayer rtl::OUString maString; public: + /// constructor TextHierarchyFieldPrimitive2D( const Primitive2DSequence& rChildren, const FieldType& rFieldType, const rtl::OUString& rString); - // get data + /// data read access FieldType getType() const { return meType; } const rtl::OUString& getString() const { return maString; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d @@ -168,20 +196,24 @@ namespace drawinglayer { namespace primitive2d { - // #i97628# - // Primitive to encapsulate text from an active text edit; some - // renderers need to suppress this output due to painting the - // edited text in e.g. an OutlinerEditView. It's derived from - // GroupPrimitive2D, so the implicit decomposition will use the - // content. To suppress, this primitive needs to be parsed by - // the renderer without taking any action + /** TextHierarchyEditPrimitive2D class + + #i97628# + Primitive to encapsulate text from an active text edit; some + renderers need to suppress this output due to painting the + edited text in e.g. an OutlinerEditView. It's derived from + GroupPrimitive2D, so the implicit decomposition will use the + content. To suppress, this primitive needs to be parsed by + the renderer without taking any action. + */ class TextHierarchyEditPrimitive2D : public GroupPrimitive2D { private: public: + /// constructor TextHierarchyEditPrimitive2D(const Primitive2DSequence& rChildren); - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx index df09718a7582..f3de43c22fd7 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textlayoutdevice.hxx @@ -49,9 +49,10 @@ class VirtualDevice; class Font; class String; class OutputDevice; +class GDIMetaFile; -namespace drawinglayer { namespace primitive2d { - class FontAttributes; +namespace drawinglayer { namespace attribute { + class FontAttribute; }} namespace basegfx { @@ -66,18 +67,27 @@ namespace drawinglayer { namespace primitive2d { + /** TextLayouterDevice class + + This helper class exists to isolate all accesses to VCL + text formatting/handling functionality for primitive implementations. + When in the future FontHandling may move to an own library independent + from VCL, primitives will be prepared. + */ class TextLayouterDevice { - // internally used VirtualDevice + /// internally used VirtualDevice VirtualDevice& mrDevice; public: + /// constructor/destructor TextLayouterDevice(); ~TextLayouterDevice(); + /// tooling methods void setFont(const Font& rFont); - void setFontAttributes( - const FontAttributes& rFontAttributes, + void setFontAttribute( + const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY, const ::com::sun::star::lang::Locale & rLocale); @@ -105,6 +115,15 @@ namespace drawinglayer const String& rText, xub_StrLen nIndex, xub_StrLen nLength) const; + + double getFontAscent() const; + double getFontDescent() const; + + void addTextRectActions( + const Rectangle& rRectangle, + const String& rText, + sal_uInt16 nStyle, + GDIMetaFile& rGDIMetaFile); }; } // end of namespace primitive2d } // end of namespace drawinglayer @@ -116,23 +135,25 @@ namespace drawinglayer { namespace primitive2d { - // Create a VCL-Font based on the definitions in FontAttributes - // and the given FontScaling. The FontScaling defines the FontHeight - // (fFontScaleY) and the FontWidth (fFontScaleX). The combination of - // both defines FontStretching, where no stretching happens at - // fFontScaleY == fFontScaleX - Font getVclFontFromFontAttributes( - const FontAttributes& rFontAttributes, + /** Create a VCL-Font based on the definitions in FontAttribute + and the given FontScaling. The FontScaling defines the FontHeight + (fFontScaleY) and the FontWidth (fFontScaleX). The combination of + both defines FontStretching, where no stretching happens at + fFontScaleY == fFontScaleX + */ + Font getVclFontFromFontAttribute( + const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY, double fFontRotation, const ::com::sun::star::lang::Locale & rLocale); - // Generate FontAttributes DataSet derived from the given VCL-Font. - // The FontScaling with fFontScaleY, fFontScaleX relationship (see - // above) will be set in return parameter o_rSize to allow further - // processing - FontAttributes getFontAttributesFromVclFont( + /** Generate FontAttribute DataSet derived from the given VCL-Font. + The FontScaling with fFontScaleY, fFontScaleX relationship (see + above) will be set in return parameter o_rSize to allow further + processing + */ + attribute::FontAttribute getFontAttributeFromVclFont( basegfx::B2DVector& o_rSize, const Font& rFont, bool bRTL, diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textlineprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textlineprimitive2d.hxx new file mode 100644 index 000000000000..a103d607e85f --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/textlineprimitive2d.hxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: textdecoratedprimitive2d.hxx,v $ + * + * $Revision: 1.6 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTLINEPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTLINEPRIMITIVE2D_HXX + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + class TextLinePrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /// geometric definitions + basegfx::B2DHomMatrix maObjectTransformation; + double mfWidth; + double mfOffset; + double mfHeight; + + /// decoration definitions + TextLine meTextLine; + basegfx::BColor maLineColor; + + protected: + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + public: + /// constructor + TextLinePrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + double fOffset, + double fHeight, + TextLine eTextLine, + const basegfx::BColor& rLineColor); + + /// data read access + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + double getWidth() const { return mfWidth; } + double getOffset() const { return mfOffset; } + double getHeight() const { return mfHeight; } + TextLine getTextLine() const { return meTextLine; } + const basegfx::BColor& getLineColor() const { return maLineColor; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const; + + /// provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTLINEPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx index d7f9bdb1e89a..bbcd8e335e23 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/textprimitive2d.hxx @@ -43,6 +43,7 @@ #include <basegfx/color/bcolor.hxx> #include <vector> #include <com/sun/star/lang/Locale.hpp> +#include <drawinglayer/attribute/fontattribute.hxx> ////////////////////////////////////////////////////////////////////////////// // predefines @@ -60,123 +61,91 @@ namespace drawinglayer { namespace primitive2d { - class FontAttributes + /** TextSimplePortionPrimitive2D class + + This is the basic primitive for representing a text portion. It contains + all needed information. If it is not handled by a renderer, it's decomposition + will provide the text PolyPolygon outlines as filled polygons, correctly + transformed. + + To get better text quality, it is suggested to handle tis primitive directly + in a renderer. In that case, e.g. hintings on the system can be supported. + */ + class TextSimplePortionPrimitive2D : public BufferedDecompositionPrimitive2D { private: - // core data - String maFamilyName; // Font Family Name - String maStyleName; // Font Style Name - sal_uInt16 mnWeight; // Font weight - - // bitfield - unsigned mbSymbol : 1; // Symbol Font Flag - unsigned mbVertical : 1; // Vertical Text Flag - unsigned mbItalic : 1; // Italic Flag - unsigned mbOutline : 1; // Outline Flag - unsigned mbRTL : 1; // RTL Flag - unsigned mbBiDiStrong : 1; // BiDi Flag - // TODO: pair kerning and CJK kerning + /// text range transformation from unit range ([0.0 .. 1.0]) to text range + basegfx::B2DHomMatrix maTextTransform; - public: - FontAttributes( - const String& rFamilyName, - const String& rStyleName, - sal_uInt16 nWeight, - bool bSymbol = false, - bool bVertical = false, - bool bItalic = false, - bool bOutline = false, - bool bRTL = false, - bool bBiDiStrong = false) - : maFamilyName(rFamilyName), - maStyleName(rStyleName), - mnWeight(nWeight), - mbSymbol(bSymbol), - mbVertical(bVertical), - mbItalic(bItalic), - mbOutline(bOutline), - mbRTL(bRTL), - mbBiDiStrong(bBiDiStrong) - { - } - - // compare operator - bool operator==(const FontAttributes& rCompare) const; - - // data access - const String& getFamilyName() const { return maFamilyName; } - const String& getStyleName() const { return maStyleName; } - sal_uInt16 getWeight() const { return mnWeight; } - bool getSymbol() const { return mbSymbol; } - bool getVertical() const { return mbVertical; } - bool getItalic() const { return mbItalic; } - bool getOutline() const { return mbOutline; } - bool getRTL() const { return mbRTL; } - bool getBiDiStrong() const { return mbBiDiStrong; } - }; - } // end of namespace primitive2d -} // end of namespace drawinglayer + /// The text, used from maTextPosition up to maTextPosition + maTextLength + String maText; -////////////////////////////////////////////////////////////////////////////// + /// The index from where on maText is used + xub_StrLen maTextPosition; -namespace drawinglayer -{ - namespace primitive2d - { - class TextSimplePortionPrimitive2D : public BasePrimitive2D - { - private: - basegfx::B2DHomMatrix maTextTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range - String maText; // the text, used from maTextPosition up to maTextPosition + maTextLength - xub_StrLen maTextPosition; // the index from where on maText is used - xub_StrLen maTextLength; // the length for maText usage, starting from maTextPosition - ::std::vector< double > maDXArray; // the DX array scale-independent in unit coordinates - FontAttributes maFontAttributes; // the font to use - ::com::sun::star::lang::Locale maLocale; // the Locale for the text - basegfx::BColor maFontColor; // font color - - // #i96669# add simple range buffering for this primitive + /// The length for maText usage, starting from maTextPosition + xub_StrLen maTextLength; + + /// The DX array scale-independent in unit coordinates + ::std::vector< double > maDXArray; + + /// The font to use + attribute::FontAttribute maFontAttribute; + + /// The Locale for the text + ::com::sun::star::lang::Locale maLocale; + + /// font color + basegfx::BColor maFontColor; + + /// #i96669# add simple range buffering for this primitive basegfx::B2DRange maB2DRange; protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor TextSimplePortionPrimitive2D( const basegfx::B2DHomMatrix& rNewTransform, const String& rText, xub_StrLen aTextPosition, xub_StrLen aTextLength, const ::std::vector< double >& rDXArray, - const FontAttributes& rFontAttributes, + const attribute::FontAttribute& rFontAttribute, const ::com::sun::star::lang::Locale& rLocale, const basegfx::BColor& rFontColor); - // helpers - // get text outlines as polygons and their according ObjectTransformation. Handles all - // the necessary VCL outline extractins, scaling adaptions and other stuff. + /// helpers + /** get text outlines as polygons and their according ObjectTransformation. Handles all + the necessary VCL outline extractins, scaling adaptions and other stuff. + */ void getTextOutlinesAndTransformation(basegfx::B2DPolyPolygonVector& rTarget, basegfx::B2DHomMatrix& rTransformation) const; - // get data + /// data read access const basegfx::B2DHomMatrix& getTextTransform() const { return maTextTransform; } const String& getText() const { return maText; } xub_StrLen getTextPosition() const { return maTextPosition; } xub_StrLen getTextLength() const { return maTextLength; } const ::std::vector< double >& getDXArray() const { return maDXArray; } - const FontAttributes& getFontAttributes() const { return maFontAttributes; } + const attribute::FontAttribute& getFontAttribute() const { return maFontAttribute; } const ::com::sun::star::lang::Locale& getLocale() const { return maLocale; } const basegfx::BColor& getFontColor() const { return maFontColor; } - // compare operator + /// compare operator virtual bool operator==( const BasePrimitive2D& rPrimitive ) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; + + /// small helper to have a compare operator for Locale + bool LocalesAreEqual(const ::com::sun::star::lang::Locale& rA, const ::com::sun::star::lang::Locale& rB); + } // end of namespace primitive2d } // end of namespace drawinglayer diff --git a/drawinglayer/inc/drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx new file mode 100644 index 000000000000..34d7d31fb93a --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx @@ -0,0 +1,167 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: textdecoratedprimitive2d.hxx,v $ + * + * $Revision: 1.6 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:17 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTSTRIKEOUTPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTSTRIKEOUTPRIMITIVE2D_HXX + +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> +#include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/color/bcolor.hxx> +#include <drawinglayer/attribute/fontattribute.hxx> +#include <com/sun/star/lang/Locale.hpp> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + class BaseTextStrikeoutPrimitive2D : public BufferedDecompositionPrimitive2D + { + private: + /// geometric definitions + basegfx::B2DHomMatrix maObjectTransformation; + double mfWidth; + + /// decoration definitions + basegfx::BColor maFontColor; + + public: + /// constructor + BaseTextStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor); + + /// data read access + const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; } + double getWidth() const { return mfWidth; } + const basegfx::BColor& getFontColor() const { return maFontColor; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const; + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + class TextCharacterStrikeoutPrimitive2D : public BaseTextStrikeoutPrimitive2D + { + private: + sal_Unicode maStrikeoutChar; + attribute::FontAttribute maFontAttribute; + ::com::sun::star::lang::Locale maLocale; + + protected: + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + public: + /// constructor + TextCharacterStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor, + sal_Unicode aStrikeoutChar, + const attribute::FontAttribute& rFontAttribute, + const ::com::sun::star::lang::Locale& rLocale); + + /// data read access + sal_Unicode getStrikeoutChar() const { return maStrikeoutChar; } + const attribute::FontAttribute& getFontAttribute() const { return maFontAttribute; } + const ::com::sun::star::lang::Locale& getLocale() const { return maLocale; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const; + + /// provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + class TextGeometryStrikeoutPrimitive2D : public BaseTextStrikeoutPrimitive2D + { + private: + double mfHeight; + double mfOffset; + TextStrikeout meTextStrikeout; + + protected: + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + public: + /// constructor + TextGeometryStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor, + double fHeight, + double fOffset, + TextStrikeout eTextStrikeout); + + /// data read access + double getHeight() const { return mfHeight; } + double getOffset() const { return mfOffset; } + TextStrikeout getTextStrikeout() const { return meTextStrikeout; } + + /// compare operator + virtual bool operator==( const BasePrimitive2D& rPrimitive ) const; + + /// provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTSTRIKEOUTPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive2d/transformprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/transformprimitive2d.hxx index 1646667342af..1723cc708ea8 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/transformprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/transformprimitive2d.hxx @@ -45,26 +45,47 @@ namespace drawinglayer { namespace primitive2d { + /** TransformPrimitive2D class + + This is one of the basic grouping primitives and it provides + embedding a sequence of primitives (a geometry) into a + transformation. All renderers have to handle this, usually by + building a current transformation stack (linear combination) + and applying this to all to-be-rendered geometry. If not handling + this, the output will be mostly wrong since this primitive is + widely used. + + It does transform by embedding an existing geometry into a + transformation as Child-content. This allows re-usage of the + refcounted Uno-Api primitives and their existung, buffered + decompositions. + + It could e.g. be used to show a single object geometry in 1000 + different, transformed states without the need to create those + thousand primitive contents. + */ class TransformPrimitive2D : public GroupPrimitive2D { private: + // the transformation to apply to the child geometry basegfx::B2DHomMatrix maTransformation; public: + /// constructor TransformPrimitive2D( const basegfx::B2DHomMatrix& rTransformation, const Primitive2DSequence& rChildren); - // get data + /// data read access const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // get range + /// get range virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx index 44f3f738b67e..6e8970e7bee5 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx @@ -44,27 +44,37 @@ namespace drawinglayer { namespace primitive2d { + /** UnifiedAlphaPrimitive2D class + + This primitive encapsualtes a child hierarchy and defines + that it shall be visualized with the given transparency. That + transparency is unique for all contained geometry, so that + e.g. overlapping polygons in the child geometry will not show + regions of combined transparency, but be all rendered with the + defined, single transparency. + */ class UnifiedAlphaPrimitive2D : public GroupPrimitive2D { private: - double mfAlpha; // unified transparence - - protected: - // create decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// the unified alpha transparence + double mfAlpha; public: + /// constructor UnifiedAlphaPrimitive2D( const Primitive2DSequence& rChildren, double fAlpha); - // get data + /// data read access double getAlpha() const { return mfAlpha; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// create decomposition + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive2d/wallpaperprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/wallpaperprimitive2d.hxx new file mode 100644 index 000000000000..ffe47cfe1b72 --- /dev/null +++ b/drawinglayer/inc/drawinglayer/primitive2d/wallpaperprimitive2d.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: bitmapprimitive2d.hxx,v $ + * + * $Revision: 1.4 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:16 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_WALLPAPERPRIMITIVE2D_HXX +#define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_WALLPAPERPRIMITIVE2D_HXX + +#include <drawinglayer/primitive2d/primitivetools2d.hxx> +#include <vcl/bitmapex.hxx> +#include <vcl/wall.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + /** WallpaperBitmapPrimitive2D class + + This is a specialized primtive for the Wallpaper definitions included in + VCL and Metafiles. The extraordinary about the bitmap definition part of + the Wallpaper is that it uses PIXEL size of the given Bitmap and not + the logic and/or discrete size derived by PrefMapMode/PrefSize methods. + To emulate this, a ViewTransformation dependent primitive is needed which + takes over the correct scaling(s). + + Since a specialized primitive is needed anyways, i opted to also add the + layouting which is dependent from WallpaperStyle; thus it does not need + to be handled anywhere else in the future. + */ + class WallpaperBitmapPrimitive2D : public ViewTransformationDependentPrimitive2D + { + private: + basegfx::B2DRange maObjectRange; + BitmapEx maBitmapEx; + WallpaperStyle meWallpaperStyle; + + protected: + /// create local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + + public: + /// constructor + WallpaperBitmapPrimitive2D( + const basegfx::B2DRange& rObjectRange, + const BitmapEx& rBitmapEx, + WallpaperStyle eWallpaperStyle); + + /// data read access + const basegfx::B2DRange& getLocalObjectRange() const { return maObjectRange; } + const BitmapEx& getBitmapEx() const { return maBitmapEx ; } + WallpaperStyle getWallpaperStyle() const { return meWallpaperStyle; } + + /// compare operator + virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + + /// get B2Drange + virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; + + /// provide unique ID + DeclPrimitrive2DIDBlock() + }; + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +#endif // INCLUDED_DRAWINGLAYER_PRIMITIVE2D_WALLPAPERPRIMITIVE2D_HXX + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/inc/drawinglayer/primitive2d/wrongspellprimitive2d.hxx b/drawinglayer/inc/drawinglayer/primitive2d/wrongspellprimitive2d.hxx index 8bd739298059..3ceae01ed3b2 100644 --- a/drawinglayer/inc/drawinglayer/primitive2d/wrongspellprimitive2d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive2d/wrongspellprimitive2d.hxx @@ -47,35 +47,53 @@ namespace drawinglayer { namespace primitive2d { - class WrongSpellPrimitive2D : public BasePrimitive2D + /** WrongSpellPrimitive2D class + + This is a helper primitive to hold evtl. WrongSpell visualisations + in the sequence of primitives. The primitive holds this information + separated form the TextPortions to where it belongs to tot expand the + TextSimplePortionPrimitive2D more as needed. + + A renderer who does not want to visualize this (if contained at all) + can detect and ignore this primitive. If it's decomposition is used, + it will be visualized as red wavelines. + + The geometric definition defines a line on the X-Axis (no Y-coordinates) + which will when transformed by Transformation, create the coordinate data. + */ + class WrongSpellPrimitive2D : public BufferedDecompositionPrimitive2D { private: + /// geometry definition basegfx::B2DHomMatrix maTransformation; double mfStart; double mfStop; + + /// color (usually red) basegfx::BColor maColor; protected: - // create local decomposition - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + /// create local decomposition + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: + /// constructor WrongSpellPrimitive2D( const basegfx::B2DHomMatrix& rTransformation, double fStart, double fStop, const basegfx::BColor& rColor); - // get data + /// data read access const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } double getStart() const { return mfStart; } double getStop() const { return mfStop; } const basegfx::BColor& getColor() const { return maColor; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive2DIDBlock() }; } // end of namespace primitive2d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/baseprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/baseprimitive3d.hxx index faeac28b0c0c..9bf56edb2c53 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/baseprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/baseprimitive3d.hxx @@ -43,16 +43,17 @@ #include <basegfx/range/b3drange.hxx> ////////////////////////////////////////////////////////////////////////////// -// defines for DeclPrimitrive3DIDBlock and ImplPrimitrive3DIDBlock -// Added to be able to simply change identification stuff later, e.g. add -// a identification string and/or ID to the interface and to the implementation -// ATM used to delclare implement getPrimitiveID() +/** defines for DeclPrimitrive3DIDBlock and ImplPrimitrive3DIDBlock + Added to be able to simply change identification stuff later, e.g. add + a identification string and/or ID to the interface and to the implementation + ATM used to delclare implement getPrimitive3DID() + */ #define DeclPrimitrive3DIDBlock() \ - virtual sal_uInt32 getPrimitiveID() const; + virtual sal_uInt32 getPrimitive3DID() const; #define ImplPrimitrive3DIDBlock(TheClass, TheID) \ - sal_uInt32 TheClass::getPrimitiveID() const { return TheID; } + sal_uInt32 TheClass::getPrimitive3DID() const { return TheID; } ////////////////////////////////////////////////////////////////////////////// // predefines @@ -61,6 +62,13 @@ namespace drawinglayer { namespace geometry { class ViewInformation3D; }} +namespace drawinglayer { namespace primitive3d { + /// typedefs for basePrimitive3DImplBase, Primitive3DSequence and Primitive3DReference + typedef cppu::WeakComponentImplHelper1< ::com::sun::star::graphic::XPrimitive3D > BasePrimitive3DImplBase; + typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive3D > Primitive3DReference; + typedef ::com::sun::star::uno::Sequence< Primitive3DReference > Primitive3DSequence; +}} + ////////////////////////////////////////////////////////////////////////////// // basePrimitive3D class @@ -68,99 +76,145 @@ namespace drawinglayer { namespace primitive3d { - // typedefs for basePrimitive3DImplBase, Primitive3DSequence and Primitive3DReference - typedef cppu::WeakComponentImplHelper1< ::com::sun::star::graphic::XPrimitive3D > BasePrimitive3DImplBase; - typedef ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XPrimitive3D > Primitive3DReference; - typedef ::com::sun::star::uno::Sequence< Primitive3DReference > Primitive3DSequence; + /** BasePrimitive3D class + + Baseclass for all C++ implementations of com::sun::star::graphic::XPrimitive2D + + The description/functionality is identical with the 2D case in baseprimitive2d.hxx, + please see there for detailed information. + Current Basic 3D Primitives are: + + - PolygonHairlinePrimitive3D (for 3D hairlines) + - PolyPolygonMaterialPrimitive3D (for 3D filled plane polygons) + + That's all for 3D! + */ class BasePrimitive3D : private boost::noncopyable, protected comphelper::OBaseMutex, public BasePrimitive3DImplBase { private: - // a sequence used for buffering the last createLocalDecomposition() result. Use - // the protected access methods to change. Only implementations of getDecomposition() - // should make use. - Primitive3DSequence maLocalDecomposition; - protected: - // access methods to maLocalDecomposition. The usage of this methods may allow - // later thread-safe stuff to be added if needed. Only to be used by getDecomposition() - // implementations for buffering the last decomposition. - const Primitive3DSequence& getLocalDecomposition() const { return maLocalDecomposition; } - void setLocalDecomposition(const Primitive3DSequence& rNew) { maLocalDecomposition = rNew; } - - // method which is to be used to implement the local decomposition of a 2D primitive. The default - // implementation will just return an empty decomposition - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; - public: - // constructor + // constructor/destructor BasePrimitive3D(); + virtual ~BasePrimitive3D(); - // the ==operator is mainly needed to allow testing newly-created high level primitives against their last - // incarnation which buffers/holds the decompositionsThe default implementation - // uses getPrimitiveID()-calls to test if it's the same ID at last. Overloaded implementation are then - // based on this implementation + /** the ==operator is mainly needed to allow testing newly-created high level primitives against their last + incarnation which buffers/holds the decompositionsThe default implementation + uses getPrimitive3DID()-calls to test if it's the same ID at last. Overloaded implementation are then + based on this implementation. + */ virtual bool operator==( const BasePrimitive3D& rPrimitive ) const; bool operator!=( const BasePrimitive3D& rPrimitive ) const { return !operator==(rPrimitive); } - // This method is for places where using the C++ implementation directly is possible. The subprocessing - // and range merging is more efficient when working directly on basegfx::B3DRange. The default implementation - // will use getDecomposition results to create the range + /** This method is for places where using the C++ implementation directly is possible. The subprocessing + and range merging is more efficient when working directly on basegfx::B3DRange. The default implementation + will use getDecomposition results to create the range + */ virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; - // provide unique ID for fast identifying of known primitive implementations in renderers. These use - // the the defines from primitivetypes3d.hxx to define unique IDs. - virtual sal_uInt32 getPrimitiveID() const = 0; + /** provide unique ID for fast identifying of known primitive implementations in renderers. These use + the the defines from primitivetypes3d.hxx to define unique IDs. + */ + virtual sal_uInt32 getPrimitive3DID() const = 0; - // The getDecomposition default implementation will on demand use createLocalDecomposition() if maLocalDecomposition is empty. - // It will set maLocalDecomposition to this obtained decomposition to buffer it. - // If the decomposition is also ViewInformation-dependent, this method needs to be overloaded and the - // ViewInformation for the last decomposition needs to be remembered, too, and be used in the next call to decide if - // the buffered decomposition may be reused or not. + /// The default implementation returns an empty sequence virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; // // Methods from XPrimitive3D // - // The getDecomposition implementation for UNO API will use getDecomposition from this implementation. It - // will get the ViewInformation from the ViewParameters for that purpose + /** The getDecomposition implementation for UNO API will use getDecomposition from this implementation. It + will get the ViewInformation from the ViewParameters for that purpose + */ virtual Primitive3DSequence SAL_CALL getDecomposition( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rViewParameters ) throw ( ::com::sun::star::uno::RuntimeException ); - // the getRange default implemenation will use getDecomposition to create the range information from merging - // getRange results from the single local decomposition primitives. + /** the getRange default implemenation will use getDecomposition to create the range information from merging + getRange results from the single local decomposition primitives. + */ virtual ::com::sun::star::geometry::RealRectangle3D SAL_CALL getRange( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rViewParameters ) throw ( ::com::sun::star::uno::RuntimeException ); }; } // end of namespace primitive3d } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// +// BufferedDecompositionPrimitive3D class + +namespace drawinglayer +{ + namespace primitive3d + { + /** BufferedDecompositionPrimitive3D class + + Baseclass for all C++ implementations of com::sun::star::graphic::XPrimitive2D + + The description/functionality is identical with the 2D case in baseprimitive2d.hxx, + please see there for detailed information + */ + class BufferedDecompositionPrimitive3D + : public BasePrimitive3D + { + private: + /// a sequence used for buffering the last create3DDecomposition() result + Primitive3DSequence maBuffered3DDecomposition; + + protected: + /** access methods to maBuffered3DDecomposition. The usage of this methods may allow + later thread-safe stuff to be added if needed. Only to be used by getDecomposition() + implementations for buffering the last decomposition. + */ + const Primitive3DSequence& getBuffered3DDecomposition() const { return maBuffered3DDecomposition; } + void setBuffered3DDecomposition(const Primitive3DSequence& rNew) { maBuffered3DDecomposition = rNew; } + + /** method which is to be used to implement the local decomposition of a 2D primitive. The default + implementation will just return an empty decomposition + */ + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + public: + // constructor + BufferedDecompositionPrimitive3D(); + + /** The getDecomposition default implementation will on demand use create3DDecomposition() if + maBuffered3DDecomposition is empty. It will set maBuffered3DDecomposition to this obtained decomposition + to buffer it. If the decomposition is also ViewInformation-dependent, this method needs to be + overloaded and the ViewInformation for the last decomposition needs to be remembered, too, and + be used in the next call to decide if the buffered decomposition may be reused or not. + */ + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + }; + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// // tooling namespace drawinglayer { namespace primitive3d { - // get B3DRange from a given Primitive3DReference + /// get B3DRange from a given Primitive3DReference basegfx::B3DRange getB3DRangeFromPrimitive3DReference(const Primitive3DReference& rCandidate, const geometry::ViewInformation3D& aViewInformation); - // get range3D from a given Primitive3DSequence + /// get range3D from a given Primitive3DSequence basegfx::B3DRange getB3DRangeFromPrimitive3DSequence(const Primitive3DSequence& rCandidate, const geometry::ViewInformation3D& aViewInformation); - // compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D) - // and using compare operator + /** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D) + and using compare operator + */ bool arePrimitive3DReferencesEqual(const Primitive3DReference& rA, const Primitive3DReference& rB); - // compare two Primitive3DReferences for equality, uses arePrimitive3DReferencesEqual internally + /// compare two Primitive3DReferences for equality, uses arePrimitive3DReferencesEqual internally bool arePrimitive3DSequencesEqual(const Primitive3DSequence& rA, const Primitive3DSequence& rB); - // concatenate sequence + /// concatenate sequence void appendPrimitive3DSequenceToPrimitive3DSequence(Primitive3DSequence& rDest, const Primitive3DSequence& rSource); - // concatenate single Primitive3D + /// concatenate single Primitive3D void appendPrimitive3DReferenceToPrimitive3DSequence(Primitive3DSequence& rDest, const Primitive3DReference& rSource); } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/groupprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/groupprimitive3d.hxx index 029b4c664fe2..69e406c75d67 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/groupprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/groupprimitive3d.hxx @@ -44,27 +44,45 @@ namespace drawinglayer { namespace primitive3d { + /** GroupPrimitive3D class + + Baseclass for all grouping 3D primitives + + The description/functionality is identical with the 2D case in groupprimitive2d.hxx, + please see there for detailed information. + + Current Basic 3D StatePrimitives are: + + - ModifiedColorPrimitive3D (for a stack of color modifications) + - ShadowPrimitive3D (for 3D objects with shadow; this is a special case + since the shadow of a 3D primitive is a 2D primitive set) + - TexturePrimitive3D (with the following variations) + - GradientTexturePrimitive3D (for 3D gradient fill) + - BitmapTexturePrimitive3D (for 3D Bitmap fill) + - AlphaTexturePrimitive3D (for 3D transparence) + - HatchTexturePrimitive3D (for 3D hatch fill) + - TransformPrimitive3D (for a transformation stack) + */ class GroupPrimitive3D : public BasePrimitive3D { private: - // the children. Declared private since this shall never be changed at all after construction + /// the children. Declared private since this shall never be changed at all after construction Primitive3DSequence maChildren; - protected: - // local decomposition. Implementation will just return children - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; - public: - // constructor + /// constructor GroupPrimitive3D(const Primitive3DSequence& rChildren); - // data access + /// data read access Primitive3DSequence getChildren() const { return maChildren; } - // compare operator + /// compare operator virtual bool operator==( const BasePrimitive3D& rPrimitive ) const; - // provide unique ID + /// local decomposition. Implementation will just return children + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/hatchtextureprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/hatchtextureprimitive3d.hxx index c1feccaaa10c..2675a1284779 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/hatchtextureprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/hatchtextureprimitive3d.hxx @@ -44,16 +44,32 @@ namespace drawinglayer { namespace primitive3d { + /** HatchTexturePrimitive3D class + + HatchTexturePrimitive3D is derived from GroupPrimitive3D, but implements + a decomposition which is complicated enough for buffering. Since the group + primitive has no default buffering, it is necessary here to add a local + buffering mechanism for the decomposition + */ class HatchTexturePrimitive3D : public TexturePrimitive3D { private: + /// the hatch definition attribute::FillHatchAttribute maHatch; + /// the buffered decomposed hatch + Primitive3DSequence maBuffered3DDecomposition; + protected: - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + /// helper: local decomposition + Primitive3DSequence impCreate3DDecomposition() const; + + /// local access methods to maBufferedDecomposition + const Primitive3DSequence& getBuffered3DDecomposition() const { return maBuffered3DDecomposition; } + void setBuffered3DDecomposition(const Primitive3DSequence& rNew) { maBuffered3DDecomposition = rNew; } public: + /// constructor HatchTexturePrimitive3D( const attribute::FillHatchAttribute& rHatch, const Primitive3DSequence& rChildren, @@ -61,13 +77,16 @@ namespace drawinglayer bool bModulate, bool bFilter); - // get data + /// data read access const attribute::FillHatchAttribute& getHatch() const { return maHatch; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // provide unique ID + /// local decomposition. + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/hittestprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/hittestprimitive3d.hxx index 28029f223b1b..4779241033b0 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/hittestprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/hittestprimitive3d.hxx @@ -44,32 +44,37 @@ namespace drawinglayer { namespace primitive3d { - // This primitive is used to represent geometry for non-visible objects, - // e.g. a 3D cube without fill attributes. To still be able to use - // primitives for HitTest functionality, the 3d decompositions produce - // an as much as possible simplified fill geometry encapsulated in this - // primtive when there is no fill geometry. Currently, the 3d hit test - // uses only areas, so maybe in a further enchanced version this will change - // to 'if neither filled nor lines' creation criteria. The whole primitive - // decomposes to nothing, so no one not knowing it will be influenced. Only - // helper processors for hit test (and maybe BoundRect extractors) will - // use it and it's children subcontent. + /** HitTestPrimitive3D class + + This primitive is used to represent geometry for non-visible objects, + e.g. a 3D cube without fill attributes. To still be able to use + primitives for HitTest functionality, the 3d decompositions produce + an as much as possible simplified fill geometry encapsulated in this + primtive when there is no fill geometry. Currently, the 3d hit test + uses only areas, so maybe in a further enchanced version this will change + to 'if neither filled nor lines' creation criteria. The whole primitive + decomposes to nothing, so no one not knowing it will be influenced. Only + helper processors for hit test (and maybe BoundRect extractors) will + use it and it's children subcontent. + */ class HitTestPrimitive3D : public GroupPrimitive3D { - protected: - // local decomposition. Implementation will return empty Primitive3DSequence - // since this is no visualisation data - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; - public: + /// constructor HitTestPrimitive3D(const Primitive3DSequence& rChildren); - // despite returning an empty decomposition since it's no visualisation data, - // range calculation is intended to use invisible replacement geometry, so - // the local implementation will return the children's range + /** despite returning an empty decomposition since it's no visualisation data, + range calculation is intended to use invisible replacement geometry, so + the local implementation will return the children's range + */ virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; - // provide unique ID + /** local decomposition. Implementation will return empty Primitive3DSequence + since this is no visualisation data + */ + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx index 0771e8117fc5..3840bf71a397 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx @@ -45,23 +45,32 @@ namespace drawinglayer { namespace primitive3d { + /** ModifiedColorPrimitive3D class + + This primitive is a grouping primitive and allows to define + how the colors of it's child content shall be modified for + visualisation. Please see the ModifiedColorPrimitive2D + description for more info. + */ class ModifiedColorPrimitive3D : public GroupPrimitive3D { private: + /// The ColorModifier to use basegfx::BColorModifier maColorModifier; public: + /// constructor ModifiedColorPrimitive3D( const Primitive3DSequence& rChildren, const basegfx::BColorModifier& rColorModifier); - // get data + /// data read access const basegfx::BColorModifier& getColorModifier() const { return maColorModifier; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/polygonprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/polygonprimitive3d.hxx index 9de2dc5949e7..c73850e4f794 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/polygonprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/polygonprimitive3d.hxx @@ -48,28 +48,40 @@ namespace drawinglayer { namespace primitive3d { + /** PolygonHairlinePrimitive3D class + + This primitive defines a Hairline in 3D. Since hairlines are view-dependent, + this primitive is view-dependent, too. + + This is one of the non-decomposable 3D primitives, so a renderer + should proccess it. + */ class PolygonHairlinePrimitive3D : public BasePrimitive3D { private: + /// the hairline geometry basegfx::B3DPolygon maPolygon; + + /// the hairline color basegfx::BColor maBColor; public: + /// constructor PolygonHairlinePrimitive3D( const basegfx::B3DPolygon& rPolygon, const basegfx::BColor& rBColor); - // get data + /// data read access const basegfx::B3DPolygon& getB3DPolygon() const { return maPolygon; } const basegfx::BColor& getBColor() const { return maBColor; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // get range + /// get range virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d @@ -81,36 +93,49 @@ namespace drawinglayer { namespace primitive3d { - class PolygonStrokePrimitive3D : public BasePrimitive3D + /** PolygonStrokePrimitive3D class + + This primitive defines a 3D line with line width, line join, line color + and stroke attributes. It will be decomposed dependent on the definition + to the needed primitives, e.g. filled Tubes for fat lines. + */ + class PolygonStrokePrimitive3D : public BufferedDecompositionPrimitive3D { private: + /// the line geometry basegfx::B3DPolygon maPolygon; + + /// the line attributes like width, join and color attribute::LineAttribute maLineAttribute; + + /// the line stroking (if used) attribute::StrokeAttribute maStrokeAttribute; protected: - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; public: + /// constructor PolygonStrokePrimitive3D( const basegfx::B3DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, const attribute::StrokeAttribute& rStrokeAttribute); + /// constructor without stroking PolygonStrokePrimitive3D( const basegfx::B3DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute); - // get data + /// data read access basegfx::B3DPolygon getB3DPolygon() const { return maPolygon; } const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/polygontubeprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/polygontubeprimitive3d.hxx index 8a9b293a8c5e..f5d45f7c1639 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/polygontubeprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/polygontubeprimitive3d.hxx @@ -52,19 +52,38 @@ namespace drawinglayer { namespace primitive3d { + /** PolygonStrokePrimitive3D class + + This 3D primitive extends a 3D hairline to a 3D tube which is + e.g. used for fat lines in 3D. It's decomposition will create all + 3D objects needed for the line tubes and the edge roundings + in full 3D. + */ class PolygonTubePrimitive3D : public PolygonHairlinePrimitive3D { private: + /// hold the last decompositon since it's expensive + Primitive3DSequence maLast3DDecomposition; + + /// visualisation parameters double mfRadius; double mfDegreeStepWidth; double mfMiterMinimumAngle; basegfx::B2DLineJoin maLineJoin; protected: - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + /** access methods to maLast3DDecomposition. The usage of this methods may allow + later thread-safe stuff to be added if needed. Only to be used by getDecomposition() + implementations for buffering the last decomposition. + */ + const Primitive3DSequence& getLast3DDecomposition() const { return maLast3DDecomposition; } + void setLast3DDecomposition(const Primitive3DSequence& rNew) { maLast3DDecomposition = rNew; } + + /// local decomposition. + Primitive3DSequence impCreate3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; public: + /// constructor PolygonTubePrimitive3D( const basegfx::B3DPolygon& rPolygon, const basegfx::BColor& rBColor, @@ -72,16 +91,21 @@ namespace drawinglayer double fDegreeStepWidth = 10.0 * F_PI180, double fMiterMinimumAngle = 15.0 * F_PI180); - // get data + /// data read access double getRadius() const { return mfRadius; } double getDegreeStepWidth() const { return mfDegreeStepWidth; } double getMiterMinimumAngle() const { return mfMiterMinimumAngle; } basegfx::B2DLineJoin getLineJoin() const { return maLineJoin; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // provide unique ID + /** local decomposition. Use own buffering since we are not derived from + BufferedDecompositionPrimitive3D + */ + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/polypolygonprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/polypolygonprimitive3d.hxx index 1c5b9e400bbb..091e8181e38f 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/polypolygonprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/polypolygonprimitive3d.hxx @@ -46,33 +46,45 @@ namespace drawinglayer { namespace primitive3d { + /** PolyPolygonMaterialPrimitive3D class + + This primitive defines a planar 3D PolyPolygon filled with a single color. + This is one of the non-decomposable primitives, so a renderer + should proccess it. + + It is assumed here that the PolyPolgon is a single plane in 3D. + */ class PolyPolygonMaterialPrimitive3D : public BasePrimitive3D { private: + /// the PolyPolygon geometry basegfx::B3DPolyPolygon maPolyPolygon; + + /// the fill parameters attribute::MaterialAttribute3D maMaterial; - // bitfield + /// bitfield unsigned mbDoubleSided : 1; public: + /// constructor PolyPolygonMaterialPrimitive3D( const basegfx::B3DPolyPolygon& rPolyPolygon, const attribute::MaterialAttribute3D& rMaterial, bool bDoubleSided); - // get data + /// data read access const basegfx::B3DPolyPolygon& getB3DPolyPolygon() const { return maPolyPolygon; } const attribute::MaterialAttribute3D& getMaterial() const { return maMaterial; } bool getDoubleSided() const { return mbDoubleSided; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // get range + /// get range virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrcubeprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrcubeprimitive3d.hxx index 57f31a46a557..b3a57f2677dc 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/sdrcubeprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrcubeprimitive3d.hxx @@ -44,26 +44,33 @@ namespace drawinglayer { namespace primitive3d { + /** SdrCubePrimitive3D class + + This 3D primitive expands the SdrPrimitive3D to a 3D cube definition. + The cube is implicitely in unit coordinates and the given transformation + defines it's geometry in space. + */ class SdrCubePrimitive3D : public SdrPrimitive3D { protected: - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; public: + /// constructor SdrCubePrimitive3D( const basegfx::B3DHomMatrix& rTransform, const basegfx::B2DVector& rTextureSize, const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute, const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute); - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // get range + /// get range virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrdecompositiontools3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrdecompositiontools3d.hxx index 772e030781fe..5b793a6928f8 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/sdrdecompositiontools3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrdecompositiontools3d.hxx @@ -42,6 +42,7 @@ ////////////////////////////////////////////////////////////////////////////// // predefines + namespace basegfx { class B3DPolygon; class B3DPolyPolygon; diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx index 43ae13d4625f..b80198d127d2 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudelathetools3d.hxx @@ -53,7 +53,7 @@ namespace drawinglayer { namespace primitive3d { - // Slice3D types + /** SliceType3D definition */ enum SliceType3D { SLICETYPE3D_REGULAR, // normal geoemtry Slice3D @@ -61,7 +61,7 @@ namespace drawinglayer SLICETYPE3D_BACKCAP // back cap }; - // class to hold one Slice3D + /// class to hold one Slice3D class Slice3D { protected: @@ -92,10 +92,10 @@ namespace drawinglayer SliceType3D getSliceType() const { return maSliceType; } }; - // typedef for a group of Slice3Ds + /// typedef for a group of Slice3Ds typedef ::std::vector< Slice3D > Slice3DVector; - // helpers for creation + /// helpers for creation void createLatheSlices( Slice3DVector& rSliceVector, const basegfx::B2DPolyPolygon& rSource, @@ -117,7 +117,7 @@ namespace drawinglayer bool bCloseFront, bool bCloseBack); - // helpers for geometry extraction + /// helpers for geometry extraction basegfx::B3DPolyPolygon extractHorizontalLinesFromSlice(const Slice3DVector& rSliceVector, bool bCloseHorLines); basegfx::B3DPolyPolygon extractVerticalLinesFromSlice(const Slice3DVector& rSliceVector); diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx index a6d386bf194a..a810e0f5ec8e 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrextrudeprimitive3d.hxx @@ -45,23 +45,34 @@ namespace drawinglayer { namespace primitive3d { + /** SdrExtrudePrimitive3D class + + This 3D primitive expands the SdrPrimitive3D to a 3D extrude definition. + The given 2D PolyPolygon geometry is imagined as lying on the XY-plane in 3D + and gets extruded in Z-Direction by Depth. + + Various possibilities e.g. for creating diagonals (edge roudings in 3D) + and similar are given. + + The decomposition will create all necessary 3D planes for visualisation. + */ class SdrExtrudePrimitive3D : public SdrPrimitive3D { private: - // geometry helper for slices + /// geometry helper for slices basegfx::B2DPolyPolygon maCorrectedPolyPolygon; Slice3DVector maSlices; - // primitive data + /// primitive geometry data basegfx::B2DPolyPolygon maPolyPolygon; double mfDepth; double mfDiagonal; double mfBackScale; - // decomposition data when ReducedLineGeometry is used, see get3DDecomposition + /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition geometry::ViewInformation3D* mpLastRLGViewInformation; - // bitfield + /// bitfield unsigned mbSmoothNormals : 1; // Plane self unsigned mbSmoothHorizontalNormals : 1; // always unsigned mbSmoothLids : 1; // Front/back @@ -69,17 +80,18 @@ namespace drawinglayer unsigned mbCloseFront : 1; unsigned mbCloseBack : 1; - // create slices + /// create slices void impCreateSlices(); - // get (evtl. create) slices + /// get (evtl. create) slices const Slice3DVector& getSlices() const; protected: - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; public: + /// constructor SdrExtrudePrimitive3D( const basegfx::B3DHomMatrix& rTransform, const basegfx::B2DVector& rTextureSize, @@ -97,7 +109,7 @@ namespace drawinglayer bool bCloseBack); virtual ~SdrExtrudePrimitive3D(); - // data access + /// data read access const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; } double getDepth() const { return mfDepth; } double getDiagonal() const { return mfDiagonal; } @@ -109,16 +121,16 @@ namespace drawinglayer bool getCloseFront() const { return mbCloseFront; } bool getCloseBack() const { return mbCloseBack; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // get range + /// get range virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; - // Overloaded to allow for reduced line mode to decide if to buffer decomposition or not + /// Overloaded to allow for reduced line mode to decide if to buffer decomposition or not virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx index 99d06e256431..084ce5bce35e 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrlatheprimitive3d.hxx @@ -45,14 +45,25 @@ namespace drawinglayer { namespace primitive3d { + /** SdrLathePrimitive3D class + + This 3D primitive expands the SdrPrimitive3D to a 3D rotation definition. + The given 2D PolyPolygon geometry is imagined as lying on the XY-plane in 3D + and gets rotated around the Y-Axis. + + Various possibilities e.g. for creating diagonals (edge roudings in 3D) + and similar are given. + + The decomposition will create all necessary 3D planes for visualisation. + */ class SdrLathePrimitive3D : public SdrPrimitive3D { private: - // geometry helper for slices + /// geometry helper for slices basegfx::B2DPolyPolygon maCorrectedPolyPolygon; Slice3DVector maSlices; - // primitive data + /// primitive geometry data basegfx::B2DPolyPolygon maPolyPolygon; sal_uInt32 mnHorizontalSegments; sal_uInt32 mnVerticalSegments; @@ -60,10 +71,10 @@ namespace drawinglayer double mfBackScale; double mfRotation; - // decomposition data when ReducedLineGeometry is used, see get3DDecomposition + /// decomposition data when ReducedLineGeometry is used, see get3DDecomposition geometry::ViewInformation3D* mpLastRLGViewInformation; - // bitfield + /// bitfield unsigned mbSmoothNormals : 1; // Plane self unsigned mbSmoothHorizontalNormals : 1; // always unsigned mbSmoothLids : 1; // Front/back @@ -71,14 +82,14 @@ namespace drawinglayer unsigned mbCloseFront : 1; unsigned mbCloseBack : 1; - // create slices + /// create slices void impCreateSlices(); - // get (evtl. create) slices + /// get (evtl. create) slices const Slice3DVector& getSlices() const; protected: - // local helpers + /// local helpers void impCreateOutlines( const geometry::ViewInformation3D& rViewInformation, const basegfx::B3DPolygon& rLoopA, @@ -90,10 +101,11 @@ namespace drawinglayer const basegfx::B2DPoint& rStart, const basegfx::B2DPoint& rEnd) const; - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; public: + /// constructor SdrLathePrimitive3D( const basegfx::B3DHomMatrix& rTransform, const basegfx::B2DVector& rTextureSize, @@ -113,7 +125,7 @@ namespace drawinglayer bool bCloseBack); virtual ~SdrLathePrimitive3D(); - // data access + /// data read access const basegfx::B2DPolyPolygon& getPolyPolygon() const { return maPolyPolygon; } sal_uInt32 getHorizontalSegments() const { return mnHorizontalSegments; } sal_uInt32 getVerticalSegments() const { return mnVerticalSegments; } @@ -127,16 +139,16 @@ namespace drawinglayer bool getCloseFront() const { return mbCloseFront; } bool getCloseBack() const { return mbCloseBack; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // get range + /// get range virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; - // Overloaded to allow for reduced line mode to decide if to buffer decomposition or not + /// Overloaded to allow for reduced line mode to decide if to buffer decomposition or not virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx index 4eec829afeb5..a6c68bd16da8 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrpolypolygonprimitive3d.hxx @@ -44,17 +44,28 @@ namespace drawinglayer { namespace primitive3d { + /** SdrPolyPolygonPrimitive3D class + + This 3D primitive defines a PolyPolgon in space which may have + Line- and FillStyles and extra 3D surface attributes. It is assumed + that the given 3D PolyPolgon (which may contain texture and normal + information) is planar in 3D. + + The decomposition will include all needed 3D data for visualisation, + including FatLines and fill styles. + */ class SdrPolyPolygonPrimitive3D : public SdrPrimitive3D { private: - // the polyPolygon evtl with normals and texture coordinates + /// the planar polyPolygon evtl with normals and texture coordinates basegfx::B3DPolyPolygon maPolyPolygon3D; protected: - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; public: + /// constructor SdrPolyPolygonPrimitive3D( const basegfx::B3DPolyPolygon& rPolyPolygon3D, const basegfx::B3DHomMatrix& rTransform, @@ -62,16 +73,16 @@ namespace drawinglayer const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute, const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute); - // data access + /// data access const basegfx::B3DPolyPolygon& getPolyPolygon3D() const { return maPolyPolygon3D; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // get range + /// get range virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx index 6b381445716e..4dd620848387 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrprimitive3d.hxx @@ -47,39 +47,49 @@ namespace drawinglayer { + /** SdrPrimitive3D class + + Base class for the more complicated geometric primitives, so + derive from buffered primitive to allow overloading of + create3DDecomposition there. + */ namespace primitive3d { - class SdrPrimitive3D : public BasePrimitive3D + class SdrPrimitive3D : public BufferedDecompositionPrimitive3D { private: + /// object surface attributes basegfx::B3DHomMatrix maTransform; basegfx::B2DVector maTextureSize; attribute::SdrLineFillShadowAttribute maSdrLFSAttribute; attribute::Sdr3DObjectAttribute maSdr3DObjectAttribute; protected: - // Standard implementation for primitive3D which - // will use maTransform as range and expand by evtl. line width / 2 + /** Standard implementation for primitive3D which + will use maTransform as range and expand by evtl. line width / 2 + */ basegfx::B3DRange getStandard3DRange() const; - // implementation for primitive3D which - // will use given Slice3Ds and expand by evtl. line width / 2 + /** implementation for primitive3D which + will use given Slice3Ds and expand by evtl. line width / 2 + */ basegfx::B3DRange get3DRangeFromSlices(const Slice3DVector& rSlices) const; public: + /// constructor SdrPrimitive3D( const basegfx::B3DHomMatrix& rTransform, const basegfx::B2DVector& rTextureSize, const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute, const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute); - // data access + /// data read access const basegfx::B3DHomMatrix& getTransform() const { return maTransform; } const basegfx::B2DVector& getTextureSize() const { return maTextureSize; } const attribute::SdrLineFillShadowAttribute& getSdrLFSAttribute() const { return maSdrLFSAttribute; } const attribute::Sdr3DObjectAttribute getSdr3DObjectAttribute() const { return maSdr3DObjectAttribute; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/sdrsphereprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/sdrsphereprimitive3d.hxx index 358298e30456..52e646e6b4dc 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/sdrsphereprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/sdrsphereprimitive3d.hxx @@ -44,17 +44,25 @@ namespace drawinglayer { namespace primitive3d { + /** SdrSpherePrimitive3D class + + This 3D primitive expands the SdrPrimitive3D to a 3D sphere definition. + The sphere is implicitely in unit coordinates and the given transformation + defines it's geometry in space. + */ class SdrSpherePrimitive3D : public SdrPrimitive3D { private: + /// additional geometry definitions sal_uInt32 mnHorizontalSegments; sal_uInt32 mnVerticalSegments; protected: - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + /// local decomposition. + virtual Primitive3DSequence create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; public: + /// constructor SdrSpherePrimitive3D( const basegfx::B3DHomMatrix& rTransform, const basegfx::B2DVector& rTextureSize, @@ -63,17 +71,17 @@ namespace drawinglayer sal_uInt32 nHorizontalSegments, sal_uInt32 nVerticalSegments); - // data access + /// data read access sal_uInt32 getHorizontalSegments() const { return mnHorizontalSegments; } sal_uInt32 getVerticalSegments() const { return mnVerticalSegments; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // get range + /// get range virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/shadowprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/shadowprimitive3d.hxx index d511c89a9998..cb8e9cd385d0 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/shadowprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/shadowprimitive3d.hxx @@ -46,17 +46,29 @@ namespace drawinglayer { namespace primitive3d { + /** ShadowPrimitive3D class + + This 3D grouping primitive is used to define a shadow for + 3d geometry by embedding it. The shadow of 3D objects are + 2D polygons, so the shadow transformation is a 2D transformation. + + If the Shadow3D flag is set, the shadow definition has to be + combined with the scene and camera definition to create the correct + projected shadow 2D-Polygons. + */ class ShadowPrimitive3D : public GroupPrimitive3D { protected: + /// 2D shadow definition basegfx::B2DHomMatrix maShadowTransform; basegfx::BColor maShadowColor; double mfShadowTransparence; - // bitfield + /// bitfield unsigned mbShadow3D : 1; public: + /// constructor ShadowPrimitive3D( const basegfx::B2DHomMatrix& rShadowTransform, const basegfx::BColor& rShadowColor, @@ -64,16 +76,16 @@ namespace drawinglayer bool bShadow3D, const Primitive3DSequence& rChildren); - // get data + /// data read access const basegfx::B2DHomMatrix& getShadowTransform() const { return maShadowTransform; } const basegfx::BColor& getShadowColor() const { return maShadowColor; } double getShadowTransparence() const { return mfShadowTransparence; } bool getShadow3D() const { return mbShadow3D; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/textureprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/textureprimitive3d.hxx index 15b8e1265709..f8b81e357ea5 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/textureprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/textureprimitive3d.hxx @@ -47,31 +47,39 @@ namespace drawinglayer { namespace primitive3d { + /** TexturePrimitive3D class + + This 3D grouping primitive is used to define a texture for + 3d geometry by embedding it. It is used as bae class for + extended texture definitions + */ class TexturePrimitive3D : public GroupPrimitive3D { private: + /// texture geometry definition basegfx::B2DVector maTextureSize; - // bitfield - // flag if texture shall be modulated with white interpolated color + /// bitfield + /// flag if texture shall be modulated with white interpolated color unsigned mbModulate : 1; - // flag if texture shall be filtered + /// flag if texture shall be filtered unsigned mbFilter : 1; public: + /// constructor TexturePrimitive3D( const Primitive3DSequence& rChildren, const basegfx::B2DVector& rTextureSize, bool bModulate, bool bFilter); - // get data + /// data read access const basegfx::B2DVector& getTextureSize() const { return maTextureSize; } bool getModulate() const { return mbModulate; } bool getFilter() const { return mbFilter; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; }; } // end of namespace primitive3d @@ -83,27 +91,34 @@ namespace drawinglayer { namespace primitive3d { + /** UnifiedAlphaTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a unified + alpha (transparence) texture definition. All 3D primitives + embedded here will be shown with the given transparency. + */ class UnifiedAlphaTexturePrimitive3D : public TexturePrimitive3D { private: + /// transparency definition double mfTransparence; - protected: - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; - public: + /// constructor UnifiedAlphaTexturePrimitive3D( double fTransparence, const Primitive3DSequence& rChildren); - // get data + /// data read access double getTransparence() const { return mfTransparence; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // provide unique ID + /// local decomposition. + virtual Primitive3DSequence get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d @@ -115,16 +130,20 @@ namespace drawinglayer { namespace primitive3d { + /** GradientTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a gradient texture + definition. All 3D primitives embedded here will be shown with the + defined gradient. + */ class GradientTexturePrimitive3D : public TexturePrimitive3D { private: + /// the gradient definition attribute::FillGradientAttribute maGradient; - protected: - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; - public: + /// constructor GradientTexturePrimitive3D( const attribute::FillGradientAttribute& rGradient, const Primitive3DSequence& rChildren, @@ -132,13 +151,13 @@ namespace drawinglayer bool bModulate, bool bFilter); - // get data + /// data read access const attribute::FillGradientAttribute& getGradient() const { return maGradient; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d @@ -150,30 +169,34 @@ namespace drawinglayer { namespace primitive3d { + /** BitmapTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a bitmap texture + definition. All 3D primitives embedded here will be shown with the + defined bitmap (maybe tiled if defined). + */ class BitmapTexturePrimitive3D : public TexturePrimitive3D { private: - attribute::FillBitmapAttribute maBitmap; - - protected: - // local decomposition. - virtual Primitive3DSequence createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const; + /// bitmap fill attribute + attribute::FillBitmapAttribute maFillBitmapAttribute; public: + /// constructor BitmapTexturePrimitive3D( - const attribute::FillBitmapAttribute& rBitmap, + const attribute::FillBitmapAttribute& rFillBitmapAttribute, const Primitive3DSequence& rChildren, const basegfx::B2DVector& rTextureSize, bool bModulate, bool bFilter); - // get data - const attribute::FillBitmapAttribute& getBitmap() const { return maBitmap; } + /// data read access + const attribute::FillBitmapAttribute& getFillBitmapAttribute() const { return maFillBitmapAttribute; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d @@ -185,18 +208,26 @@ namespace drawinglayer { namespace primitive3d { + /** AlphaTexturePrimitive3D class + + This 3D primitive expands TexturePrimitive3D to a alpha texture + definition. For alpha definition, a gradient is used. The values in + that gradient will be interpreted as luminance Alpha-Values. All 3D + primitives embedded here will be shown with the defined transparence. + */ class AlphaTexturePrimitive3D : public GradientTexturePrimitive3D { public: + /// constructor AlphaTexturePrimitive3D( const attribute::FillGradientAttribute& rGradient, const Primitive3DSequence& rChildren, const basegfx::B2DVector& rTextureSize); - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/primitive3d/transformprimitive3d.hxx b/drawinglayer/inc/drawinglayer/primitive3d/transformprimitive3d.hxx index 720f28445dec..bbf2b8444969 100644 --- a/drawinglayer/inc/drawinglayer/primitive3d/transformprimitive3d.hxx +++ b/drawinglayer/inc/drawinglayer/primitive3d/transformprimitive3d.hxx @@ -45,26 +45,37 @@ namespace drawinglayer { namespace primitive3d { + /** TransformPrimitive3D class + + This is one of the basic grouping 3D primitives and it provides + embedding a sequence of primitives (a geometry) into a + 3D transformation. + + Please see the description for TransformPrimitive2D since these + primitives are pretty similar. + */ class TransformPrimitive3D : public GroupPrimitive3D { private: + // the 3D transformation to apply basegfx::B3DHomMatrix maTransformation; public: + /// constructor TransformPrimitive3D( const basegfx::B3DHomMatrix& rTransformation, const Primitive3DSequence& rChildren); - // get data + /// data read access const basegfx::B3DHomMatrix& getTransformation() const { return maTransformation; } - // compare operator + /// compare operator virtual bool operator==(const BasePrimitive3D& rPrimitive) const; - // get range + /// get range virtual basegfx::B3DRange getB3DRange(const geometry::ViewInformation3D& rViewInformation) const; - // provide unique ID + /// provide unique ID DeclPrimitrive3DIDBlock() }; } // end of namespace primitive3d diff --git a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx index 66ca140c2e56..ff77cc3fd5d0 100644 --- a/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx +++ b/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx @@ -64,6 +64,7 @@ namespace drawinglayer { namespace primitive2d { class PolygonStrokePrimitive2D; class ControlPrimitive2D; class PagePreviewPrimitive2D; + class EpsPrimitive2D; }} ////////////////////////////////////////////////////////////////////////////// @@ -113,6 +114,7 @@ namespace drawinglayer void RenderMarkerArrayPrimitive2D(const primitive2d::MarkerArrayPrimitive2D& rMarkerArrayCandidate); void RenderPointArrayPrimitive2D(const primitive2d::PointArrayPrimitive2D& rPointArrayCandidate); void RenderPolygonStrokePrimitive2D(const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokeCandidate); + void RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D); ///////////////////////////////////////////////////////////////////////////// // DrawMode adaption support diff --git a/drawinglayer/prj/d.lst b/drawinglayer/prj/d.lst index 1ba3c2e7b614..ee5b96d98a03 100644 --- a/drawinglayer/prj/d.lst +++ b/drawinglayer/prj/d.lst @@ -39,6 +39,7 @@ mkdir: %_DEST%\inc%_EXT%\drawinglayer\primitive2d ..\inc\drawinglayer\primitive2d\sceneprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\sceneprimitive2d.hxx ..\inc\drawinglayer\primitive2d\shadowprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\shadowprimitive2d.hxx ..\inc\drawinglayer\primitive2d\structuretagprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\structuretagprimitive2d.hxx +..\inc\drawinglayer\primitive2d\textenumsprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\textenumsprimitive2d.hxx ..\inc\drawinglayer\primitive2d\texteffectprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\texteffectprimitive2d.hxx ..\inc\drawinglayer\primitive2d\textlayoutdevice.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\textlayoutdevice.hxx ..\inc\drawinglayer\primitive2d\textprimitive2d.hxx %_DEST%\inc%_EXT%\drawinglayer\primitive2d\textprimitive2d.hxx @@ -98,6 +99,7 @@ mkdir: %_DEST%\inc%_EXT%\drawinglayer\processor3d mkdir: %_DEST%\inc%_EXT%\drawinglayer\attribute ..\inc\drawinglayer\attribute\fillattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\attribute\fillattribute.hxx ..\inc\drawinglayer\attribute\fillbitmapattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\attribute\fillbitmapattribute.hxx +..\inc\drawinglayer\attribute\fontattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\attribute\fontattribute.hxx ..\inc\drawinglayer\attribute\materialattribute3d.hxx %_DEST%\inc%_EXT%\drawinglayer\attribute\materialattribute3d.hxx ..\inc\drawinglayer\attribute\sdrallattribute3d.hxx %_DEST%\inc%_EXT%\drawinglayer\attribute\sdrallattribute3d.hxx ..\inc\drawinglayer\attribute\sdrattribute.hxx %_DEST%\inc%_EXT%\drawinglayer\attribute\sdrattribute.hxx diff --git a/drawinglayer/source/attribute/fillbitmapattribute.cxx b/drawinglayer/source/attribute/fillbitmapattribute.cxx index 539e85ab2733..99afb234bda5 100644 --- a/drawinglayer/source/attribute/fillbitmapattribute.cxx +++ b/drawinglayer/source/attribute/fillbitmapattribute.cxx @@ -44,8 +44,12 @@ namespace drawinglayer { namespace attribute { - FillBitmapAttribute::FillBitmapAttribute(const Bitmap& rBitmap, const basegfx::B2DPoint& rTopLeft, const basegfx::B2DVector& rSize, bool bTiling) - : maBitmap(rBitmap), + FillBitmapAttribute::FillBitmapAttribute( + const BitmapEx& rBitmapEx, + const basegfx::B2DPoint& rTopLeft, + const basegfx::B2DVector& rSize, + bool bTiling) + : maBitmapEx(rBitmapEx), maTopLeft(rTopLeft), maSize(rSize), mbTiling(bTiling) @@ -54,10 +58,10 @@ namespace drawinglayer bool FillBitmapAttribute::operator==(const FillBitmapAttribute& rCandidate) const { - return (maBitmap == rCandidate.maBitmap - && maTopLeft == rCandidate.maTopLeft - && maSize == rCandidate.maSize - && mbTiling == rCandidate.mbTiling); + return (getBitmapEx() == rCandidate.getBitmapEx() + && getTopLeft() == rCandidate.getTopLeft() + && getSize() == rCandidate.getSize() + && getTiling() == rCandidate.getTiling()); } } // end of namespace attribute } // end of namespace drawinglayer diff --git a/drawinglayer/source/attribute/fontattribute.cxx b/drawinglayer/source/attribute/fontattribute.cxx new file mode 100644 index 000000000000..5163e2f6a59a --- /dev/null +++ b/drawinglayer/source/attribute/fontattribute.cxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: strokeattribute.cxx,v $ + * + * $Revision: 1.3 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:19 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_drawinglayer.hxx" + +#include <drawinglayer/attribute/fontattribute.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace attribute + { + bool FontAttribute::operator==(const FontAttribute& rCompare) const + { + return (getFamilyName() == rCompare.getFamilyName() + && getStyleName() == rCompare.getStyleName() + && getWeight() == rCompare.getWeight() + && getSymbol() == rCompare.getSymbol() + && getVertical() == rCompare.getVertical() + && getItalic() == rCompare.getItalic() + && getOutline() == rCompare.getOutline() + && getRTL() == rCompare.getRTL() + && getBiDiStrong() == rCompare.getBiDiStrong()); + } + } // end of namespace attribute +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/attribute/makefile.mk b/drawinglayer/source/attribute/makefile.mk index fa91224e64b6..65f899f67177 100644 --- a/drawinglayer/source/attribute/makefile.mk +++ b/drawinglayer/source/attribute/makefile.mk @@ -47,6 +47,7 @@ ENABLE_EXCEPTIONS=TRUE SLOFILES= \ $(SLO)$/fillattribute.obj \ $(SLO)$/fillbitmapattribute.obj \ + $(SLO)$/fontattribute.obj \ $(SLO)$/materialattribute3d.obj \ $(SLO)$/sdrallattribute3d.obj \ $(SLO)$/sdrattribute.obj \ diff --git a/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx b/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx index c35d0ba5c15f..d7e9090b0f62 100644 --- a/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx +++ b/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx @@ -228,7 +228,7 @@ namespace drawinglayer aBitmapSize.setY(aBitmapSize.getY() / fRangeHeight); } - return FillBitmapAttribute(aBitmap, aBitmapTopLeft, aBitmapSize, mbTiling); + return FillBitmapAttribute(BitmapEx(aBitmap), aBitmapTopLeft, aBitmapSize, mbTiling); } } // end of namespace attribute } // end of namespace drawinglayer diff --git a/drawinglayer/source/geometry/viewinformation2d.cxx b/drawinglayer/source/geometry/viewinformation2d.cxx index 706684c5f7d8..3a3fd68831db 100644 --- a/drawinglayer/source/geometry/viewinformation2d.cxx +++ b/drawinglayer/source/geometry/viewinformation2d.cxx @@ -157,7 +157,7 @@ namespace drawinglayer mxExtendedInformation[nExtendedInsert++] = rProp; // for performance reasons, also cache content locally - sal_Bool bSalBool = sal_True; + sal_Bool bSalBool(false); rProp.Value >>= bSalBool; mbReducedDisplayQuality = bSalBool; } diff --git a/drawinglayer/source/primitive2d/animatedprimitive2d.cxx b/drawinglayer/source/primitive2d/animatedprimitive2d.cxx index 13f1f699f1ab..df38c627ec9f 100644 --- a/drawinglayer/source/primitive2d/animatedprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/animatedprimitive2d.cxx @@ -52,33 +52,12 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence AnimatedSwitchPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const - { - if(getChildren().hasElements()) - { - const double fState(getAnimationEntry().getStateAtTime(rViewInformation.getViewTime())); - const sal_uInt32 nLen(getChildren().getLength()); - sal_uInt32 nIndex(basegfx::fround(fState * (double)nLen)); - - if(nIndex >= nLen) - { - nIndex = nLen - 1L; - } - - const Primitive2DReference xRef(getChildren()[nIndex], uno::UNO_QUERY_THROW); - return Primitive2DSequence(&xRef, 1L); - } - - return Primitive2DSequence(); - } - AnimatedSwitchPrimitive2D::AnimatedSwitchPrimitive2D( const animation::AnimationEntry& rAnimationEntry, const Primitive2DSequence& rChildren, bool bIsTextAnimation) : GroupPrimitive2D(rChildren), mpAnimationEntry(0), - mfDecomposeViewTime(0.0), mbIsTextAnimation(bIsTextAnimation) { // clone given animation description @@ -105,29 +84,22 @@ namespace drawinglayer Primitive2DSequence AnimatedSwitchPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { - ::osl::MutexGuard aGuard( m_aMutex ); - - if(getLocalDecomposition().hasElements() && mfDecomposeViewTime != rViewInformation.getViewTime()) + if(getChildren().hasElements()) { - // conditions of last local decomposition have changed, delete - const_cast< AnimatedSwitchPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); - } + const double fState(getAnimationEntry().getStateAtTime(rViewInformation.getViewTime())); + const sal_uInt32 nLen(getChildren().getLength()); + sal_uInt32 nIndex(basegfx::fround(fState * (double)nLen)); - if(!getLocalDecomposition().hasElements()) - { - // remember time - const_cast< AnimatedSwitchPrimitive2D* >(this)->mfDecomposeViewTime = rViewInformation.getViewTime(); - } + if(nIndex >= nLen) + { + nIndex = nLen - 1L; + } - // use parent implementation - return GroupPrimitive2D::get2DDecomposition(rViewInformation); - } + const Primitive2DReference xRef(getChildren()[nIndex], uno::UNO_QUERY_THROW); + return Primitive2DSequence(&xRef, 1L); + } - basegfx::B2DRange AnimatedSwitchPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const - { - // to get range from decomposition and not from group content, call implementation from - // BasePrimitive2D here - return BasePrimitive2D::getB2DRange(rViewInformation); + return Primitive2DSequence(); } // provide unique ID @@ -142,7 +114,15 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence AnimatedBlinkPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + AnimatedBlinkPrimitive2D::AnimatedBlinkPrimitive2D( + const animation::AnimationEntry& rAnimationEntry, + const Primitive2DSequence& rChildren, + bool bIsTextAnimation) + : AnimatedSwitchPrimitive2D(rAnimationEntry, rChildren, bIsTextAnimation) + { + } + + Primitive2DSequence AnimatedBlinkPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { if(getChildren().hasElements()) { @@ -157,14 +137,6 @@ namespace drawinglayer return Primitive2DSequence(); } - AnimatedBlinkPrimitive2D::AnimatedBlinkPrimitive2D( - const animation::AnimationEntry& rAnimationEntry, - const Primitive2DSequence& rChildren, - bool bIsTextAnimation) - : AnimatedSwitchPrimitive2D(rAnimationEntry, rChildren, bIsTextAnimation) - { - } - // provide unique ID ImplPrimitrive2DIDBlock(AnimatedBlinkPrimitive2D, PRIMITIVE2D_ID_ANIMATEDBLINKPRIMITIVE2D) @@ -172,41 +144,30 @@ namespace drawinglayer } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// -// helper class for AnimatedInterpolatePrimitive2D namespace drawinglayer { namespace primitive2d { - BufferedMatrixDecompose::BufferedMatrixDecompose(const basegfx::B2DHomMatrix& rMatrix) - : maB2DHomMatrix(rMatrix), - maScale(0.0, 0.0), - maTranslate(0.0, 0.0), - mfRotate(0.0), - mfShearX(0.0), - mbDecomposed(false) + AnimatedInterpolatePrimitive2D::AnimatedInterpolatePrimitive2D( + const std::vector< basegfx::B2DHomMatrix >& rmMatrixStack, + const animation::AnimationEntry& rAnimationEntry, + const Primitive2DSequence& rChildren, + bool bIsTextAnimation) + : AnimatedSwitchPrimitive2D(rAnimationEntry, rChildren, bIsTextAnimation), + maMatrixStack() { - } + // copy matrices to locally pre-decomposed matrix stack + const sal_uInt32 nCount(rmMatrixStack.size()); + maMatrixStack.reserve(nCount); - void BufferedMatrixDecompose::ensureDecompose() const - { - if(!mbDecomposed) + for(sal_uInt32 a(0L); a < nCount; a++) { - BufferedMatrixDecompose* pThis = const_cast< BufferedMatrixDecompose* >(this); - maB2DHomMatrix.decompose(pThis->maScale, pThis->maTranslate, pThis->mfRotate, pThis->mfShearX); - pThis->mbDecomposed = true; + maMatrixStack.push_back(basegfx::tools::B2DHomMatrixBufferedDecompose(rmMatrixStack[a])); } } - } // end of anonymous namespace -} // end of namespace drawinglayer -////////////////////////////////////////////////////////////////////////////// - -namespace drawinglayer -{ - namespace primitive2d - { - Primitive2DSequence AnimatedInterpolatePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence AnimatedInterpolatePrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { const sal_uInt32 nSize(maMatrixStack.size()); @@ -227,21 +188,18 @@ namespace drawinglayer const sal_uInt32 nIndA(sal_uInt32(floor(fIndex))); const double fOffset(fIndex - (double)nIndA); basegfx::B2DHomMatrix aTargetTransform; + std::vector< basegfx::tools::B2DHomMatrixBufferedDecompose >::const_iterator aMatA(maMatrixStack.begin() + nIndA); if(basegfx::fTools::equalZero(fOffset)) { // use matrix from nIndA directly - aTargetTransform = maMatrixStack[nIndA].getB2DHomMatrix(); + aTargetTransform = aMatA->getB2DHomMatrix(); } else { - // interpolate. Get involved matrices and ensure they are decomposed + // interpolate. Get involved buffered decomposed matrices const sal_uInt32 nIndB((nIndA + 1L) % nSize); - std::vector< BufferedMatrixDecompose >::const_iterator aMatA(maMatrixStack.begin() + nIndA); - std::vector< BufferedMatrixDecompose >::const_iterator aMatB(maMatrixStack.begin() + nIndB); - - aMatA->ensureDecompose(); - aMatB->ensureDecompose(); + std::vector< basegfx::tools::B2DHomMatrixBufferedDecompose >::const_iterator aMatB(maMatrixStack.begin() + nIndB); // interpolate for fOffset [0.0 .. 1.0[ const basegfx::B2DVector aScale(basegfx::interpolate(aMatA->getScale(), aMatB->getScale(), fOffset)); @@ -250,10 +208,8 @@ namespace drawinglayer const double fShearX(((aMatB->getShearX() - aMatA->getShearX()) * fOffset) + aMatA->getShearX()); // build matrix for state - aTargetTransform.scale(aScale.getX(), aScale.getY()); - aTargetTransform.shearX(fShearX); - aTargetTransform.rotate(fRotate); - aTargetTransform.translate(aTranslate.getX(), aTranslate.getY()); + aTargetTransform = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aScale, fShearX, fRotate, aTranslate); } // create new transform primitive reference, return new sequence @@ -266,23 +222,6 @@ namespace drawinglayer } } - AnimatedInterpolatePrimitive2D::AnimatedInterpolatePrimitive2D( - const std::vector< basegfx::B2DHomMatrix >& rmMatrixStack, - const animation::AnimationEntry& rAnimationEntry, - const Primitive2DSequence& rChildren, - bool bIsTextAnimation) - : AnimatedSwitchPrimitive2D(rAnimationEntry, rChildren, bIsTextAnimation), - maMatrixStack() - { - // copy matrices - const sal_uInt32 nCount(rmMatrixStack.size()); - - for(sal_uInt32 a(0L); a < nCount; a++) - { - maMatrixStack.push_back(BufferedMatrixDecompose(rmMatrixStack[a])); - } - } - // provide unique ID ImplPrimitrive2DIDBlock(AnimatedInterpolatePrimitive2D, PRIMITIVE2D_ID_ANIMATEDINTERPOLATEPRIMITIVE2D) diff --git a/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx b/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx index cff797451954..d425b1ea3138 100644 --- a/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/backgroundcolorprimitive2d.cxx @@ -54,7 +54,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence BackgroundColorPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence BackgroundColorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { if(!rViewInformation.getViewport().isEmpty()) { @@ -70,7 +70,7 @@ namespace drawinglayer BackgroundColorPrimitive2D::BackgroundColorPrimitive2D( const basegfx::BColor& rBColor) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maBColor(rBColor), maLastViewport() { @@ -78,7 +78,7 @@ namespace drawinglayer bool BackgroundColorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const BackgroundColorPrimitive2D& rCompare = (BackgroundColorPrimitive2D&)rPrimitive; @@ -98,20 +98,20 @@ namespace drawinglayer { ::osl::MutexGuard aGuard( m_aMutex ); - if(getLocalDecomposition().hasElements() && (maLastViewport != rViewInformation.getViewport())) + if(getBuffered2DDecomposition().hasElements() && (maLastViewport != rViewInformation.getViewport())) { // conditions of last local decomposition have changed, delete - const_cast< BackgroundColorPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + const_cast< BackgroundColorPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); } - if(!getLocalDecomposition().hasElements()) + if(!getBuffered2DDecomposition().hasElements()) { // remember ViewRange const_cast< BackgroundColorPrimitive2D* >(this)->maLastViewport = rViewInformation.getViewport(); } // use parent implementation - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID diff --git a/drawinglayer/source/primitive2d/baseprimitive2d.cxx b/drawinglayer/source/primitive2d/baseprimitive2d.cxx index 63941512bfb0..dffde631b8c3 100644 --- a/drawinglayer/source/primitive2d/baseprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/baseprimitive2d.cxx @@ -50,20 +50,18 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence BasePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + BasePrimitive2D::BasePrimitive2D() + : BasePrimitive2DImplBase(m_aMutex) { - return Primitive2DSequence(); } - BasePrimitive2D::BasePrimitive2D() - : BasePrimitive2DImplBase(m_aMutex), - maLocalDecomposition() + BasePrimitive2D::~BasePrimitive2D() { } bool BasePrimitive2D::operator==( const BasePrimitive2D& rPrimitive ) const { - return (getPrimitiveID() == rPrimitive.getPrimitiveID()); + return (getPrimitive2DID() == rPrimitive.getPrimitive2DID()); } basegfx::B2DRange BasePrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const @@ -71,17 +69,9 @@ namespace drawinglayer return getB2DRangeFromPrimitive2DSequence(get2DDecomposition(rViewInformation), rViewInformation); } - Primitive2DSequence BasePrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence BasePrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { - ::osl::MutexGuard aGuard( m_aMutex ); - - if(!getLocalDecomposition().hasElements()) - { - const Primitive2DSequence aNewSequence(createLocalDecomposition(rViewInformation)); - const_cast< BasePrimitive2D* >(this)->setLocalDecomposition(aNewSequence); - } - - return getLocalDecomposition(); + return Primitive2DSequence(); } Primitive2DSequence SAL_CALL BasePrimitive2D::getDecomposition( const uno::Sequence< beans::PropertyValue >& rViewParameters ) throw ( uno::RuntimeException ) @@ -99,6 +89,38 @@ namespace drawinglayer } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence BufferedDecompositionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + return Primitive2DSequence(); + } + + BufferedDecompositionPrimitive2D::BufferedDecompositionPrimitive2D() + : BasePrimitive2D(), + maBuffered2DDecomposition() + { + } + + Primitive2DSequence BufferedDecompositionPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + if(!getBuffered2DDecomposition().hasElements()) + { + const Primitive2DSequence aNewSequence(create2DDecomposition(rViewInformation)); + const_cast< BufferedDecompositionPrimitive2D* >(this)->setBuffered2DDecomposition(aNewSequence); + } + + return getBuffered2DDecomposition(); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// // tooling namespace drawinglayer diff --git a/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx b/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx index 5900900bcf06..43de0ef3b514 100644 --- a/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/bitmapprimitive2d.cxx @@ -65,8 +65,8 @@ namespace drawinglayer { const BitmapPrimitive2D& rCompare = (BitmapPrimitive2D&)rPrimitive; - return (maBitmapEx == rCompare.maBitmapEx - && maTransform == rCompare.maTransform); + return (getBitmapEx() == rCompare.getBitmapEx() + && getTransform() == rCompare.getTransform()); } return false; diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx index ba73f920cb08..1341a22f0d89 100644 --- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx @@ -49,7 +49,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence BorderLinePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence BorderLinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { Primitive2DSequence xRetval; @@ -194,7 +194,7 @@ namespace drawinglayer bool bCreateInside, bool bCreateOutside, const basegfx::BColor& rRGBColor) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maStart(rStart), maEnd(rEnd), mfLeftWidth(fLeftWidth), @@ -212,7 +212,7 @@ namespace drawinglayer bool BorderLinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const BorderLinePrimitive2D& rCompare = (BorderLinePrimitive2D&)rPrimitive; diff --git a/drawinglayer/source/primitive2d/controlprimitive2d.cxx b/drawinglayer/source/primitive2d/controlprimitive2d.cxx index 6241eeb2fa73..5d536fa8812f 100644 --- a/drawinglayer/source/primitive2d/controlprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/controlprimitive2d.cxx @@ -54,6 +54,7 @@ #include <svtools/optionsdrawinglayer.hxx> #include <toolkit/awt/vclxwindow.hxx> #include <vcl/window.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -230,12 +231,8 @@ namespace drawinglayer } // short form for scale and translate transformation - basegfx::B2DHomMatrix aBitmapTransform; - - aBitmapTransform.set(0L, 0L, aBitmapSizeLogic.getX()); - aBitmapTransform.set(1L, 1L, aBitmapSizeLogic.getY()); - aBitmapTransform.set(0L, 2L, aTranslate.getX()); - aBitmapTransform.set(1L, 2L, aTranslate.getY()); + const basegfx::B2DHomMatrix aBitmapTransform(basegfx::tools::createScaleTranslateB2DHomMatrix( + aBitmapSizeLogic.getX(), aBitmapSizeLogic.getY(), aTranslate.getX(), aTranslate.getY())); // create primitive xRetval = new BitmapPrimitive2D(BitmapEx(aContent), aBitmapTransform); @@ -266,7 +263,7 @@ namespace drawinglayer return xRetval; } - Primitive2DSequence ControlPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence ControlPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { // try to create a bitmap decomposition. If that fails for some reason, // at least create a replacement decomposition. @@ -283,7 +280,7 @@ namespace drawinglayer ControlPrimitive2D::ControlPrimitive2D( const basegfx::B2DHomMatrix& rTransform, const uno::Reference< awt::XControlModel >& rxControlModel) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), mxControlModel(rxControlModel), mxXControl(), @@ -295,7 +292,7 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rTransform, const uno::Reference< awt::XControlModel >& rxControlModel, const uno::Reference< awt::XControl >& rxXControl) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), mxControlModel(rxControlModel), mxXControl(rxXControl), @@ -316,7 +313,7 @@ namespace drawinglayer bool ControlPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { // use base class compare operator - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const ControlPrimitive2D& rCompare = (ControlPrimitive2D&)rPrimitive; @@ -365,23 +362,23 @@ namespace drawinglayer ::osl::MutexGuard aGuard( m_aMutex ); const basegfx::B2DVector aNewScaling(rViewInformation.getObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0)); - if(getLocalDecomposition().hasElements()) + if(getBuffered2DDecomposition().hasElements()) { if(!maLastViewScaling.equal(aNewScaling)) { // conditions of last local decomposition have changed, delete - const_cast< ControlPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + const_cast< ControlPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); } } - if(!getLocalDecomposition().hasElements()) + if(!getBuffered2DDecomposition().hasElements()) { // remember ViewTransformation const_cast< ControlPrimitive2D* >(this)->maLastViewScaling = aNewScaling; } // use parent implementation - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID diff --git a/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx b/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx new file mode 100644 index 000000000000..6e3a5b8e516e --- /dev/null +++ b/drawinglayer/source/primitive2d/discretebitmapprimitive2d.cxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: bitmapprimitive2d.cxx,v $ + * + * $Revision: 1.5 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_drawinglayer.hxx" + +#include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence DiscreteBitmapPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // use getViewTransformation() and getObjectTransformation() from + // ObjectAndViewTransformationDependentPrimitive2D to create a BitmapPrimitive2D + // with the correct mapping + Primitive2DSequence xRetval; + + if(!getBitmapEx().IsEmpty()) + { + // get discrete size + const Size& rSizePixel = getBitmapEx().GetSizePixel(); + const basegfx::B2DVector aDiscreteSize(rSizePixel.Width(), rSizePixel.Height()); + + // get inverse ViewTransformation + basegfx::B2DHomMatrix aInverseViewTransformation(getViewTransformation()); + aInverseViewTransformation.invert(); + + // get size and position in world coordinates + const basegfx::B2DVector aWorldSize(aInverseViewTransformation * aDiscreteSize); + const basegfx::B2DPoint aWorldTopLeft(getObjectTransformation() * getTopLeft()); + + // build object matrix in world coordinates so that the top-left + // position remains, but eventual transformations (e.g. rotations) + // in the ObjectToView stack remain and get correctly applied + basegfx::B2DHomMatrix aObjectTransform; + + aObjectTransform.set(0, 0, aWorldSize.getX()); + aObjectTransform.set(1, 1, aWorldSize.getY()); + aObjectTransform.set(0, 2, aWorldTopLeft.getX()); + aObjectTransform.set(1, 2, aWorldTopLeft.getY()); + + // get inverse ObjectTransformation + basegfx::B2DHomMatrix aInverseObjectTransformation(getObjectTransformation()); + aInverseObjectTransformation.invert(); + + // transform to object coordinate system + aObjectTransform = aInverseObjectTransformation * aObjectTransform; + + // create BitmapPrimitive2D with now object-local coordinate data + const Primitive2DReference xRef(new BitmapPrimitive2D(getBitmapEx(), aObjectTransform)); + xRetval = Primitive2DSequence(&xRef, 1); + } + + return xRetval; + } + + DiscreteBitmapPrimitive2D::DiscreteBitmapPrimitive2D( + const BitmapEx& rBitmapEx, + const basegfx::B2DPoint& rTopLeft) + : ObjectAndViewTransformationDependentPrimitive2D(), + maBitmapEx(rBitmapEx), + maTopLeft(rTopLeft) + { + } + + bool DiscreteBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(ObjectAndViewTransformationDependentPrimitive2D::operator==(rPrimitive)) + { + const DiscreteBitmapPrimitive2D& rCompare = (DiscreteBitmapPrimitive2D&)rPrimitive; + + return (getBitmapEx() == rCompare.getBitmapEx() + && getTopLeft() == rCompare.getTopLeft()); + } + + return false; + } + + // provide unique ID + ImplPrimitrive2DIDBlock(DiscreteBitmapPrimitive2D, PRIMITIVE2D_ID_DISCRETEBITMAPPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx b/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx index 5805c02a61ed..0c0a863733de 100644 --- a/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/embedded3dprimitive2d.cxx @@ -84,7 +84,7 @@ namespace drawinglayer return maShadowPrimitives.hasElements(); } - Primitive2DSequence Embedded3DPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence Embedded3DPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { // use info to create a yellow 2d rectangle, similar to empty 3d scenes and/or groups const basegfx::B2DRange aLocal2DRange(getB2DRange(rViewInformation)); @@ -102,7 +102,7 @@ namespace drawinglayer const basegfx::B3DVector& rLightNormal, double fShadowSlant, const basegfx::B3DRange& rScene3DRange) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), mxChildren3D(rxChildren3D), maObjectTransformation(rObjectTransformation), maViewInformation3D(rViewInformation3D), @@ -118,7 +118,7 @@ namespace drawinglayer bool Embedded3DPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const Embedded3DPrimitive2D& rCompare = static_cast< const Embedded3DPrimitive2D& >(rPrimitive); diff --git a/drawinglayer/source/primitive2d/epsprimitive2d.cxx b/drawinglayer/source/primitive2d/epsprimitive2d.cxx new file mode 100644 index 000000000000..5854e90cfb9f --- /dev/null +++ b/drawinglayer/source/primitive2d/epsprimitive2d.cxx @@ -0,0 +1,111 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: backgroundcolorprimitive2d.cxx,v $ + * + * $Revision: 1.5 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_drawinglayer.hxx" + +#include <drawinglayer/primitive2d/epsprimitive2d.hxx> +#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <drawinglayer/primitive2d/metafileprimitive2d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence EpsPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + Primitive2DSequence xRetval; + const GDIMetaFile& rSubstituteContent = getMetaFile(); + + if(rSubstituteContent.GetActionCount()) + { + // the default decomposition will use the Metafile replacement visualisation. + // To really use the Eps data, a renderer has to know and interpret this primitive + // directly. + xRetval.realloc(1); + + xRetval[0] = Primitive2DReference( + new MetafilePrimitive2D( + getEpsTransform(), + rSubstituteContent)); + } + + return xRetval; + } + + EpsPrimitive2D::EpsPrimitive2D( + const basegfx::B2DHomMatrix& rEpsTransform, + const GfxLink& rGfxLink, + const GDIMetaFile& rMetaFile) + : BufferedDecompositionPrimitive2D(), + maEpsTransform(rEpsTransform), + maGfxLink(rGfxLink), + maMetaFile(rMetaFile) + { + } + + bool EpsPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) + { + const EpsPrimitive2D& rCompare = (EpsPrimitive2D&)rPrimitive; + + return (getEpsTransform() == rCompare.getEpsTransform() + && getGfxLink().IsEqual(rCompare.getGfxLink()) + && getMetaFile() == rCompare.getMetaFile()); + } + + return false; + } + + basegfx::B2DRange EpsPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // use own implementation to quickly answer the getB2DRange question. + basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0); + aRetval.transform(getEpsTransform()); + + return aRetval; + } + + // provide unique ID + ImplPrimitrive2DIDBlock(EpsPrimitive2D, PRIMITIVE2D_ID_EPSPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/fillbitmapprimitive2d.cxx b/drawinglayer/source/primitive2d/fillbitmapprimitive2d.cxx index 125c2cb42193..ab9e9d19f6d2 100644 --- a/drawinglayer/source/primitive2d/fillbitmapprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/fillbitmapprimitive2d.cxx @@ -54,9 +54,9 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence FillBitmapPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence FillBitmapPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { - const Size aTileSizePixel(getFillBitmap().getBitmap().GetSizePixel()); + const Size aTileSizePixel(getFillBitmap().getBitmapEx().GetSizePixel()); Primitive2DSequence aRetval; // is there a tile with some size at all? @@ -79,7 +79,7 @@ namespace drawinglayer aNewMatrix *= getTransformation(); // create bitmap primitive and add to result - const Primitive2DReference xRef(new BitmapPrimitive2D(BitmapEx(getFillBitmap().getBitmap()), aNewMatrix)); + const Primitive2DReference xRef(new BitmapPrimitive2D(getFillBitmap().getBitmapEx(), aNewMatrix)); aRetval[a] = xRef; } } @@ -94,7 +94,7 @@ namespace drawinglayer aObjectTransform *= getTransformation(); // create bitmap primitive and add exclusive to decomposition (hand over ownership) - const Primitive2DReference xRef(new BitmapPrimitive2D(BitmapEx(getFillBitmap().getBitmap()), aObjectTransform)); + const Primitive2DReference xRef(new BitmapPrimitive2D(getFillBitmap().getBitmapEx(), aObjectTransform)); aRetval = Primitive2DSequence(&xRef, 1L); } } @@ -105,7 +105,7 @@ namespace drawinglayer FillBitmapPrimitive2D::FillBitmapPrimitive2D( const basegfx::B2DHomMatrix& rTransformation, const attribute::FillBitmapAttribute& rFillBitmap) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransformation(rTransformation), maFillBitmap(rFillBitmap) { @@ -113,7 +113,7 @@ namespace drawinglayer bool FillBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const FillBitmapPrimitive2D& rCompare = static_cast< const FillBitmapPrimitive2D& >(rPrimitive); diff --git a/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx b/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx index ff0c031b38a1..625dae6cb93a 100644 --- a/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/fillgradientprimitive2d.cxx @@ -54,37 +54,27 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence FillGradientPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + void FillGradientPrimitive2D::generateMatricesAndColors( + std::vector< basegfx::B2DHomMatrix >& rMatrices, + std::vector< basegfx::BColor >& rColors) const { - const attribute::GradientStyle aGradientStyle(maFillGradient.getStyle()); - ::std::vector< basegfx::B2DHomMatrix > aMatrices; - ::std::vector< basegfx::BColor > aColors; - basegfx::B2DPolygon aUnitPolygon; - sal_uInt32 nSteps(maFillGradient.getSteps()); - - if(attribute::GRADIENTSTYLE_RADIAL == aGradientStyle || attribute::GRADIENTSTYLE_ELLIPTICAL == aGradientStyle) - { - const basegfx::B2DPoint aCircleCenter(0.5, 0.5); - aUnitPolygon = basegfx::tools::createPolygonFromEllipse(aCircleCenter, 0.5, 0.5); - } - else - { - aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0)); - } + rMatrices.clear(); + rColors.clear(); // make sure steps is not too high/low const basegfx::BColor aStart(maFillGradient.getStartColor()); const basegfx::BColor aEnd(maFillGradient.getEndColor()); const sal_uInt32 nMaxSteps(sal_uInt32((aStart.getMaximumDistance(aEnd) * 127.5) + 0.5)); + sal_uInt32 nSteps(maFillGradient.getSteps()); - if(nSteps == 0L) + if(nSteps == 0) { nSteps = nMaxSteps; } - if(nSteps < 2L) + if(nSteps < 2) { - nSteps = 2L; + nSteps = 2; } if(nSteps > nMaxSteps) @@ -92,82 +82,184 @@ namespace drawinglayer nSteps = nMaxSteps; } - switch(aGradientStyle) + switch(maFillGradient.getStyle()) { case attribute::GRADIENTSTYLE_LINEAR: { texture::GeoTexSvxGradientLinear aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), -maFillGradient.getAngle()); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformations(rMatrices); + aGradient.appendColors(rColors); break; } case attribute::GRADIENTSTYLE_AXIAL: { texture::GeoTexSvxGradientAxial aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), -maFillGradient.getAngle()); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformations(rMatrices); + aGradient.appendColors(rColors); break; } case attribute::GRADIENTSTYLE_RADIAL: { texture::GeoTexSvxGradientRadial aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), maFillGradient.getOffsetX(), maFillGradient.getOffsetY()); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformations(rMatrices); + aGradient.appendColors(rColors); break; } case attribute::GRADIENTSTYLE_ELLIPTICAL: { texture::GeoTexSvxGradientElliptical aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), maFillGradient.getOffsetX(), maFillGradient.getOffsetY(), -maFillGradient.getAngle()); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformations(rMatrices); + aGradient.appendColors(rColors); break; } case attribute::GRADIENTSTYLE_SQUARE: { texture::GeoTexSvxGradientSquare aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), maFillGradient.getOffsetX(), maFillGradient.getOffsetY(), -maFillGradient.getAngle()); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformations(rMatrices); + aGradient.appendColors(rColors); break; } case attribute::GRADIENTSTYLE_RECT: { texture::GeoTexSvxGradientRect aGradient(getObjectRange(), aStart, aEnd, nSteps, maFillGradient.getBorder(), maFillGradient.getOffsetX(), maFillGradient.getOffsetY(), -maFillGradient.getAngle()); - aGradient.appendTransformations(aMatrices); - aGradient.appendColors(aColors); + aGradient.appendTransformations(rMatrices); + aGradient.appendColors(rColors); break; } } + } + Primitive2DSequence FillGradientPrimitive2D::createOverlappingFill( + const std::vector< basegfx::B2DHomMatrix >& rMatrices, + const std::vector< basegfx::BColor >& rColors, + const basegfx::B2DPolygon& rUnitPolygon) const + { // prepare return value - Primitive2DSequence aRetval(aColors.size() ? aMatrices.size() + 1L : aMatrices.size()); + Primitive2DSequence aRetval(rColors.size() ? rMatrices.size() + 1 : rMatrices.size()); // create solid fill with start color - if(aColors.size()) + if(rColors.size()) { // create primitive - const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(getObjectRange())), aColors[0L])); - aRetval[0L] = xRef; + const Primitive2DReference xRef( + new PolyPolygonColorPrimitive2D( + basegfx::B2DPolyPolygon(basegfx::tools::createPolygonFromRect(getObjectRange())), + rColors[0])); + aRetval[0] = xRef; } // create solid fill steps - for(sal_uInt32 a(0L); a < aMatrices.size(); a++) + for(sal_uInt32 a(0); a < rMatrices.size(); a++) { // create part polygon - basegfx::B2DPolygon aNewPoly(aUnitPolygon); - aNewPoly.transform(aMatrices[a]); + basegfx::B2DPolygon aNewPoly(rUnitPolygon); + aNewPoly.transform(rMatrices[a]); // create solid fill - const Primitive2DReference xRef(new PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aNewPoly), aColors[a + 1L])); - aRetval[a + 1L] = xRef; + const Primitive2DReference xRef( + new PolyPolygonColorPrimitive2D( + basegfx::B2DPolyPolygon(aNewPoly), + rColors[a + 1])); + aRetval[a + 1] = xRef; + } + + return aRetval; + } + + Primitive2DSequence FillGradientPrimitive2D::createNonOverlappingFill( + const std::vector< basegfx::B2DHomMatrix >& rMatrices, + const std::vector< basegfx::BColor >& rColors, + const basegfx::B2DPolygon& rUnitPolygon) const + { + // prepare return value + Primitive2DSequence aRetval; + const sal_uInt32 nMatricesSize(rMatrices.size()); + + if(nMatricesSize) + { + basegfx::B2DPolygon aOuterPoly(rUnitPolygon); + aOuterPoly.transform(rMatrices[0]); + basegfx::B2DPolyPolygon aCombinedPolyPoly(aOuterPoly); + const sal_uInt32 nEntryCount(rColors.size() ? rMatrices.size() + 1 : rMatrices.size()); + sal_uInt32 nIndex(0); + + aRetval.realloc(nEntryCount); + + if(rColors.size()) + { + basegfx::B2DRange aOuterPolyRange(aOuterPoly.getB2DRange()); + aOuterPolyRange.expand(getObjectRange()); + aCombinedPolyPoly.append(basegfx::tools::createPolygonFromRect(aOuterPolyRange)); + aRetval[nIndex++] = Primitive2DReference(new PolyPolygonColorPrimitive2D(aCombinedPolyPoly, rColors[0])); + aCombinedPolyPoly = basegfx::B2DPolyPolygon(aOuterPoly); + } + + for(sal_uInt32 a(1); a < nMatricesSize - 1; a++) + { + basegfx::B2DPolygon aInnerPoly(rUnitPolygon); + aInnerPoly.transform(rMatrices[a]); + aCombinedPolyPoly.append(aInnerPoly); + aRetval[nIndex++] = Primitive2DReference(new PolyPolygonColorPrimitive2D(aCombinedPolyPoly, rColors[a])); + aCombinedPolyPoly = basegfx::B2DPolyPolygon(aInnerPoly); + } + + if(rColors.size()) + { + aRetval[nIndex] = Primitive2DReference(new PolyPolygonColorPrimitive2D( + aCombinedPolyPoly, rColors[rColors.size() - 1])); + } } return aRetval; } + Primitive2DSequence FillGradientPrimitive2D::createFill(bool bOverlapping) const + { + // prepare shape of the Unit Polygon + basegfx::B2DPolygon aUnitPolygon; + + if(attribute::GRADIENTSTYLE_RADIAL == maFillGradient.getStyle() + || attribute::GRADIENTSTYLE_ELLIPTICAL == maFillGradient.getStyle()) + { + const basegfx::B2DPoint aCircleCenter(0.5, 0.5); + aUnitPolygon = basegfx::tools::createPolygonFromEllipse(aCircleCenter, 0.5, 0.5); + } + else + { + aUnitPolygon = basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0)); + } + + // get the transform matrices and colors (where colors + // will have one more entry that matrices) + std::vector< basegfx::B2DHomMatrix > aMatrices; + std::vector< basegfx::BColor > aColors; + generateMatricesAndColors(aMatrices, aColors); + + if(bOverlapping) + { + return createOverlappingFill(aMatrices, aColors, aUnitPolygon); + } + else + { + return createNonOverlappingFill(aMatrices, aColors, aUnitPolygon); + } + } + + Primitive2DSequence FillGradientPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // default creates overlapping fill which works with AntiAliasing and without. + // The non-overlapping version does not create single filled polygons, but + // PolyPolygons where each one describes a 'ring' for the gradient such + // that the rings will not overlap. This is useful fir the old XOR-paint + // 'trick' of VCL which is recorded in Metafiles; so this version may be + // used from the MetafilePrimitive2D in it's decomposition. + return createFill(true); + } + FillGradientPrimitive2D::FillGradientPrimitive2D( const basegfx::B2DRange& rObjectRange, const attribute::FillGradientAttribute& rFillGradient) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maObjectRange(rObjectRange), maFillGradient(rFillGradient) { @@ -175,7 +267,7 @@ namespace drawinglayer bool FillGradientPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const FillGradientPrimitive2D& rCompare = (FillGradientPrimitive2D&)rPrimitive; diff --git a/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx index 06d04111686d..9e6e69516d43 100644 --- a/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/fillhatchprimitive2d.cxx @@ -55,7 +55,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence FillHatchPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence FillHatchPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { // create hatch const basegfx::BColor aHatchColor(maFillHatch.getColor()); @@ -125,7 +125,7 @@ namespace drawinglayer const basegfx::B2DRange& rObjectRange, const basegfx::BColor& rBColor, const attribute::FillHatchAttribute& rFillHatch) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maObjectRange(rObjectRange), maFillHatch(rFillHatch), maBColor(rBColor) @@ -134,7 +134,7 @@ namespace drawinglayer bool FillHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const FillHatchPrimitive2D& rCompare = (FillHatchPrimitive2D&)rPrimitive; diff --git a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx index 1ed826dab562..6d1540594dc9 100644 --- a/drawinglayer/source/primitive2d/graphicprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitive2d.cxx @@ -56,6 +56,18 @@ #include <vcl/svapp.hxx> ////////////////////////////////////////////////////////////////////////////// +// includes for testing MetafilePrimitive2D::create2DDecomposition + +// this switch defines if the test code is included or not +#undef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE + +#ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE +#include <vcl/gradient.hxx> +#include <vcl/pngread.hxx> +#include <vcl/lineinfo.hxx> +#endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE + +////////////////////////////////////////////////////////////////////////////// namespace { @@ -211,19 +223,52 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence GraphicPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence GraphicPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& +#ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE + rViewInformation +#else + /*rViewInformation*/ +#endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE + ) const { Primitive2DSequence aRetval; if(255L != getGraphicAttr().GetTransparency()) { - // get transformed graphic. Suppress rotation and cropping, only filtering is needed - // here (and may be replaced later on). Cropping is handled below as mask primitive (if set) + Primitive2DReference xPrimitive; + + // do not apply mirroring from GraphicAttr to the Metafile by calling + // GetTransformedGraphic, this will try to mirror the Metafile using Scale() + // at the Metafile. This again calls Scale at the single MetaFile actions, + // but this implementation never worked. I reworked that implementations, + // but for security reasons i will try not to use it. + basegfx::B2DHomMatrix aTransform(getTransform()); + + if(getGraphicAttr().IsMirrored()) + { + // content needs mirroring + const bool bHMirr(getGraphicAttr().GetMirrorFlags() & BMP_MIRROR_HORZ); + const bool bVMirr(getGraphicAttr().GetMirrorFlags() & BMP_MIRROR_VERT); + + // mirror by applying negative scale to the unit primitive and + // applying the object transformation on it. + aTransform = basegfx::tools::createScaleB2DHomMatrix( + bHMirr ? -1.0 : 1.0, + bVMirr ? -1.0 : 1.0); + aTransform.translate( + bHMirr ? 1.0 : 0.0, + bVMirr ? 1.0 : 0.0); + aTransform = getTransform() * aTransform; + } + + // Get transformed graphic. Suppress rotation and cropping, only filtering is needed + // here (and may be replaced later on). Cropping is handled below as mask primitive (if set). + // Also need to suppress mirroring, it is part of the transformation now (see above). GraphicAttr aSuppressGraphicAttr(getGraphicAttr()); - aSuppressGraphicAttr.SetCrop(0L, 0L, 0L, 0L); + aSuppressGraphicAttr.SetCrop(0, 0, 0, 0); aSuppressGraphicAttr.SetRotation(0); - Graphic aTransformedGraphic(getGraphicObject().GetTransformedGraphic(&aSuppressGraphicAttr)); - Primitive2DReference xPrimitive; + aSuppressGraphicAttr.SetMirrorFlags(0); + const Graphic aTransformedGraphic(getGraphicObject().GetTransformedGraphic(&aSuppressGraphicAttr)); switch(aTransformedGraphic.GetType()) { @@ -244,7 +289,7 @@ namespace drawinglayer { animation::AnimationEntryFixed aTime((double)aData.stepTime(a), (double)a / (double)aData.count()); aAnimationLoop.append(aTime); - const Primitive2DReference xRef(new BitmapPrimitive2D(aData.stepBitmapEx(a), getTransform())); + const Primitive2DReference xRef(new BitmapPrimitive2D(aData.stepBitmapEx(a), aTransform)); aBitmapPrimitives[a] = xRef; } @@ -258,7 +303,7 @@ namespace drawinglayer } else { - xPrimitive = Primitive2DReference(new BitmapPrimitive2D(aTransformedGraphic.GetBitmapEx(), getTransform())); + xPrimitive = Primitive2DReference(new BitmapPrimitive2D(aTransformedGraphic.GetBitmapEx(), aTransform)); } break; @@ -266,37 +311,480 @@ namespace drawinglayer case GRAPHIC_GDIMETAFILE : { - // create MetafilePrimitive2D - const GDIMetaFile& rMetafile = aTransformedGraphic.GetGDIMetaFile(); - - xPrimitive = Primitive2DReference( - new MetafilePrimitive2D( - getTransform(), - rMetafile)); - - // #i100357# find out if clipping is needed for this primitive. Unfortunately, - // there exist Metafiles who's content is bigger than the proposed PrefSize set - // at them. This is an error, but we need to work around this - const Size aMetaFilePrefSize(rMetafile.GetPrefSize()); - const Size aMetaFileRealSize( - const_cast< GDIMetaFile& >(rMetafile).GetBoundRect( - *Application::GetDefaultDevice()).GetSize()); - - if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth() - || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight()) +#ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE + static bool bDoTest(false); + + if(bDoTest) { - // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon - const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1); - basegfx::B2DPolygon aMaskPolygon( - basegfx::tools::createPolygonFromRect( - basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); - aMaskPolygon.transform(getTransform()); + // All this is/was test code for testing MetafilePrimitive2D::create2DDecomposition + // extensively. It may be needed again when diverse actions need debugging, so i leave + // it in here, but take it out using USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE. + // Use it by compiling with the code, insert any DrawObject, convert to Metafile. The + // debugger will then stop here (when breakpoint set, of course). You may enter single + // parts of actions and/or change to true what You want to check. + GDIMetaFile aMtf; + VirtualDevice aOut; + const basegfx::B2DRange aRange(getB2DRange(rViewInformation)); + const Rectangle aRectangle( + basegfx::fround(aRange.getMinX()), basegfx::fround(aRange.getMinY()), + basegfx::fround(aRange.getMaxX()), basegfx::fround(aRange.getMaxY())); + const Point aOrigin(aRectangle.TopLeft()); + const Fraction aScaleX(aRectangle.getWidth()); + const Fraction aScaleY(aRectangle.getHeight()); + MapMode aMapMode(MAP_100TH_MM, aOrigin, aScaleX, aScaleY); + + Size aDummySize(2, 2); + aOut.SetOutputSizePixel(aDummySize); + aOut.EnableOutput(FALSE); + aOut.SetMapMode(aMapMode); + + aMtf.Clear(); + aMtf.Record(&aOut); + + const Fraction aNeutralFraction(1, 1); + const MapMode aRelativeMapMode( + MAP_RELATIVE, + Point(-aRectangle.Left(), -aRectangle.Top()), + aNeutralFraction, aNeutralFraction); + aOut.SetMapMode(aRelativeMapMode); + + if(false) + { + const sal_Int32 nHor(aRectangle.getWidth() / 4); + const sal_Int32 nVer(aRectangle.getHeight() / 4); + const Rectangle aCenteredRectangle( + aRectangle.Left() + nHor, aRectangle.Top() + nVer, + aRectangle.Right() - nHor, aRectangle.Bottom() - nVer); + aOut.SetClipRegion(aCenteredRectangle); + } + + if(false) + { + const Rectangle aRightRectangle(aRectangle.TopCenter(), aRectangle.BottomRight()); + aOut.IntersectClipRegion(aRightRectangle); + } + + if(false) + { + const Rectangle aRightRectangle(aRectangle.TopCenter(), aRectangle.BottomRight()); + const Rectangle aBottomRectangle(aRectangle.LeftCenter(), aRectangle.BottomRight()); + Region aRegion(aRightRectangle); + aRegion.Intersect(aBottomRectangle); + aOut.IntersectClipRegion(aRegion); + } + + if(false) + { + const sal_Int32 nHor(aRectangle.getWidth() / 10); + const sal_Int32 nVer(aRectangle.getHeight() / 10); + aOut.MoveClipRegion(nHor, nVer); + } + + if(false) + { + Wallpaper aWallpaper(Color(COL_BLACK)); + aOut.DrawWallpaper(aRectangle, aWallpaper); + } + + if(false) + { + Wallpaper aWallpaper(Gradient(GRADIENT_LINEAR, Color(COL_RED), Color(COL_GREEN))); + aOut.DrawWallpaper(aRectangle, aWallpaper); + } + + if(false) + { + SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ); + vcl::PNGReader aPNGReader(aRead); + BitmapEx aBitmapEx(aPNGReader.Read()); + Wallpaper aWallpaper(aBitmapEx); + aOut.DrawWallpaper(aRectangle, aWallpaper); + } + + if(false) + { + const double fHor(aRectangle.getWidth()); + const double fVer(aRectangle.getHeight()); + Color aColor(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)); + + for(sal_uInt32 a(0); a < 5000; a++) + { + const Point aPoint( + aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), + aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0))); + + if(!(a % 3)) + { + aColor = Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0)); + } + + aOut.DrawPixel(aPoint, aColor); + } + } + + if(false) + { + const double fHor(aRectangle.getWidth()); + const double fVer(aRectangle.getHeight()); + + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(); + + for(sal_uInt32 a(0); a < 5000; a++) + { + const Point aPoint( + aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), + aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0))); + aOut.DrawPixel(aPoint); + } + } + + if(false) + { + const double fHor(aRectangle.getWidth()); + const double fVer(aRectangle.getHeight()); + + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(); + + Point aStart( + aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), + aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0))); + Point aStop( + aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), + aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0))); + + LineInfo aLineInfo(LINE_SOLID, basegfx::fround(fHor / 50.0)); + bool bUseLineInfo(false); + + for(sal_uInt32 a(0); a < 20; a++) + { + if(!(a%6)) + { + bUseLineInfo = !bUseLineInfo; + } + + if(!(a%4)) + { + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + } + + if(a%3) + { + aStart = aStop; + aStop = Point( + aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), + aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0))); + } + else + { + aStart = Point( + aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), + aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0))); + aStop = Point( + aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), + aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0))); + } + + if(bUseLineInfo) + { + aOut.DrawLine(aStart, aStop, aLineInfo); + } + else + { + aOut.DrawLine(aStart, aStop); + } + } + } + + if(false) + { + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.DrawRect(aRectangle); + } + + if(false) + { + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + const sal_uInt32 nHor(aRectangle.getWidth() / 10); + const sal_uInt32 nVer(aRectangle.getHeight() / 10); + aOut.DrawRect(aRectangle, nHor, nVer); + } + + if(false) + { + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.DrawEllipse(aRectangle); + } + + if(false) + { + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.DrawArc(aRectangle, aRectangle.TopLeft(), aRectangle.BottomCenter()); + } + + if(false) + { + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.DrawPie(aRectangle, aRectangle.TopLeft(), aRectangle.BottomCenter()); + } + + if(false) + { + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.DrawChord(aRectangle, aRectangle.TopLeft(), aRectangle.BottomCenter()); + } + + if(false) + { + const double fHor(aRectangle.getWidth()); + const double fVer(aRectangle.getHeight()); + + for(sal_uInt32 b(0); b < 5; b++) + { + const sal_uInt32 nCount(basegfx::fround(rand() * (20 / 32767.0))); + const bool bClose(basegfx::fround(rand() / 32767.0)); + Polygon aPolygon(nCount + (bClose ? 1 : 0)); + + for(sal_uInt32 a(0); a < nCount; a++) + { + const Point aPoint( + aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), + aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0))); + aPolygon[a] = aPoint; + } + + if(bClose) + { + aPolygon[aPolygon.GetSize() - 1] = aPolygon[0]; + } + + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + + if(!(b%2)) + { + const LineInfo aLineInfo(LINE_SOLID, basegfx::fround(fHor / 50.0)); + aOut.DrawPolyLine(aPolygon, aLineInfo); + } + else + { + aOut.DrawPolyLine(aPolygon); + } + } + } + + if(false) + { + const double fHor(aRectangle.getWidth()); + const double fVer(aRectangle.getHeight()); + + for(sal_uInt32 b(0); b < 5; b++) + { + const sal_uInt32 nCount(basegfx::fround(rand() * (20 / 32767.0))); + const bool bClose(basegfx::fround(rand() / 32767.0)); + Polygon aPolygon(nCount + (bClose ? 1 : 0)); + + for(sal_uInt32 a(0); a < nCount; a++) + { + const Point aPoint( + aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), + aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0))); + aPolygon[a] = aPoint; + } + + if(bClose) + { + aPolygon[aPolygon.GetSize() - 1] = aPolygon[0]; + } + + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.DrawPolygon(aPolygon); + } + } + + if(false) + { + const double fHor(aRectangle.getWidth()); + const double fVer(aRectangle.getHeight()); + PolyPolygon aPolyPolygon; + + for(sal_uInt32 b(0); b < 3; b++) + { + const sal_uInt32 nCount(basegfx::fround(rand() * (6 / 32767.0))); + const bool bClose(basegfx::fround(rand() / 32767.0)); + Polygon aPolygon(nCount + (bClose ? 1 : 0)); + + for(sal_uInt32 a(0); a < nCount; a++) + { + const Point aPoint( + aRectangle.Left() + basegfx::fround(rand() * (fHor / 32767.0)), + aRectangle.Top() + basegfx::fround(rand() * (fVer / 32767.0))); + aPolygon[a] = aPoint; + } + + if(bClose) + { + aPolygon[aPolygon.GetSize() - 1] = aPolygon[0]; + } + + aPolyPolygon.Insert(aPolygon); + } + + aOut.SetLineColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.SetFillColor(Color(basegfx::BColor(rand() / 32767.0, rand() / 32767.0, rand() / 32767.0))); + aOut.DrawPolyPolygon(aPolyPolygon); + } + + if(false) + { + SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ); + vcl::PNGReader aPNGReader(aRead); + BitmapEx aBitmapEx(aPNGReader.Read()); + aOut.DrawBitmapEx(aRectangle.TopLeft(), aBitmapEx); + } + + if(false) + { + SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ); + vcl::PNGReader aPNGReader(aRead); + BitmapEx aBitmapEx(aPNGReader.Read()); + aOut.DrawBitmapEx(aRectangle.TopLeft(), aRectangle.GetSize(), aBitmapEx); + } + + if(false) + { + SvFileStream aRead((const String&)String(ByteString( "c:\\test.png" ), RTL_TEXTENCODING_UTF8), STREAM_READ); + vcl::PNGReader aPNGReader(aRead); + BitmapEx aBitmapEx(aPNGReader.Read()); + const Size aSizePixel(aBitmapEx.GetSizePixel()); + aOut.DrawBitmapEx( + aRectangle.TopLeft(), + aRectangle.GetSize(), + Point(0, 0), + Size(aSizePixel.Width() /2, aSizePixel.Height() / 2), + aBitmapEx); + } + + if(false) + { + const double fHor(aRectangle.getWidth()); + const double fVer(aRectangle.getHeight()); + const Point aPointA( + aRectangle.Left() + basegfx::fround(fHor * 0.2), + aRectangle.Top() + basegfx::fround(fVer * 0.3)); + const Point aPointB( + aRectangle.Left() + basegfx::fround(fHor * 0.2), + aRectangle.Top() + basegfx::fround(fVer * 0.5)); + const Point aPointC( + aRectangle.Left() + basegfx::fround(fHor * 0.2), + aRectangle.Top() + basegfx::fround(fVer * 0.7)); + const String aText(ByteString("Hello, World!"), RTL_TEXTENCODING_UTF8); + + const String aFontName(ByteString("Comic Sans MS"), RTL_TEXTENCODING_UTF8); + Font aFont(aFontName, Size(0, 1000)); + aFont.SetAlign(ALIGN_BASELINE); + aFont.SetColor(COL_RED); + //sal_Int32* pDXArray = new sal_Int32[aText.Len()]; + + aFont.SetOutline(true); + aOut.SetFont(aFont); + aOut.DrawText(aPointA, aText, 0, aText.Len()); + + aFont.SetShadow(true); + aOut.SetFont(aFont); + aOut.DrawText(aPointB, aText, 0, aText.Len()); + + aFont.SetRelief(RELIEF_EMBOSSED); + aOut.SetFont(aFont); + aOut.DrawText(aPointC, aText, 0, aText.Len()); + + //delete pDXArray; + } + + if(false) + { + const double fHor(aRectangle.getWidth()); + const double fVer(aRectangle.getHeight()); + const Point aPointA( + aRectangle.Left() + basegfx::fround(fHor * 0.2), + aRectangle.Top() + basegfx::fround(fVer * 0.3)); + const Point aPointB( + aRectangle.Left() + basegfx::fround(fHor * 0.2), + aRectangle.Top() + basegfx::fround(fVer * 0.5)); + const Point aPointC( + aRectangle.Left() + basegfx::fround(fHor * 0.2), + aRectangle.Top() + basegfx::fround(fVer * 0.7)); + const String aText(ByteString("Hello, World!"), RTL_TEXTENCODING_UTF8); + + const String aFontName(ByteString("Comic Sans MS"), RTL_TEXTENCODING_UTF8); + Font aFont(aFontName, Size(0, 1000)); + aFont.SetAlign(ALIGN_BASELINE); + aFont.SetColor(COL_RED); + + aOut.SetFont(aFont); + const sal_Int32 nWidth(aOut.GetTextWidth(aText, 0, aText.Len())); + aOut.DrawText(aPointA, aText, 0, aText.Len()); + aOut.DrawTextLine(aPointA, nWidth, STRIKEOUT_SINGLE, UNDERLINE_SINGLE, UNDERLINE_SMALLWAVE); + aOut.DrawTextLine(aPointB, nWidth, STRIKEOUT_SINGLE, UNDERLINE_SINGLE, UNDERLINE_SMALLWAVE); + aOut.DrawTextLine(aPointC, nWidth, STRIKEOUT_SINGLE, UNDERLINE_SINGLE, UNDERLINE_SMALLWAVE); + } + + aMtf.Stop(); + aMtf.WindStart(); + aMtf.SetPrefMapMode(MapMode(MAP_100TH_MM)); + aMtf.SetPrefSize(Size(aRectangle.getWidth(), aRectangle.getHeight())); + + xPrimitive = Primitive2DReference( + new MetafilePrimitive2D( + aTransform, + aMtf)); + } + else + { +#endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE + // create MetafilePrimitive2D + const Graphic aGraphic(getGraphicObject().GetGraphic()); + const GDIMetaFile& rMetafile = aTransformedGraphic.GetGDIMetaFile(); xPrimitive = Primitive2DReference( - new MaskPrimitive2D( - basegfx::B2DPolyPolygon(aMaskPolygon), - aChildContent)); + new MetafilePrimitive2D( + aTransform, + rMetafile)); + + // #i100357# find out if clipping is needed for this primitive. Unfortunately, + // there exist Metafiles who's content is bigger than the proposed PrefSize set + // at them. This is an error, but we need to work around this + const Size aMetaFilePrefSize(rMetafile.GetPrefSize()); + const Size aMetaFileRealSize( + const_cast< GDIMetaFile& >(rMetafile).GetBoundRect( + *Application::GetDefaultDevice()).GetSize()); + + if(aMetaFileRealSize.getWidth() > aMetaFilePrefSize.getWidth() + || aMetaFileRealSize.getHeight() > aMetaFilePrefSize.getHeight()) + { + // clipping needed. Embed to MaskPrimitive2D. Create childs and mask polygon + const primitive2d::Primitive2DSequence aChildContent(&xPrimitive, 1); + basegfx::B2DPolygon aMaskPolygon( + basegfx::tools::createPolygonFromRect( + basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); + aMaskPolygon.transform(aTransform); + + xPrimitive = Primitive2DReference( + new MaskPrimitive2D( + basegfx::B2DPolyPolygon(aMaskPolygon), + aChildContent)); + } +#ifdef USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE } +#endif // USE_DEBUG_CODE_TO_TEST_METAFILE_DECOMPOSE break; } @@ -319,7 +807,9 @@ namespace drawinglayer getTransform().decompose(aScale, aTranslate, fRotate, fShearX); // create ranges. The current object range is just scale and translate - const basegfx::B2DRange aCurrent(aTranslate.getX(), aTranslate.getY(), aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY()); + const basegfx::B2DRange aCurrent( + aTranslate.getX(), aTranslate.getY(), + aTranslate.getX() + aScale.getX(), aTranslate.getY() + aScale.getY()); // calculate scalings between real image size and logic object size. This // is necessary since the crop values are relative to original bitmap size @@ -369,11 +859,15 @@ namespace drawinglayer // build new object transformation for transform primitive which contains xPrimitive basegfx::B2DHomMatrix aNewObjectTransform(getTransform()); aNewObjectTransform.invert(); - aNewObjectTransform.scale(aCropped.getWidth(), aCropped.getHeight()); - aNewObjectTransform.translate(aCropped.getMinX() - aCurrent.getMinX(), aCropped.getMinY() - aCurrent.getMinY()); - aNewObjectTransform.shearX(fShearX); - aNewObjectTransform.rotate(fRotate); - aNewObjectTransform.translate(aTranslate.getX(), aTranslate.getY()); + aNewObjectTransform = basegfx::tools::createScaleTranslateB2DHomMatrix( + aCropped.getWidth(), aCropped.getHeight(), + aCropped.getMinX() - aCurrent.getMinX(), aCropped.getMinY() - aCurrent.getMinY()) + * aNewObjectTransform; + + // add shear, rotate and translate using combined matrix to speedup + const basegfx::B2DHomMatrix aCombinedMatrix(basegfx::tools::createShearXRotateTranslateB2DHomMatrix( + fShearX, fRotate, aTranslate.getX(), aTranslate.getY())); + aNewObjectTransform = aCombinedMatrix * aNewObjectTransform; // prepare TransformPrimitive2D with xPrimitive const Primitive2DReference xTransformPrimitive(new TransformPrimitive2D(aNewObjectTransform, Primitive2DSequence(&xPrimitive, 1L))); @@ -410,7 +904,7 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rTransform, const GraphicObject& rGraphicObject, const GraphicAttr& rGraphicAttr) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), maGraphicObject(rGraphicObject), maGraphicAttr(rGraphicAttr) @@ -420,7 +914,7 @@ namespace drawinglayer GraphicPrimitive2D::GraphicPrimitive2D( const basegfx::B2DHomMatrix& rTransform, const GraphicObject& rGraphicObject) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), maGraphicObject(rGraphicObject), maGraphicAttr() @@ -429,7 +923,7 @@ namespace drawinglayer bool GraphicPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const GraphicPrimitive2D& rCompare = (GraphicPrimitive2D&)rPrimitive; diff --git a/drawinglayer/source/primitive2d/gridprimitive2d.cxx b/drawinglayer/source/primitive2d/gridprimitive2d.cxx index df4171309389..d2bd4b9d5243 100644 --- a/drawinglayer/source/primitive2d/gridprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/gridprimitive2d.cxx @@ -42,6 +42,7 @@ #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -53,7 +54,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence GridPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence GridPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { Primitive2DSequence aRetval; @@ -65,10 +66,8 @@ namespace drawinglayer getTransform().decompose(aScale, aTranslate, fRotate, fShearX); // create grid matrix which transforms from scaled logic to view - basegfx::B2DHomMatrix aRST; - aRST.shearX(fShearX); - aRST.rotate(fRotate); - aRST.translate(aTranslate.getX(), aTranslate.getY()); + basegfx::B2DHomMatrix aRST(basegfx::tools::createShearXRotateTranslateB2DHomMatrix( + fShearX, fRotate, aTranslate.getX(), aTranslate.getY())); aRST *= rViewInformation.getObjectToViewTransformation(); // get step widths @@ -248,7 +247,7 @@ namespace drawinglayer sal_uInt32 nSubdivisionsY, const basegfx::BColor& rBColor, const BitmapEx& rCrossMarker) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), mfWidth(fWidth), mfHeight(fHeight), @@ -265,7 +264,7 @@ namespace drawinglayer bool GridPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const GridPrimitive2D& rCompare = (GridPrimitive2D&)rPrimitive; @@ -299,16 +298,16 @@ namespace drawinglayer { ::osl::MutexGuard aGuard( m_aMutex ); - if(getLocalDecomposition().hasElements()) + if(getBuffered2DDecomposition().hasElements()) { if(maLastViewport != rViewInformation.getViewport() || maLastObjectToViewTransformation != rViewInformation.getObjectToViewTransformation()) { // conditions of last local decomposition have changed, delete - const_cast< GridPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + const_cast< GridPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); } } - if(!getLocalDecomposition().hasElements()) + if(!getBuffered2DDecomposition().hasElements()) { // remember ViewRange and ViewTransformation const_cast< GridPrimitive2D* >(this)->maLastObjectToViewTransformation = rViewInformation.getObjectToViewTransformation(); @@ -316,7 +315,7 @@ namespace drawinglayer } // use parent implementation - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID diff --git a/drawinglayer/source/primitive2d/groupprimitive2d.cxx b/drawinglayer/source/primitive2d/groupprimitive2d.cxx index ae899af6e84d..c9e2a1ea1438 100644 --- a/drawinglayer/source/primitive2d/groupprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/groupprimitive2d.cxx @@ -49,12 +49,6 @@ namespace drawinglayer { namespace primitive2d { - /// default: just return children, so all renderers not supporting group will use it's content - Primitive2DSequence GroupPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const - { - return getChildren(); - } - GroupPrimitive2D::GroupPrimitive2D( const Primitive2DSequence& rChildren ) : BasePrimitive2D(), maChildren(rChildren) @@ -77,6 +71,12 @@ namespace drawinglayer return false; } + /// default: just return children, so all renderers not supporting group will use it's content + Primitive2DSequence GroupPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + return getChildren(); + } + // provide unique ID ImplPrimitrive2DIDBlock(GroupPrimitive2D, PRIMITIVE2D_ID_GROUPPRIMITIVE2D) diff --git a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx index 3232e635b561..251ac110acd6 100644 --- a/drawinglayer/source/primitive2d/helplineprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/helplineprimitive2d.cxx @@ -54,7 +54,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence HelplinePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence HelplinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { std::vector< BasePrimitive2D* > aTempPrimitiveTarget; @@ -167,7 +167,7 @@ namespace drawinglayer const basegfx::BColor& rRGBColA, const basegfx::BColor& rRGBColB, double fDiscreteDashLength) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maPosition(rPosition), maDirection(rDirection), meStyle(eStyle), @@ -181,7 +181,7 @@ namespace drawinglayer bool HelplinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const HelplinePrimitive2D& rCompare = (HelplinePrimitive2D&)rPrimitive; @@ -200,16 +200,16 @@ namespace drawinglayer { ::osl::MutexGuard aGuard( m_aMutex ); - if(getLocalDecomposition().hasElements()) + if(getBuffered2DDecomposition().hasElements()) { if(maLastViewport != rViewInformation.getViewport() || maLastObjectToViewTransformation != rViewInformation.getObjectToViewTransformation()) { // conditions of last local decomposition have changed, delete - const_cast< HelplinePrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + const_cast< HelplinePrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); } } - if(!getLocalDecomposition().hasElements()) + if(!getBuffered2DDecomposition().hasElements()) { // remember ViewRange and ViewTransformation const_cast< HelplinePrimitive2D* >(this)->maLastObjectToViewTransformation = rViewInformation.getObjectToViewTransformation(); @@ -217,7 +217,7 @@ namespace drawinglayer } // use parent implementation - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID diff --git a/drawinglayer/source/primitive2d/hittestprimitive2d.cxx b/drawinglayer/source/primitive2d/hittestprimitive2d.cxx index daf65abd81d4..137f8cf8ad5c 100644 --- a/drawinglayer/source/primitive2d/hittestprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/hittestprimitive2d.cxx @@ -49,12 +49,6 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence HitTestPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const - { - // return empty sequence - return Primitive2DSequence(); - } - HitTestPrimitive2D::HitTestPrimitive2D( const Primitive2DSequence& rChildren) : GroupPrimitive2D(rChildren) @@ -66,6 +60,12 @@ namespace drawinglayer return getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation); } + Primitive2DSequence HitTestPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // return empty sequence + return Primitive2DSequence(); + } + // provide unique ID ImplPrimitrive2DIDBlock(HitTestPrimitive2D, PRIMITIVE2D_ID_HITTESTPRIMITIVE2D) diff --git a/drawinglayer/source/primitive2d/makefile.mk b/drawinglayer/source/primitive2d/makefile.mk index e10d1ddbcc71..c9a3cc191a35 100644 --- a/drawinglayer/source/primitive2d/makefile.mk +++ b/drawinglayer/source/primitive2d/makefile.mk @@ -53,7 +53,9 @@ SLOFILES= \ $(SLO)$/borderlineprimitive2d.obj \ $(SLO)$/chartprimitive2d.obj \ $(SLO)$/controlprimitive2d.obj \ + $(SLO)$/discretebitmapprimitive2d.obj \ $(SLO)$/embedded3dprimitive2d.obj \ + $(SLO)$/epsprimitive2d.obj \ $(SLO)$/fillbitmapprimitive2d.obj \ $(SLO)$/fillgradientprimitive2d.obj \ $(SLO)$/fillhatchprimitive2d.obj \ @@ -77,12 +79,16 @@ SLOFILES= \ $(SLO)$/shadowprimitive2d.obj \ $(SLO)$/structuretagprimitive2d.obj \ $(SLO)$/texteffectprimitive2d.obj \ + $(SLO)$/textenumsprimitive2d.obj \ $(SLO)$/textlayoutdevice.obj \ + $(SLO)$/textlineprimitive2d.obj \ $(SLO)$/textprimitive2d.obj \ + $(SLO)$/textstrikeoutprimitive2d.obj \ $(SLO)$/textdecoratedprimitive2d.obj \ $(SLO)$/texthierarchyprimitive2d.obj \ $(SLO)$/transformprimitive2d.obj \ $(SLO)$/unifiedalphaprimitive2d.obj \ + $(SLO)$/wallpaperprimitive2d.obj \ $(SLO)$/wrongspellprimitive2d.obj # --- Targets ---------------------------------- diff --git a/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx b/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx index 5737b9ef6cec..acb2335c0d1f 100644 --- a/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/markerarrayprimitive2d.cxx @@ -55,7 +55,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence MarkerArrayPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence MarkerArrayPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { Primitive2DSequence xRetval; const std::vector< basegfx::B2DPoint >& rPositions = getPositions(); @@ -100,7 +100,7 @@ namespace drawinglayer MarkerArrayPrimitive2D::MarkerArrayPrimitive2D( const std::vector< basegfx::B2DPoint >& rPositions, const BitmapEx& rMarker) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maPositions(rPositions), maMarker(rMarker) { @@ -108,7 +108,7 @@ namespace drawinglayer bool MarkerArrayPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const MarkerArrayPrimitive2D& rCompare = (MarkerArrayPrimitive2D&)rPrimitive; diff --git a/drawinglayer/source/primitive2d/maskprimitive2d.cxx b/drawinglayer/source/primitive2d/maskprimitive2d.cxx index 20a4c98db67d..b32abae874ca 100644 --- a/drawinglayer/source/primitive2d/maskprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/maskprimitive2d.cxx @@ -69,6 +69,11 @@ namespace drawinglayer return false; } + basegfx::B2DRange MaskPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + return getMask().getB2DRange(); + } + // provide unique ID ImplPrimitrive2DIDBlock(MaskPrimitive2D, PRIMITIVE2D_ID_MASKPRIMITIVE2D) diff --git a/drawinglayer/source/primitive2d/mediaprimitive2d.cxx b/drawinglayer/source/primitive2d/mediaprimitive2d.cxx index e8b6b6fbd5e6..76c2036eb71e 100644 --- a/drawinglayer/source/primitive2d/mediaprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/mediaprimitive2d.cxx @@ -53,7 +53,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence MediaPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence MediaPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { Primitive2DSequence xRetval(1); @@ -114,7 +114,7 @@ namespace drawinglayer const rtl::OUString& rURL, const basegfx::BColor& rBackgroundColor, sal_uInt32 nDiscreteBorder) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), maURL(rURL), maBackgroundColor(rBackgroundColor), @@ -124,7 +124,7 @@ namespace drawinglayer bool MediaPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const MediaPrimitive2D& rCompare = (MediaPrimitive2D&)rPrimitive; diff --git a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx index 2d1c0428a6a3..2fb3d119d4bd 100644 --- a/drawinglayer/source/primitive2d/metafileprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/metafileprimitive2d.cxx @@ -39,6 +39,39 @@ #include <drawinglayer/primitive2d/metafileprimitive2d.hxx> #include <basegfx/tools/canvastools.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <basegfx/color/bcolor.hxx> +#include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx> +#include <vcl/lineinfo.hxx> +#include <drawinglayer/attribute/lineattribute.hxx> +#include <drawinglayer/attribute/strokeattribute.hxx> +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#include <vcl/metaact.hxx> +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <drawinglayer/primitive2d/discretebitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <vcl/salbtype.hxx> +#include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx> +#include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx> +#include <vcl/svapp.hxx> +#include <drawinglayer/primitive2d/alphaprimitive2d.hxx> +#include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx> +#include <drawinglayer/primitive2d/maskprimitive2d.hxx> +#include <basegfx/polygon/b2dpolygonclipper.hxx> +#include <drawinglayer/primitive2d/invertprimitive2d.hxx> +#include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> +#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/wallpaperprimitive2d.hxx> +#include <drawinglayer/primitive2d/textprimitive2d.hxx> +#include <drawinglayer/primitive2d/textlayoutdevice.hxx> +#include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx> +#include <i18npool/mslangid.hxx> +#include <drawinglayer/primitive2d/textlineprimitive2d.hxx> +#include <drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx> +#include <drawinglayer/primitive2d/epsprimitive2d.hxx> +#include <numeric> ////////////////////////////////////////////////////////////////////////////// @@ -46,14 +79,2980 @@ using namespace com::sun::star; ////////////////////////////////////////////////////////////////////////////// +namespace +{ + /** helper class for graphic context + + This class allows to hold a complete status of classic + VCL OutputDevice stati. This data is needed for correct + interpretation of the MetaFile action flow. + */ + class PropertyHolder + { + private: + /// current transformation (aka MapMode) + basegfx::B2DHomMatrix maTransformation; + MapUnit maMapUnit; + + /// current colors + basegfx::BColor maLineColor; + basegfx::BColor maFillColor; + basegfx::BColor maTextColor; + basegfx::BColor maTextFillColor; + basegfx::BColor maTextLineColor; + basegfx::BColor maOverlineColor; + + /// clipping, font, etc. + Region maRegion; + Font maFont; + RasterOp maRasterOp; + sal_uInt32 mnLayoutMode; + LanguageType maLanguageType; + sal_uInt16 mnPushFlags; + + /// bitfield + /// contains all active markers + bool mbLineColor : 1; + bool mbFillColor : 1; + bool mbTextColor : 1; + bool mbTextFillColor : 1; + bool mbTextLineColor : 1; + bool mbOverlineColor : 1; + bool mbRegion : 1; + + public: + PropertyHolder() + : maTransformation(), + maMapUnit(MAP_100TH_MM), + maLineColor(), + maFillColor(), + maTextColor(COL_BLACK), + maTextFillColor(), + maTextLineColor(), + maOverlineColor(), + maRegion(), + maFont(), + maRasterOp(ROP_OVERPAINT), + mnLayoutMode(0), + maLanguageType(0), + mnPushFlags(0), + mbLineColor(false), + mbFillColor(false), + mbTextColor(true), + mbTextFillColor(false), + mbTextLineColor(false), + mbOverlineColor(false), + mbRegion(false) + { + } + + ~PropertyHolder() + { + } + + /// read/write accesses + const basegfx::B2DHomMatrix& getTransformation() const { return maTransformation; } + void setTransformation(const basegfx::B2DHomMatrix& rNew) { if(rNew != maTransformation) maTransformation = rNew; } + + MapUnit getMapUnit() const { return maMapUnit; } + void setMapUnit(MapUnit eNew) { if(eNew != maMapUnit) maMapUnit = eNew; } + + const basegfx::BColor& getLineColor() const { return maLineColor; } + void setLineColor(const basegfx::BColor& rNew) { if(rNew != maLineColor) maLineColor = rNew; } + bool getLineColorActive() const { return mbLineColor; } + void setLineColorActive(bool bNew) { if(bNew != mbLineColor) mbLineColor = bNew; } + + const basegfx::BColor& getFillColor() const { return maFillColor; } + void setFillColor(const basegfx::BColor& rNew) { if(rNew != maFillColor) maFillColor = rNew; } + bool getFillColorActive() const { return mbFillColor; } + void setFillColorActive(bool bNew) { if(bNew != mbFillColor) mbFillColor = bNew; } + + const basegfx::BColor& getTextColor() const { return maTextColor; } + void setTextColor(const basegfx::BColor& rNew) { if(rNew != maTextColor) maTextColor = rNew; } + bool getTextColorActive() const { return mbTextColor; } + void setTextColorActive(bool bNew) { if(bNew != mbTextColor) mbTextColor = bNew; } + + const basegfx::BColor& getTextFillColor() const { return maTextFillColor; } + void setTextFillColor(const basegfx::BColor& rNew) { if(rNew != maTextFillColor) maTextFillColor = rNew; } + bool getTextFillColorActive() const { return mbTextFillColor; } + void setTextFillColorActive(bool bNew) { if(bNew != mbTextFillColor) mbTextFillColor = bNew; } + + const basegfx::BColor& getTextLineColor() const { return maTextLineColor; } + void setTextLineColor(const basegfx::BColor& rNew) { if(rNew != maTextLineColor) maTextLineColor = rNew; } + bool getTextLineColorActive() const { return mbTextLineColor; } + void setTextLineColorActive(bool bNew) { if(bNew != mbTextLineColor) mbTextLineColor = bNew; } + + const basegfx::BColor& getOverlineColor() const { return maOverlineColor; } + void setOverlineColor(const basegfx::BColor& rNew) { if(rNew != maOverlineColor) maOverlineColor = rNew; } + bool getOverlineColorActive() const { return mbOverlineColor; } + void setOverlineColorActive(bool bNew) { if(bNew != mbOverlineColor) mbOverlineColor = bNew; } + + const Region& getRegion() const { return maRegion; } + void setRegion(const Region& rRegion) { if(rRegion != maRegion) maRegion = rRegion; } + bool getRegionActive() const { return mbRegion; } + void setRegionActive(bool bNew) { if(bNew != mbRegion) mbRegion = bNew; } + + const Font& getFont() const { return maFont; } + void setFont(const Font& rFont) { if(rFont != maFont) maFont = rFont; } + + const RasterOp& getRasterOp() const { return maRasterOp; } + void setRasterOp(const RasterOp& rRasterOp) { if(rRasterOp != maRasterOp) maRasterOp = rRasterOp; } + bool isRasterOpInvert() const { return (ROP_XOR == maRasterOp || ROP_INVERT == maRasterOp); } + bool isRasterOpForceBlack() const { return ROP_0 == maRasterOp; } + bool isRasterOpActive() const { return isRasterOpInvert() || isRasterOpForceBlack(); } + + sal_uInt32 getLayoutMode() const { return mnLayoutMode; } + void setLayoutMode(sal_uInt32 nNew) { if(nNew != mnLayoutMode) mnLayoutMode = nNew; } + + LanguageType getLanguageType() const { return maLanguageType; } + void setLanguageType(LanguageType aNew) { if(aNew != maLanguageType) maLanguageType = aNew; } + + sal_uInt16 getPushFlags() const { return mnPushFlags; } + void setPushFlags(sal_uInt16 nNew) { if(nNew != mnPushFlags) mnPushFlags = nNew; } + + bool getLineOrFillActive() const { return (mbLineColor || mbFillColor); } + }; +} // end of anonymous namespace + +////////////////////////////////////////////////////////////////////////////// + +namespace +{ + /** stack for properites + + This class builds a stack based on the PropertyHolder + class. It encapsulates the pointer/new/delete usage to + make it safe and implements the push/pop as needed by a + VCL Metafile interpreter. The critical part here are the + flag values VCL OutputDevice uses here; not all stuff is + pushed and thus needs to be copied at pop. + */ + class PropertyHolders + { + private: + std::vector< PropertyHolder* > maPropertyHolders; + + public: + PropertyHolders() + { + maPropertyHolders.push_back(new PropertyHolder()); + } + + sal_uInt32 size() + { + return maPropertyHolders.size(); + } + + void Push(sal_uInt16 nPushFlags) + { + if(nPushFlags) + { + OSL_ENSURE(maPropertyHolders.size(), "PropertyHolders: PUSH with no property holders (!)"); + PropertyHolder* pNew = new PropertyHolder(*maPropertyHolders.back()); + pNew->setPushFlags(nPushFlags); + maPropertyHolders.push_back(pNew); + } + } + + void Pop() + { + OSL_ENSURE(maPropertyHolders.size(), "PropertyHolders: POP with no property holders (!)"); + const sal_uInt32 nSize(maPropertyHolders.size()); + + if(nSize) + { + const PropertyHolder* pTip = maPropertyHolders.back(); + const sal_uInt16 nPushFlags(pTip->getPushFlags()); + + if(nPushFlags) + { + if(nSize > 1) + { + // copy back content for all non-set flags + PropertyHolder* pLast = maPropertyHolders[nSize - 2]; + + if(PUSH_ALL != nPushFlags) + { + if(!(nPushFlags & PUSH_LINECOLOR )) + { + pLast->setLineColor(pTip->getLineColor()); + pLast->setLineColorActive(pTip->getLineColorActive()); + } + if(!(nPushFlags & PUSH_FILLCOLOR )) + { + pLast->setFillColor(pTip->getFillColor()); + pLast->setFillColorActive(pTip->getFillColorActive()); + } + if(!(nPushFlags & PUSH_FONT )) + { + pLast->setFont(pTip->getFont()); + } + if(!(nPushFlags & PUSH_TEXTCOLOR )) + { + pLast->setTextColor(pTip->getTextColor()); + pLast->setTextColorActive(pTip->getTextColorActive()); + } + if(!(nPushFlags & PUSH_MAPMODE )) + { + pLast->setTransformation(pTip->getTransformation()); + pLast->setMapUnit(pTip->getMapUnit()); + } + if(!(nPushFlags & PUSH_CLIPREGION )) + { + pLast->setRegion(pTip->getRegion()); + pLast->setRegionActive(pTip->getRegionActive()); + } + if(!(nPushFlags & PUSH_RASTEROP )) + { + pLast->setRasterOp(pTip->getRasterOp()); + } + if(!(nPushFlags & PUSH_TEXTFILLCOLOR )) + { + pLast->setTextFillColor(pTip->getTextFillColor()); + pLast->setTextFillColorActive(pTip->getTextFillColorActive()); + } + if(!(nPushFlags & PUSH_TEXTALIGN )) + { + if(pLast->getFont().GetAlign() != pTip->getFont().GetAlign()) + { + Font aFont(pLast->getFont()); + aFont.SetAlign(pTip->getFont().GetAlign()); + pLast->setFont(aFont); + } + } + if(!(nPushFlags & PUSH_REFPOINT )) + { + // not supported + } + if(!(nPushFlags & PUSH_TEXTLINECOLOR )) + { + pLast->setTextLineColor(pTip->getTextLineColor()); + pLast->setTextLineColorActive(pTip->getTextLineColorActive()); + } + if(!(nPushFlags & PUSH_TEXTLAYOUTMODE )) + { + pLast->setLayoutMode(pTip->getLayoutMode()); + } + if(!(nPushFlags & PUSH_TEXTLANGUAGE )) + { + pLast->setLanguageType(pTip->getLanguageType()); + } + if(!(nPushFlags & PUSH_OVERLINECOLOR )) + { + pLast->setOverlineColor(pTip->getOverlineColor()); + pLast->setOverlineColorActive(pTip->getOverlineColorActive()); + } + } + } + + // execute the pop + delete maPropertyHolders.back(); + maPropertyHolders.pop_back(); + } + } + } + + PropertyHolder& Current() + { + OSL_ENSURE(maPropertyHolders.size(), "PropertyHolders: CURRENT with no property holders (!)"); + return *maPropertyHolders.back(); + } + + ~PropertyHolders() + { + while(maPropertyHolders.size()) + { + delete maPropertyHolders.back(); + maPropertyHolders.pop_back(); + } + } + }; +} // end of anonymous namespace + +////////////////////////////////////////////////////////////////////////////// + +namespace +{ + /** helper to convert a Region to a B2DPolyPolygon + when it does not yet contain one. In the future + this may be expanded to merge the polygons created + from rectangles or use a special algo to directly turn + the spans of regions to a single, already merged + PolyPolygon. + */ + basegfx::B2DPolyPolygon getB2DPolyPolygonFromRegion(const Region& rRegion) + { + basegfx::B2DPolyPolygon aRetval; + + if(!rRegion.IsEmpty()) + { + Region aRegion(rRegion); + aRetval = aRegion.GetB2DPolyPolygon(); + + if(!aRetval.count()) + { + RegionHandle aRegionHandle(aRegion.BeginEnumRects()); + Rectangle aRegionRectangle; + + while(aRegion.GetEnumRects(aRegionHandle, aRegionRectangle)) + { + if(!aRegionRectangle.IsEmpty()) + { + const basegfx::B2DRange aRegionRange( + aRegionRectangle.Left(), aRegionRectangle.Top(), + aRegionRectangle.Right(), aRegionRectangle.Bottom()); + aRetval.append(basegfx::tools::createPolygonFromRect(aRegionRange)); + } + } + + aRegion.EndEnumRects(aRegionHandle); + } + } + + return aRetval; + } +} // end of anonymous namespace + +////////////////////////////////////////////////////////////////////////////// + +namespace +{ + /** Helper class to buffer and hold a Primive target vector. It + encapsulates the new/delete functionality and aloows to work + on pointers of the implementation classes. All data will + be converted to uno sequences of uno references when accessing the + data. + */ + class TargetHolder + { + private: + std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aTargets; + + public: + TargetHolder() + : aTargets() + { + } + + ~TargetHolder() + { + const sal_uInt32 nCount(aTargets.size()); + + for(sal_uInt32 a(0); a < nCount; a++) + { + delete aTargets[a]; + } + } + + sal_uInt32 size() + { + return aTargets.size(); + } + + void append(drawinglayer::primitive2d::BasePrimitive2D* pCandidate) + { + if(pCandidate) + { + aTargets.push_back(pCandidate); + } + } + + drawinglayer::primitive2d::Primitive2DSequence getPrimitive2DSequence(const PropertyHolder& rPropertyHolder) + { + const sal_uInt32 nCount(aTargets.size()); + drawinglayer::primitive2d::Primitive2DSequence xRetval(nCount); + + for(sal_uInt32 a(0); a < nCount; a++) + { + xRetval[a] = aTargets[a]; + } + + // All Targets were pointers, but do not need to be deleted since they + // were converted to UNO API references now, so they stay as long as + // referenced. Do NOT delete the C++ implementation classes here, but clear + // the buffer to not delete them in the destructor. + aTargets.clear(); + + if(xRetval.hasElements() && rPropertyHolder.getRegionActive()) + { + const Region& rRegion = rPropertyHolder.getRegion(); + + if(!rRegion.IsEmpty()) + { + basegfx::B2DPolyPolygon aClipPolyPolygon(getB2DPolyPolygonFromRegion(rRegion)); + + if(aClipPolyPolygon.count()) + { + aClipPolyPolygon.transform(rPropertyHolder.getTransformation()); + + const drawinglayer::primitive2d::Primitive2DReference xMask( + new drawinglayer::primitive2d::MaskPrimitive2D( + aClipPolyPolygon, + xRetval)); + + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xMask, 1); + } + } + } + + return xRetval; + } + }; +} // end of anonymous namespace + +////////////////////////////////////////////////////////////////////////////// + +namespace +{ + /** Helper class which builds a stack on the TargetHolder class */ + class TargetHolders + { + private: + std::vector< TargetHolder* > maTargetHolders; + + public: + TargetHolders() + { + maTargetHolders.push_back(new TargetHolder()); + } + + sal_uInt32 size() + { + return maTargetHolders.size(); + } + + void Push() + { + maTargetHolders.push_back(new TargetHolder()); + } + + void Pop() + { + OSL_ENSURE(maTargetHolders.size(), "TargetHolders: POP with no property holders (!)"); + if(maTargetHolders.size()) + { + delete maTargetHolders.back(); + maTargetHolders.pop_back(); + } + } + + TargetHolder& Current() + { + OSL_ENSURE(maTargetHolders.size(), "TargetHolders: CURRENT with no property holders (!)"); + return *maTargetHolders.back(); + } + + ~TargetHolders() + { + while(maTargetHolders.size()) + { + delete maTargetHolders.back(); + maTargetHolders.pop_back(); + } + } + }; +} // end of anonymous namespace + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + /** NonOverlappingFillGradientPrimitive2D class + + This is a special version of the FillGradientPrimitive2D which decomposes + to a non-overlapping geometry version of the gradient. This needs to be + used to support the old XOR paint-'trick'. + + It does not need an own identifier since a renderer who wants to interpret + it itself may do so. It just overloads the decomposition of the C++ + implementation class to do an alternative decomposition. + */ + class NonOverlappingFillGradientPrimitive2D : public FillGradientPrimitive2D + { + protected: + /// local decomposition. + virtual Primitive2DSequence create2DDecomposition( + const geometry::ViewInformation2D& rViewInformation) const; + + public: + /// constructor + NonOverlappingFillGradientPrimitive2D( + const basegfx::B2DRange& rObjectRange, + const attribute::FillGradientAttribute& rFillGradient) + : FillGradientPrimitive2D(rObjectRange, rFillGradient) + { + } + }; + + Primitive2DSequence NonOverlappingFillGradientPrimitive2D::create2DDecomposition( + const geometry::ViewInformation2D& /*rViewInformation*/) const + { + return createFill(false); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace +{ + /** helper to convert a MapMode to a transformation */ + basegfx::B2DHomMatrix getTransformFromMapMode(const MapMode& rMapMode) + { + basegfx::B2DHomMatrix aMapping; + const Fraction aNoScale(1, 1); + const Point& rOrigin(rMapMode.GetOrigin()); + + if(0 != rOrigin.X() || 0 != rOrigin.Y()) + { + aMapping.translate(rOrigin.X(), rOrigin.Y()); + } + + if(rMapMode.GetScaleX() != aNoScale || rMapMode.GetScaleY() != aNoScale) + { + aMapping.scale( + double(rMapMode.GetScaleX()), + double(rMapMode.GetScaleY())); + } + + return aMapping; + } + + /** helper to create a PointArrayPrimitive2D based on current context */ + void createPointArrayPrimitive( + const std::vector< basegfx::B2DPoint >& rPositions, + TargetHolder& rTarget, + PropertyHolder& rProperties, + basegfx::BColor aBColor) + { + if(rPositions.size()) + { + if(rProperties.getTransformation().isIdentity()) + { + rTarget.append( + new drawinglayer::primitive2d::PointArrayPrimitive2D( + rPositions, + aBColor)); + } + else + { + std::vector< basegfx::B2DPoint > aPositions(rPositions); + + for(sal_uInt32 a(0); a < aPositions.size(); a++) + { + aPositions[a] = rProperties.getTransformation() * aPositions[a]; + } + + rTarget.append( + new drawinglayer::primitive2d::PointArrayPrimitive2D( + aPositions, + aBColor)); + } + } + } + + /** helper to create a PolygonHairlinePrimitive2D based on current context */ + void createHairlinePrimitive( + const basegfx::B2DPolygon& rLinePolygon, + TargetHolder& rTarget, + PropertyHolder& rProperties) + { + if(rLinePolygon.count()) + { + basegfx::B2DPolygon aLinePolygon(rLinePolygon); + aLinePolygon.transform(rProperties.getTransformation()); + rTarget.append( + new drawinglayer::primitive2d::PolygonHairlinePrimitive2D( + aLinePolygon, + rProperties.getLineColor())); + } + } + + /** helper to create a PolyPolygonColorPrimitive2D based on current context */ + void createFillPrimitive( + const basegfx::B2DPolyPolygon& rFillPolyPolygon, + TargetHolder& rTarget, + PropertyHolder& rProperties) + { + if(rFillPolyPolygon.count()) + { + basegfx::B2DPolyPolygon aFillPolyPolygon(rFillPolyPolygon); + aFillPolyPolygon.transform(rProperties.getTransformation()); + rTarget.append( + new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( + aFillPolyPolygon, + rProperties.getFillColor())); + } + } + + /** helper to create a PolygonStrokePrimitive2D based on current context */ + void createLinePrimitive( + const basegfx::B2DPolygon& rLinePolygon, + const LineInfo& rLineInfo, + TargetHolder& rTarget, + PropertyHolder& rProperties) + { + if(rLinePolygon.count()) + { + const bool bDashDotUsed(LINE_DASH == rLineInfo.GetStyle()); + const bool bWidthUsed(rLineInfo.GetWidth() > 1); + + if(bDashDotUsed || bWidthUsed) + { + basegfx::B2DPolygon aLinePolygon(rLinePolygon); + aLinePolygon.transform(rProperties.getTransformation()); + const drawinglayer::attribute::LineAttribute aLineAttribute( + rProperties.getLineColor(), + bWidthUsed ? rLineInfo.GetWidth() : 0.0, + rLineInfo.GetLineJoin()); + + if(bDashDotUsed) + { + ::std::vector< double > fDotDashArray; + const double fDashLen(rLineInfo.GetDashLen()); + const double fDotLen(rLineInfo.GetDotLen()); + const double fDistance(rLineInfo.GetDistance()); + + for(sal_uInt16 a(0); a < rLineInfo.GetDashCount(); a++) + { + fDotDashArray.push_back(fDashLen); + fDotDashArray.push_back(fDistance); + } + + for(sal_uInt16 b(0); b < rLineInfo.GetDotCount(); b++) + { + fDotDashArray.push_back(fDotLen); + fDotDashArray.push_back(fDistance); + } + + const double fAccumulated(::std::accumulate(fDotDashArray.begin(), fDotDashArray.end(), 0.0)); + const drawinglayer::attribute::StrokeAttribute aStrokeAttribute( + fDotDashArray, + fAccumulated); + + rTarget.append( + new drawinglayer::primitive2d::PolygonStrokePrimitive2D( + aLinePolygon, + aLineAttribute, + aStrokeAttribute)); + } + else + { + rTarget.append( + new drawinglayer::primitive2d::PolygonStrokePrimitive2D( + aLinePolygon, + aLineAttribute)); + } + } + else + { + createHairlinePrimitive(rLinePolygon, rTarget, rProperties); + } + } + } + + /** helper to create needed line and fill primitives based on current context */ + void createHairlineAndFillPrimitive( + const basegfx::B2DPolygon& rPolygon, + TargetHolder& rTarget, + PropertyHolder& rProperties) + { + if(rProperties.getFillColorActive()) + { + createFillPrimitive(basegfx::B2DPolyPolygon(rPolygon), rTarget, rProperties); + } + + if(rProperties.getLineColorActive()) + { + createHairlinePrimitive(rPolygon, rTarget, rProperties); + } + } + + /** helper to create needed line and fill primitives based on current context */ + void createHairlineAndFillPrimitive( + const basegfx::B2DPolyPolygon& rPolyPolygon, + TargetHolder& rTarget, + PropertyHolder& rProperties) + { + if(rProperties.getFillColorActive()) + { + createFillPrimitive(rPolyPolygon, rTarget, rProperties); + } + + if(rProperties.getLineColorActive()) + { + for(sal_uInt32 a(0); a < rPolyPolygon.count(); a++) + { + createHairlinePrimitive(rPolyPolygon.getB2DPolygon(a), rTarget, rProperties); + } + } + } + + /** helper to create DiscreteBitmapPrimitive2D based on current context. + The DiscreteBitmapPrimitive2D is especially created for this usage + since no other usage defines a bitmap visualisation based on top-left + position and size in pixels. At the end it will create a view-dependent + transformed embedding of a BitmapPrimitive2D. + */ + void createBitmapExPrimitive( + const BitmapEx& rBitmapEx, + const Point& rPoint, + TargetHolder& rTarget, + PropertyHolder& rProperties) + { + if(!rBitmapEx.IsEmpty()) + { + basegfx::B2DPoint aPoint(rPoint.X(), rPoint.Y()); + aPoint = rProperties.getTransformation() * aPoint; + + rTarget.append( + new drawinglayer::primitive2d::DiscreteBitmapPrimitive2D( + rBitmapEx, + aPoint)); + } + } + + /** helper to create BitmapPrimitive2D based on current context */ + void createBitmapExPrimitive( + const BitmapEx& rBitmapEx, + const Point& rPoint, + const Size& rSize, + TargetHolder& rTarget, + PropertyHolder& rProperties) + { + if(!rBitmapEx.IsEmpty()) + { + basegfx::B2DHomMatrix aObjectTransform; + + aObjectTransform.set(0, 0, rSize.Width()); + aObjectTransform.set(1, 1, rSize.Height()); + aObjectTransform.set(0, 2, rPoint.X()); + aObjectTransform.set(1, 2, rPoint.Y()); + + aObjectTransform = rProperties.getTransformation() * aObjectTransform; + + rTarget.append( + new drawinglayer::primitive2d::BitmapPrimitive2D( + rBitmapEx, + aObjectTransform)); + } + } + + /** helper to create a regular BotmapEx from a MaskAction (definitions + which use a bitmap without alpha but define one of the colors as + transparent) + */ + BitmapEx createMaskBmpEx(const Bitmap& rBitmap, const Color& rMaskColor) + { + const Color aWhite(COL_WHITE); + BitmapPalette aBiLevelPalette(2); + + aBiLevelPalette[0] = aWhite; + aBiLevelPalette[1] = rMaskColor; + + Bitmap aMask(rBitmap.CreateMask(aWhite)); + Bitmap aSolid(rBitmap.GetSizePixel(), 1, &aBiLevelPalette); + + aSolid.Erase(rMaskColor); + + return BitmapEx(aSolid, aMask); + } + + /** helper to convert from a VCL Gradient definition to the corresponding + data for primitive representation + */ + drawinglayer::attribute::FillGradientAttribute createFillGradientAttribute(const Gradient& rGradient) + { + const Color aStartColor(rGradient.GetStartColor()); + const sal_uInt16 nStartIntens(rGradient.GetStartIntensity()); + basegfx::BColor aStart(aStartColor.getBColor()); + + if(nStartIntens != 100) + { + const basegfx::BColor aBlack; + aStart = interpolate(aBlack, aStart, (double)nStartIntens * 0.01); + } + + const Color aEndColor(rGradient.GetEndColor()); + const sal_uInt16 nEndIntens(rGradient.GetEndIntensity()); + basegfx::BColor aEnd(aEndColor.getBColor()); + + if(nEndIntens != 100) + { + const basegfx::BColor aBlack; + aEnd = interpolate(aBlack, aEnd, (double)nEndIntens * 0.01); + } + + drawinglayer::attribute::GradientStyle aGradientStyle(drawinglayer::attribute::GRADIENTSTYLE_RECT); + + switch(rGradient.GetStyle()) + { + case GRADIENT_LINEAR : + { + aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_LINEAR; + break; + } + case GRADIENT_AXIAL : + { + aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_AXIAL; + break; + } + case GRADIENT_RADIAL : + { + aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_RADIAL; + break; + } + case GRADIENT_ELLIPTICAL : + { + aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_ELLIPTICAL; + break; + } + case GRADIENT_SQUARE : + { + aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_SQUARE; + break; + } + default : // GRADIENT_RECT + { + aGradientStyle = drawinglayer::attribute::GRADIENTSTYLE_RECT; + break; + } + } + + return drawinglayer::attribute::FillGradientAttribute( + aGradientStyle, + (double)rGradient.GetBorder() * 0.01, + (double)rGradient.GetOfsX() * 0.01, + (double)rGradient.GetOfsY() * 0.01, + (double)rGradient.GetAngle() * F_PI1800, + aStart, + aEnd, + rGradient.GetSteps()); + } + + /** helper to convert from a VCL Hatch definition to the corresponding + data for primitive representation + */ + drawinglayer::attribute::FillHatchAttribute createFillHatchAttribute(const Hatch& rHatch) + { + drawinglayer::attribute::HatchStyle aHatchStyle(drawinglayer::attribute::HATCHSTYLE_SINGLE); + + switch(rHatch.GetStyle()) + { + default : // case HATCH_SINGLE : + { + aHatchStyle = drawinglayer::attribute::HATCHSTYLE_SINGLE; + } + case HATCH_DOUBLE : + { + aHatchStyle = drawinglayer::attribute::HATCHSTYLE_DOUBLE; + } + case HATCH_TRIPLE : + { + aHatchStyle = drawinglayer::attribute::HATCHSTYLE_TRIPLE; + } + } + + return drawinglayer::attribute::FillHatchAttribute( + aHatchStyle, + (double)rHatch.GetDistance(), + (double)rHatch.GetAngle() * F_PI1800, + rHatch.GetColor().getBColor(), + false); + } + + /** helper to take needed action on ClipRegion change. This method needs to be called + on any Region change, e.g. at the obvious actions doing this, but also at pop-calls + whcih change the Region of the current context. It takes care of creating the + current embeddec context, set the new Region at the context and eventually prepare + a new target for embracing new geometry to the current region + */ + void HandleNewClipRegion( + const Region* pRegion, + TargetHolders& rTargetHolders, + PropertyHolders& rPropertyHolders) + { + // process evtl. created primitives which belong to the current region settings + if(rPropertyHolders.Current().getRegionActive() && rTargetHolders.size() > 1) + { + drawinglayer::primitive2d::Primitive2DSequence aSubContent; + + if(!rPropertyHolders.Current().getRegion().IsEmpty() && rTargetHolders.Current().size()) + { + aSubContent = rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current()); + } + + rTargetHolders.Pop(); + + if(aSubContent.hasElements()) + { + rTargetHolders.Current().append( + new drawinglayer::primitive2d::GroupPrimitive2D( + aSubContent)); + } + } + + // apply new settings + const bool bNewActive(pRegion && !pRegion->IsEmpty()); + rPropertyHolders.Current().setRegionActive(bNewActive); + + if(bNewActive) + { + rPropertyHolders.Current().setRegion(*pRegion); + + // prepare new content holder for new active region + rTargetHolders.Push(); + } + } + + /** helper to handle the change of RasterOp. It takes care of encapsulating all current + geometry to the current RasterOp (if changed) and needs to be called on any RasterOp + change. It will also start a new geometry target to embrace to the new RasterOp if + a changuing RasterOp is used. Currently, ROP_XOR and ROP_INVERT are supported using + InvertPrimitive2D, and ROP_0 by using a ModifiedColorPrimitive2D to force to black paint + */ + void HandleNewRasterOp( + RasterOp aRasterOp, + TargetHolders& rTargetHolders, + PropertyHolders& rPropertyHolders) + { + // check if currently active + if(rPropertyHolders.Current().isRasterOpActive() && rTargetHolders.size() > 1) + { + drawinglayer::primitive2d::Primitive2DSequence aSubContent; + + if(rTargetHolders.Current().size()) + { + aSubContent = rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current()); + } + + rTargetHolders.Pop(); + + if(aSubContent.hasElements()) + { + if(rPropertyHolders.Current().isRasterOpForceBlack()) + { + // force content to black + rTargetHolders.Current().append( + new drawinglayer::primitive2d::ModifiedColorPrimitive2D( + aSubContent, + basegfx::BColorModifier(basegfx::BColor(0.0, 0.0, 0.0)))); + } + else // if(rPropertyHolders.Current().isRasterOpInvert()) + { + // invert content + rTargetHolders.Current().append( + new drawinglayer::primitive2d::InvertPrimitive2D( + aSubContent)); + } + } + } + + // apply new settings + rPropertyHolders.Current().setRasterOp(aRasterOp); + + // check if now active + if(rPropertyHolders.Current().isRasterOpActive()) + { + // prepare new content holder for new invert + rTargetHolders.Push(); + } + } + + /** helper to create needed data to emulate the VCL Wallpaper Metafile action. + It is a quite mighty action. This helper is for simple color filled background. + */ + drawinglayer::primitive2d::BasePrimitive2D* CreateColorWallpaper( + const basegfx::B2DRange& rRange, + const basegfx::BColor& rColor, + PropertyHolder& rPropertyHolder) + { + basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(rRange)); + aOutline.transform(rPropertyHolder.getTransformation()); + + return new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( + basegfx::B2DPolyPolygon(aOutline), + rColor); + } + + /** helper to create needed data to emulate the VCL Wallpaper Metafile action. + It is a quite mighty action. This helper is for gradient filled background. + */ + drawinglayer::primitive2d::BasePrimitive2D* CreateGradientWallpaper( + const basegfx::B2DRange& rRange, + const Gradient& rGradient, + PropertyHolder& rPropertyHolder) + { + const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + + if(aAttribute.getStartColor() == aAttribute.getEndColor()) + { + // not really a gradient. Create filled rectangle + return CreateColorWallpaper(rRange, aAttribute.getStartColor(), rPropertyHolder); + } + else + { + // really a gradient + drawinglayer::primitive2d::BasePrimitive2D* pRetval = + new drawinglayer::primitive2d::FillGradientPrimitive2D( + rRange, + aAttribute); + + if(!rPropertyHolder.getTransformation().isIdentity()) + { + const drawinglayer::primitive2d::Primitive2DReference xPrim(pRetval); + const drawinglayer::primitive2d::Primitive2DSequence xSeq(&xPrim, 1); + + pRetval = new drawinglayer::primitive2d::TransformPrimitive2D( + rPropertyHolder.getTransformation(), + xSeq); + } + + return pRetval; + } + } + + /** helper to create needed data to emulate the VCL Wallpaper Metafile action. + It is a quite mighty action. This helper decides if color and/or gradient + background is needed for the wnated bitmap fill and then creates the needed + WallpaperBitmapPrimitive2D. This primitive was created for this purpose and + takes over all needed logic of orientations and tiling. + */ + void CreateAndAppendBitmapWallpaper( + basegfx::B2DRange aWallpaperRange, + const Wallpaper& rWallpaper, + TargetHolder& rTarget, + PropertyHolder& rProperty) + { + const BitmapEx aBitmapEx(rWallpaper.GetBitmap()); + const WallpaperStyle eWallpaperStyle(rWallpaper.GetStyle()); + + // if bitmap visualisation is transparent, maybe background + // needs to be filled. Create background + if(aBitmapEx.IsTransparent() + || (WALLPAPER_TILE != eWallpaperStyle && WALLPAPER_SCALE != eWallpaperStyle)) + { + if(rWallpaper.IsGradient()) + { + rTarget.append( + CreateGradientWallpaper( + aWallpaperRange, + rWallpaper.GetGradient(), + rProperty)); + } + else if(!rWallpaper.GetColor().GetTransparency()) + { + rTarget.append( + CreateColorWallpaper( + aWallpaperRange, + rWallpaper.GetColor().getBColor(), + rProperty)); + } + } + + // use wallpaper rect if set + if(rWallpaper.IsRect() && !rWallpaper.GetRect().IsEmpty()) + { + aWallpaperRange = basegfx::B2DRange( + rWallpaper.GetRect().Left(), rWallpaper.GetRect().Top(), + rWallpaper.GetRect().Right(), rWallpaper.GetRect().Bottom()); + } + + drawinglayer::primitive2d::BasePrimitive2D* pBitmapWallpaperFill = + new drawinglayer::primitive2d::WallpaperBitmapPrimitive2D( + aWallpaperRange, + aBitmapEx, + eWallpaperStyle); + + if(rProperty.getTransformation().isIdentity()) + { + // add directly + rTarget.append(pBitmapWallpaperFill); + } + else + { + // when a transformation is set, embed to it + const drawinglayer::primitive2d::Primitive2DReference xPrim(pBitmapWallpaperFill); + + rTarget.append( + new drawinglayer::primitive2d::TransformPrimitive2D( + rProperty.getTransformation(), + drawinglayer::primitive2d::Primitive2DSequence(&xPrim, 1))); + } + } + + /** helper to decide UnderlineAbove for text primitives */ + bool isUnderlineAbove(const Font& rFont) + { + if(!rFont.IsVertical()) + { + return false; + } + + if((LANGUAGE_JAPANESE == rFont.GetLanguage()) || (LANGUAGE_JAPANESE == rFont.GetCJKContextLanguage())) + { + // the underline is right for Japanese only + return true; + } + + return false; + } + + void createFontAttributeTransformAndAlignment( + drawinglayer::attribute::FontAttribute& rFontAttribute, + basegfx::B2DHomMatrix& rTextTransform, + basegfx::B2DVector& rAlignmentOffset, + PropertyHolder& rProperty) + { + const Font& rFont = rProperty.getFont(); + basegfx::B2DVector aFontScaling; + + rFontAttribute = drawinglayer::attribute::FontAttribute( + drawinglayer::primitive2d::getFontAttributeFromVclFont( + aFontScaling, + rFont, + 0 != (rProperty.getLayoutMode() & TEXT_LAYOUT_BIDI_RTL), + 0 != (rProperty.getLayoutMode() & TEXT_LAYOUT_BIDI_STRONG))); + + // add FontScaling + rTextTransform.scale(aFontScaling.getX(), aFontScaling.getY()); + + // take text align into account + if(ALIGN_BASELINE != rFont.GetAlign()) + { + drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice; + aTextLayouterDevice.setFont(rFont); + + if(ALIGN_TOP == rFont.GetAlign()) + { + rAlignmentOffset.setY(aTextLayouterDevice.getFontAscent()); + } + else // ALIGN_BOTTOM + { + rAlignmentOffset.setY(-aTextLayouterDevice.getFontDescent()); + } + + rTextTransform.translate(rAlignmentOffset.getX(), rAlignmentOffset.getY()); + } + + // add FontRotation (if used) + if(rFont.GetOrientation()) + { + rTextTransform.rotate(-rFont.GetOrientation() * F_PI1800); + } + } + + /** helper which takes complete care for creating the needed text primitives. It + takes care of decorated stuff and all the geometry adaptions needed + */ + void proccessMetaTextAction( + const Point& rTextStartPosition, + const XubString& rText, + sal_uInt16 nTextStart, + sal_uInt16 nTextLength, + sal_Int32* pDXArray, + TargetHolder& rTarget, + PropertyHolder& rProperty) + { + drawinglayer::primitive2d::BasePrimitive2D* pResult = 0; + const Font& rFont = rProperty.getFont(); + std::vector< double > aDXArray; + basegfx::B2DVector aAlignmentOffset(0.0, 0.0); + + if(nTextLength) + { + drawinglayer::attribute::FontAttribute aFontAttribute; + basegfx::B2DHomMatrix aTextTransform; + + // fill parameters derived from current font + createFontAttributeTransformAndAlignment( + aFontAttribute, + aTextTransform, + aAlignmentOffset, + rProperty); + + // add TextStartPosition + aTextTransform.translate(rTextStartPosition.X(), rTextStartPosition.Y()); + + // preapare DXArray (if used) + if(pDXArray && nTextLength) + { + aDXArray.reserve(nTextLength); + + for(xub_StrLen a(0); a < nTextLength; a++) + { + aDXArray.push_back((double)(*(pDXArray + a))); + } + } + + // prepare FontColor and Locale + const basegfx::BColor aFontColor(rProperty.getTextColor()); + const com::sun::star::lang::Locale aLocale(MsLangId::convertLanguageToLocale(rProperty.getLanguageType())); + const bool bWordLineMode(rFont.IsWordLineMode()); + + const bool bDecoratedIsNeeded( + UNDERLINE_NONE != rFont.GetOverline() + || UNDERLINE_NONE != rFont.GetUnderline() + || STRIKEOUT_NONE != rFont.GetStrikeout() + || EMPHASISMARK_NONE != (rFont.GetEmphasisMark() & EMPHASISMARK_STYLE) + || RELIEF_NONE != rFont.GetRelief() + || rFont.IsShadow() + || bWordLineMode); + + if(bDecoratedIsNeeded) + { + // prepare overline, underline and srikeout data + const drawinglayer::primitive2d::TextLine eFontOverline(drawinglayer::primitive2d::mapFontUnderlineToTextLine(rFont.GetOverline())); + const drawinglayer::primitive2d::TextLine eFontUnderline(drawinglayer::primitive2d::mapFontUnderlineToTextLine(rFont.GetUnderline())); + const drawinglayer::primitive2d::TextStrikeout eTextStrikeout(drawinglayer::primitive2d::mapFontStrikeoutToTextStrikeout(rFont.GetStrikeout())); + + // check UndelineAbove + const bool bUnderlineAbove(drawinglayer::primitive2d::TEXT_LINE_NONE != eFontUnderline && isUnderlineAbove(rFont)); + + // prepare emphasis mark data + drawinglayer::primitive2d::TextEmphasisMark eTextEmphasisMark(drawinglayer::primitive2d::TEXT_EMPHASISMARK_NONE); + + switch(rFont.GetEmphasisMark() & EMPHASISMARK_STYLE) + { + case EMPHASISMARK_DOT : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_DOT; break; + case EMPHASISMARK_CIRCLE : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_CIRCLE; break; + case EMPHASISMARK_DISC : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_DISC; break; + case EMPHASISMARK_ACCENT : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_ACCENT; break; + } + + const bool bEmphasisMarkAbove(rFont.GetEmphasisMark() & EMPHASISMARK_POS_ABOVE); + const bool bEmphasisMarkBelow(rFont.GetEmphasisMark() & EMPHASISMARK_POS_BELOW); + + // prepare font relief data + drawinglayer::primitive2d::TextRelief eTextRelief(drawinglayer::primitive2d::TEXT_RELIEF_NONE); + + switch(rFont.GetRelief()) + { + case RELIEF_EMBOSSED : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_EMBOSSED; break; + case RELIEF_ENGRAVED : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_ENGRAVED; break; + default : break; // RELIEF_NONE, FontRelief_FORCE_EQUAL_SIZE + } + + // prepare shadow/outline data + const bool bShadow(rFont.IsShadow()); + + // TextDecoratedPortionPrimitive2D is needed, create one + pResult = new drawinglayer::primitive2d::TextDecoratedPortionPrimitive2D( + + // attributes for TextSimplePortionPrimitive2D + aTextTransform, + rText, + nTextStart, + nTextLength, + aDXArray, + aFontAttribute, + aLocale, + aFontColor, + + // attributes for TextDecoratedPortionPrimitive2D + rProperty.getOverlineColorActive() ? rProperty.getOverlineColor() : aFontColor, + rProperty.getTextLineColorActive() ? rProperty.getTextLineColor() : aFontColor, + eFontOverline, + eFontUnderline, + bUnderlineAbove, + eTextStrikeout, + bWordLineMode, + eTextEmphasisMark, + bEmphasisMarkAbove, + bEmphasisMarkBelow, + eTextRelief, + bShadow); + } + else + { + // TextSimplePortionPrimitive2D is enough + pResult = new drawinglayer::primitive2d::TextSimplePortionPrimitive2D( + aTextTransform, + rText, + nTextStart, + nTextLength, + aDXArray, + aFontAttribute, + aLocale, + aFontColor); + } + } + + if(pResult && rProperty.getTextFillColorActive()) + { + // text background is requested, add and encapsulate both to new primitive + drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice; + aTextLayouterDevice.setFont(rFont); + + // get text width + double fTextWidth(0.0); + + if(aDXArray.empty()) + { + fTextWidth = aTextLayouterDevice.getTextWidth(rText, nTextStart, nTextLength); + } + else + { + fTextWidth = aDXArray.back(); + } + + if(basegfx::fTools::more(fTextWidth, 0.0)) + { + // build text range + const basegfx::B2DRange aTextRange( + 0.0, -aTextLayouterDevice.getFontAscent(), + fTextWidth, aTextLayouterDevice.getFontDescent()); + + // create Transform + basegfx::B2DHomMatrix aTextTransform; + + aTextTransform.translate(aAlignmentOffset.getX(), aAlignmentOffset.getY()); + + if(rFont.GetOrientation()) + { + aTextTransform.rotate(-rFont.GetOrientation() * F_PI1800); + } + + aTextTransform.translate(rTextStartPosition.X(), rTextStartPosition.Y()); + + // prepare Primitive2DSequence, put text in foreground + drawinglayer::primitive2d::Primitive2DSequence aSequence(2); + aSequence[1] = drawinglayer::primitive2d::Primitive2DReference(pResult); + + // prepare filled polygon + basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aTextRange)); + aOutline.transform(aTextTransform); + + aSequence[0] = drawinglayer::primitive2d::Primitive2DReference( + new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( + basegfx::B2DPolyPolygon(aOutline), + rProperty.getTextFillColor())); + + // set as group at pResult + pResult = new drawinglayer::primitive2d::GroupPrimitive2D(aSequence); + } + } + + if(pResult) + { + // add created text primitive to target + if(rProperty.getTransformation().isIdentity()) + { + rTarget.append(pResult); + } + else + { + // when a transformation is set, embed to it + const drawinglayer::primitive2d::Primitive2DReference aReference(pResult); + + rTarget.append( + new drawinglayer::primitive2d::TransformPrimitive2D( + rProperty.getTransformation(), + drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1))); + } + } + } + + /** helper which takes complete care for creating the needed textLine primitives */ + void proccessMetaTextLineAction( + const MetaTextLineAction& rAction, + TargetHolder& rTarget, + PropertyHolder& rProperty) + { + const double fLineWidth(fabs((double)rAction.GetWidth())); + + if(fLineWidth > 0.0) + { + const drawinglayer::primitive2d::TextLine aOverlineMode(drawinglayer::primitive2d::mapFontUnderlineToTextLine(rAction.GetOverline())); + const drawinglayer::primitive2d::TextLine aUnderlineMode(drawinglayer::primitive2d::mapFontUnderlineToTextLine(rAction.GetUnderline())); + const drawinglayer::primitive2d::TextStrikeout aTextStrikeout(drawinglayer::primitive2d::mapFontStrikeoutToTextStrikeout(rAction.GetStrikeout())); + + const bool bOverlineUsed(drawinglayer::primitive2d::TEXT_LINE_NONE != aOverlineMode); + const bool bUnderlineUsed(drawinglayer::primitive2d::TEXT_LINE_NONE != aUnderlineMode); + const bool bStrikeoutUsed(drawinglayer::primitive2d::TEXT_STRIKEOUT_NONE != aTextStrikeout); + + if(bUnderlineUsed || bStrikeoutUsed || bOverlineUsed) + { + std::vector< drawinglayer::primitive2d::BasePrimitive2D* > aTargetVector; + basegfx::B2DVector aAlignmentOffset(0.0, 0.0); + drawinglayer::attribute::FontAttribute aFontAttribute; + basegfx::B2DHomMatrix aTextTransform; + + // fill parameters derived from current font + createFontAttributeTransformAndAlignment( + aFontAttribute, + aTextTransform, + aAlignmentOffset, + rProperty); + + // add TextStartPosition + aTextTransform.translate(rAction.GetStartPoint().X(), rAction.GetStartPoint().Y()); + + // prepare TextLayouter (used in most cases) + drawinglayer::primitive2d::TextLayouterDevice aTextLayouter; + aTextLayouter.setFont(rProperty.getFont()); + + if(bOverlineUsed) + { + // create primitive geometry for overline + aTargetVector.push_back( + new drawinglayer::primitive2d::TextLinePrimitive2D( + aTextTransform, + fLineWidth, + aTextLayouter.getOverlineOffset(), + aTextLayouter.getOverlineHeight(), + aOverlineMode, + rProperty.getOverlineColor())); + } + + if(bUnderlineUsed) + { + // create primitive geometry for underline + aTargetVector.push_back( + new drawinglayer::primitive2d::TextLinePrimitive2D( + aTextTransform, + fLineWidth, + aTextLayouter.getUnderlineOffset(), + aTextLayouter.getUnderlineHeight(), + aUnderlineMode, + rProperty.getTextLineColor())); + } + + if(bStrikeoutUsed) + { + // create primitive geometry for strikeout + if(drawinglayer::primitive2d::TEXT_STRIKEOUT_SLASH == aTextStrikeout + || drawinglayer::primitive2d::TEXT_STRIKEOUT_X == aTextStrikeout) + { + // strikeout with character + const sal_Unicode aStrikeoutChar( + drawinglayer::primitive2d::TEXT_STRIKEOUT_SLASH == aTextStrikeout ? '/' : 'X'); + const com::sun::star::lang::Locale aLocale(MsLangId::convertLanguageToLocale( + rProperty.getLanguageType())); + + aTargetVector.push_back( + new drawinglayer::primitive2d::TextCharacterStrikeoutPrimitive2D( + aTextTransform, + fLineWidth, + rProperty.getTextColor(), + aStrikeoutChar, + aFontAttribute, + aLocale)); + } + else + { + // strikeout with geometry + aTargetVector.push_back( + new drawinglayer::primitive2d::TextGeometryStrikeoutPrimitive2D( + aTextTransform, + fLineWidth, + rProperty.getTextColor(), + aTextLayouter.getUnderlineHeight(), + aTextLayouter.getStrikeoutOffset(), + aTextStrikeout)); + } + } + + if(aTargetVector.size()) + { + // add created text primitive to target + if(rProperty.getTransformation().isIdentity()) + { + for(sal_uInt32 a(0); a < aTargetVector.size(); a++) + { + rTarget.append(aTargetVector[a]); + } + } + else + { + // when a transformation is set, embed to it + drawinglayer::primitive2d::Primitive2DSequence xTargets(aTargetVector.size()); + + for(sal_uInt32 a(0); a < aTargetVector.size(); a++) + { + xTargets[a] = drawinglayer::primitive2d::Primitive2DReference(aTargetVector[a]); + } + + rTarget.append( + new drawinglayer::primitive2d::TransformPrimitive2D( + rProperty.getTransformation(), + xTargets)); + } + } + } + } + + } + + /** This is the main interpreter method. It is designed to handle the given Metafile + completely inside the given context and target. It may use and modify the context and + target. This design allows to call itself recursively wich adapted contexts and + targets as e.g. needed for the META_FLOATTRANSPARENT_ACTION where the content is expressed + as a metafile as sub-content. + + This interpreter is as free of VCL functionality as possible. It uses VCL data classes + (else reading the data would not be possible), but e.g. does NOT use a local OutputDevice + as most other MetaFile interpreters/exporters do to hold and work with the current context. + This is necessary to be able to get away from the strong internal VCL-binding. + + It tries to combine e.g. pixel and/or point actions and to stitch together single line primitives + where possible (which is not trivial with the possible line geometry definitions). + + It tries to handle clipping no longer as Regions and spans of Rectangles, but as PolyPolygon + ClipRegions with (where possible) high precision by using the best possible data quality + from the Region. The Region is unavoidable as data container, but nowadays allows the transport + of Polygon-based clip regions. Where this is not used, a Polygon is constructed from the + Region ranges. All primitive clipping uses the MaskPrimitive2D with Polygon-based clipping. + + I have marked the single MetaActions with: + + SIMPLE, DONE: + Simple, e.g nothing to do or value setting in the context + + CHECKED, WORKS WELL: + Thoroughly tested with extra written test code which created a replacement + Metafile just to test this action in various combinations + + NEEDS IMPLEMENTATION: + Not implemented and asserted, but also no usage found, neither in own Metafile + creations, nor in EMF/WMF imports (checked with a whole bunch of critical EMF/WMF + bugdocs) + + For more commens, see the single action implementations. + */ + void interpretMetafile( + const GDIMetaFile& rMetaFile, + TargetHolders& rTargetHolders, + PropertyHolders& rPropertyHolders, + const drawinglayer::geometry::ViewInformation2D& rViewInformation) + { + const sal_uInt32 nCount(rMetaFile.GetActionCount()); + + for(sal_uInt32 nAction(0); nAction < nCount; nAction++) + { + MetaAction* pAction = rMetaFile.GetAction(nAction); + + switch(pAction->GetType()) + { + case META_NULL_ACTION : + { + /** SIMPLE, DONE */ + break; + } + case META_PIXEL_ACTION : + { + /** CHECKED, WORKS WELL */ + std::vector< basegfx::B2DPoint > aPositions; + Color aLastColor(COL_BLACK); + + while(META_PIXEL_ACTION == pAction->GetType() && nAction < nCount) + { + const MetaPixelAction* pA = (const MetaPixelAction*)pAction; + + if(pA->GetColor() != aLastColor) + { + if(aPositions.size()) + { + createPointArrayPrimitive(aPositions, rTargetHolders.Current(), rPropertyHolders.Current(), aLastColor.getBColor()); + aPositions.clear(); + } + + aLastColor = pA->GetColor(); + } + + const Point& rPoint = pA->GetPoint(); + aPositions.push_back(basegfx::B2DPoint(rPoint.X(), rPoint.Y())); + nAction++; if(nAction < nCount) pAction = rMetaFile.GetAction(nAction); + } + + nAction--; + + if(aPositions.size()) + { + createPointArrayPrimitive(aPositions, rTargetHolders.Current(), rPropertyHolders.Current(), aLastColor.getBColor()); + } + + break; + } + case META_POINT_ACTION : + { + /** CHECKED, WORKS WELL */ + if(rPropertyHolders.Current().getLineColorActive()) + { + std::vector< basegfx::B2DPoint > aPositions; + + while(META_POINT_ACTION == pAction->GetType() && nAction < nCount) + { + const MetaPointAction* pA = (const MetaPointAction*)pAction; + const Point& rPoint = pA->GetPoint(); + aPositions.push_back(basegfx::B2DPoint(rPoint.X(), rPoint.Y())); + nAction++; if(nAction < nCount) pAction = rMetaFile.GetAction(nAction); + } + + nAction--; + + if(aPositions.size()) + { + createPointArrayPrimitive(aPositions, rTargetHolders.Current(), rPropertyHolders.Current(), rPropertyHolders.Current().getLineColor()); + } + } + + break; + } + case META_LINE_ACTION : + { + /** CHECKED, WORKS WELL */ + if(rPropertyHolders.Current().getLineColorActive()) + { + basegfx::B2DPolygon aLinePolygon; + LineInfo aLineInfo; + + while(META_LINE_ACTION == pAction->GetType() && nAction < nCount) + { + const MetaLineAction* pA = (const MetaLineAction*)pAction; + const Point& rStartPoint = pA->GetStartPoint(); + const Point& rEndPoint = pA->GetEndPoint(); + const basegfx::B2DPoint aStart(rStartPoint.X(), rStartPoint.Y()); + const basegfx::B2DPoint aEnd(rEndPoint.X(), rEndPoint.Y()); + + if(aLinePolygon.count()) + { + if(pA->GetLineInfo() == aLineInfo + && aStart == aLinePolygon.getB2DPoint(aLinePolygon.count() - 1)) + { + aLinePolygon.append(aEnd); + } + else + { + aLineInfo.SetLineJoin(basegfx::B2DLINEJOIN_NONE); // It were lines; force to NONE + createLinePrimitive(aLinePolygon, aLineInfo, rTargetHolders.Current(), rPropertyHolders.Current()); + aLinePolygon.clear(); + aLineInfo = pA->GetLineInfo(); + aLinePolygon.append(aStart); + aLinePolygon.append(aEnd); + } + } + else + { + aLineInfo = pA->GetLineInfo(); + aLinePolygon.append(aStart); + aLinePolygon.append(aEnd); + } + + nAction++; if(nAction < nCount) pAction = rMetaFile.GetAction(nAction); + } + + nAction--; + + if(aLinePolygon.count()) + { + aLineInfo.SetLineJoin(basegfx::B2DLINEJOIN_NONE); // It were lines; force to NONE + createLinePrimitive(aLinePolygon, aLineInfo, rTargetHolders.Current(), rPropertyHolders.Current()); + } + } + + break; + } + case META_RECT_ACTION : + { + /** CHECKED, WORKS WELL */ + if(rPropertyHolders.Current().getLineOrFillActive()) + { + const MetaRectAction* pA = (const MetaRectAction*)pAction; + const Rectangle& rRectangle = pA->GetRect(); + + if(!rRectangle.IsEmpty()) + { + const basegfx::B2DRange aRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom()); + + if(!aRange.isEmpty()) + { + const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange)); + createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current()); + } + } + } + + break; + } + case META_ROUNDRECT_ACTION : + { + /** CHECKED, WORKS WELL */ + /** The original OutputDevice::DrawRect paints nothing when nHor or nVer is zero; but just + because the tools::Polygon operator creating the rounding does produce nonsense. I assume + this an error and create an unrounded rectangle in that case (implicit in + createPolygonFromRect) + */ + if(rPropertyHolders.Current().getLineOrFillActive()) + { + const MetaRoundRectAction* pA = (const MetaRoundRectAction*)pAction; + const Rectangle& rRectangle = pA->GetRect(); + + if(!rRectangle.IsEmpty()) + { + const basegfx::B2DRange aRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom()); + + if(!aRange.isEmpty()) + { + const sal_uInt32 nHor(pA->GetHorzRound()); + const sal_uInt32 nVer(pA->GetVertRound()); + basegfx::B2DPolygon aOutline; + + if(nHor || nVer) + { + double fRadiusX((nHor * 2.0) / (aRange.getWidth() > 0.0 ? aRange.getWidth() : 1.0)); + double fRadiusY((nVer * 2.0) / (aRange.getHeight() > 0.0 ? aRange.getHeight() : 1.0)); + fRadiusX = std::max(0.0, std::min(1.0, fRadiusX)); + fRadiusY = std::max(0.0, std::min(1.0, fRadiusY)); + + aOutline = basegfx::tools::createPolygonFromRect(aRange, fRadiusX, fRadiusY); + } + else + { + aOutline = basegfx::tools::createPolygonFromRect(aRange); + } + + createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current()); + } + } + } + + break; + } + case META_ELLIPSE_ACTION : + { + /** CHECKED, WORKS WELL */ + if(rPropertyHolders.Current().getLineOrFillActive()) + { + const MetaEllipseAction* pA = (const MetaEllipseAction*)pAction; + const Rectangle& rRectangle = pA->GetRect(); + + if(!rRectangle.IsEmpty()) + { + const basegfx::B2DRange aRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom()); + + if(!aRange.isEmpty()) + { + const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromEllipse( + aRange.getCenter(), aRange.getWidth() * 0.5, aRange.getHeight() * 0.5)); + + createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current()); + } + } + } + + break; + } + case META_ARC_ACTION : + { + /** CHECKED, WORKS WELL */ + if(rPropertyHolders.Current().getLineColorActive()) + { + const MetaArcAction* pA = (const MetaArcAction*)pAction; + const Polygon aToolsPoly(pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_ARC); + const basegfx::B2DPolygon aOutline(aToolsPoly.getB2DPolygon()); + + createHairlinePrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current()); + } + + break; + } + case META_PIE_ACTION : + { + /** CHECKED, WORKS WELL */ + if(rPropertyHolders.Current().getLineOrFillActive()) + { + const MetaPieAction* pA = (const MetaPieAction*)pAction; + const Polygon aToolsPoly(pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_PIE); + const basegfx::B2DPolygon aOutline(aToolsPoly.getB2DPolygon()); + + createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current()); + } + + break; + } + case META_CHORD_ACTION : + { + /** CHECKED, WORKS WELL */ + if(rPropertyHolders.Current().getLineOrFillActive()) + { + const MetaChordAction* pA = (const MetaChordAction*)pAction; + const Polygon aToolsPoly(pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_CHORD); + const basegfx::B2DPolygon aOutline(aToolsPoly.getB2DPolygon()); + + createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current()); + } + + break; + } + case META_POLYLINE_ACTION : + { + /** CHECKED, WORKS WELL */ + if(rPropertyHolders.Current().getLineColorActive()) + { + const MetaPolyLineAction* pA = (const MetaPolyLineAction*)pAction; + createLinePrimitive(pA->GetPolygon().getB2DPolygon(), pA->GetLineInfo(), rTargetHolders.Current(), rPropertyHolders.Current()); + } + + break; + } + case META_POLYGON_ACTION : + { + /** CHECKED, WORKS WELL */ + if(rPropertyHolders.Current().getLineOrFillActive()) + { + const MetaPolygonAction* pA = (const MetaPolygonAction*)pAction; + basegfx::B2DPolygon aOutline(pA->GetPolygon().getB2DPolygon()); + + // the metafile play interprets the polygons from MetaPolygonAction + // always as closed and always paints an edge from last to first point, + // so force to closed here to emulate that + if(aOutline.count() > 1 && !aOutline.isClosed()) + { + aOutline.setClosed(true); + } + + createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current()); + } + + break; + } + case META_POLYPOLYGON_ACTION : + { + /** CHECKED, WORKS WELL */ + if(rPropertyHolders.Current().getLineOrFillActive()) + { + const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*)pAction; + basegfx::B2DPolyPolygon aPolyPolygonOutline(pA->GetPolyPolygon().getB2DPolyPolygon()); + + // the metafile play interprets the single polygons from MetaPolyPolygonAction + // always as closed and always paints an edge from last to first point, + // so force to closed here to emulate that + for(sal_uInt32 b(0); b < aPolyPolygonOutline.count(); b++) + { + basegfx::B2DPolygon aPolygonOutline(aPolyPolygonOutline.getB2DPolygon(b)); + + if(aPolygonOutline.count() > 1 && !aPolygonOutline.isClosed()) + { + aPolygonOutline.setClosed(true); + aPolyPolygonOutline.setB2DPolygon(b, aPolygonOutline); + } + } + + createHairlineAndFillPrimitive(aPolyPolygonOutline, rTargetHolders.Current(), rPropertyHolders.Current()); + } + + break; + } + case META_TEXT_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaTextAction* pA = (const MetaTextAction*)pAction; + + if(pA->GetLen() && rPropertyHolders.Current().getTextColorActive()) + { + proccessMetaTextAction( + pA->GetPoint(), + pA->GetText(), + pA->GetIndex(), + pA->GetLen(), + 0, + rTargetHolders.Current(), + rPropertyHolders.Current()); + } + + break; + } + case META_TEXTARRAY_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaTextArrayAction* pA = (const MetaTextArrayAction*)pAction; + + if(pA->GetLen() && rPropertyHolders.Current().getTextColorActive()) + { + proccessMetaTextAction( + pA->GetPoint(), + pA->GetText(), + pA->GetIndex(), + pA->GetLen(), + pA->GetDXArray(), + rTargetHolders.Current(), + rPropertyHolders.Current()); + } + + break; + } + case META_STRETCHTEXT_ACTION : + { + /** NEEDS IMPLEMENTATION */ + OSL_ENSURE(false, "META_STRETCHTEXT_ACTION requested (!)"); + // use OutputDevice::GetTextArray() to map the... + // const MetaStretchTextAction* pA = (const MetaStretchTextAction*)pAction; + break; + } + case META_TEXTRECT_ACTION : + { + /** CHECKED, WORKS WELL */ + // OSL_ENSURE(false, "META_TEXTRECT_ACTION requested (!)"); + const MetaTextRectAction* pA = (const MetaTextRectAction*)pAction; + const Rectangle& rRectangle = pA->GetRect(); + + if(!rRectangle.IsEmpty() && 0 != pA->GetText().Len()) + { + // The problem with this action is that it describes unlayouted text + // and the layout capabilities are in EditEngine/Outliner in SVX. The + // same problem is true for VCL which internally has implementations + // to layout text in this case. There exists even a call + // OutputDevice::AddTextRectActions(...) to create the needed actions + // as 'sub-content' of a Metafile. Unfortunately i do not have an + // OutputDevice here since this interpreter tries to work without + // VCL AFAP. + // Since AddTextRectActions is the only way as long as we do not have + // a simple text layouter available, i will try to add it to the + // TextLayouterDevice isloation. + drawinglayer::primitive2d::TextLayouterDevice aTextLayouterDevice; + aTextLayouterDevice.setFont(rPropertyHolders.Current().getFont()); + GDIMetaFile aGDIMetaFile; + + aTextLayouterDevice.addTextRectActions( + rRectangle, pA->GetText(), pA->GetStyle(), aGDIMetaFile); + + if(aGDIMetaFile.GetActionCount()) + { + // cerate sub-content + drawinglayer::primitive2d::Primitive2DSequence xSubContent; + { + rTargetHolders.Push(); + interpretMetafile(aGDIMetaFile, rTargetHolders, rPropertyHolders, rViewInformation); + xSubContent = rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current()); + rTargetHolders.Pop(); + } + + if(xSubContent.hasElements()) + { + // add with transformation + rTargetHolders.Current().append( + new drawinglayer::primitive2d::TransformPrimitive2D( + rPropertyHolders.Current().getTransformation(), + xSubContent)); + } + } + } + + break; + } + case META_BMP_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaBmpAction* pA = (const MetaBmpAction*)pAction; + const BitmapEx aBitmapEx(pA->GetBitmap()); + + createBitmapExPrimitive(aBitmapEx, pA->GetPoint(), rTargetHolders.Current(), rPropertyHolders.Current()); + + break; + } + case META_BMPSCALE_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*)pAction; + const Bitmap aBitmapEx(pA->GetBitmap()); + + createBitmapExPrimitive(aBitmapEx, pA->GetPoint(), pA->GetSize(), rTargetHolders.Current(), rPropertyHolders.Current()); + + break; + } + case META_BMPSCALEPART_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*)pAction; + const Bitmap& rBitmap = pA->GetBitmap(); + + if(!rBitmap.IsEmpty()) + { + Bitmap aCroppedBitmap(rBitmap); + const Rectangle aCropRectangle(pA->GetSrcPoint(), pA->GetSrcSize()); + + if(!aCropRectangle.IsEmpty()) + { + aCroppedBitmap.Crop(aCropRectangle); + } + + const BitmapEx aCroppedBitmapEx(aCroppedBitmap); + createBitmapExPrimitive(aCroppedBitmapEx, pA->GetDestPoint(), pA->GetDestSize(), rTargetHolders.Current(), rPropertyHolders.Current()); + } + + break; + } + case META_BMPEX_ACTION : + { + /** CHECKED, WORKS WELL: Simply same as META_BMP_ACTION */ + const MetaBmpExAction* pA = (const MetaBmpExAction*)pAction; + const BitmapEx& rBitmapEx = pA->GetBitmapEx(); + + createBitmapExPrimitive(rBitmapEx, pA->GetPoint(), rTargetHolders.Current(), rPropertyHolders.Current()); + + break; + } + case META_BMPEXSCALE_ACTION : + { + /** CHECKED, WORKS WELL: Simply same as META_BMPSCALE_ACTION */ + const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*)pAction; + const BitmapEx& rBitmapEx = pA->GetBitmapEx(); + + createBitmapExPrimitive(rBitmapEx, pA->GetPoint(), pA->GetSize(), rTargetHolders.Current(), rPropertyHolders.Current()); + + break; + } + case META_BMPEXSCALEPART_ACTION : + { + /** CHECKED, WORKS WELL: Simply same as META_BMPSCALEPART_ACTION */ + const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*)pAction; + const BitmapEx& rBitmapEx = pA->GetBitmapEx(); + + if(!rBitmapEx.IsEmpty()) + { + BitmapEx aCroppedBitmapEx(rBitmapEx); + const Rectangle aCropRectangle(pA->GetSrcPoint(), pA->GetSrcSize()); + + if(!aCropRectangle.IsEmpty()) + { + aCroppedBitmapEx.Crop(aCropRectangle); + } + + createBitmapExPrimitive(aCroppedBitmapEx, pA->GetDestPoint(), pA->GetDestSize(), rTargetHolders.Current(), rPropertyHolders.Current()); + } + + break; + } + case META_MASK_ACTION : + { + /** CHECKED, WORKS WELL: Simply same as META_BMP_ACTION */ + const MetaMaskAction* pA = (const MetaMaskAction*)pAction; + const BitmapEx aBitmapEx(createMaskBmpEx(pA->GetBitmap(), pA->GetColor())); + + createBitmapExPrimitive(aBitmapEx, pA->GetPoint(), rTargetHolders.Current(), rPropertyHolders.Current()); + + break; + } + case META_MASKSCALE_ACTION : + { + /** CHECKED, WORKS WELL: Simply same as META_BMPSCALE_ACTION */ + const MetaMaskScaleAction* pA = (const MetaMaskScaleAction*)pAction; + const BitmapEx aBitmapEx(createMaskBmpEx(pA->GetBitmap(), pA->GetColor())); + + createBitmapExPrimitive(aBitmapEx, pA->GetPoint(), pA->GetSize(), rTargetHolders.Current(), rPropertyHolders.Current()); + + break; + } + case META_MASKSCALEPART_ACTION : + { + /** CHECKED, WORKS WELL: Simply same as META_BMPSCALEPART_ACTION */ + const MetaMaskScalePartAction* pA = (const MetaMaskScalePartAction*)pAction; + const Bitmap& rBitmap = pA->GetBitmap(); + + if(!rBitmap.IsEmpty()) + { + Bitmap aCroppedBitmap(rBitmap); + const Rectangle aCropRectangle(pA->GetSrcPoint(), pA->GetSrcSize()); + + if(!aCropRectangle.IsEmpty()) + { + aCroppedBitmap.Crop(aCropRectangle); + } + + const BitmapEx aCroppedBitmapEx(createMaskBmpEx(aCroppedBitmap, pA->GetColor())); + createBitmapExPrimitive(aCroppedBitmapEx, pA->GetDestPoint(), pA->GetDestSize(), rTargetHolders.Current(), rPropertyHolders.Current()); + } + + break; + } + case META_GRADIENT_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaGradientAction* pA = (const MetaGradientAction*)pAction; + const Rectangle& rRectangle = pA->GetRect(); + + if(!rRectangle.IsEmpty()) + { + basegfx::B2DRange aRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom()); + + if(!aRange.isEmpty()) + { + const Gradient& rGradient = pA->GetGradient(); + const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + + if(aAttribute.getStartColor() == aAttribute.getEndColor()) + { + // not really a gradient. Create filled rectangle + const basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aRange)); + createFillPrimitive(basegfx::B2DPolyPolygon(aOutline), rTargetHolders.Current(), rPropertyHolders.Current()); + } + else + { + // really a gradient + aRange.transform(rPropertyHolders.Current().getTransformation()); + + if(rPropertyHolders.Current().isRasterOpInvert()) + { + // use a special version of FillGradientPrimitive2D which creates + // non-overlapping geometry on decomposition to makethe old XOR + // paint 'trick' work. + rTargetHolders.Current().append( + new drawinglayer::primitive2d::NonOverlappingFillGradientPrimitive2D( + aRange, + aAttribute)); + } + else + { + rTargetHolders.Current().append( + new drawinglayer::primitive2d::FillGradientPrimitive2D( + aRange, + aAttribute)); + } + } + } + } + + break; + } + case META_HATCH_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaHatchAction* pA = (const MetaHatchAction*)pAction; + basegfx::B2DPolyPolygon aOutline(pA->GetPolyPolygon().getB2DPolyPolygon()); + + if(aOutline.count()) + { + const Hatch& rHatch = pA->GetHatch(); + const drawinglayer::attribute::FillHatchAttribute aAttribute(createFillHatchAttribute(rHatch)); + + aOutline.transform(rPropertyHolders.Current().getTransformation()); + + const basegfx::B2DRange aObjectRange(aOutline.getB2DRange()); + const drawinglayer::primitive2d::Primitive2DReference aFillHatch( + new drawinglayer::primitive2d::FillHatchPrimitive2D( + aObjectRange, + basegfx::BColor(), + aAttribute)); + + rTargetHolders.Current().append( + new drawinglayer::primitive2d::MaskPrimitive2D( + aOutline, + drawinglayer::primitive2d::Primitive2DSequence(&aFillHatch, 1))); + } + + break; + } + case META_WALLPAPER_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaWallpaperAction* pA = (const MetaWallpaperAction*)pAction; + Rectangle aWallpaperRectangle(pA->GetRect()); + + if(!aWallpaperRectangle.IsEmpty()) + { + const Wallpaper& rWallpaper = pA->GetWallpaper(); + const WallpaperStyle eWallpaperStyle(rWallpaper.GetStyle()); + basegfx::B2DRange aWallpaperRange( + aWallpaperRectangle.Left(), aWallpaperRectangle.Top(), + aWallpaperRectangle.Right(), aWallpaperRectangle.Bottom()); + + if(WALLPAPER_NULL != eWallpaperStyle) + { + if(rWallpaper.IsBitmap()) + { + // create bitmap background. Caution: This + // also will create gradient/color background(s) + // when the bitmap is transparent or not tiled + CreateAndAppendBitmapWallpaper( + aWallpaperRange, + rWallpaper, + rTargetHolders.Current(), + rPropertyHolders.Current()); + } + else if(rWallpaper.IsGradient()) + { + // create gradient background + rTargetHolders.Current().append( + CreateGradientWallpaper( + aWallpaperRange, + rWallpaper.GetGradient(), + rPropertyHolders.Current())); + } + else if(!rWallpaper.GetColor().GetTransparency()) + { + // create color background + rTargetHolders.Current().append( + CreateColorWallpaper( + aWallpaperRange, + rWallpaper.GetColor().getBColor(), + rPropertyHolders.Current())); + } + } + } + + break; + } + case META_CLIPREGION_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaClipRegionAction* pA = (const MetaClipRegionAction*)pAction; + + if(pA->IsClipping()) + { + // new clipping + HandleNewClipRegion(&pA->GetRegion(), rTargetHolders, rPropertyHolders); + } + else + { + // end clipping + HandleNewClipRegion(0, rTargetHolders, rPropertyHolders); + } + + break; + } + case META_ISECTRECTCLIPREGION_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaISectRectClipRegionAction* pA = (const MetaISectRectClipRegionAction*)pAction; + const Rectangle& rRectangle = pA->GetRect(); + + if(rRectangle.IsEmpty()) + { + // intersect with empty rectangle will always give empty + // region; start new clipping with empty region + const Region aNewRegion; + HandleNewClipRegion(&aNewRegion, rTargetHolders, rPropertyHolders); + } + else + { + if(rPropertyHolders.Current().getRegionActive()) + { + if(rPropertyHolders.Current().getRegion().IsEmpty()) + { + // nothing to do, empty active clip region will stay + // empty when intersecting + } + else + { + // AND existing region and new rectangle + const basegfx::B2DPolyPolygon aOriginalPolyPolygon( + getB2DPolyPolygonFromRegion(rPropertyHolders.Current().getRegion())); + basegfx::B2DPolyPolygon aClippedPolyPolygon; + + if(aOriginalPolyPolygon.count()) + { + const basegfx::B2DRange aIntersectRange( + rRectangle.Left(), rRectangle.Top(), + rRectangle.Right(), rRectangle.Bottom()); + + aClippedPolyPolygon = basegfx::tools::clipPolyPolygonOnRange( + aOriginalPolyPolygon, aIntersectRange, true, false); + } + + if(aClippedPolyPolygon != aOriginalPolyPolygon) + { + // start new clipping with intersected region + const Region aNewRegion(aClippedPolyPolygon); + HandleNewClipRegion(&aNewRegion, rTargetHolders, rPropertyHolders); + } + } + } + else + { + // start new clipping with rectangle + const Region aNewRegion(rRectangle); + HandleNewClipRegion(&aNewRegion, rTargetHolders, rPropertyHolders); + } + } + + break; + } + case META_ISECTREGIONCLIPREGION_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaISectRegionClipRegionAction* pA = (const MetaISectRegionClipRegionAction*)pAction; + const Region& rNewRegion = pA->GetRegion(); + + if(rNewRegion.IsEmpty()) + { + // intersect with empty region will always give empty + // region; start new clipping with empty region + const Region aNewRegion; + HandleNewClipRegion(&aNewRegion, rTargetHolders, rPropertyHolders); + } + else + { + if(rPropertyHolders.Current().getRegionActive()) + { + if(rPropertyHolders.Current().getRegion().IsEmpty()) + { + // nothing to do, empty active clip region will stay empty + // when intersecting with any region + } + else + { + // AND existing and new region + const basegfx::B2DPolyPolygon aOriginalPolyPolygon( + getB2DPolyPolygonFromRegion(rPropertyHolders.Current().getRegion())); + basegfx::B2DPolyPolygon aClippedPolyPolygon; + + if(aOriginalPolyPolygon.count()) + { + const basegfx::B2DPolyPolygon aClipPolyPolygon( + getB2DPolyPolygonFromRegion(rNewRegion)); + + if(aClipPolyPolygon.count()) + { + aClippedPolyPolygon = basegfx::tools::clipPolyPolygonOnPolyPolygon( + aOriginalPolyPolygon, aClipPolyPolygon, true, false); + } + } + + if(aClippedPolyPolygon != aOriginalPolyPolygon) + { + // start new clipping with intersected region + const Region aNewRegion(aClippedPolyPolygon); + HandleNewClipRegion(&aNewRegion, rTargetHolders, rPropertyHolders); + } + } + } + else + { + // start new clipping with new region + HandleNewClipRegion(&rNewRegion, rTargetHolders, rPropertyHolders); + } + } + + break; + } + case META_MOVECLIPREGION_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaMoveClipRegionAction* pA = (const MetaMoveClipRegionAction*)pAction; + + if(rPropertyHolders.Current().getRegionActive()) + { + if(rPropertyHolders.Current().getRegion().IsEmpty()) + { + // nothing to do + } + else + { + // move using old interface + Region aRegion(rPropertyHolders.Current().getRegion()); + + const sal_Int32 nHor(pA->GetHorzMove()); + const sal_Int32 nVer(pA->GetVertMove()); + + if(0 != nHor || 0 != nVer) + { + aRegion.Move(nHor, nVer); + HandleNewClipRegion(&aRegion, rTargetHolders, rPropertyHolders); + } + } + } + + break; + } + case META_LINECOLOR_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaLineColorAction* pA = (const MetaLineColorAction*)pAction; + const bool bActive(pA->IsSetting()); + + rPropertyHolders.Current().setLineColorActive(bActive); + if(bActive) + rPropertyHolders.Current().setLineColor(pA->GetColor().getBColor()); + + break; + } + case META_FILLCOLOR_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaFillColorAction* pA = (const MetaFillColorAction*)pAction; + const bool bActive(pA->IsSetting()); + + rPropertyHolders.Current().setFillColorActive(bActive); + if(bActive) + rPropertyHolders.Current().setFillColor(pA->GetColor().getBColor()); + + break; + } + case META_TEXTCOLOR_ACTION : + { + /** SIMPLE, DONE */ + const MetaTextColorAction* pA = (const MetaTextColorAction*)pAction; + const bool bActivate(COL_TRANSPARENT != pA->GetColor().GetColor()); + + rPropertyHolders.Current().setTextColorActive(bActivate); + rPropertyHolders.Current().setTextColor(pA->GetColor().getBColor()); + + break; + } + case META_TEXTFILLCOLOR_ACTION : + { + /** SIMPLE, DONE */ + const MetaTextFillColorAction* pA = (const MetaTextFillColorAction*)pAction; + const bool bWithColorArgument(pA->IsSetting()); + + if(bWithColorArgument) + { + // emulate OutputDevice::SetTextFillColor(...) WITH argument + const Color& rFontFillColor = pA->GetColor(); + rPropertyHolders.Current().setTextFillColor(rFontFillColor.getBColor()); + rPropertyHolders.Current().setTextFillColorActive(COL_TRANSPARENT != rFontFillColor.GetColor()); + } + else + { + // emulate SetFillColor() <- NO argument (!) + rPropertyHolders.Current().setTextFillColorActive(false); + } + + break; + } + case META_TEXTALIGN_ACTION : + { + /** SIMPLE, DONE */ + const MetaTextAlignAction* pA = (const MetaTextAlignAction*)pAction; + const TextAlign aNewTextAlign = pA->GetTextAlign(); + + // TextAlign is applied to the current font (as in + // OutputDevice::SetTextAlign which would be used when + // playing the Metafile) + if(rPropertyHolders.Current().getFont().GetAlign() != aNewTextAlign) + { + Font aNewFont(rPropertyHolders.Current().getFont()); + aNewFont.SetAlign(aNewTextAlign); + rPropertyHolders.Current().setFont(aNewFont); + } + + break; + } + case META_MAPMODE_ACTION : + { + /** CHECKED, WORKS WELL */ + // the most necessary MapMode to be interpreted is MAP_RELATIVE, + // but also the others may occur. Even not yet supported ones + // may need to be added here later + const MetaMapModeAction* pA = (const MetaMapModeAction*)pAction; + const MapMode& rMapMode = pA->GetMapMode(); + basegfx::B2DHomMatrix aMapping; + + if(MAP_RELATIVE == rMapMode.GetMapUnit()) + { + aMapping = getTransformFromMapMode(rMapMode); + } + else + { + switch(rMapMode.GetMapUnit()) + { + case MAP_100TH_MM : + { + if(MAP_TWIP == rPropertyHolders.Current().getMapUnit()) + { + // MAP_TWIP -> MAP_100TH_MM + const double fTwipTo100thMm(127.0 / 72.0); + aMapping.scale(fTwipTo100thMm, fTwipTo100thMm); + } + break; + } + case MAP_TWIP : + { + if(MAP_100TH_MM == rPropertyHolders.Current().getMapUnit()) + { + // MAP_100TH_MM -> MAP_TWIP + const double f100thMmToTwip(72.0 / 127.0); + aMapping.scale(f100thMmToTwip, f100thMmToTwip); + } + break; + } + default : + { + OSL_ENSURE(false, "interpretMetafile: META_MAPMODE_ACTION with unsupported MapUnit (!)"); + break; + } + } + + aMapping = getTransformFromMapMode(rMapMode) * aMapping; + rPropertyHolders.Current().setMapUnit(rMapMode.GetMapUnit()); + } + + if(!aMapping.isIdentity()) + { + aMapping = aMapping * rPropertyHolders.Current().getTransformation(); + rPropertyHolders.Current().setTransformation(aMapping); + } + + break; + } + case META_FONT_ACTION : + { + /** SIMPLE, DONE */ + const MetaFontAction* pA = (const MetaFontAction*)pAction; + rPropertyHolders.Current().setFont(pA->GetFont()); + Size aFontSize(pA->GetFont().GetSize()); + + if(0 == aFontSize.Height()) + { + // this should not happen but i got Metafiles where this was the + // case. A height needs to be guessed (similar to OutputDevice::ImplNewFont()) + Font aCorrectedFont(pA->GetFont()); + + // guess 16 pixel (as in VCL) + aFontSize = Size(0, 16); + + // convert to target MapUnit if not pixels + aFontSize = Application::GetDefaultDevice()->LogicToLogic( + aFontSize, MAP_PIXEL, rPropertyHolders.Current().getMapUnit()); + + aCorrectedFont.SetSize(aFontSize); + rPropertyHolders.Current().setFont(aCorrectedFont); + } + + // older Metafiles have no META_TEXTCOLOR_ACTION which defines + // the FontColor now, so use the Font's color when not transparent + const Color& rFontColor = pA->GetFont().GetColor(); + const bool bActivate(COL_TRANSPARENT != rFontColor.GetColor()); + + if(bActivate) + { + rPropertyHolders.Current().setTextColor(rFontColor.getBColor()); + } + + // caution: do NOT decativate here on transparet, see + // OutputDevice::SetFont(..) for more info + // rPropertyHolders.Current().setTextColorActive(bActivate); + + // for fill color emulate a MetaTextFillColorAction with !transparent as bool, + // see OutputDevice::SetFont(..) the if(mpMetaFile) case + if(bActivate) + { + const Color& rFontFillColor = pA->GetFont().GetFillColor(); + rPropertyHolders.Current().setTextFillColor(rFontFillColor.getBColor()); + rPropertyHolders.Current().setTextFillColorActive(COL_TRANSPARENT != rFontFillColor.GetColor()); + } + else + { + rPropertyHolders.Current().setTextFillColorActive(false); + } + + break; + } + case META_PUSH_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaPushAction* pA = (const MetaPushAction*)pAction; + rPropertyHolders.Push(pA->GetFlags()); + + break; + } + case META_POP_ACTION : + { + /** CHECKED, WORKS WELL */ + const bool bRegionMayChange(rPropertyHolders.Current().getPushFlags() & PUSH_CLIPREGION); + const bool bRasterOpMayChange(rPropertyHolders.Current().getPushFlags() & PUSH_RASTEROP); + + if(bRegionMayChange && rPropertyHolders.Current().getRegionActive()) + { + // end evtl. clipping + HandleNewClipRegion(0, rTargetHolders, rPropertyHolders); + } + + if(bRasterOpMayChange && rPropertyHolders.Current().isRasterOpActive()) + { + // end evtl. RasterOp + HandleNewRasterOp(ROP_OVERPAINT, rTargetHolders, rPropertyHolders); + } + + rPropertyHolders.Pop(); + + if(bRasterOpMayChange && rPropertyHolders.Current().isRasterOpActive()) + { + // start evtl. RasterOp + HandleNewRasterOp(rPropertyHolders.Current().getRasterOp(), rTargetHolders, rPropertyHolders); + } + + if(bRegionMayChange && rPropertyHolders.Current().getRegionActive()) + { + // start evtl. clipping + HandleNewClipRegion(&rPropertyHolders.Current().getRegion(), rTargetHolders, rPropertyHolders); + } + + break; + } + case META_RASTEROP_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaRasterOpAction* pA = (const MetaRasterOpAction*)pAction; + const RasterOp aRasterOp = pA->GetRasterOp(); + + HandleNewRasterOp(aRasterOp, rTargetHolders, rPropertyHolders); + + break; + } + case META_TRANSPARENT_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaTransparentAction* pA = (const MetaTransparentAction*)pAction; + const basegfx::B2DPolyPolygon aOutline(pA->GetPolyPolygon().getB2DPolyPolygon()); + + if(aOutline.count()) + { + const sal_uInt16 nTransparence(pA->GetTransparence()); + + if(0 == nTransparence) + { + // not transparent + createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current()); + } + else if(nTransparence >= 100) + { + // fully or more than transparent + } + else + { + // transparent. Create new target + rTargetHolders.Push(); + + // create primitives there and get them + createHairlineAndFillPrimitive(aOutline, rTargetHolders.Current(), rPropertyHolders.Current()); + const drawinglayer::primitive2d::Primitive2DSequence aSubContent( + rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current())); + + // back to old target + rTargetHolders.Pop(); + + if(aSubContent.hasElements()) + { + rTargetHolders.Current().append( + new drawinglayer::primitive2d::UnifiedAlphaPrimitive2D( + aSubContent, + nTransparence * 0.01)); + } + } + } + + break; + } + case META_EPS_ACTION : + { + /** CHECKED, WORKS WELL */ + // To support this action, i have added a EpsPrimitive2D which will + // by default decompose to the Metafile replacement data. To support + // this EPS on screen, the renderer visualizing this has to support + // that primitive and visualize the Eps file (e.g. printing) + const MetaEPSAction* pA = (const MetaEPSAction*)pAction; + const Rectangle aRectangle(pA->GetPoint(), pA->GetSize()); + + if(!aRectangle.IsEmpty()) + { + // create object transform + basegfx::B2DHomMatrix aObjectTransform; + + aObjectTransform.set(0, 0, aRectangle.GetWidth()); + aObjectTransform.set(1, 1, aRectangle.GetHeight()); + aObjectTransform.set(0, 2, aRectangle.Left()); + aObjectTransform.set(1, 2, aRectangle.Top()); + + // add current transformation + aObjectTransform = rPropertyHolders.Current().getTransformation() * aObjectTransform; + + // embed using EpsPrimitive + rTargetHolders.Current().append( + new drawinglayer::primitive2d::EpsPrimitive2D( + aObjectTransform, + pA->GetLink(), + pA->GetSubstitute())); + } + + break; + } + case META_REFPOINT_ACTION : + { + /** SIMPLE, DONE */ + // only used for hatch and line pattern offsets, pretty much no longer + // supported today + // const MetaRefPointAction* pA = (const MetaRefPointAction*)pAction; + break; + } + case META_TEXTLINECOLOR_ACTION : + { + /** SIMPLE, DONE */ + const MetaTextLineColorAction* pA = (const MetaTextLineColorAction*)pAction; + const bool bActive(pA->IsSetting()); + + rPropertyHolders.Current().setTextLineColorActive(bActive); + if(bActive) + rPropertyHolders.Current().setTextLineColor(pA->GetColor().getBColor()); + + break; + } + case META_TEXTLINE_ACTION : + { + /** CHECKED, WORKS WELL */ + // actually creates overline, underline and strikeouts, so + // these should be isolated from TextDecoratedPortionPrimitive2D + // to own primitives. Done, available now. + // + // This Metaaction seems not to be used (was not used in any + // checked files). It's used in combination with the current + // Font. + const MetaTextLineAction* pA = (const MetaTextLineAction*)pAction; + + proccessMetaTextLineAction( + *pA, + rTargetHolders.Current(), + rPropertyHolders.Current()); + + break; + } + case META_FLOATTRANSPARENT_ACTION : + { + /** CHECKED, WORKS WELL */ + const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*)pAction; + const Rectangle aTargetRectangle(pA->GetPoint(), pA->GetSize()); + + if(!aTargetRectangle.IsEmpty()) + { + const GDIMetaFile& rContent = pA->GetGDIMetaFile(); + + if(rContent.GetActionCount()) + { + // create the sub-content with no embedding specific to the + // sub-metafile, this seems not to be used. + drawinglayer::primitive2d::Primitive2DSequence xSubContent; + { + rTargetHolders.Push(); + interpretMetafile(rContent, rTargetHolders, rPropertyHolders, rViewInformation); + xSubContent = rTargetHolders.Current().getPrimitive2DSequence(rPropertyHolders.Current()); + rTargetHolders.Pop(); + } + + if(xSubContent.hasElements()) + { + // check if gradient is a real gradient + const Gradient& rGradient = pA->GetGradient(); + const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + + if(aAttribute.getStartColor() == aAttribute.getEndColor()) + { + // not really a gradient; create UnifiedAlphaPrimitive2D + rTargetHolders.Current().append( + new drawinglayer::primitive2d::UnifiedAlphaPrimitive2D( + xSubContent, + aAttribute.getStartColor().luminance())); + } + else + { + // really a gradient. Create gradient sub-content (with correct scaling) + basegfx::B2DRange aRange( + aTargetRectangle.Left(), aTargetRectangle.Top(), + aTargetRectangle.Right(), aTargetRectangle.Bottom()); + aRange.transform(rPropertyHolders.Current().getTransformation()); + + // prepare gradient for alpha content + const drawinglayer::primitive2d::Primitive2DReference xAlpha( + new drawinglayer::primitive2d::FillGradientPrimitive2D( + aRange, + aAttribute)); + + // create alpha primitive + rTargetHolders.Current().append( + new drawinglayer::primitive2d::AlphaPrimitive2D( + xSubContent, + drawinglayer::primitive2d::Primitive2DSequence(&xAlpha, 1))); + } + } + } + } + + break; + } + case META_GRADIENTEX_ACTION : + { + /** SIMPLE, DONE */ + // This is only a data holder which is interpreted inside comment actions, + // see META_COMMENT_ACTION for more info + // const MetaGradientExAction* pA = (const MetaGradientExAction*)pAction; + break; + } + case META_LAYOUTMODE_ACTION : + { + /** SIMPLE, DONE */ + const MetaLayoutModeAction* pA = (const MetaLayoutModeAction*)pAction; + rPropertyHolders.Current().setLayoutMode(pA->GetLayoutMode()); + break; + } + case META_TEXTLANGUAGE_ACTION : + { + /** SIMPLE, DONE */ + const MetaTextLanguageAction* pA = (const MetaTextLanguageAction*)pAction; + rPropertyHolders.Current().setLanguageType(pA->GetTextLanguage()); + break; + } + case META_OVERLINECOLOR_ACTION : + { + /** SIMPLE, DONE */ + const MetaOverlineColorAction* pA = (const MetaOverlineColorAction*)pAction; + const bool bActive(pA->IsSetting()); + + rPropertyHolders.Current().setOverlineColorActive(bActive); + if(bActive) + rPropertyHolders.Current().setOverlineColor(pA->GetColor().getBColor()); + + break; + } + case META_COMMENT_ACTION : + { + /** CHECKED, WORKS WELL */ + // I already implemented + // XPATHFILL_SEQ_BEGIN, XPATHFILL_SEQ_END + // XPATHSTROKE_SEQ_BEGIN, XPATHSTROKE_SEQ_END, + // but opted to remove these again; it works well without them + // and makes the code less dependent from those Metafile Add-Ons + const MetaCommentAction* pA = (const MetaCommentAction*)pAction; + + if(COMPARE_EQUAL == pA->GetComment().CompareIgnoreCaseToAscii("XGRAD_SEQ_BEGIN")) + { + // XGRAD_SEQ_BEGIN, XGRAD_SEQ_END should be supported since the + // pure recorded paint of the gradients uses the XOR paint functionality + // ('trick'). This is (and will be) broblematic with AntAliasing, so it's + // better to use this info + const MetaGradientExAction* pMetaGradientExAction = 0; + bool bDone(false); + sal_uInt32 b(nAction + 1); + + for(; !bDone && b < nCount; b++) + { + pAction = rMetaFile.GetAction(b); + + if(META_GRADIENTEX_ACTION == pAction->GetType()) + { + pMetaGradientExAction = (const MetaGradientExAction*)pAction; + } + else if(META_COMMENT_ACTION == pAction->GetType()) + { + if(COMPARE_EQUAL == ((const MetaCommentAction*)pAction)->GetComment().CompareIgnoreCaseToAscii("XGRAD_SEQ_END")) + { + bDone = true; + } + } + } + + if(bDone && pMetaGradientExAction) + { + // consume actions and skip forward + nAction = b - 1; + + // get geometry data + basegfx::B2DPolyPolygon aPolyPolygon(pMetaGradientExAction->GetPolyPolygon().getB2DPolyPolygon()); + + if(aPolyPolygon.count()) + { + // transform geometry + aPolyPolygon.transform(rPropertyHolders.Current().getTransformation()); + + // get and check if gradient is a real gradient + const Gradient& rGradient = pMetaGradientExAction->GetGradient(); + const drawinglayer::attribute::FillGradientAttribute aAttribute(createFillGradientAttribute(rGradient)); + + if(aAttribute.getStartColor() == aAttribute.getEndColor()) + { + // not really a gradient + rTargetHolders.Current().append( + new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( + aPolyPolygon, + aAttribute.getStartColor())); + } + else + { + // really a gradient + rTargetHolders.Current().append( + new drawinglayer::primitive2d::PolyPolygonGradientPrimitive2D( + aPolyPolygon, + aAttribute)); + } + } + } + } + + break; + } + default: + { + OSL_ENSURE(false, "Unknown MetaFile Action (!)"); + break; + } + } + } + } +} // end of anonymous namespace + +////////////////////////////////////////////////////////////////////////////// + namespace drawinglayer { namespace primitive2d { + Primitive2DSequence MetafilePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + // prepare target and porperties; each will have one default entry + TargetHolders aTargetHolders; + PropertyHolders aPropertyHolders; + + // set target MapUnit at Properties + aPropertyHolders.Current().setMapUnit(getMetaFile().GetPrefMapMode().GetMapUnit()); + + // interpret the Metafile + interpretMetafile(getMetaFile(), aTargetHolders, aPropertyHolders, rViewInformation); + + // get the content. There should be ony one target, as in the start condition, + // but iterating will be the right thing to do when some push/pop is not closed + Primitive2DSequence xRetval; + + while(aTargetHolders.size() > 1) + { + appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, + aTargetHolders.Current().getPrimitive2DSequence(aPropertyHolders.Current())); + aTargetHolders.Pop(); + } + + appendPrimitive2DSequenceToPrimitive2DSequence(xRetval, + aTargetHolders.Current().getPrimitive2DSequence(aPropertyHolders.Current())); + + if(xRetval.hasElements()) + { + // get target size + const Rectangle aMtfTarget(getMetaFile().GetPrefMapMode().GetOrigin(), getMetaFile().GetPrefSize()); + + // create transformation + basegfx::B2DHomMatrix aAdaptedTransform; + + aAdaptedTransform.translate(-aMtfTarget.Left(), -aMtfTarget.Top()); + aAdaptedTransform.scale( + aMtfTarget.getWidth() ? 1.0 / aMtfTarget.getWidth() : 1.0, + aMtfTarget.getHeight() ? 1.0 / aMtfTarget.getHeight() : 1.0); + aAdaptedTransform = getTransform() * aAdaptedTransform; + + // embed to target transformation + const Primitive2DReference aEmbeddedTransform( + new TransformPrimitive2D( + aAdaptedTransform, + xRetval)); + + xRetval = Primitive2DSequence(&aEmbeddedTransform, 1); + } + + return xRetval; + } + MetafilePrimitive2D::MetafilePrimitive2D( const basegfx::B2DHomMatrix& rMetaFileTransform, const GDIMetaFile& rMetaFile) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maMetaFileTransform(rMetaFileTransform), maMetaFile(rMetaFile) { @@ -61,7 +3060,7 @@ namespace drawinglayer bool MetafilePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const MetafilePrimitive2D& rCompare = (MetafilePrimitive2D&)rPrimitive; @@ -74,8 +3073,13 @@ namespace drawinglayer basegfx::B2DRange MetafilePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const { + // use own implementation to quickly answer the getB2DRange question. The + // MetafilePrimitive2D assumes that all geometry is inside of the shape. If + // this is not the case (i have already seen some wrong Metafiles) it should + // be embedded to a MaskPrimitive2D basegfx::B2DRange aRetval(0.0, 0.0, 1.0, 1.0); aRetval.transform(getTransform()); + return aRetval; } diff --git a/drawinglayer/source/primitive2d/pagepreviewprimitive2d.cxx b/drawinglayer/source/primitive2d/pagepreviewprimitive2d.cxx index 01a82299682d..b747c79ee0c7 100644 --- a/drawinglayer/source/primitive2d/pagepreviewprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/pagepreviewprimitive2d.cxx @@ -42,6 +42,7 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -53,10 +54,10 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PagePreviewPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence PagePreviewPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { Primitive2DSequence xRetval; - Primitive2DSequence aContent(getChildren()); + Primitive2DSequence aContent(getPageContent()); if(aContent.hasElements() && basegfx::fTools::more(getContentWidth(), 0.0) @@ -112,9 +113,9 @@ namespace drawinglayer } // add the missing object transformation aspects - aPageTrans.shearX(fShearX); - aPageTrans.rotate(fRotate); - aPageTrans.translate(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DHomMatrix aCombined(basegfx::tools::createShearXRotateTranslateB2DHomMatrix( + fShearX, fRotate, aTranslate.getX(), aTranslate.getY())); + aPageTrans = aCombined * aPageTrans; } else { @@ -139,10 +140,11 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rTransform, double fContentWidth, double fContentHeight, - const Primitive2DSequence& rChildren, + const Primitive2DSequence& rPageContent, bool bKeepAspectRatio) - : GroupPrimitive2D(rChildren), + : BufferedDecompositionPrimitive2D(), mxDrawPage(rxDrawPage), + maPageContent(rPageContent), maTransform(rTransform), mfContentWidth(fContentWidth), mfContentHeight(fContentHeight), @@ -152,11 +154,12 @@ namespace drawinglayer bool PagePreviewPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(GroupPrimitive2D::operator==(rPrimitive)) + if(BasePrimitive2D::operator==(rPrimitive)) { const PagePreviewPrimitive2D& rCompare = static_cast< const PagePreviewPrimitive2D& >(rPrimitive); return (getXDrawPage() == rCompare.getXDrawPage() + && getPageContent() == rCompare.getPageContent() && getTransform() == rCompare.getTransform() && getContentWidth() == rCompare.getContentWidth() && getContentHeight() == rCompare.getContentHeight() diff --git a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx index b5212da54688..69cbd046efd2 100644 --- a/drawinglayer/source/primitive2d/polygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polygonprimitive2d.cxx @@ -110,7 +110,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolygonMarkerPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence PolygonMarkerPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { // calculate logic DashLength const basegfx::B2DVector aDashVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(getDiscreteDashLength(), 0.0)); @@ -147,7 +147,7 @@ namespace drawinglayer const basegfx::BColor& rRGBColorA, const basegfx::BColor& rRGBColorB, double fDiscreteDashLength) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maPolygon(rPolygon), maRGBColorA(rRGBColorA), maRGBColorB(rRGBColorB), @@ -158,7 +158,7 @@ namespace drawinglayer bool PolygonMarkerPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const PolygonMarkerPrimitive2D& rCompare = (PolygonMarkerPrimitive2D&)rPrimitive; @@ -198,7 +198,7 @@ namespace drawinglayer ::osl::MutexGuard aGuard( m_aMutex ); bool bNeedNewDecomposition(false); - if(getLocalDecomposition().hasElements()) + if(getBuffered2DDecomposition().hasElements()) { if(rViewInformation.getInverseObjectToViewTransformation() != maLastInverseObjectToViewTransformation) { @@ -209,10 +209,10 @@ namespace drawinglayer if(bNeedNewDecomposition) { // conditions of last local decomposition have changed, delete - const_cast< PolygonMarkerPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + const_cast< PolygonMarkerPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); } - if(!getLocalDecomposition().hasElements()) + if(!getBuffered2DDecomposition().hasElements()) { // remember last used InverseObjectToViewTransformation PolygonMarkerPrimitive2D* pThat = const_cast< PolygonMarkerPrimitive2D* >(this); @@ -220,7 +220,7 @@ namespace drawinglayer } // use parent implementation - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID @@ -235,7 +235,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolygonStrokePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolygonStrokePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { if(getB2DPolygon().count()) { @@ -307,7 +307,7 @@ namespace drawinglayer const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, const attribute::StrokeAttribute& rStrokeAttribute) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maPolygon(rPolygon), maLineAttribute(rLineAttribute), maStrokeAttribute(rStrokeAttribute) @@ -317,7 +317,7 @@ namespace drawinglayer PolygonStrokePrimitive2D::PolygonStrokePrimitive2D( const basegfx::B2DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maPolygon(rPolygon), maLineAttribute(rLineAttribute), maStrokeAttribute() @@ -326,7 +326,7 @@ namespace drawinglayer bool PolygonStrokePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const PolygonStrokePrimitive2D& rCompare = (PolygonStrokePrimitive2D&)rPrimitive; @@ -348,7 +348,7 @@ namespace drawinglayer { // if line is mitered, use parent call since mitered line // geometry may use more space than the geometry grown by half line width - aRetval = BasePrimitive2D::getB2DRange(rViewInformation); + aRetval = BufferedDecompositionPrimitive2D::getB2DRange(rViewInformation); } else { @@ -392,7 +392,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolygonWavePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolygonWavePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { Primitive2DSequence aRetval; @@ -505,7 +505,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolygonStrokeArrowPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolygonStrokeArrowPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { // copy local polygon, it may be changed basegfx::B2DPolygon aLocalPolygon(getB2DPolygon()); @@ -614,7 +614,7 @@ namespace drawinglayer if(getStart().isActive() || getEnd().isActive()) { // use decomposition when line start/end is used - return BasePrimitive2D::getB2DRange(rViewInformation); + return BufferedDecompositionPrimitive2D::getB2DRange(rViewInformation); } else { diff --git a/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx b/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx index 9dd14aeb11e3..55c334434c70 100644 --- a/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx @@ -57,7 +57,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolyPolygonHairlinePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolyPolygonHairlinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon()); const sal_uInt32 nCount(aPolyPolygon.count()); @@ -80,7 +80,7 @@ namespace drawinglayer } PolyPolygonHairlinePrimitive2D::PolyPolygonHairlinePrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rBColor) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maPolyPolygon(rPolyPolygon), maBColor(rBColor) { @@ -88,7 +88,7 @@ namespace drawinglayer bool PolyPolygonHairlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const PolyPolygonHairlinePrimitive2D& rCompare = (PolyPolygonHairlinePrimitive2D&)rPrimitive; @@ -117,7 +117,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolyPolygonMarkerPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolyPolygonMarkerPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon()); const sal_uInt32 nCount(aPolyPolygon.count()); @@ -144,7 +144,7 @@ namespace drawinglayer const basegfx::BColor& rRGBColorA, const basegfx::BColor& rRGBColorB, double fDiscreteDashLength) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maPolyPolygon(rPolyPolygon), maRGBColorA(rRGBColorA), maRGBColorB(rRGBColorB), @@ -154,7 +154,7 @@ namespace drawinglayer bool PolyPolygonMarkerPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const PolyPolygonMarkerPrimitive2D& rCompare = (PolyPolygonMarkerPrimitive2D&)rPrimitive; @@ -185,7 +185,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolyPolygonStrokePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolyPolygonStrokePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon()); const sal_uInt32 nCount(aPolyPolygon.count()); @@ -211,7 +211,7 @@ namespace drawinglayer const basegfx::B2DPolyPolygon& rPolyPolygon, const attribute::LineAttribute& rLineAttribute, const attribute::StrokeAttribute& rStrokeAttribute) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maPolyPolygon(rPolyPolygon), maLineAttribute(rLineAttribute), maStrokeAttribute(rStrokeAttribute) @@ -221,7 +221,7 @@ namespace drawinglayer PolyPolygonStrokePrimitive2D::PolyPolygonStrokePrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, const attribute::LineAttribute& rLineAttribute) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maPolyPolygon(rPolyPolygon), maLineAttribute(rLineAttribute), maStrokeAttribute() @@ -230,7 +230,7 @@ namespace drawinglayer bool PolyPolygonStrokePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const PolyPolygonStrokePrimitive2D& rCompare = (PolyPolygonStrokePrimitive2D&)rPrimitive; @@ -268,7 +268,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolyPolygonStrokeArrowPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolyPolygonStrokeArrowPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon()); const sal_uInt32 nCount(aPolyPolygon.count()); @@ -343,7 +343,7 @@ namespace drawinglayer if(getStart().isActive() || getEnd().isActive()) { // use decomposition when line start/end is used - return BasePrimitive2D::getB2DRange(rViewInformation); + return BufferedDecompositionPrimitive2D::getB2DRange(rViewInformation); } else { @@ -404,7 +404,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolyPolygonGradientPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolyPolygonGradientPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { // create SubSequence with FillGradientPrimitive2D const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange()); @@ -420,16 +420,16 @@ namespace drawinglayer PolyPolygonGradientPrimitive2D::PolyPolygonGradientPrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, - const basegfx::BColor& rBColor, const attribute::FillGradientAttribute& rFillGradient) - : PolyPolygonColorPrimitive2D(rPolyPolygon, rBColor), + : BufferedDecompositionPrimitive2D(), + maPolyPolygon(rPolyPolygon), maFillGradient(rFillGradient) { } bool PolyPolygonGradientPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(PolyPolygonColorPrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const PolyPolygonGradientPrimitive2D& rCompare = (PolyPolygonGradientPrimitive2D&)rPrimitive; @@ -451,11 +451,11 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolyPolygonHatchPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolyPolygonHatchPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { // create SubSequence with FillHatchPrimitive2D const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange()); - FillHatchPrimitive2D* pNewHatch = new FillHatchPrimitive2D(aPolyPolygonRange, getBColor(), getFillHatch()); + FillHatchPrimitive2D* pNewHatch = new FillHatchPrimitive2D(aPolyPolygonRange, getBackgroundColor(), getFillHatch()); const Primitive2DReference xSubRef(pNewHatch); const Primitive2DSequence aSubSequence(&xSubRef, 1L); @@ -467,20 +467,23 @@ namespace drawinglayer PolyPolygonHatchPrimitive2D::PolyPolygonHatchPrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, - const basegfx::BColor& rBColor, + const basegfx::BColor& rBackgroundColor, const attribute::FillHatchAttribute& rFillHatch) - : PolyPolygonColorPrimitive2D(rPolyPolygon, rBColor), + : BufferedDecompositionPrimitive2D(), + maPolyPolygon(rPolyPolygon), + maBackgroundColor(rBackgroundColor), maFillHatch(rFillHatch) { } bool PolyPolygonHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(PolyPolygonColorPrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const PolyPolygonHatchPrimitive2D& rCompare = (PolyPolygonHatchPrimitive2D&)rPrimitive; - return (getFillHatch() == rCompare.getFillHatch()); + return (getBackgroundColor() == rCompare.getBackgroundColor() + && getFillHatch() == rCompare.getFillHatch()); } return false; @@ -498,7 +501,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence PolyPolygonBitmapPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence PolyPolygonBitmapPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { // create SubSequence with FillBitmapPrimitive2D const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange()); @@ -519,16 +522,16 @@ namespace drawinglayer PolyPolygonBitmapPrimitive2D::PolyPolygonBitmapPrimitive2D( const basegfx::B2DPolyPolygon& rPolyPolygon, - const basegfx::BColor& rBColor, const attribute::FillBitmapAttribute& rFillBitmap) - : PolyPolygonColorPrimitive2D(rPolyPolygon, rBColor), + : BufferedDecompositionPrimitive2D(), + maPolyPolygon(rPolyPolygon), maFillBitmap(rFillBitmap) { } bool PolyPolygonBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(PolyPolygonColorPrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const PolyPolygonBitmapPrimitive2D& rCompare = (PolyPolygonBitmapPrimitive2D&)rPrimitive; diff --git a/drawinglayer/source/primitive2d/primitivetools2d.cxx b/drawinglayer/source/primitive2d/primitivetools2d.cxx index d288a697d729..2b25590bf1f4 100644 --- a/drawinglayer/source/primitive2d/primitivetools2d.cxx +++ b/drawinglayer/source/primitive2d/primitivetools2d.cxx @@ -53,20 +53,20 @@ namespace drawinglayer // get the current DiscreteUnit const double fDiscreteUnit((rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength()); - if(getLocalDecomposition().hasElements() && !basegfx::fTools::equal(fDiscreteUnit, getDiscreteUnit())) + if(getBuffered2DDecomposition().hasElements() && !basegfx::fTools::equal(fDiscreteUnit, getDiscreteUnit())) { // conditions of last local decomposition have changed, delete - const_cast< DiscreteMetricDependentPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + const_cast< DiscreteMetricDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); } - if(!getLocalDecomposition().hasElements()) + if(!getBuffered2DDecomposition().hasElements()) { // remember new valid DiscreteUnit const_cast< DiscreteMetricDependentPrimitive2D* >(this)->mfDiscreteUnit = fDiscreteUnit; } // call base implementation - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } } // end of namespace primitive2d } // end of namespace drawinglayer @@ -84,20 +84,92 @@ namespace drawinglayer // get the current Viewport const basegfx::B2DRange& rViewport = rViewInformation.getViewport(); - if(getLocalDecomposition().hasElements() && !rViewport.equal(getViewport())) + if(getBuffered2DDecomposition().hasElements() && !rViewport.equal(getViewport())) { // conditions of last local decomposition have changed, delete - const_cast< ViewportDependentPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + const_cast< ViewportDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); } - if(!getLocalDecomposition().hasElements()) + if(!getBuffered2DDecomposition().hasElements()) { // remember new valid DiscreteUnit const_cast< ViewportDependentPrimitive2D* >(this)->maViewport = rViewport; } // call base implementation - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence ViewTransformationDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + // get the current ViewTransformation + const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation(); + + if(getBuffered2DDecomposition().hasElements() && rViewTransformation != getViewTransformation()) + { + // conditions of last local decomposition have changed, delete + const_cast< ViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); + } + + if(!getBuffered2DDecomposition().hasElements()) + { + // remember new valid ViewTransformation + const_cast< ViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation; + } + + // call base implementation + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence ObjectAndViewTransformationDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + // get the current ViewTransfromation + const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation(); + + if(getBuffered2DDecomposition().hasElements() && rViewTransformation != getViewTransformation()) + { + // conditions of last local decomposition have changed, delete + const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); + } + + // get the current ObjectTransformation + const basegfx::B2DHomMatrix& rObjectTransformation = rViewInformation.getObjectTransformation(); + + if(getBuffered2DDecomposition().hasElements() && rObjectTransformation != getObjectTransformation()) + { + // conditions of last local decomposition have changed, delete + const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); + } + + if(!getBuffered2DDecomposition().hasElements()) + { + // remember new valid ViewTransformation, and ObjectTransformation + const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation; + const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maObjectTransformation = rObjectTransformation; + } + + // call base implementation + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } } // end of namespace primitive2d } // end of namespace drawinglayer diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx index ad36a40ea996..6b346d5abdc0 100644 --- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx @@ -147,7 +147,7 @@ namespace drawinglayer } } - Primitive2DSequence ScenePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence ScenePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { Primitive2DSequence aRetval; @@ -356,7 +356,7 @@ namespace drawinglayer const attribute::SdrLightingAttribute& rSdrLightingAttribute, const basegfx::B2DHomMatrix& rObjectTransformation, const geometry::ViewInformation3D& rViewInformation3D) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), mxChildren3D(rxChildren3D), maSdrSceneAttribute(rSdrSceneAttribute), maSdrLightingAttribute(rSdrLightingAttribute), @@ -373,7 +373,7 @@ namespace drawinglayer bool ScenePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const ScenePrimitive2D& rCompare = (ScenePrimitive2D&)rPrimitive; @@ -424,7 +424,7 @@ namespace drawinglayer bool bNeedNewDecomposition(false); bool bDiscreteSizesAreCalculated(false); - if(getLocalDecomposition().hasElements()) + if(getBuffered2DDecomposition().hasElements()) { basegfx::B2DRange aVisibleDiscreteRange; calculateDiscreteSizes(rViewInformation, aDiscreteRange, aVisibleDiscreteRange, aUnitVisibleRange); @@ -452,10 +452,10 @@ namespace drawinglayer if(bNeedNewDecomposition) { // conditions of last local decomposition have changed, delete - const_cast< ScenePrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + const_cast< ScenePrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); } - if(!getLocalDecomposition().hasElements()) + if(!getBuffered2DDecomposition().hasElements()) { if(!bDiscreteSizesAreCalculated) { @@ -471,7 +471,7 @@ namespace drawinglayer } // use parent implementation - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID diff --git a/drawinglayer/source/primitive2d/shadowprimitive2d.cxx b/drawinglayer/source/primitive2d/shadowprimitive2d.cxx index 5681f7f98d7e..b6ce7dc3248d 100644 --- a/drawinglayer/source/primitive2d/shadowprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/shadowprimitive2d.cxx @@ -55,25 +55,6 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence ShadowPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const - { - Primitive2DSequence aRetval; - - if(getChildren().hasElements()) - { - // create a modifiedColorPrimitive containing the shadow color and the content - const basegfx::BColorModifier aBColorModifier(getShadowColor()); - const Primitive2DReference xRefA(new ModifiedColorPrimitive2D(getChildren(), aBColorModifier)); - const Primitive2DSequence aSequenceB(&xRefA, 1L); - - // build transformed primitiveVector with shadow offset and add to target - const Primitive2DReference xRefB(new TransformPrimitive2D(getShadowTransform(), aSequenceB)); - aRetval = Primitive2DSequence(&xRefB, 1L); - } - - return aRetval; - } - ShadowPrimitive2D::ShadowPrimitive2D( const basegfx::B2DHomMatrix& rShadowTransform, const basegfx::BColor& rShadowColor, @@ -86,7 +67,7 @@ namespace drawinglayer bool ShadowPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(GroupPrimitive2D::operator==(rPrimitive)) + if(BasePrimitive2D::operator==(rPrimitive)) { const ShadowPrimitive2D& rCompare = static_cast< const ShadowPrimitive2D& >(rPrimitive); @@ -104,6 +85,25 @@ namespace drawinglayer return aRetval; } + Primitive2DSequence ShadowPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + Primitive2DSequence aRetval; + + if(getChildren().hasElements()) + { + // create a modifiedColorPrimitive containing the shadow color and the content + const basegfx::BColorModifier aBColorModifier(getShadowColor()); + const Primitive2DReference xRefA(new ModifiedColorPrimitive2D(getChildren(), aBColorModifier)); + const Primitive2DSequence aSequenceB(&xRefA, 1L); + + // build transformed primitiveVector with shadow offset and add to target + const Primitive2DReference xRefB(new TransformPrimitive2D(getShadowTransform(), aSequenceB)); + aRetval = Primitive2DSequence(&xRefB, 1L); + } + + return aRetval; + } + // provide unique ID ImplPrimitrive2DIDBlock(ShadowPrimitive2D, PRIMITIVE2D_ID_SHADOWPRIMITIVE2D) diff --git a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx index d337950c6c6b..f9d245f76a34 100644 --- a/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textdecoratedprimitive2d.cxx @@ -48,6 +48,8 @@ #include <drawinglayer/primitive2d/shadowprimitive2d.hxx> #include <com/sun/star/i18n/XBreakIterator.hpp> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#include <drawinglayer/primitive2d/textlineprimitive2d.hxx> +#include <drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -55,226 +57,14 @@ namespace drawinglayer { namespace primitive2d { - void TextDecoratedPortionPrimitive2D::impCreateTextLine( - std::vector< Primitive2DReference >& rTarget, - basegfx::DecomposedB2DHomMatrixContainer& rDecTrans, - const basegfx::B2DHomMatrix &rUnscaledTransform, - FontUnderline eLineStyle, - double fLineOffset, - double fLineHeight, - double fLineWidth, - const basegfx::BColor& rLineColor) const - { - bool bDoubleLine(false); - bool bWaveLine(false); - bool bBoldLine(false); - const int* pDotDashArray(0); - basegfx::B2DLineJoin eLineJoin(basegfx::B2DLINEJOIN_NONE); - - static const int aDottedArray[] = { 1, 1, 0}; // DOTTED LINE - static const int aDotDashArray[] = { 1, 1, 4, 1, 0}; // DASHDOT - static const int aDashDotDotArray[] = { 1, 1, 1, 1, 4, 1, 0}; // DASHDOTDOT - static const int aDashedArray[] = { 5, 2, 0}; // DASHED LINE - static const int aLongDashArray[] = { 7, 2, 0}; // LONGDASH - - switch(eLineStyle) - { - default: // case FONT_UNDERLINE_SINGLE: - { - break; - } - case FONT_UNDERLINE_DOUBLE: - { - bDoubleLine = true; - break; - } - case FONT_UNDERLINE_DOTTED: - { - pDotDashArray = aDottedArray; - break; - } - case FONT_UNDERLINE_DASH: - { - pDotDashArray = aDashedArray; - break; - } - case FONT_UNDERLINE_LONGDASH: - { - pDotDashArray = aLongDashArray; - break; - } - case FONT_UNDERLINE_DASHDOT: - { - pDotDashArray = aDotDashArray; - break; - } - case FONT_UNDERLINE_DASHDOTDOT: - { - pDotDashArray = aDashDotDotArray; - break; - } - case FONT_UNDERLINE_SMALLWAVE: - { - bWaveLine = true; - break; - } - case FONT_UNDERLINE_WAVE: - { - bWaveLine = true; - break; - } - case FONT_UNDERLINE_DOUBLEWAVE: - { - bDoubleLine = true; - bWaveLine = true; - break; - } - case FONT_UNDERLINE_BOLD: - { - bBoldLine = true; - break; - } - case FONT_UNDERLINE_BOLDDOTTED: - { - bBoldLine = true; - pDotDashArray = aDottedArray; - break; - } - case FONT_UNDERLINE_BOLDDASH: - { - bBoldLine = true; - pDotDashArray = aDashedArray; - break; - } - case FONT_UNDERLINE_BOLDLONGDASH: - { - bBoldLine = true; - pDotDashArray = aLongDashArray; - break; - } - case FONT_UNDERLINE_BOLDDASHDOT: - { - bBoldLine = true; - pDotDashArray = aDotDashArray; - break; - } - case FONT_UNDERLINE_BOLDDASHDOTDOT: - { - bBoldLine = true; - pDotDashArray = aDashDotDotArray; - break; - } - case FONT_UNDERLINE_BOLDWAVE: - { - bWaveLine = true; - bBoldLine = true; - break; - } - } - - if(bBoldLine) - { - fLineHeight *= 2.0; - } - - if(bDoubleLine) - { - fLineOffset -= 0.50 * fLineHeight; - fLineHeight *= 0.64; - } - - if(bWaveLine) - { - eLineJoin = basegfx::B2DLINEJOIN_ROUND; - fLineHeight *= 0.25; - } - - // prepare Line and Stroke Attributes - const attribute::LineAttribute aLineAttribute(rLineColor, fLineHeight, eLineJoin); - attribute::StrokeAttribute aStrokeAttribute; - - if(pDotDashArray) - { - ::std::vector< double > aDoubleArray; - - for(const int* p = pDotDashArray; *p; ++p) - { - aDoubleArray.push_back((double)(*p) * fLineHeight); - } - - aStrokeAttribute = attribute::StrokeAttribute(aDoubleArray); - } - - // create base polygon and new primitive - basegfx::B2DPolygon aLine; - Primitive2DReference aNewPrimitive; - - aLine.append(basegfx::B2DPoint(0.0, fLineOffset)); - aLine.append(basegfx::B2DPoint(fLineWidth, fLineOffset)); - aLine.transform(rUnscaledTransform); - - if(bWaveLine) - { - double fWaveWidth(10.6 * fLineHeight); - - if(FONT_UNDERLINE_SMALLWAVE == eLineStyle) - { - fWaveWidth *= 0.7; - } - else if(FONT_UNDERLINE_WAVE == eLineStyle) - { - // extra multiply to get the same WaveWidth as with the bold version - fWaveWidth *= 2.0; - } - - aNewPrimitive = Primitive2DReference(new PolygonWavePrimitive2D(aLine, aLineAttribute, aStrokeAttribute, fWaveWidth, fWaveWidth * 0.5)); - } - else - { - aNewPrimitive = Primitive2DReference(new PolygonStrokePrimitive2D(aLine, aLineAttribute, aStrokeAttribute)); - } - - // add primitive - rTarget.push_back(aNewPrimitive); - - if(bDoubleLine) - { - // double line, create 2nd primitive with offset using TransformPrimitive based on - // already created NewPrimitive - double fLineDist(2.3 * fLineHeight); - - if(bWaveLine) - { - fLineDist = 6.3 * fLineHeight; - } - - basegfx::B2DHomMatrix aTransform; - - // move base point of text to 0.0 and de-rotate - aTransform.translate(-rDecTrans.getTranslate().getX(), -rDecTrans.getTranslate().getY()); - aTransform.rotate(-rDecTrans.getRotate()); - - // translate in Y by offset - aTransform.translate(0.0, fLineDist); - - // move back and rotate - aTransform.rotate(rDecTrans.getRotate()); - aTransform.translate(rDecTrans.getTranslate().getX(), rDecTrans.getTranslate().getY()); - - // add transform primitive - const Primitive2DSequence aContent(&aNewPrimitive, 1); - rTarget.push_back(Primitive2DReference(new TransformPrimitive2D(aTransform, aContent))); - } - } - void TextDecoratedPortionPrimitive2D::impCreateGeometryContent( std::vector< Primitive2DReference >& rTarget, - basegfx::DecomposedB2DHomMatrixContainer& rDecTrans, + basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose& rDecTrans, const String& rText, xub_StrLen aTextPosition, xub_StrLen aTextLength, const ::std::vector< double >& rDXArray, - const FontAttributes& rFontAttributes) const + const attribute::FontAttribute& rFontAttribute) const { // create the SimpleTextPrimitive needed in any case rTarget.push_back(Primitive2DReference( @@ -284,30 +74,24 @@ namespace drawinglayer aTextPosition, aTextLength, rDXArray, - rFontAttributes, + rFontAttribute, getLocale(), getFontColor()))); // see if something else needs to be done - const bool bOverlineUsed(FONT_UNDERLINE_NONE != getFontOverline()); - const bool bUnderlineUsed(FONT_UNDERLINE_NONE != getFontUnderline()); - const bool bStrikeoutUsed(FONT_STRIKEOUT_NONE != getFontStrikeout()); + const bool bOverlineUsed(TEXT_LINE_NONE != getFontOverline()); + const bool bUnderlineUsed(TEXT_LINE_NONE != getFontUnderline()); + const bool bStrikeoutUsed(TEXT_STRIKEOUT_NONE != getTextStrikeout()); if(bUnderlineUsed || bStrikeoutUsed || bOverlineUsed) { // common preparations - basegfx::B2DHomMatrix aUnscaledTransform; TextLayouterDevice aTextLayouter; - // unscaled is needed since scale contains already the font size - aUnscaledTransform.shearX(rDecTrans.getShearX()); - aUnscaledTransform.rotate(rDecTrans.getRotate()); - aUnscaledTransform.translate(rDecTrans.getTranslate().getX(), rDecTrans.getTranslate().getY()); - // TextLayouterDevice is needed to get metrics for text decorations like // underline/strikeout/emphasis marks from it. For setup, the font size is needed - aTextLayouter.setFontAttributes( - getFontAttributes(), + aTextLayouter.setFontAttribute( + getFontAttribute(), rDecTrans.getScale().getX(), rDecTrans.getScale().getY(), getLocale()); @@ -335,115 +119,57 @@ namespace drawinglayer if(bOverlineUsed) { // create primitive geometry for overline - impCreateTextLine(rTarget, rDecTrans, aUnscaledTransform, getFontOverline(), aTextLayouter.getOverlineOffset(), - aTextLayouter.getOverlineHeight(), fTextWidth, getOverlineColor()); + rTarget.push_back(Primitive2DReference( + new TextLinePrimitive2D( + rDecTrans.getB2DHomMatrix(), + fTextWidth, + aTextLayouter.getOverlineOffset(), + aTextLayouter.getOverlineHeight(), + getFontOverline(), + getOverlineColor()))); } if(bUnderlineUsed) { // create primitive geometry for underline - impCreateTextLine(rTarget, rDecTrans, aUnscaledTransform, getFontUnderline(), aTextLayouter.getUnderlineOffset(), - aTextLayouter.getUnderlineHeight(), fTextWidth, getTextlineColor()); + rTarget.push_back(Primitive2DReference( + new TextLinePrimitive2D( + rDecTrans.getB2DHomMatrix(), + fTextWidth, + aTextLayouter.getUnderlineOffset(), + aTextLayouter.getUnderlineHeight(), + getFontUnderline(), + getTextlineColor()))); } if(bStrikeoutUsed) { // create primitive geometry for strikeout - if(FONT_STRIKEOUT_SLASH == getFontStrikeout() || FONT_STRIKEOUT_X == getFontStrikeout()) + if(TEXT_STRIKEOUT_SLASH == getTextStrikeout() || TEXT_STRIKEOUT_X == getTextStrikeout()) { // strikeout with character - const sal_Unicode aStrikeoutChar(FONT_STRIKEOUT_SLASH == getFontStrikeout() ? '/' : 'X'); - const String aSingleCharString(aStrikeoutChar); - const double fStrikeCharWidth(aTextLayouter.getTextWidth(aSingleCharString, 0, 1)); - const double fStrikeCharCount(fabs(fTextWidth/fStrikeCharWidth)); - const sal_uInt32 nStrikeCharCount(static_cast< sal_uInt32 >(fStrikeCharCount + 0.5)); - std::vector<double> aDXArray(nStrikeCharCount); - String aStrikeoutString; - - for(sal_uInt32 a(0); a < nStrikeCharCount; a++) - { - aStrikeoutString += aSingleCharString; - aDXArray[a] = (a + 1) * fStrikeCharWidth; - } + const sal_Unicode aStrikeoutChar(TEXT_STRIKEOUT_SLASH == getTextStrikeout() ? '/' : 'X'); rTarget.push_back(Primitive2DReference( - new TextSimplePortionPrimitive2D( + new TextCharacterStrikeoutPrimitive2D( rDecTrans.getB2DHomMatrix(), - aStrikeoutString, - 0, - aStrikeoutString.Len(), - aDXArray, - rFontAttributes, - getLocale(), - getFontColor()))); + fTextWidth, + getFontColor(), + aStrikeoutChar, + getFontAttribute(), + getLocale()))); } else { // strikeout with geometry - double fStrikeoutHeight(aTextLayouter.getUnderlineHeight()); - double fStrikeoutOffset(aTextLayouter.getStrikeoutOffset()); - bool bDoubleLine(false); - - // set line attribute - switch(getFontStrikeout()) - { - default : // case primitive2d::FONT_STRIKEOUT_SINGLE: - { - break; - } - case primitive2d::FONT_STRIKEOUT_DOUBLE: - { - bDoubleLine = true; - break; - } - case primitive2d::FONT_STRIKEOUT_BOLD: - { - fStrikeoutHeight *= 2.0; - break; - } - } - - if(bDoubleLine) - { - fStrikeoutOffset -= 0.50 * fStrikeoutHeight; - fStrikeoutHeight *= 0.64; - } - - // create base polygon and new primitive - basegfx::B2DPolygon aStrikeoutLine; - - aStrikeoutLine.append(basegfx::B2DPoint(0.0, -fStrikeoutOffset)); - aStrikeoutLine.append(basegfx::B2DPoint(fTextWidth, -fStrikeoutOffset)); - aStrikeoutLine.transform(aUnscaledTransform); - - const attribute::LineAttribute aLineAttribute(getFontColor(), fStrikeoutHeight, basegfx::B2DLINEJOIN_NONE); - Primitive2DReference aNewPrimitive(new PolygonStrokePrimitive2D(aStrikeoutLine, aLineAttribute)); - - // add primitive - rTarget.push_back(aNewPrimitive); - - if(bDoubleLine) - { - // double line, create 2nd primitive with offset using TransformPrimitive based on - // already created NewPrimitive - const double fLineDist(2.0 * fStrikeoutHeight); - basegfx::B2DHomMatrix aTransform; - - // move base point of text to 0.0 and de-rotate - aTransform.translate(-rDecTrans.getTranslate().getX(), -rDecTrans.getTranslate().getY()); - aTransform.rotate(-rDecTrans.getRotate()); - - // translate in Y by offset - aTransform.translate(0.0, -fLineDist); - - // move back and rotate - aTransform.rotate(rDecTrans.getRotate()); - aTransform.translate(rDecTrans.getTranslate().getX(), rDecTrans.getTranslate().getY()); - - // add transform primitive - const Primitive2DSequence aContent(&aNewPrimitive, 1); - rTarget.push_back(Primitive2DReference(new TransformPrimitive2D(aTransform, aContent))); - } + rTarget.push_back(Primitive2DReference( + new TextGeometryStrikeoutPrimitive2D( + rDecTrans.getB2DHomMatrix(), + fTextWidth, + getFontColor(), + aTextLayouter.getUnderlineHeight(), + aTextLayouter.getStrikeoutOffset(), + getTextStrikeout()))); } } } @@ -480,7 +206,7 @@ namespace drawinglayer void TextDecoratedPortionPrimitive2D::impSplitSingleWords( std::vector< Primitive2DReference >& rTarget, - basegfx::DecomposedB2DHomMatrixContainer& rDecTrans) const + basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose& rDecTrans) const { // break iterator support // made static so it only needs to be fetched once, even with many single @@ -510,21 +236,21 @@ namespace drawinglayer impCorrectTextBoundary(aNextWordBoundary); // prepare new font attributes WITHOUT outline - const FontAttributes aNewFontAttributes( - getFontAttributes().getFamilyName(), - getFontAttributes().getStyleName(), - getFontAttributes().getWeight(), - getFontAttributes().getSymbol(), - getFontAttributes().getVertical(), - getFontAttributes().getItalic(), + const attribute::FontAttribute aNewFontAttribute( + getFontAttribute().getFamilyName(), + getFontAttribute().getStyleName(), + getFontAttribute().getWeight(), + getFontAttribute().getSymbol(), + getFontAttribute().getVertical(), + getFontAttribute().getItalic(), false, // no outline anymore, handled locally - getFontAttributes().getRTL(), - getFontAttributes().getBiDiStrong()); + getFontAttribute().getRTL(), + getFontAttribute().getBiDiStrong()); if(aNextWordBoundary.startPos == getTextPosition() && aNextWordBoundary.endPos == getTextLength()) { // it IS only a single word, handle as one word - impCreateGeometryContent(rTarget, rDecTrans, getText(), getTextPosition(), getTextLength(), getDXArray(), aNewFontAttributes); + impCreateGeometryContent(rTarget, rDecTrans, getText(), getTextPosition(), getTextLength(), getDXArray(), aNewFontAttribute); } else { @@ -535,8 +261,8 @@ namespace drawinglayer if(bNoDXArray) { // ..but only completely when no DXArray - aTextLayouter.setFontAttributes( - getFontAttributes(), + aTextLayouter.setFontAttribute( + getFontAttribute(), rDecTrans.getScale().getX(), rDecTrans.getScale().getY(), getLocale()); @@ -612,10 +338,10 @@ namespace drawinglayer // create geometry content for the single word. Do not forget // to use the new transformation - basegfx::DecomposedB2DHomMatrixContainer aDecTrans(aNewTransform); + basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose aDecTrans(aNewTransform); impCreateGeometryContent(rTarget, aDecTrans, getText(), nNewTextStart, - nNewTextEnd - nNewTextStart, aNewDXArray, aNewFontAttributes); + nNewTextEnd - nNewTextStart, aNewDXArray, aNewFontAttribute); if(aNextWordBoundary.endPos >= getTextPosition() + getTextLength()) { @@ -646,10 +372,10 @@ namespace drawinglayer } } - Primitive2DSequence TextDecoratedPortionPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence TextDecoratedPortionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { std::vector< Primitive2DReference > aNewPrimitives; - basegfx::DecomposedB2DHomMatrixContainer aDecTrans(getTextTransform()); + basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose aDecTrans(getTextTransform()); Primitive2DSequence aRetval; // create basic geometry such as SimpleTextPrimitive, Overline, Underline, @@ -662,19 +388,19 @@ namespace drawinglayer else { // prepare new font attributes WITHOUT outline - const FontAttributes aNewFontAttributes( - getFontAttributes().getFamilyName(), - getFontAttributes().getStyleName(), - getFontAttributes().getWeight(), - getFontAttributes().getSymbol(), - getFontAttributes().getVertical(), - getFontAttributes().getItalic(), + const attribute::FontAttribute aNewFontAttribute( + getFontAttribute().getFamilyName(), + getFontAttribute().getStyleName(), + getFontAttribute().getWeight(), + getFontAttribute().getSymbol(), + getFontAttribute().getVertical(), + getFontAttribute().getItalic(), false, // no outline anymore, handled locally - getFontAttributes().getRTL(), - getFontAttributes().getBiDiStrong()); + getFontAttribute().getRTL(), + getFontAttribute().getBiDiStrong()); // handle as one word - impCreateGeometryContent(aNewPrimitives, aDecTrans, getText(), getTextPosition(), getTextLength(), getDXArray(), aNewFontAttributes); + impCreateGeometryContent(aNewPrimitives, aDecTrans, getText(), getTextPosition(), getTextLength(), getDXArray(), aNewFontAttribute); } // convert to Primitive2DSequence @@ -690,15 +416,15 @@ namespace drawinglayer } } - // Handle Shadow, Outline and FontRelief + // Handle Shadow, Outline and TextRelief if(aRetval.hasElements()) { - // outline AND shadow depend on NO FontRelief (see dialog) - const bool bHasFontRelief(FONT_RELIEF_NONE != getFontRelief()); - const bool bHasShadow(!bHasFontRelief && getShadow()); - const bool bHasOutline(!bHasFontRelief && getFontAttributes().getOutline()); + // outline AND shadow depend on NO TextRelief (see dialog) + const bool bHasTextRelief(TEXT_RELIEF_NONE != getTextRelief()); + const bool bHasShadow(!bHasTextRelief && getShadow()); + const bool bHasOutline(!bHasTextRelief && getFontAttribute().getOutline()); - if(bHasShadow || bHasFontRelief || bHasOutline) + if(bHasShadow || bHasTextRelief || bHasOutline) { Primitive2DReference aShadow; @@ -713,8 +439,8 @@ namespace drawinglayer static basegfx::BColor aShadowColor(0.3, 0.3, 0.3); // preapare shadow transform matrix - basegfx::B2DHomMatrix aShadowTransform; - aShadowTransform.translate(fTextShadowOffset, fTextShadowOffset); + const basegfx::B2DHomMatrix aShadowTransform(basegfx::tools::createTranslateB2DHomMatrix( + fTextShadowOffset, fTextShadowOffset)); // create shadow primitive aShadow = Primitive2DReference(new ShadowPrimitive2D( @@ -723,7 +449,7 @@ namespace drawinglayer aRetval)); } - if(bHasFontRelief) + if(bHasTextRelief) { // create emboss using an own helper primitive since this will // be view-dependent @@ -733,7 +459,7 @@ namespace drawinglayer if(bDefaultTextColor) { - if(FONT_RELIEF_ENGRAVED == getFontRelief()) + if(TEXT_RELIEF_ENGRAVED == getTextRelief()) { aTextEffectStyle2D = TEXTEFFECTSTYLE2D_RELIEF_ENGRAVED_DEFAULT; } @@ -744,7 +470,7 @@ namespace drawinglayer } else { - if(FONT_RELIEF_ENGRAVED == getFontRelief()) + if(TEXT_RELIEF_ENGRAVED == getTextRelief()) { aTextEffectStyle2D = TEXTEFFECTSTYLE2D_RELIEF_ENGRAVED; } @@ -795,31 +521,31 @@ namespace drawinglayer xub_StrLen aTextPosition, xub_StrLen aTextLength, const ::std::vector< double >& rDXArray, - const FontAttributes& rFontAttributes, + const attribute::FontAttribute& rFontAttribute, const ::com::sun::star::lang::Locale& rLocale, const basegfx::BColor& rFontColor, // local parameters const basegfx::BColor& rOverlineColor, const basegfx::BColor& rTextlineColor, - FontUnderline eFontOverline, - FontUnderline eFontUnderline, + TextLine eFontOverline, + TextLine eFontUnderline, bool bUnderlineAbove, - FontStrikeout eFontStrikeout, + TextStrikeout eTextStrikeout, bool bWordLineMode, - FontEmphasisMark eFontEmphasisMark, + TextEmphasisMark eTextEmphasisMark, bool bEmphasisMarkAbove, bool bEmphasisMarkBelow, - FontRelief eFontRelief, + TextRelief eTextRelief, bool bShadow) - : TextSimplePortionPrimitive2D(rNewTransform, rText, aTextPosition, aTextLength, rDXArray, rFontAttributes, rLocale, rFontColor), + : TextSimplePortionPrimitive2D(rNewTransform, rText, aTextPosition, aTextLength, rDXArray, rFontAttribute, rLocale, rFontColor), maOverlineColor(rOverlineColor), maTextlineColor(rTextlineColor), meFontOverline(eFontOverline), meFontUnderline(eFontUnderline), - meFontStrikeout(eFontStrikeout), - meFontEmphasisMark(eFontEmphasisMark), - meFontRelief(eFontRelief), + meTextStrikeout(eTextStrikeout), + meTextEmphasisMark(eTextEmphasisMark), + meTextRelief(eTextRelief), mbUnderlineAbove(bUnderlineAbove), mbWordLineMode(bWordLineMode), mbEmphasisMarkAbove(bEmphasisMarkAbove), @@ -838,9 +564,9 @@ namespace drawinglayer && getTextlineColor() == rCompare.getTextlineColor() && getFontOverline() == rCompare.getFontOverline() && getFontUnderline() == rCompare.getFontUnderline() - && getFontStrikeout() == rCompare.getFontStrikeout() - && getFontEmphasisMark() == rCompare.getFontEmphasisMark() - && getFontRelief() == rCompare.getFontRelief() + && getTextStrikeout() == rCompare.getTextStrikeout() + && getTextEmphasisMark() == rCompare.getTextEmphasisMark() + && getTextRelief() == rCompare.getTextRelief() && getUnderlineAbove() == rCompare.getUnderlineAbove() && getWordLineMode() == rCompare.getWordLineMode() && getEmphasisMarkAbove() == rCompare.getEmphasisMarkAbove() @@ -857,19 +583,19 @@ namespace drawinglayer basegfx::B2DRange TextDecoratedPortionPrimitive2D::getB2DRange(const geometry::ViewInformation2D& rViewInformation) const { const bool bDecoratedIsNeeded( - FONT_UNDERLINE_NONE != getFontOverline() - || FONT_UNDERLINE_NONE != getFontUnderline() - || FONT_STRIKEOUT_NONE != getFontStrikeout() - || FONT_EMPHASISMARK_NONE != getFontEmphasisMark() - || FONT_RELIEF_NONE != getFontRelief() + TEXT_LINE_NONE != getFontOverline() + || TEXT_LINE_NONE != getFontUnderline() + || TEXT_STRIKEOUT_NONE != getTextStrikeout() + || TEXT_EMPHASISMARK_NONE != getTextEmphasisMark() + || TEXT_RELIEF_NONE != getTextRelief() || getShadow()); if(bDecoratedIsNeeded) { - // decoration is used, fallback to BasePrimitive2D::getB2DRange which uses + // decoration is used, fallback to BufferedDecompositionPrimitive2D::getB2DRange which uses // the own local decomposition for computation and thus creates all necessary // geometric objects - return BasePrimitive2D::getB2DRange(rViewInformation); + return BufferedDecompositionPrimitive2D::getB2DRange(rViewInformation); } else { diff --git a/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx b/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx index c1963f4ba2a4..5e98a9d6d34b 100644 --- a/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/texteffectprimitive2d.cxx @@ -41,6 +41,7 @@ #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -50,7 +51,7 @@ namespace drawinglayer { static double fDiscreteSize(1.1); - Primitive2DSequence TextEffectPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence TextEffectPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { Primitive2DSequence aRetval; @@ -68,13 +69,12 @@ namespace drawinglayer case TEXTEFFECTSTYLE2D_RELIEF_ENGRAVED_DEFAULT: { // prepare transform of sub-group back to (0,0) and align to X-Axis - basegfx::B2DHomMatrix aBackTransform; - aBackTransform.translate(-getRotationCenter().getX(), -getRotationCenter().getY()); + basegfx::B2DHomMatrix aBackTransform(basegfx::tools::createTranslateB2DHomMatrix( + -getRotationCenter().getX(), -getRotationCenter().getY())); aBackTransform.rotate(-getDirection()); // prepare transform of sub-group back to it's position and rotation - basegfx::B2DHomMatrix aForwardTransform; - aForwardTransform.rotate(getDirection()); + basegfx::B2DHomMatrix aForwardTransform(basegfx::tools::createRotateB2DHomMatrix(getDirection())); aForwardTransform.translate(getRotationCenter().getX(), getRotationCenter().getY()); // create transformation for one discrete unit @@ -104,22 +104,22 @@ namespace drawinglayer { // emboss/engrave in black, original forced to white const basegfx::BColorModifier aBColorModifierToGray(basegfx::BColor(0.0)); - const Primitive2DReference xModifiedColor(new ModifiedColorPrimitive2D(getChildren(), aBColorModifierToGray)); + const Primitive2DReference xModifiedColor(new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToGray)); aRetval[0] = Primitive2DReference(new TransformPrimitive2D(aTransform, Primitive2DSequence(&xModifiedColor, 1))); // add original, too const basegfx::BColorModifier aBColorModifierToWhite(basegfx::BColor(1.0)); - aRetval[1] = Primitive2DReference(new ModifiedColorPrimitive2D(getChildren(), aBColorModifierToWhite)); + aRetval[1] = Primitive2DReference(new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToWhite)); } else { // emboss/engrave in gray, keep original's color const basegfx::BColorModifier aBColorModifierToGray(basegfx::BColor(0.75)); // 192 - const Primitive2DReference xModifiedColor(new ModifiedColorPrimitive2D(getChildren(), aBColorModifierToGray)); + const Primitive2DReference xModifiedColor(new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToGray)); aRetval[0] = Primitive2DReference(new TransformPrimitive2D(aTransform, Primitive2DSequence(&xModifiedColor, 1))); // add original, too - aRetval[1] = Primitive2DReference(new GroupPrimitive2D(getChildren())); + aRetval[1] = Primitive2DReference(new GroupPrimitive2D(getTextContent())); } break; @@ -132,39 +132,39 @@ namespace drawinglayer aTransform.set(0, 2, aDistance.getX()); aTransform.set(1, 2, 0.0); - aRetval[0] = Primitive2DReference(new TransformPrimitive2D(aTransform, getChildren())); + aRetval[0] = Primitive2DReference(new TransformPrimitive2D(aTransform, getTextContent())); aTransform.set(0, 2, aDiagonalDistance.getX()); aTransform.set(1, 2, aDiagonalDistance.getY()); - aRetval[1] = Primitive2DReference(new TransformPrimitive2D(aTransform, getChildren())); + aRetval[1] = Primitive2DReference(new TransformPrimitive2D(aTransform, getTextContent())); aTransform.set(0, 2, 0.0); aTransform.set(1, 2, aDistance.getY()); - aRetval[2] = Primitive2DReference(new TransformPrimitive2D(aTransform, getChildren())); + aRetval[2] = Primitive2DReference(new TransformPrimitive2D(aTransform, getTextContent())); aTransform.set(0, 2, -aDiagonalDistance.getX()); aTransform.set(1, 2, aDiagonalDistance.getY()); - aRetval[3] = Primitive2DReference(new TransformPrimitive2D(aTransform, getChildren())); + aRetval[3] = Primitive2DReference(new TransformPrimitive2D(aTransform, getTextContent())); aTransform.set(0, 2, -aDistance.getX()); aTransform.set(1, 2, 0.0); - aRetval[4] = Primitive2DReference(new TransformPrimitive2D(aTransform, getChildren())); + aRetval[4] = Primitive2DReference(new TransformPrimitive2D(aTransform, getTextContent())); aTransform.set(0, 2, -aDiagonalDistance.getX()); aTransform.set(1, 2, -aDiagonalDistance.getY()); - aRetval[5] = Primitive2DReference(new TransformPrimitive2D(aTransform, getChildren())); + aRetval[5] = Primitive2DReference(new TransformPrimitive2D(aTransform, getTextContent())); aTransform.set(0, 2, 0.0); aTransform.set(1, 2, -aDistance.getY()); - aRetval[6] = Primitive2DReference(new TransformPrimitive2D(aTransform, getChildren())); + aRetval[6] = Primitive2DReference(new TransformPrimitive2D(aTransform, getTextContent())); aTransform.set(0, 2, aDiagonalDistance.getX()); aTransform.set(1, 2, -aDiagonalDistance.getY()); - aRetval[7] = Primitive2DReference(new TransformPrimitive2D(aTransform, getChildren())); + aRetval[7] = Primitive2DReference(new TransformPrimitive2D(aTransform, getTextContent())); // at last, place original over it, but force to white const basegfx::BColorModifier aBColorModifierToWhite(basegfx::BColor(1.0, 1.0, 1.0)); - aRetval[8] = Primitive2DReference(new ModifiedColorPrimitive2D(getChildren(), aBColorModifierToWhite)); + aRetval[8] = Primitive2DReference(new ModifiedColorPrimitive2D(getTextContent(), aBColorModifierToWhite)); break; } @@ -174,11 +174,12 @@ namespace drawinglayer } TextEffectPrimitive2D::TextEffectPrimitive2D( - const Primitive2DSequence& rChildren, + const Primitive2DSequence& rTextContent, const basegfx::B2DPoint& rRotationCenter, double fDirection, TextEffectStyle2D eTextEffectStyle2D) - : GroupPrimitive2D(rChildren), + : BufferedDecompositionPrimitive2D(), + maTextContent(rTextContent), maRotationCenter(rRotationCenter), mfDirection(fDirection), meTextEffectStyle2D(eTextEffectStyle2D) @@ -187,11 +188,12 @@ namespace drawinglayer bool TextEffectPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(GroupPrimitive2D::operator==(rPrimitive)) + if(BasePrimitive2D::operator==(rPrimitive)) { const TextEffectPrimitive2D& rCompare = (TextEffectPrimitive2D&)rPrimitive; - return (getRotationCenter() == rCompare.getRotationCenter() + return (getTextContent() == rCompare.getTextContent() + && getRotationCenter() == rCompare.getRotationCenter() && getDirection() == rCompare.getDirection() && getTextEffectStyle2D() == rCompare.getTextEffectStyle2D()); } @@ -206,7 +208,7 @@ namespace drawinglayer // then will ask 9 times at nearly the same content. This may even be refined here using the // TextEffectStyle information, e.g. for TEXTEFFECTSTYLE2D_RELIEF the grow needs only to // be in two directions - basegfx::B2DRange aRetval(getB2DRangeFromPrimitive2DSequence(getChildren(), rViewInformation)); + basegfx::B2DRange aRetval(getB2DRangeFromPrimitive2DSequence(getTextContent(), rViewInformation)); aRetval.grow(fDiscreteSize); return aRetval; @@ -216,23 +218,23 @@ namespace drawinglayer { ::osl::MutexGuard aGuard( m_aMutex ); - if(getLocalDecomposition().hasElements()) + if(getBuffered2DDecomposition().hasElements()) { if(maLastObjectToViewTransformation != rViewInformation.getObjectToViewTransformation()) { // conditions of last local decomposition have changed, delete - const_cast< TextEffectPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + const_cast< TextEffectPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); } } - if(!getLocalDecomposition().hasElements()) + if(!getBuffered2DDecomposition().hasElements()) { // remember ViewRange and ViewTransformation const_cast< TextEffectPrimitive2D* >(this)->maLastObjectToViewTransformation = rViewInformation.getObjectToViewTransformation(); } // use parent implementation - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } // provide unique ID diff --git a/drawinglayer/source/primitive2d/textenumsprimitive2d.cxx b/drawinglayer/source/primitive2d/textenumsprimitive2d.cxx new file mode 100644 index 000000000000..8b24668cb056 --- /dev/null +++ b/drawinglayer/source/primitive2d/textenumsprimitive2d.cxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: textprimitive2d.cxx,v $ + * + * $Revision: 1.22 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_drawinglayer.hxx" + +#include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + TextLine mapFontUnderlineToTextLine(FontUnderline eLineStyle) + { + switch(eLineStyle) + { + case UNDERLINE_SINGLE: return TEXT_LINE_SINGLE; + case UNDERLINE_DOUBLE: return TEXT_LINE_DOUBLE; + case UNDERLINE_DOTTED: return TEXT_LINE_DOTTED; + case UNDERLINE_DASH: return TEXT_LINE_DASH; + case UNDERLINE_LONGDASH: return TEXT_LINE_LONGDASH; + case UNDERLINE_DASHDOT: return TEXT_LINE_DASHDOT; + case UNDERLINE_DASHDOTDOT: return TEXT_LINE_DASHDOTDOT; + case UNDERLINE_SMALLWAVE: return TEXT_LINE_SMALLWAVE; + case UNDERLINE_WAVE: return TEXT_LINE_WAVE; + case UNDERLINE_DOUBLEWAVE: return TEXT_LINE_DOUBLEWAVE; + case UNDERLINE_BOLD: return TEXT_LINE_BOLD; + case UNDERLINE_BOLDDOTTED: return TEXT_LINE_BOLDDOTTED; + case UNDERLINE_BOLDDASH: return TEXT_LINE_BOLDDASH; + case UNDERLINE_BOLDLONGDASH: return TEXT_LINE_BOLDLONGDASH; + case UNDERLINE_BOLDDASHDOT: return TEXT_LINE_BOLDDASHDOT; + case UNDERLINE_BOLDDASHDOTDOT: return TEXT_LINE_BOLDDASHDOTDOT; + case UNDERLINE_BOLDWAVE: return TEXT_LINE_BOLDWAVE; + // FontUnderline_FORCE_EQUAL_SIZE, UNDERLINE_DONTKNOW, UNDERLINE_NONE + default: return TEXT_LINE_NONE; + } + } + + FontUnderline mapTextLineToFontUnderline(TextLine eLineStyle) + { + switch(eLineStyle) + { + default: /*TEXT_LINE_NONE*/ return UNDERLINE_NONE; + case TEXT_LINE_SINGLE: return UNDERLINE_SINGLE; + case TEXT_LINE_DOUBLE: return UNDERLINE_DOUBLE; + case TEXT_LINE_DOTTED: return UNDERLINE_DOTTED; + case TEXT_LINE_DASH: return UNDERLINE_DASH; + case TEXT_LINE_LONGDASH: return UNDERLINE_LONGDASH; + case TEXT_LINE_DASHDOT: return UNDERLINE_DASHDOT; + case TEXT_LINE_DASHDOTDOT: return UNDERLINE_DASHDOTDOT; + case TEXT_LINE_SMALLWAVE: return UNDERLINE_SMALLWAVE; + case TEXT_LINE_WAVE: return UNDERLINE_WAVE; + case TEXT_LINE_DOUBLEWAVE: return UNDERLINE_DOUBLEWAVE; + case TEXT_LINE_BOLD: return UNDERLINE_BOLD; + case TEXT_LINE_BOLDDOTTED: return UNDERLINE_BOLDDOTTED; + case TEXT_LINE_BOLDDASH: return UNDERLINE_BOLDDASH; + case TEXT_LINE_BOLDLONGDASH: return UNDERLINE_LONGDASH; + case TEXT_LINE_BOLDDASHDOT: return UNDERLINE_BOLDDASHDOT; + case TEXT_LINE_BOLDDASHDOTDOT:return UNDERLINE_BOLDDASHDOT; + case TEXT_LINE_BOLDWAVE: return UNDERLINE_BOLDWAVE; + } + } + + TextStrikeout mapFontStrikeoutToTextStrikeout(FontStrikeout eFontStrikeout) + { + switch(eFontStrikeout) + { + case STRIKEOUT_SINGLE: return TEXT_STRIKEOUT_SINGLE; + case STRIKEOUT_DOUBLE: return TEXT_STRIKEOUT_DOUBLE; + case STRIKEOUT_BOLD: return TEXT_STRIKEOUT_BOLD; + case STRIKEOUT_SLASH: return TEXT_STRIKEOUT_SLASH; + case STRIKEOUT_X: return TEXT_STRIKEOUT_X; + // FontStrikeout_FORCE_EQUAL_SIZE, STRIKEOUT_NONE, STRIKEOUT_DONTKNOW + default: return TEXT_STRIKEOUT_NONE; + } + } + + FontStrikeout mapTextStrikeoutToFontStrikeout(TextStrikeout eTextStrikeout) + { + switch(eTextStrikeout) + { + default: /*case primitive2d::TEXT_STRIKEOUT_NONE*/ return STRIKEOUT_NONE; + case TEXT_STRIKEOUT_SINGLE: return STRIKEOUT_SINGLE; + case TEXT_STRIKEOUT_DOUBLE: return STRIKEOUT_DOUBLE; + case TEXT_STRIKEOUT_BOLD: return STRIKEOUT_BOLD; + case TEXT_STRIKEOUT_SLASH: return STRIKEOUT_SLASH; + case TEXT_STRIKEOUT_X: return STRIKEOUT_X; + } + } + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx index e321783c8406..2950427d6b57 100644 --- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx +++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx @@ -167,14 +167,14 @@ namespace drawinglayer mrDevice.SetFont( rFont ); } - void TextLayouterDevice::setFontAttributes( - const FontAttributes& rFontAttributes, + void TextLayouterDevice::setFontAttribute( + const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY, const ::com::sun::star::lang::Locale& rLocale) { - setFont(getVclFontFromFontAttributes( - rFontAttributes, + setFont(getVclFontFromFontAttribute( + rFontAttribute, fFontScaleX, fFontScaleY, 0.0, @@ -297,6 +297,28 @@ namespace drawinglayer return basegfx::B2DRange(); } + + double TextLayouterDevice::getFontAscent() const + { + const ::FontMetric& rMetric = mrDevice.GetFontMetric(); + return rMetric.GetAscent(); + } + + double TextLayouterDevice::getFontDescent() const + { + const ::FontMetric& rMetric = mrDevice.GetFontMetric(); + return rMetric.GetDescent(); + } + + void TextLayouterDevice::addTextRectActions( + const Rectangle& rRectangle, + const String& rText, + sal_uInt16 nStyle, + GDIMetaFile& rGDIMetaFile) + { + mrDevice.AddTextRectActions( + rRectangle, rText, nStyle, rGDIMetaFile); + } } // end of namespace primitive2d } // end of namespace drawinglayer @@ -307,8 +329,8 @@ namespace drawinglayer { namespace primitive2d { - Font getVclFontFromFontAttributes( - const FontAttributes& rFontAttributes, + Font getVclFontFromFontAttribute( + const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY, double fFontRotation, @@ -324,8 +346,8 @@ namespace drawinglayer // is wanted, that width needs to be adapted using FontMetric again to get a // width of the unscaled font Font aRetval( - rFontAttributes.getFamilyName(), - rFontAttributes.getStyleName(), + rFontAttribute.getFamilyName(), + rFontAttribute.getStyleName(), Size(0, nHeight)); #else // for non-WIN32 systems things are easier since these accept a Font creation @@ -334,17 +356,17 @@ namespace drawinglayer // Font would be recorded in a MetaFile (The MetaFile FontAction WILL record a // set FontWidth; import that in a WIN32 system, and trouble is there) Font aRetval( - rFontAttributes.getFamilyName(), - rFontAttributes.getStyleName(), + rFontAttribute.getFamilyName(), + rFontAttribute.getStyleName(), Size(bFontIsScaled ? nWidth : 0, nHeight)); #endif - // define various other FontAttributes + // define various other FontAttribute aRetval.SetAlign(ALIGN_BASELINE); - aRetval.SetCharSet(rFontAttributes.getSymbol() ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE); - aRetval.SetVertical(rFontAttributes.getVertical() ? TRUE : FALSE); - aRetval.SetWeight(static_cast<FontWeight>(rFontAttributes.getWeight())); - aRetval.SetItalic(rFontAttributes.getItalic() ? ITALIC_NORMAL : ITALIC_NONE); - aRetval.SetOutline(rFontAttributes.getOutline()); + aRetval.SetCharSet(rFontAttribute.getSymbol() ? RTL_TEXTENCODING_SYMBOL : RTL_TEXTENCODING_UNICODE); + aRetval.SetVertical(rFontAttribute.getVertical() ? TRUE : FALSE); + aRetval.SetWeight(static_cast<FontWeight>(rFontAttribute.getWeight())); + aRetval.SetItalic(rFontAttribute.getItalic() ? ITALIC_NORMAL : ITALIC_NONE); + aRetval.SetOutline(rFontAttribute.getOutline()); aRetval.SetLanguage(MsLangId::convertLocaleToLanguage(rLocale)); #ifdef WIN32 @@ -371,13 +393,13 @@ namespace drawinglayer return aRetval; } - FontAttributes getFontAttributesFromVclFont( + attribute::FontAttribute getFontAttributeFromVclFont( basegfx::B2DVector& o_rSize, const Font& rFont, bool bRTL, bool bBiDiStrong) { - const FontAttributes aRetval( + const attribute::FontAttribute aRetval( rFont.GetName(), rFont.GetStyleName(), static_cast<sal_uInt16>(rFont.GetWeight()), diff --git a/drawinglayer/source/primitive2d/textlineprimitive2d.cxx b/drawinglayer/source/primitive2d/textlineprimitive2d.cxx new file mode 100644 index 000000000000..45b2809be2ce --- /dev/null +++ b/drawinglayer/source/primitive2d/textlineprimitive2d.cxx @@ -0,0 +1,317 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: textdecoratedprimitive2d.cxx,v $ + * + * $Revision: 1.12 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_drawinglayer.hxx" + +#include <drawinglayer/primitive2d/textlineprimitive2d.hxx> +#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <drawinglayer/attribute/strokeattribute.hxx> +#include <drawinglayer/attribute/lineattribute.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence TextLinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + Primitive2DSequence xRetval; + + if(TEXT_LINE_NONE != getTextLine()) + { + bool bDoubleLine(false); + bool bWaveLine(false); + bool bBoldLine(false); + const int* pDotDashArray(0); + basegfx::B2DLineJoin eLineJoin(basegfx::B2DLINEJOIN_NONE); + double fOffset(getOffset()); + double fHeight(getHeight()); + + static const int aDottedArray[] = { 1, 1, 0}; // DOTTED LINE + static const int aDotDashArray[] = { 1, 1, 4, 1, 0}; // DASHDOT + static const int aDashDotDotArray[] = { 1, 1, 1, 1, 4, 1, 0}; // DASHDOTDOT + static const int aDashedArray[] = { 5, 2, 0}; // DASHED LINE + static const int aLongDashArray[] = { 7, 2, 0}; // LONGDASH + + // get decomposition + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + getObjectTransformation().decompose(aScale, aTranslate, fRotate, fShearX); + + switch(getTextLine()) + { + default: // case TEXT_LINE_SINGLE: + { + break; + } + case TEXT_LINE_DOUBLE: + { + bDoubleLine = true; + break; + } + case TEXT_LINE_DOTTED: + { + pDotDashArray = aDottedArray; + break; + } + case TEXT_LINE_DASH: + { + pDotDashArray = aDashedArray; + break; + } + case TEXT_LINE_LONGDASH: + { + pDotDashArray = aLongDashArray; + break; + } + case TEXT_LINE_DASHDOT: + { + pDotDashArray = aDotDashArray; + break; + } + case TEXT_LINE_DASHDOTDOT: + { + pDotDashArray = aDashDotDotArray; + break; + } + case TEXT_LINE_SMALLWAVE: + { + bWaveLine = true; + break; + } + case TEXT_LINE_WAVE: + { + bWaveLine = true; + break; + } + case TEXT_LINE_DOUBLEWAVE: + { + bDoubleLine = true; + bWaveLine = true; + break; + } + case TEXT_LINE_BOLD: + { + bBoldLine = true; + break; + } + case TEXT_LINE_BOLDDOTTED: + { + bBoldLine = true; + pDotDashArray = aDottedArray; + break; + } + case TEXT_LINE_BOLDDASH: + { + bBoldLine = true; + pDotDashArray = aDashedArray; + break; + } + case TEXT_LINE_BOLDLONGDASH: + { + bBoldLine = true; + pDotDashArray = aLongDashArray; + break; + } + case TEXT_LINE_BOLDDASHDOT: + { + bBoldLine = true; + pDotDashArray = aDotDashArray; + break; + } + case TEXT_LINE_BOLDDASHDOTDOT: + { + bBoldLine = true; + pDotDashArray = aDashDotDotArray; + break; + } + case TEXT_LINE_BOLDWAVE: + { + bWaveLine = true; + bBoldLine = true; + break; + } + } + + if(bBoldLine) + { + fHeight *= 2.0; + } + + if(bDoubleLine) + { + fOffset -= 0.50 * fHeight; + fHeight *= 0.64; + } + + if(bWaveLine) + { + eLineJoin = basegfx::B2DLINEJOIN_ROUND; + fHeight *= 0.25; + } + + // prepare Line and Stroke Attributes + const attribute::LineAttribute aLineAttribute(getLineColor(), fHeight, eLineJoin); + attribute::StrokeAttribute aStrokeAttribute; + + if(pDotDashArray) + { + ::std::vector< double > aDoubleArray; + + for(const int* p = pDotDashArray; *p; ++p) + { + aDoubleArray.push_back((double)(*p) * fHeight); + } + + aStrokeAttribute = attribute::StrokeAttribute(aDoubleArray); + } + + // create base polygon and new primitive + basegfx::B2DPolygon aLine; + Primitive2DReference aNewPrimitive; + + aLine.append(basegfx::B2DPoint(0.0, fOffset)); + aLine.append(basegfx::B2DPoint(getWidth(), fOffset)); + + const basegfx::B2DHomMatrix aUnscaledTransform( + basegfx::tools::createShearXRotateTranslateB2DHomMatrix( + fShearX, fRotate, aTranslate)); + + aLine.transform(aUnscaledTransform); + + if(bWaveLine) + { + double fWaveWidth(10.6 * fHeight); + + if(TEXT_LINE_SMALLWAVE == getTextLine()) + { + fWaveWidth *= 0.7; + } + else if(TEXT_LINE_WAVE == getTextLine()) + { + // extra multiply to get the same WaveWidth as with the bold version + fWaveWidth *= 2.0; + } + + aNewPrimitive = Primitive2DReference(new PolygonWavePrimitive2D(aLine, aLineAttribute, aStrokeAttribute, fWaveWidth, fWaveWidth * 0.5)); + } + else + { + aNewPrimitive = Primitive2DReference(new PolygonStrokePrimitive2D(aLine, aLineAttribute, aStrokeAttribute)); + } + + // add primitive + appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, aNewPrimitive); + + if(bDoubleLine) + { + // double line, create 2nd primitive with offset using TransformPrimitive based on + // already created NewPrimitive + double fLineDist(2.3 * fHeight); + + if(bWaveLine) + { + fLineDist = 6.3 * fHeight; + } + + // move base point of text to 0.0 and de-rotate + basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix( + -aTranslate.getX(), -aTranslate.getY())); + aTransform.rotate(-fRotate); + + // translate in Y by offset + aTransform.translate(0.0, fLineDist); + + // move back and rotate + aTransform.rotate(fRotate); + aTransform.translate(aTranslate.getX(), aTranslate.getY()); + + // add transform primitive + const Primitive2DSequence aContent(&aNewPrimitive, 1); + appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, + Primitive2DReference(new TransformPrimitive2D(aTransform, aContent))); + } + } + + return xRetval; + } + + TextLinePrimitive2D::TextLinePrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + double fOffset, + double fHeight, + TextLine eTextLine, + const basegfx::BColor& rLineColor) + : BufferedDecompositionPrimitive2D(), + maObjectTransformation(rObjectTransformation), + mfWidth(fWidth), + mfOffset(fOffset), + mfHeight(fHeight), + meTextLine(eTextLine), + maLineColor(rLineColor) + { + } + + bool TextLinePrimitive2D::operator==( const BasePrimitive2D& rPrimitive ) const + { + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) + { + const TextLinePrimitive2D& rCompare = (TextLinePrimitive2D&)rPrimitive; + + return (getObjectTransformation() == rCompare.getObjectTransformation() + && getWidth() == rCompare.getWidth() + && getOffset() == rCompare.getOffset() + && getHeight() == rCompare.getHeight() + && getTextLine() == rCompare.getTextLine() + && getLineColor() == rCompare.getLineColor()); + } + + return false; + } + + // provide unique ID + ImplPrimitrive2DIDBlock(TextLinePrimitive2D, PRIMITIVE2D_ID_TEXTLINEPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/textprimitive2d.cxx b/drawinglayer/source/primitive2d/textprimitive2d.cxx index f8e413da0e8c..61a0c6d15897 100644 --- a/drawinglayer/source/primitive2d/textprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/textprimitive2d.cxx @@ -42,6 +42,7 @@ #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> #include <drawinglayer/primitive2d/texteffectprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -49,27 +50,6 @@ using namespace com::sun::star; ////////////////////////////////////////////////////////////////////////////// -namespace drawinglayer -{ - namespace primitive2d - { - bool FontAttributes::operator==(const FontAttributes& rCompare) const - { - return (getFamilyName() == rCompare.getFamilyName() - && getStyleName() == rCompare.getStyleName() - && getWeight() == rCompare.getWeight() - && getSymbol() == rCompare.getSymbol() - && getVertical() == rCompare.getVertical() - && getItalic() == rCompare.getItalic() - && getOutline() == rCompare.getOutline() - && getRTL() == rCompare.getRTL() - && getBiDiStrong() == rCompare.getBiDiStrong()); - } - } // end of namespace primitive2d -} // end of namespace drawinglayer - -////////////////////////////////////////////////////////////////////////////// - namespace { // adapts fontScale for usage with TextLayouter. Input is rScale which is the extracted @@ -155,8 +135,8 @@ namespace drawinglayer // prepare textlayoutdevice TextLayouterDevice aTextLayouter; - aTextLayouter.setFontAttributes( - getFontAttributes(), + aTextLayouter.setFontAttribute( + getFontAttribute(), aFontScale.getX(), aFontScale.getY(), getLocale()); @@ -199,17 +179,14 @@ namespace drawinglayer if(nCount) { // prepare object transformation for polygons - rTransformation.identity(); - rTransformation.scale(aScale.getX(), aScale.getY()); - rTransformation.shearX(fShearX); - rTransformation.rotate(fRotate); - rTransformation.translate(aTranslate.getX(), aTranslate.getY()); + rTransformation = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aScale, fShearX, fRotate, aTranslate); } } } } - Primitive2DSequence TextSimplePortionPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence TextSimplePortionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { Primitive2DSequence aRetval; @@ -238,7 +215,7 @@ namespace drawinglayer aRetval[a] = new PolyPolygonColorPrimitive2D(rPolyPolygon, getFontColor()); } - if(getFontAttributes().getOutline()) + if(getFontAttribute().getOutline()) { // decompose polygon transformation to single values basegfx::B2DVector aScale, aTranslate; @@ -266,16 +243,16 @@ namespace drawinglayer xub_StrLen aTextPosition, xub_StrLen aTextLength, const ::std::vector< double >& rDXArray, - const FontAttributes& rFontAttributes, + const attribute::FontAttribute& rFontAttribute, const ::com::sun::star::lang::Locale& rLocale, const basegfx::BColor& rFontColor) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTextTransform(rNewTransform), maText(rText), maTextPosition(aTextPosition), maTextLength(aTextLength), maDXArray(rDXArray), - maFontAttributes(rFontAttributes), + maFontAttribute(rFontAttribute), maLocale(rLocale), maFontColor(rFontColor), maB2DRange() @@ -287,7 +264,7 @@ namespace drawinglayer #endif } - bool impLocalesAreEqual(const ::com::sun::star::lang::Locale& rA, const ::com::sun::star::lang::Locale& rB) + bool LocalesAreEqual(const ::com::sun::star::lang::Locale& rA, const ::com::sun::star::lang::Locale& rB) { return (rA.Language == rB.Language && rA.Country == rB.Country @@ -296,7 +273,7 @@ namespace drawinglayer bool TextSimplePortionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const TextSimplePortionPrimitive2D& rCompare = (TextSimplePortionPrimitive2D&)rPrimitive; @@ -305,8 +282,8 @@ namespace drawinglayer && getTextPosition() == rCompare.getTextPosition() && getTextLength() == rCompare.getTextLength() && getDXArray() == rCompare.getDXArray() - && getFontAttributes() == rCompare.getFontAttributes() - && impLocalesAreEqual(getLocale(), rCompare.getLocale()) + && getFontAttribute() == rCompare.getFontAttribute() + && LocalesAreEqual(getLocale(), rCompare.getLocale()) && getFontColor() == rCompare.getFontColor()); } @@ -332,8 +309,8 @@ namespace drawinglayer // prepare textlayoutdevice TextLayouterDevice aTextLayouter; - aTextLayouter.setFontAttributes( - getFontAttributes(), + aTextLayouter.setFontAttribute( + getFontAttribute(), aFontScale.getX(), aFontScale.getY(), getLocale()); @@ -345,12 +322,8 @@ namespace drawinglayer if(!aNewRange.isEmpty()) { // prepare object transformation for range - basegfx::B2DHomMatrix aRangeTransformation; - - aRangeTransformation.scale(aScale.getX(), aScale.getY()); - aRangeTransformation.shearX(fShearX); - aRangeTransformation.rotate(fRotate); - aRangeTransformation.translate(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DHomMatrix aRangeTransformation(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aScale, fShearX, fRotate, aTranslate)); // apply range transformation to it aNewRange.transform(aRangeTransformation); diff --git a/drawinglayer/source/primitive2d/textstrikeoutprimitive2d.cxx b/drawinglayer/source/primitive2d/textstrikeoutprimitive2d.cxx new file mode 100644 index 000000000000..936c690d8af5 --- /dev/null +++ b/drawinglayer/source/primitive2d/textstrikeoutprimitive2d.cxx @@ -0,0 +1,294 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: textdecoratedprimitive2d.cxx,v $ + * + * $Revision: 1.12 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_drawinglayer.hxx" + +#include <drawinglayer/primitive2d/textstrikeoutprimitive2d.hxx> +#include <drawinglayer/primitive2d/textlayoutdevice.hxx> +#include <drawinglayer/primitive2d/textprimitive2d.hxx> +#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <drawinglayer/attribute/lineattribute.hxx> +#include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#include <drawinglayer/primitive2d/transformprimitive2d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + BaseTextStrikeoutPrimitive2D::BaseTextStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor) + : BufferedDecompositionPrimitive2D(), + maObjectTransformation(rObjectTransformation), + mfWidth(fWidth), + maFontColor(rFontColor) + { + } + + bool BaseTextStrikeoutPrimitive2D::operator==( const BasePrimitive2D& rPrimitive ) const + { + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) + { + const BaseTextStrikeoutPrimitive2D& rCompare = (BaseTextStrikeoutPrimitive2D&)rPrimitive; + + return (getObjectTransformation() == rCompare.getObjectTransformation() + && getWidth() == rCompare.getWidth() + && getFontColor() == rCompare.getFontColor()); + } + + return false; + } + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence TextCharacterStrikeoutPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + // strikeout with character + const String aSingleCharString(getStrikeoutChar()); + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + + // get decomposition + getObjectTransformation().decompose(aScale, aTranslate, fRotate, fShearX); + + // prepare TextLayouter + TextLayouterDevice aTextLayouter; + + aTextLayouter.setFontAttribute( + getFontAttribute(), + aScale.getX(), + aScale.getY(), + getLocale()); + + const double fStrikeCharWidth(aTextLayouter.getTextWidth(aSingleCharString, 0, 1)); + const double fStrikeCharCount(fabs(getWidth()/fStrikeCharWidth)); + const sal_uInt32 nStrikeCharCount(static_cast< sal_uInt32 >(fStrikeCharCount + 0.5)); + std::vector<double> aDXArray(nStrikeCharCount); + String aStrikeoutString; + + for(sal_uInt32 a(0); a < nStrikeCharCount; a++) + { + aStrikeoutString += aSingleCharString; + aDXArray[a] = (a + 1) * fStrikeCharWidth; + } + + Primitive2DReference xReference( + new TextSimplePortionPrimitive2D( + getObjectTransformation(), + aStrikeoutString, + 0, + aStrikeoutString.Len(), + aDXArray, + getFontAttribute(), + getLocale(), + getFontColor())); + + return Primitive2DSequence(&xReference, 1); + } + + TextCharacterStrikeoutPrimitive2D::TextCharacterStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor, + sal_Unicode aStrikeoutChar, + const attribute::FontAttribute& rFontAttribute, + const ::com::sun::star::lang::Locale& rLocale) + : BaseTextStrikeoutPrimitive2D(rObjectTransformation, fWidth, rFontColor), + maStrikeoutChar(aStrikeoutChar), + maFontAttribute(rFontAttribute), + maLocale(rLocale) + { + } + + bool TextCharacterStrikeoutPrimitive2D::operator==( const BasePrimitive2D& rPrimitive ) const + { + if(BaseTextStrikeoutPrimitive2D::operator==(rPrimitive)) + { + const TextCharacterStrikeoutPrimitive2D& rCompare = (TextCharacterStrikeoutPrimitive2D&)rPrimitive; + + return (getStrikeoutChar() == rCompare.getStrikeoutChar() + && getFontAttribute() == rCompare.getFontAttribute() + && LocalesAreEqual(getLocale(), rCompare.getLocale())); + } + + return false; + } + + // provide unique ID + ImplPrimitrive2DIDBlock(TextCharacterStrikeoutPrimitive2D, PRIMITIVE2D_ID_TEXTCHARACTERSTRIKEOUTPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence TextGeometryStrikeoutPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + OSL_ENSURE(TEXT_STRIKEOUT_SLASH != getTextStrikeout() && TEXT_STRIKEOUT_X != getTextStrikeout(), + "Wrong TEXT_STRIKEOUT type; a TextCharacterStrikeoutPrimitive2D should be used (!)"); + + // strikeout with geometry + double fStrikeoutHeight(getHeight()); + double fStrikeoutOffset(getOffset()); + bool bDoubleLine(false); + + // get decomposition + basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + getObjectTransformation().decompose(aScale, aTranslate, fRotate, fShearX); + + // set line attribute + switch(getTextStrikeout()) + { + default : // case primitive2d::TEXT_STRIKEOUT_SINGLE: + { + break; + } + case primitive2d::TEXT_STRIKEOUT_DOUBLE: + { + bDoubleLine = true; + break; + } + case primitive2d::TEXT_STRIKEOUT_BOLD: + { + fStrikeoutHeight *= 2.0; + break; + } + } + + if(bDoubleLine) + { + fStrikeoutOffset -= 0.50 * fStrikeoutHeight; + fStrikeoutHeight *= 0.64; + } + + // create base polygon and new primitive + basegfx::B2DPolygon aStrikeoutLine; + + aStrikeoutLine.append(basegfx::B2DPoint(0.0, -fStrikeoutOffset)); + aStrikeoutLine.append(basegfx::B2DPoint(getWidth(), -fStrikeoutOffset)); + + const basegfx::B2DHomMatrix aUnscaledTransform( + basegfx::tools::createShearXRotateTranslateB2DHomMatrix( + fShearX, fRotate, aTranslate)); + + aStrikeoutLine.transform(aUnscaledTransform); + + // add primitive + const attribute::LineAttribute aLineAttribute(getFontColor(), fStrikeoutHeight, basegfx::B2DLINEJOIN_NONE); + Primitive2DSequence xRetval(1); + xRetval[0] = Primitive2DReference(new PolygonStrokePrimitive2D(aStrikeoutLine, aLineAttribute)); + + if(bDoubleLine) + { + // double line, create 2nd primitive with offset using TransformPrimitive based on + // already created NewPrimitive + const double fLineDist(2.0 * fStrikeoutHeight); + + // move base point of text to 0.0 and de-rotate + basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix( + -aTranslate.getX(), -aTranslate.getY())); + aTransform.rotate(-fRotate); + + // translate in Y by offset + aTransform.translate(0.0, -fLineDist); + + // move back and rotate + aTransform.rotate(fRotate); + aTransform.translate(aTranslate.getX(), aTranslate.getY()); + + // add transform primitive + appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, + Primitive2DReference( + new TransformPrimitive2D( + aTransform, + xRetval))); + } + + return xRetval; + } + + TextGeometryStrikeoutPrimitive2D::TextGeometryStrikeoutPrimitive2D( + const basegfx::B2DHomMatrix& rObjectTransformation, + double fWidth, + const basegfx::BColor& rFontColor, + double fHeight, + double fOffset, + TextStrikeout eTextStrikeout) + : BaseTextStrikeoutPrimitive2D(rObjectTransformation, fWidth, rFontColor), + mfHeight(fHeight), + mfOffset(fOffset), + meTextStrikeout(eTextStrikeout) + { + } + + bool TextGeometryStrikeoutPrimitive2D::operator==( const BasePrimitive2D& rPrimitive ) const + { + if(BaseTextStrikeoutPrimitive2D::operator==(rPrimitive)) + { + const TextGeometryStrikeoutPrimitive2D& rCompare = (TextGeometryStrikeoutPrimitive2D&)rPrimitive; + + return (getHeight() == rCompare.getHeight() + && getOffset() == rCompare.getOffset() + && getTextStrikeout() == rCompare.getTextStrikeout()); + } + + return false; + } + + // provide unique ID + ImplPrimitrive2DIDBlock(TextGeometryStrikeoutPrimitive2D, PRIMITIVE2D_ID_TEXTGEOMETRYSTRIKEOUTPRIMITIVE2D) + + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx b/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx index 49039e1a6e5c..a66ac0f3a539 100644 --- a/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/unifiedalphaprimitive2d.cxx @@ -55,7 +55,27 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence UnifiedAlphaPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + UnifiedAlphaPrimitive2D::UnifiedAlphaPrimitive2D( + const Primitive2DSequence& rChildren, + double fAlpha) + : GroupPrimitive2D(rChildren), + mfAlpha(fAlpha) + { + } + + bool UnifiedAlphaPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(GroupPrimitive2D::operator==(rPrimitive)) + { + const UnifiedAlphaPrimitive2D& rCompare = (UnifiedAlphaPrimitive2D&)rPrimitive; + + return (getAlpha() == rCompare.getAlpha()); + } + + return false; + } + + Primitive2DSequence UnifiedAlphaPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { if(0.0 == getAlpha()) { @@ -99,26 +119,6 @@ namespace drawinglayer } } - UnifiedAlphaPrimitive2D::UnifiedAlphaPrimitive2D( - const Primitive2DSequence& rChildren, - double fAlpha) - : GroupPrimitive2D(rChildren), - mfAlpha(fAlpha) - { - } - - bool UnifiedAlphaPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const - { - if(GroupPrimitive2D::operator==(rPrimitive)) - { - const UnifiedAlphaPrimitive2D& rCompare = (UnifiedAlphaPrimitive2D&)rPrimitive; - - return (getAlpha() == rCompare.getAlpha()); - } - - return false; - } - // provide unique ID ImplPrimitrive2DIDBlock(UnifiedAlphaPrimitive2D, PRIMITIVE2D_ID_UNIFIEDALPHAPRIMITIVE2D) diff --git a/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx b/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx new file mode 100644 index 000000000000..621b0b25ad98 --- /dev/null +++ b/drawinglayer/source/primitive2d/wallpaperprimitive2d.cxx @@ -0,0 +1,276 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: bitmapprimitive2d.cxx,v $ + * + * $Revision: 1.5 $ + * + * last change: $Author: aw $ $Date: 2008-05-27 14:11:20 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_drawinglayer.hxx" + +#include <drawinglayer/primitive2d/wallpaperprimitive2d.hxx> +#include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> +#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> +#include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <drawinglayer/primitive2d/maskprimitive2d.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive2d + { + Primitive2DSequence WallpaperBitmapPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + Primitive2DSequence aRetval; + + if(!getLocalObjectRange().isEmpty() && !getBitmapEx().IsEmpty()) + { + // get bitmap PIXEL size + const Size& rPixelSize = getBitmapEx().GetSizePixel(); + + if(rPixelSize.Width() > 0 && rPixelSize.Height() > 0) + { + if(WALLPAPER_SCALE == getWallpaperStyle()) + { + // shortcut for scale; use simple BitmapPrimitive2D + basegfx::B2DHomMatrix aObjectTransform; + + aObjectTransform.set(0, 0, getLocalObjectRange().getWidth()); + aObjectTransform.set(1, 1, getLocalObjectRange().getHeight()); + aObjectTransform.set(0, 2, getLocalObjectRange().getMinX()); + aObjectTransform.set(1, 2, getLocalObjectRange().getMinY()); + + Primitive2DReference xReference( + new BitmapPrimitive2D( + getBitmapEx(), + aObjectTransform)); + + aRetval = Primitive2DSequence(&xReference, 1); + } + else + { + // transform to logic size + basegfx::B2DHomMatrix aInverseViewTransformation(getViewTransformation()); + aInverseViewTransformation.invert(); + basegfx::B2DVector aLogicSize(rPixelSize.Width(), rPixelSize.Height()); + aLogicSize = aInverseViewTransformation * aLogicSize; + + // apply laout + basegfx::B2DPoint aTargetTopLeft(getLocalObjectRange().getMinimum()); + bool bUseTargetTopLeft(true); + bool bNeedsClipping(false); + + switch(getWallpaperStyle()) + { + default: //case WALLPAPER_TILE :, also WALLPAPER_NULL and WALLPAPER_APPLICATIONGRADIENT + { + bUseTargetTopLeft = false; + break; + } + case WALLPAPER_SCALE : + { + // handled by shortcut above + break; + } + case WALLPAPER_TOPLEFT : + { + // nothing to do + break; + } + case WALLPAPER_TOP : + { + const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter()); + aTargetTopLeft.setX(aCenter.getX() - (aLogicSize.getX() * 0.5)); + break; + } + case WALLPAPER_TOPRIGHT : + { + aTargetTopLeft.setX(getLocalObjectRange().getMaxX() - aLogicSize.getX()); + break; + } + case WALLPAPER_LEFT : + { + const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter()); + aTargetTopLeft.setY(aCenter.getY() - (aLogicSize.getY() * 0.5)); + break; + } + case WALLPAPER_CENTER : + { + const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter()); + aTargetTopLeft = aCenter - (aLogicSize * 0.5); + break; + } + case WALLPAPER_RIGHT : + { + const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter()); + aTargetTopLeft.setX(getLocalObjectRange().getMaxX() - aLogicSize.getX()); + aTargetTopLeft.setY(aCenter.getY() - (aLogicSize.getY() * 0.5)); + break; + } + case WALLPAPER_BOTTOMLEFT : + { + aTargetTopLeft.setY(getLocalObjectRange().getMaxY() - aLogicSize.getY()); + break; + } + case WALLPAPER_BOTTOM : + { + const basegfx::B2DPoint aCenter(getLocalObjectRange().getCenter()); + aTargetTopLeft.setX(aCenter.getX() - (aLogicSize.getX() * 0.5)); + aTargetTopLeft.setY(getLocalObjectRange().getMaxY() - aLogicSize.getY()); + break; + } + case WALLPAPER_BOTTOMRIGHT : + { + aTargetTopLeft = getLocalObjectRange().getMaximum() - aLogicSize; + break; + } + } + + if(bUseTargetTopLeft) + { + // fill target range + const basegfx::B2DRange aTargetRange(aTargetTopLeft, aTargetTopLeft + aLogicSize); + + // create aligned, single BitmapPrimitive2D + basegfx::B2DHomMatrix aObjectTransform; + + aObjectTransform.set(0, 0, aTargetRange.getWidth()); + aObjectTransform.set(1, 1, aTargetRange.getHeight()); + aObjectTransform.set(0, 2, aTargetRange.getMinX()); + aObjectTransform.set(1, 2, aTargetRange.getMinY()); + + Primitive2DReference xReference( + new BitmapPrimitive2D( + getBitmapEx(), + aObjectTransform)); + aRetval = Primitive2DSequence(&xReference, 1); + + // clip when not completely inside object range + bNeedsClipping = !getLocalObjectRange().isInside(aTargetRange); + } + else + { + // WALLPAPER_TILE, WALLPAPER_NULL, WALLPAPER_APPLICATIONGRADIENT + // convert to relative positions + const basegfx::B2DVector aRelativeSize( + aLogicSize.getX() / (getLocalObjectRange().getWidth() ? getLocalObjectRange().getWidth() : 1.0), + aLogicSize.getY() / (getLocalObjectRange().getHeight() ? getLocalObjectRange().getHeight() : 1.0)); + basegfx::B2DPoint aRelativeTopLeft(0.0, 0.0); + + if(WALLPAPER_TILE != getWallpaperStyle()) + { + aRelativeTopLeft.setX(0.5 - aRelativeSize.getX()); + aRelativeTopLeft.setY(0.5 - aRelativeSize.getY()); + } + + // prepare FillBitmapAttribute + const attribute::FillBitmapAttribute aFillBitmapAttribute( + getBitmapEx(), + aRelativeTopLeft, + aRelativeSize, + true); + + // create ObjectTransform + basegfx::B2DHomMatrix aObjectTransform; + + aObjectTransform.set(0, 0, getLocalObjectRange().getWidth()); + aObjectTransform.set(1, 1, getLocalObjectRange().getHeight()); + aObjectTransform.set(0, 2, getLocalObjectRange().getMinX()); + aObjectTransform.set(1, 2, getLocalObjectRange().getMinY()); + + // create FillBitmapPrimitive + const drawinglayer::primitive2d::Primitive2DReference xFillBitmap( + new drawinglayer::primitive2d::FillBitmapPrimitive2D( + aObjectTransform, + aFillBitmapAttribute)); + aRetval = Primitive2DSequence(&xFillBitmap, 1); + + // always embed tiled fill to clipping + bNeedsClipping = true; + } + + if(bNeedsClipping) + { + // embed to clipping; this is necessary for tiled fills + const basegfx::B2DPolyPolygon aPolyPolygon(basegfx::tools::createPolygonFromRect(getLocalObjectRange())); + const drawinglayer::primitive2d::Primitive2DReference xClippedFill( + new drawinglayer::primitive2d::MaskPrimitive2D( + aPolyPolygon, + aRetval)); + aRetval = Primitive2DSequence(&xClippedFill, 1); + } + } + } + } + + return aRetval; + } + + WallpaperBitmapPrimitive2D::WallpaperBitmapPrimitive2D( + const basegfx::B2DRange& rObjectRange, + const BitmapEx& rBitmapEx, + WallpaperStyle eWallpaperStyle) + : ViewTransformationDependentPrimitive2D(), + maObjectRange(rObjectRange), + maBitmapEx(rBitmapEx), + meWallpaperStyle(eWallpaperStyle) + { + } + + bool WallpaperBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(ViewTransformationDependentPrimitive2D::operator==(rPrimitive)) + { + const WallpaperBitmapPrimitive2D& rCompare = (WallpaperBitmapPrimitive2D&)rPrimitive; + + return (getLocalObjectRange() == rCompare.getLocalObjectRange() + && getBitmapEx() == rCompare.getBitmapEx() + && getWallpaperStyle() == rCompare.getWallpaperStyle()); + } + + return false; + } + + basegfx::B2DRange WallpaperBitmapPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const + { + return getLocalObjectRange(); + } + + // provide unique ID + ImplPrimitrive2DIDBlock(WallpaperBitmapPrimitive2D, PRIMITIVE2D_ID_WALLPAPERBITMAPPRIMITIVE2D) + } // end of namespace primitive2d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// +// eof diff --git a/drawinglayer/source/primitive2d/wrongspellprimitive2d.cxx b/drawinglayer/source/primitive2d/wrongspellprimitive2d.cxx index 93a51d5379b3..4d50cb78da06 100644 --- a/drawinglayer/source/primitive2d/wrongspellprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/wrongspellprimitive2d.cxx @@ -48,7 +48,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence WrongSpellPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence WrongSpellPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { // ATM this decompose is view-independent, what the original VCL-Display is not. To mimic // the old behaviour here if wanted it is necessary to add get2DDecomposition and implement @@ -97,7 +97,7 @@ namespace drawinglayer double fStart, double fStop, const basegfx::BColor& rColor) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransformation(rTransformation), mfStart(fStart), mfStop(fStop), @@ -107,7 +107,7 @@ namespace drawinglayer bool WrongSpellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const WrongSpellPrimitive2D& rCompare = (WrongSpellPrimitive2D&)rPrimitive; diff --git a/drawinglayer/source/primitive3d/baseprimitive3d.cxx b/drawinglayer/source/primitive3d/baseprimitive3d.cxx index 032ae068003b..c30545e4f7c3 100644 --- a/drawinglayer/source/primitive3d/baseprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/baseprimitive3d.cxx @@ -50,20 +50,18 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence BasePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + BasePrimitive3D::BasePrimitive3D() + : BasePrimitive3DImplBase(m_aMutex) { - return Primitive3DSequence(); } - BasePrimitive3D::BasePrimitive3D() - : BasePrimitive3DImplBase(m_aMutex), - maLocalDecomposition() + BasePrimitive3D::~BasePrimitive3D() { } bool BasePrimitive3D::operator==( const BasePrimitive3D& rPrimitive ) const { - return (getPrimitiveID() == rPrimitive.getPrimitiveID()); + return (getPrimitive3DID() == rPrimitive.getPrimitive3DID()); } basegfx::B3DRange BasePrimitive3D::getB3DRange(const geometry::ViewInformation3D& rViewInformation) const @@ -71,17 +69,9 @@ namespace drawinglayer return getB3DRangeFromPrimitive3DSequence(get3DDecomposition(rViewInformation), rViewInformation); } - Primitive3DSequence BasePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const + Primitive3DSequence BasePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const { - ::osl::MutexGuard aGuard( m_aMutex ); - - if(!getLocalDecomposition().hasElements()) - { - const Primitive3DSequence aNewSequence(createLocalDecomposition(rViewInformation)); - const_cast< BasePrimitive3D* >(this)->setLocalDecomposition(aNewSequence); - } - - return getLocalDecomposition(); + return Primitive3DSequence(); } Primitive3DSequence SAL_CALL BasePrimitive3D::getDecomposition( const uno::Sequence< beans::PropertyValue >& rViewParameters ) throw ( uno::RuntimeException ) @@ -99,6 +89,38 @@ namespace drawinglayer } // end of namespace drawinglayer ////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace primitive3d + { + Primitive3DSequence BufferedDecompositionPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + { + return Primitive3DSequence(); + } + + BufferedDecompositionPrimitive3D::BufferedDecompositionPrimitive3D() + : BasePrimitive3D(), + maBuffered3DDecomposition() + { + } + + Primitive3DSequence BufferedDecompositionPrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + if(!getBuffered3DDecomposition().hasElements()) + { + const Primitive3DSequence aNewSequence(create3DDecomposition(rViewInformation)); + const_cast< BufferedDecompositionPrimitive3D* >(this)->setBuffered3DDecomposition(aNewSequence); + } + + return getBuffered3DDecomposition(); + } + } // end of namespace primitive3d +} // end of namespace drawinglayer + +////////////////////////////////////////////////////////////////////////////// // tooling namespace drawinglayer diff --git a/drawinglayer/source/primitive3d/groupprimitive3d.cxx b/drawinglayer/source/primitive3d/groupprimitive3d.cxx index b8ed86ee952a..17736a276b38 100644 --- a/drawinglayer/source/primitive3d/groupprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/groupprimitive3d.cxx @@ -49,12 +49,6 @@ namespace drawinglayer { namespace primitive3d { - /// default: just return children, so all renderers not supporting group will use it's content - Primitive3DSequence GroupPrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const - { - return getChildren(); - } - GroupPrimitive3D::GroupPrimitive3D( const Primitive3DSequence& rChildren ) : BasePrimitive3D(), maChildren(rChildren) @@ -77,6 +71,12 @@ namespace drawinglayer return false; } + /// default: just return children, so all renderers not supporting group will use it's content + Primitive3DSequence GroupPrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + { + return getChildren(); + } + // provide unique ID ImplPrimitrive3DIDBlock(GroupPrimitive3D, PRIMITIVE3D_ID_GROUPPRIMITIVE3D) diff --git a/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx b/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx index dd49f99b751c..381b70d4f6cc 100644 --- a/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/hatchtextureprimitive3d.cxx @@ -59,7 +59,7 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence HatchTexturePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + Primitive3DSequence HatchTexturePrimitive3D::impCreate3DDecomposition() const { Primitive3DSequence aRetval; @@ -81,9 +81,9 @@ namespace drawinglayer if(pBasePrimitive) { - // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch + // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch // not all content is needed, remove transparencies and ModifiedColorPrimitives - switch(pBasePrimitive->getPrimitiveID()) + switch(pBasePrimitive->getPrimitive3DID()) { case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D : { @@ -287,7 +287,8 @@ namespace drawinglayer bool bModulate, bool bFilter) : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter), - maHatch(rHatch) + maHatch(rHatch), + maBuffered3DDecomposition() { } @@ -303,6 +304,19 @@ namespace drawinglayer return false; } + Primitive3DSequence HatchTexturePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + if(!getBuffered3DDecomposition().hasElements()) + { + const Primitive3DSequence aNewSequence(impCreate3DDecomposition()); + const_cast< HatchTexturePrimitive3D* >(this)->setBuffered3DDecomposition(aNewSequence); + } + + return getBuffered3DDecomposition(); + } + // provide unique ID ImplPrimitrive3DIDBlock(HatchTexturePrimitive3D, PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D) diff --git a/drawinglayer/source/primitive3d/hittestprimitive3d.cxx b/drawinglayer/source/primitive3d/hittestprimitive3d.cxx index 50616ab1548b..65aede8142aa 100644 --- a/drawinglayer/source/primitive3d/hittestprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/hittestprimitive3d.cxx @@ -49,12 +49,6 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence HitTestPrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const - { - // return empty sequence - return Primitive3DSequence(); - } - HitTestPrimitive3D::HitTestPrimitive3D( const Primitive3DSequence& rChildren) : GroupPrimitive3D(rChildren) @@ -66,6 +60,12 @@ namespace drawinglayer return getB3DRangeFromPrimitive3DSequence(getChildren(), rViewInformation); } + Primitive3DSequence HitTestPrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + { + // return empty sequence + return Primitive3DSequence(); + } + // provide unique ID ImplPrimitrive3DIDBlock(HitTestPrimitive3D, PRIMITIVE3D_ID_HITTESTPRIMITIVE3D) diff --git a/drawinglayer/source/primitive3d/polygonprimitive3d.cxx b/drawinglayer/source/primitive3d/polygonprimitive3d.cxx index b89499091dd0..ee38b8782cff 100644 --- a/drawinglayer/source/primitive3d/polygonprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/polygonprimitive3d.cxx @@ -92,7 +92,7 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence PolygonStrokePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + Primitive3DSequence PolygonStrokePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const { Primitive3DSequence aRetval; @@ -145,7 +145,7 @@ namespace drawinglayer const basegfx::B3DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute, const attribute::StrokeAttribute& rStrokeAttribute) - : BasePrimitive3D(), + : BufferedDecompositionPrimitive3D(), maPolygon(rPolygon), maLineAttribute(rLineAttribute), maStrokeAttribute(rStrokeAttribute) @@ -155,7 +155,7 @@ namespace drawinglayer PolygonStrokePrimitive3D::PolygonStrokePrimitive3D( const basegfx::B3DPolygon& rPolygon, const attribute::LineAttribute& rLineAttribute) - : BasePrimitive3D(), + : BufferedDecompositionPrimitive3D(), maPolygon(rPolygon), maLineAttribute(rLineAttribute), maStrokeAttribute() @@ -164,7 +164,7 @@ namespace drawinglayer bool PolygonStrokePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(BasePrimitive3D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive3D::operator==(rPrimitive)) { const PolygonStrokePrimitive3D& rCompare = (PolygonStrokePrimitive3D&)rPrimitive; diff --git a/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx b/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx index 09c4acdcaed5..de28e3ad74e5 100644 --- a/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/polygontubeprimitive3d.cxx @@ -417,7 +417,7 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence PolygonTubePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + Primitive3DSequence PolygonTubePrimitive3D::impCreate3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const { const sal_uInt32 nPointCount(getB3DPolygon().count()); std::vector< BasePrimitive3D* > aResultVector; @@ -541,6 +541,7 @@ namespace drawinglayer double fDegreeStepWidth, double fMiterMinimumAngle) : PolygonHairlinePrimitive3D(rPolygon, rBColor), + maLast3DDecomposition(), mfRadius(fRadius), mfDegreeStepWidth(fDegreeStepWidth), mfMiterMinimumAngle(fMiterMinimumAngle), @@ -563,6 +564,19 @@ namespace drawinglayer return false; } + Primitive3DSequence PolygonTubePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const + { + ::osl::MutexGuard aGuard( m_aMutex ); + + if(!getLast3DDecomposition().hasElements()) + { + const Primitive3DSequence aNewSequence(impCreate3DDecomposition(rViewInformation)); + const_cast< PolygonTubePrimitive3D* >(this)->setLast3DDecomposition(aNewSequence); + } + + return getLast3DDecomposition(); + } + // provide unique ID ImplPrimitrive3DIDBlock(PolygonTubePrimitive3D, PRIMITIVE3D_ID_POLYGONTUBEPRIMITIVE3D) diff --git a/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx index 341d2907a53d..739914562071 100644 --- a/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrcubeprimitive3d.cxx @@ -56,7 +56,7 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence SdrCubePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + Primitive3DSequence SdrCubePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const { const basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); Primitive3DSequence aRetval; diff --git a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx index e9ef154c95f3..3554e9266ec1 100644 --- a/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrextrudeprimitive3d.cxx @@ -57,7 +57,7 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence SdrExtrudePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const + Primitive3DSequence SdrExtrudePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const { Primitive3DSequence aRetval; @@ -510,14 +510,14 @@ namespace drawinglayer if(getSdr3DObjectAttribute().getReducedLineGeometry()) { if(!mpLastRLGViewInformation || - (getLocalDecomposition().hasElements() + (getBuffered3DDecomposition().hasElements() && *mpLastRLGViewInformation != rViewInformation)) { // conditions of last local decomposition with reduced lines have changed. Remember // new one and clear current decompositiopn ::osl::Mutex m_mutex; SdrExtrudePrimitive3D* pThat = const_cast< SdrExtrudePrimitive3D* >(this); - pThat->setLocalDecomposition(Primitive3DSequence()); + pThat->setBuffered3DDecomposition(Primitive3DSequence()); delete pThat->mpLastRLGViewInformation; pThat->mpLastRLGViewInformation = new geometry::ViewInformation3D(rViewInformation); } diff --git a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx index 33008e762c0a..5e6c34e644de 100644 --- a/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrlatheprimitive3d.cxx @@ -57,7 +57,7 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence SdrLathePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& rViewInformation) const + Primitive3DSequence SdrLathePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& rViewInformation) const { Primitive3DSequence aRetval; @@ -369,14 +369,14 @@ namespace drawinglayer if(getSdr3DObjectAttribute().getReducedLineGeometry()) { if(!mpLastRLGViewInformation || - (getLocalDecomposition().hasElements() + (getBuffered3DDecomposition().hasElements() && *mpLastRLGViewInformation != rViewInformation)) { // conditions of last local decomposition with reduced lines have changed. Remember // new one and clear current decompositiopn ::osl::Mutex m_mutex; SdrLathePrimitive3D* pThat = const_cast< SdrLathePrimitive3D* >(this); - pThat->setLocalDecomposition(Primitive3DSequence()); + pThat->setBuffered3DDecomposition(Primitive3DSequence()); delete pThat->mpLastRLGViewInformation; pThat->mpLastRLGViewInformation = new geometry::ViewInformation3D(rViewInformation); } diff --git a/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx index a0813d3202a8..69049fb7b24d 100644 --- a/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrpolypolygonprimitive3d.cxx @@ -53,7 +53,7 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence SdrPolyPolygonPrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + Primitive3DSequence SdrPolyPolygonPrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const { Primitive3DSequence aRetval; diff --git a/drawinglayer/source/primitive3d/sdrprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrprimitive3d.cxx index dc93d0c0f339..f8489b6418ff 100644 --- a/drawinglayer/source/primitive3d/sdrprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrprimitive3d.cxx @@ -103,7 +103,7 @@ namespace drawinglayer const basegfx::B2DVector& rTextureSize, const attribute::SdrLineFillShadowAttribute& rSdrLFSAttribute, const attribute::Sdr3DObjectAttribute& rSdr3DObjectAttribute) - : BasePrimitive3D(), + : BufferedDecompositionPrimitive3D(), maTransform(rTransform), maTextureSize(rTextureSize), maSdrLFSAttribute(rSdrLFSAttribute), @@ -113,7 +113,7 @@ namespace drawinglayer bool SdrPrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const { - if(BasePrimitive3D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive3D::operator==(rPrimitive)) { const SdrPrimitive3D& rCompare = static_cast< const SdrPrimitive3D& >(rPrimitive); diff --git a/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx b/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx index e7149c611dd9..663ae6ad0d37 100644 --- a/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/sdrsphereprimitive3d.cxx @@ -56,7 +56,7 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence SdrSpherePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + Primitive3DSequence SdrSpherePrimitive3D::create3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const { Primitive3DSequence aRetval; const basegfx::B3DRange aUnitRange(0.0, 0.0, 0.0, 1.0, 1.0, 1.0); diff --git a/drawinglayer/source/primitive3d/textureprimitive3d.cxx b/drawinglayer/source/primitive3d/textureprimitive3d.cxx index 3393346d0b2d..deeed95a71fd 100644 --- a/drawinglayer/source/primitive3d/textureprimitive3d.cxx +++ b/drawinglayer/source/primitive3d/textureprimitive3d.cxx @@ -81,7 +81,27 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence UnifiedAlphaTexturePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const + UnifiedAlphaTexturePrimitive3D::UnifiedAlphaTexturePrimitive3D( + double fTransparence, + const Primitive3DSequence& rChildren) + : TexturePrimitive3D(rChildren, basegfx::B2DVector(), false, false), + mfTransparence(fTransparence) + { + } + + bool UnifiedAlphaTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const + { + if(TexturePrimitive3D::operator==(rPrimitive)) + { + const UnifiedAlphaTexturePrimitive3D& rCompare = (UnifiedAlphaTexturePrimitive3D&)rPrimitive; + + return (getTransparence() == rCompare.getTransparence()); + } + + return false; + } + + Primitive3DSequence UnifiedAlphaTexturePrimitive3D::get3DDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const { if(0.0 == getTransparence()) { @@ -103,26 +123,6 @@ namespace drawinglayer } } - UnifiedAlphaTexturePrimitive3D::UnifiedAlphaTexturePrimitive3D( - double fTransparence, - const Primitive3DSequence& rChildren) - : TexturePrimitive3D(rChildren, basegfx::B2DVector(), false, false), - mfTransparence(fTransparence) - { - } - - bool UnifiedAlphaTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const - { - if(TexturePrimitive3D::operator==(rPrimitive)) - { - const UnifiedAlphaTexturePrimitive3D& rCompare = (UnifiedAlphaTexturePrimitive3D&)rPrimitive; - - return (getTransparence() == rCompare.getTransparence()); - } - - return false; - } - // provide unique ID ImplPrimitrive3DIDBlock(UnifiedAlphaTexturePrimitive3D, PRIMITIVE3D_ID_UNIFIEDALPHATEXTUREPRIMITIVE3D) @@ -135,11 +135,6 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence GradientTexturePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const - { - return getChildren(); - } - GradientTexturePrimitive3D::GradientTexturePrimitive3D( const attribute::FillGradientAttribute& rGradient, const Primitive3DSequence& rChildren, @@ -175,18 +170,13 @@ namespace drawinglayer { namespace primitive3d { - Primitive3DSequence BitmapTexturePrimitive3D::createLocalDecomposition(const geometry::ViewInformation3D& /*rViewInformation*/) const - { - return getChildren(); - } - BitmapTexturePrimitive3D::BitmapTexturePrimitive3D( - const attribute::FillBitmapAttribute& rBitmap, + const attribute::FillBitmapAttribute& rFillBitmapAttribute, const Primitive3DSequence& rChildren, const basegfx::B2DVector& rTextureSize, bool bModulate, bool bFilter) : TexturePrimitive3D(rChildren, rTextureSize, bModulate, bFilter), - maBitmap(rBitmap) + maFillBitmapAttribute(rFillBitmapAttribute) { } @@ -196,7 +186,7 @@ namespace drawinglayer { const BitmapTexturePrimitive3D& rCompare = (BitmapTexturePrimitive3D&)rPrimitive; - return (getBitmap() == rCompare.getBitmap()); + return (getFillBitmapAttribute() == rCompare.getFillBitmapAttribute()); } return false; diff --git a/drawinglayer/source/processor2d/canvasprocessor.cxx b/drawinglayer/source/processor2d/canvasprocessor.cxx index 43e40183bc6e..8eb713258b25 100644 --- a/drawinglayer/source/processor2d/canvasprocessor.cxx +++ b/drawinglayer/source/processor2d/canvasprocessor.cxx @@ -76,6 +76,7 @@ #include <helperchartrenderer.hxx> #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx> #include <helperwrongspellrenderer.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -675,7 +676,7 @@ using namespace com::sun::star; // directdraw of text simple portion void canvasProcessor::impRender_STXP(const textSimplePortionPrimitive& rTextCandidate) { - const fontAttributes& rFontAttrs( rTextCandidate.getFontAttributes() ); + const fontAttributes& rFontAttrs( rTextCandidate.getFontAttribute() ); rendering::FontRequest aFontRequest; aFontRequest.FontDescription.FamilyName = rFontAttrs.maFamilyName; @@ -1341,10 +1342,9 @@ namespace drawinglayer // prepare discrete offset for XBitmap, do not forget that the buffer bitmap // may be truncated to discrete visible pixels - basegfx::B2DHomMatrix aDiscreteOffset; - aDiscreteOffset.translate( + const basegfx::B2DHomMatrix aDiscreteOffset(basegfx::tools::createTranslateB2DHomMatrix( aDiscreteRange.getMinX() > 0.0 ? -aDiscreteRange.getMinX() : 0.0, - aDiscreteRange.getMinY() > 0.0 ? -aDiscreteRange.getMinY() : 0.0); + aDiscreteRange.getMinY() > 0.0 ? -aDiscreteRange.getMinY() : 0.0)); // create new local ViewInformation2D with new transformation const geometry::ViewInformation2D aViewInformation2D( @@ -1517,16 +1517,16 @@ namespace drawinglayer } else { - const primitive2d::FontAttributes& rFontAttrs(rTextCandidate.getFontAttributes()); + const attribute::FontAttribute& rFontAttr(rTextCandidate.getFontAttribute()); rendering::FontRequest aFontRequest; - aFontRequest.FontDescription.FamilyName = rFontAttrs.getFamilyName(); - aFontRequest.FontDescription.StyleName = rFontAttrs.getStyleName(); - aFontRequest.FontDescription.IsSymbolFont = rFontAttrs.getSymbol() ? util::TriState_YES : util::TriState_NO; - aFontRequest.FontDescription.IsVertical = rFontAttrs.getVertical() ? util::TriState_YES : util::TriState_NO; + aFontRequest.FontDescription.FamilyName = rFontAttr.getFamilyName(); + aFontRequest.FontDescription.StyleName = rFontAttr.getStyleName(); + aFontRequest.FontDescription.IsSymbolFont = rFontAttr.getSymbol() ? util::TriState_YES : util::TriState_NO; + aFontRequest.FontDescription.IsVertical = rFontAttr.getVertical() ? util::TriState_YES : util::TriState_NO; // TODO(F2): improve vclenum->panose conversion - aFontRequest.FontDescription.FontDescription.Weight = static_cast< sal_uInt8 >(rFontAttrs.getWeight()); - aFontRequest.FontDescription.FontDescription.Letterform = rFontAttrs.getItalic() ? 9 : 0; + aFontRequest.FontDescription.FontDescription.Weight = static_cast< sal_uInt8 >(rFontAttr.getWeight()); + aFontRequest.FontDescription.FontDescription.Letterform = rFontAttr.getItalic() ? 9 : 0; // init CellSize to 1.0, else a default font height will be used aFontRequest.CellSize = 1.0; @@ -1600,16 +1600,14 @@ namespace drawinglayer // adapt object's transformation to the correct scale basegfx::B2DVector aScale, aTranslate; double fRotate, fShearX; - basegfx::B2DHomMatrix aNewMatrix; const Size aSizePixel(aModifiedBitmapEx.GetSizePixel()); if(0 != aSizePixel.Width() && 0 != aSizePixel.Height()) { rBitmapCandidate.getTransform().decompose(aScale, aTranslate, fRotate, fShearX); - aNewMatrix.scale(aScale.getX() / aSizePixel.Width(), aScale.getY() / aSizePixel.Height()); - aNewMatrix.shearX(fShearX); - aNewMatrix.rotate(fRotate); - aNewMatrix.translate(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DHomMatrix aNewMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aScale.getX() / aSizePixel.Width(), aScale.getY() / aSizePixel.Height(), + fShearX, fRotate, aTranslate.getX(), aTranslate.getY())); canvas::tools::setRenderStateTransform(maRenderState, getViewInformation2D().getObjectTransformation() * aNewMatrix); @@ -1658,10 +1656,9 @@ namespace drawinglayer // prepare discrete offset for XBitmap, do not forget that the buffer bitmap // may be truncated to discrete visible pixels - basegfx::B2DHomMatrix aDiscreteOffset; - aDiscreteOffset.translate( + const basegfx::B2DHomMatrix aDiscreteOffset(basegfx::tools::createTranslateB2DHomMatrix( aDiscreteRange.getMinX() > 0.0 ? -aDiscreteRange.getMinX() : 0.0, - aDiscreteRange.getMinY() > 0.0 ? -aDiscreteRange.getMinY() : 0.0); + aDiscreteRange.getMinY() > 0.0 ? -aDiscreteRange.getMinY() : 0.0)); // create new local ViewInformation2D with new transformation const geometry::ViewInformation2D aViewInformation2D( @@ -1798,7 +1795,7 @@ namespace drawinglayer if(rFillBitmapAttribute.getTiling()) { // apply possible color modification to Bitmap - const BitmapEx aChangedBitmapEx(impModifyBitmapEx(maBColorModifierStack, BitmapEx(rFillBitmapAttribute.getBitmap()))); + const BitmapEx aChangedBitmapEx(impModifyBitmapEx(maBColorModifierStack, rFillBitmapAttribute.getBitmapEx())); if(aChangedBitmapEx.IsEmpty()) { @@ -1821,13 +1818,9 @@ namespace drawinglayer { // create texture matrix from texture to object (where object is unit square here), // so use values directly - basegfx::B2DHomMatrix aTextureMatrix; - aTextureMatrix.scale( - rFillBitmapAttribute.getSize().getX(), - rFillBitmapAttribute.getSize().getY()); - aTextureMatrix.translate( - rFillBitmapAttribute.getTopLeft().getX(), - rFillBitmapAttribute.getTopLeft().getY()); + const basegfx::B2DHomMatrix aTextureMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix( + rFillBitmapAttribute.getSize().getX(), rFillBitmapAttribute.getSize().getY(), + rFillBitmapAttribute.getTopLeft().getX(), rFillBitmapAttribute.getTopLeft().getY())); // create and fill texture rendering::Texture aTexture; @@ -1883,7 +1876,7 @@ namespace drawinglayer const primitive2d::Primitive2DReference xReference(rChildren[0]); const primitive2d::PolyPolygonColorPrimitive2D* pPoPoColor = dynamic_cast< const primitive2d::PolyPolygonColorPrimitive2D* >(xReference.get()); - if(pPoPoColor && PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D == pPoPoColor->getPrimitiveID()) + if(pPoPoColor && PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D == pPoPoColor->getPrimitive2DID()) { // direct draw of PolyPolygon with color and transparence const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(pPoPoColor->getBColor())); @@ -1922,7 +1915,7 @@ namespace drawinglayer void canvasProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) { - switch(rCandidate.getPrimitiveID()) + switch(rCandidate.getPrimitive2DID()) { case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D : { diff --git a/drawinglayer/source/processor2d/contourextractor2d.cxx b/drawinglayer/source/processor2d/contourextractor2d.cxx index 1f629cb25c9c..3225651a6754 100644 --- a/drawinglayer/source/processor2d/contourextractor2d.cxx +++ b/drawinglayer/source/processor2d/contourextractor2d.cxx @@ -70,7 +70,7 @@ namespace drawinglayer void ContourExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) { - switch(rCandidate.getPrimitiveID()) + switch(rCandidate.getPrimitive2DID()) { case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D : { diff --git a/drawinglayer/source/processor2d/hittestprocessor2d.cxx b/drawinglayer/source/processor2d/hittestprocessor2d.cxx index 4ffef7515389..b10e10706520 100644 --- a/drawinglayer/source/processor2d/hittestprocessor2d.cxx +++ b/drawinglayer/source/processor2d/hittestprocessor2d.cxx @@ -289,7 +289,7 @@ namespace drawinglayer return; } - switch(rCandidate.getPrimitiveID()) + switch(rCandidate.getPrimitive2DID()) { case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D : { @@ -451,8 +451,9 @@ namespace drawinglayer { if(!getHitTextOnly()) { - const primitive2d::ScenePrimitive2D& rSceneCandidate(static_cast< const primitive2d::ScenePrimitive2D& >(rCandidate)); - check3DHit(rSceneCandidate); + const primitive2d::ScenePrimitive2D& rScenePrimitive2D( + static_cast< const primitive2d::ScenePrimitive2D& >(rCandidate)); + check3DHit(rScenePrimitive2D); } break; diff --git a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx index 5f0ab63ee1b3..cc474b7c0736 100644 --- a/drawinglayer/source/processor2d/linegeometryextractor2d.cxx +++ b/drawinglayer/source/processor2d/linegeometryextractor2d.cxx @@ -66,7 +66,7 @@ namespace drawinglayer void LineGeometryExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) { - switch(rCandidate.getPrimitiveID()) + switch(rCandidate.getPrimitive2DID()) { case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D : case PRIMITIVE2D_ID_POLYGONSTROKEARROWPRIMITIVE2D : diff --git a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx index 9358c7f39c57..ce53d1e86399 100644 --- a/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx +++ b/drawinglayer/source/processor2d/textaspolygonextractor2d.cxx @@ -51,7 +51,7 @@ namespace drawinglayer { void TextAsPolygonExtractor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) { - switch(rCandidate.getPrimitiveID()) + switch(rCandidate.getPrimitive2DID()) { case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D : { diff --git a/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx b/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx index d517b603eea3..c1e7702e6933 100644 --- a/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx +++ b/drawinglayer/source/processor2d/vclhelperbitmaprender.cxx @@ -43,6 +43,7 @@ #include <basegfx/range/b2drange.hxx> #include <vcl/outdev.hxx> #include <vclhelperbitmaptransform.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// // support for different kinds of bitmap rendering using vcl @@ -84,10 +85,9 @@ namespace drawinglayer else { // if rotated, create the unrotated output rectangle for the GraphicManager paint - basegfx::B2DHomMatrix aSimpleObjectMatrix; - - aSimpleObjectMatrix.scale(fabs(aScale.getX()), fabs(aScale.getY())); - aSimpleObjectMatrix.translate(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DHomMatrix aSimpleObjectMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix( + fabs(aScale.getX()), fabs(aScale.getY()), + aTranslate.getX(), aTranslate.getY())); aOutlineRange.transform(aSimpleObjectMatrix); } @@ -190,11 +190,11 @@ namespace drawinglayer } // build transform from pixel in aDestination to pixel in rBitmapEx - basegfx::B2DHomMatrix aTransform; - // from relative in aCroppedRectPixel to relative in aDestRectPixel // No need to take bNeedToReduce into account, TopLeft is unchanged - aTransform.translate(aCroppedRectPixel.Left() - aDestRectPixel.Left(), aCroppedRectPixel.Top() - aDestRectPixel.Top()); + basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix( + aCroppedRectPixel.Left() - aDestRectPixel.Left(), + aCroppedRectPixel.Top() - aDestRectPixel.Top())); // from relative in aDestRectPixel to absolute Logic. Here it // is essential to adapt to reduce factor (if used) @@ -207,8 +207,10 @@ namespace drawinglayer fAdaptedDRPHeight *= fReduceFactor; } - aTransform.scale(aDestRectLogic.getWidth() / fAdaptedDRPWidth, aDestRectLogic.getHeight() / fAdaptedDRPHeight); - aTransform.translate(aDestRectLogic.Left(), aDestRectLogic.Top()); + aTransform = basegfx::tools::createScaleTranslateB2DHomMatrix( + aDestRectLogic.getWidth() / fAdaptedDRPWidth, aDestRectLogic.getHeight() / fAdaptedDRPHeight, + aDestRectLogic.Left(), aDestRectLogic.Top()) + * aTransform; // from absolute in Logic to unified object coordinates (0.0 .. 1.0 in x and y) basegfx::B2DHomMatrix aInvBitmapTransform(rTransform); diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 8293fc048f5b..6e53677bbe09 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -74,6 +74,7 @@ #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> #include <helperchartrenderer.hxx> #include <drawinglayer/primitive2d/hittestprimitive2d.hxx> +#include <drawinglayer/primitive2d/epsprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// // for PDFExtOutDevData Graphic support @@ -592,7 +593,7 @@ namespace drawinglayer void VclMetafileProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) { - switch(rCandidate.getPrimitiveID()) + switch(rCandidate.getPrimitive2DID()) { case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D : { @@ -1008,26 +1009,12 @@ namespace drawinglayer SvtGraphicStroke* pSvtGraphicStroke = impTryToCreateSvtGraphicStroke(rStrokePrimitive.getB2DPolygon(), 0, &rStrokePrimitive.getLineAttribute(), &rStrokePrimitive.getStrokeAttribute(), 0, 0); - // Adapt OutDev's DrawMode if special ones were used - const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); - adaptLineToFillDrawMode(); - - impStartSvtGraphicStroke(pSvtGraphicStroke); - - // #i101491# - // Change default of fat line generation for MetaFiles: Create MetaPolyLineAction - // instead of decomposing all geometries when the polygon has more than given amount of - // points; else the decomposition will get too expensive quiclky. OTOH - // the decomposition provides the better quality e.g. taking edge roundings - // into account which will NOT be taken into account with LineInfo-based actions - const sal_uInt32 nSubPolygonCount(rStrokePrimitive.getB2DPolygon().count()); - bool bDone(0 == nSubPolygonCount); - - if(!bDone && nSubPolygonCount > 1000) + if(true) { - // create MetaPolyLineActions, but without LINE_DASH + impStartSvtGraphicStroke(pSvtGraphicStroke); const attribute::LineAttribute& rLine = rStrokePrimitive.getLineAttribute(); + // create MetaPolyLineActions, but without LINE_DASH if(basegfx::fTools::more(rLine.getWidth(), 0.0)) { const attribute::StrokeAttribute& rStroke = rStrokePrimitive.getStrokeAttribute(); @@ -1047,10 +1034,9 @@ namespace drawinglayer const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLine.getColor())); mpOutputDevice->SetLineColor(Color(aHairlineColor)); mpOutputDevice->SetFillColor(); - aHairLinePolyPolygon.transform(maCurrentTransformation); - - const LineInfo aLineInfo(LINE_SOLID, basegfx::fround(rLine.getWidth())); + LineInfo aLineInfo(LINE_SOLID, basegfx::fround(rLine.getWidth())); + aLineInfo.SetLineJoin(rLine.getLineJoin()); for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++) { @@ -1063,22 +1049,88 @@ namespace drawinglayer mpMetaFile->AddAction(new MetaPolyLineAction(aToolsPolygon, aLineInfo)); } } - - bDone = true; } - } + else + { + process(rCandidate.get2DDecomposition(getViewInformation2D())); + } - if(!bDone) - { - // use decomposition (creates line geometry as filled polygon - // geometry) - process(rCandidate.get2DDecomposition(getViewInformation2D())); + impEndSvtGraphicStroke(pSvtGraphicStroke); } + else + { + // Adapt OutDev's DrawMode if special ones were used + const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); + adaptLineToFillDrawMode(); + + impStartSvtGraphicStroke(pSvtGraphicStroke); + + // #i101491# + // Change default of fat line generation for MetaFiles: Create MetaPolyLineAction + // instead of decomposing all geometries when the polygon has more than given amount of + // points; else the decomposition will get too expensive quiclky. OTOH + // the decomposition provides the better quality e.g. taking edge roundings + // into account which will NOT be taken into account with LineInfo-based actions + const sal_uInt32 nSubPolygonCount(rStrokePrimitive.getB2DPolygon().count()); + bool bDone(0 == nSubPolygonCount); + + if(!bDone && nSubPolygonCount > 1000) + { + // create MetaPolyLineActions, but without LINE_DASH + const attribute::LineAttribute& rLine = rStrokePrimitive.getLineAttribute(); - impEndSvtGraphicStroke(pSvtGraphicStroke); + if(basegfx::fTools::more(rLine.getWidth(), 0.0)) + { + const attribute::StrokeAttribute& rStroke = rStrokePrimitive.getStrokeAttribute(); + basegfx::B2DPolyPolygon aHairLinePolyPolygon; - // restore DrawMode - mpOutputDevice->SetDrawMode(nOriginalDrawMode); + if(0.0 == rStroke.getFullDotDashLen()) + { + aHairLinePolyPolygon.append(rStrokePrimitive.getB2DPolygon()); + } + else + { + basegfx::tools::applyLineDashing( + rStrokePrimitive.getB2DPolygon(), rStroke.getDotDashArray(), + &aHairLinePolyPolygon, 0, rStroke.getFullDotDashLen()); + } + + const basegfx::BColor aHairlineColor(maBColorModifierStack.getModifiedColor(rLine.getColor())); + mpOutputDevice->SetLineColor(Color(aHairlineColor)); + mpOutputDevice->SetFillColor(); + + aHairLinePolyPolygon.transform(maCurrentTransformation); + + const LineInfo aLineInfo(LINE_SOLID, basegfx::fround(rLine.getWidth())); + + for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++) + { + const basegfx::B2DPolygon aCandidate(aHairLinePolyPolygon.getB2DPolygon(a)); + + if(aCandidate.count() > 1) + { + const Polygon aToolsPolygon(aCandidate); + + mpMetaFile->AddAction(new MetaPolyLineAction(aToolsPolygon, aLineInfo)); + } + } + + bDone = true; + } + } + + if(!bDone) + { + // use decomposition (creates line geometry as filled polygon + // geometry) + process(rCandidate.get2DDecomposition(getViewInformation2D())); + } + + impEndSvtGraphicStroke(pSvtGraphicStroke); + + // restore DrawMode + mpOutputDevice->SetDrawMode(nOriginalDrawMode); + } break; } @@ -1124,8 +1176,8 @@ namespace drawinglayer const basegfx::B2DPoint aFillBitmapTopLeft(rFillBitmapAttribute.getTopLeft() * aOutlineSize); // the scaling needs scale from pixel to logic coordinate system - const Bitmap& rBitmap = rFillBitmapAttribute.getBitmap(); - Size aBmpSizePixel(rBitmap.GetSizePixel()); + const BitmapEx& rBitmapEx = rFillBitmapAttribute.getBitmapEx(); + Size aBmpSizePixel(rBitmapEx.GetSizePixel()); if(!aBmpSizePixel.Width()) { @@ -1149,7 +1201,7 @@ namespace drawinglayer aTransform.matrix[5] = aFillBitmapTopLeft.getY(); // setup fill graphic like in impgrfll - Graphic aFillGraphic = Graphic(rBitmap); + Graphic aFillGraphic = Graphic(rBitmapEx); aFillGraphic.SetPrefMapMode(MapMode(MAP_PIXEL)); aFillGraphic.SetPrefSize(aBmpSizePixel); @@ -1456,7 +1508,7 @@ namespace drawinglayer // PolyPolygonGradientPrimitive2D, PolyPolygonHatchPrimitive2D and // PolyPolygonBitmapPrimitive2D are derived from PolyPolygonColorPrimitive2D. // Check also for correct ID to exclude derived implementations - if(pPoPoColor && PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D == pPoPoColor->getPrimitiveID()) + if(pPoPoColor && PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D == pPoPoColor->getPrimitive2DID()) { // single transparent PolyPolygon identified, use directly const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(pPoPoColor->getBColor())); @@ -1567,7 +1619,7 @@ namespace drawinglayer } // Check also for correct ID to exclude derived implementations - if(pFiGradient && PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D == pFiGradient->getPrimitiveID()) + if(pFiGradient && PRIMITIVE2D_ID_FILLGRADIENTPRIMITIVE2D == pFiGradient->getPrimitive2DID()) { // various content, create content-metafile GDIMetaFile aContentMetafile; @@ -1754,6 +1806,11 @@ namespace drawinglayer break; } + case PRIMITIVE2D_ID_EPSPRIMITIVE2D : + { + RenderEpsPrimitive2D(static_cast< const primitive2d::EpsPrimitive2D& >(rCandidate)); + break; + } default : { // process recursively diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index ef351002a1ea..5a74b0471b7f 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -67,6 +67,8 @@ #include <drawinglayer/primitive2d/invertprimitive2d.hxx> #include <cstdio> #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <drawinglayer/primitive2d/epsprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -111,7 +113,7 @@ namespace drawinglayer void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate) { - switch(rCandidate.getPrimitiveID()) + switch(rCandidate.getPrimitive2DID()) { case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D : { @@ -204,18 +206,8 @@ namespace drawinglayer } case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D : { - if(getOptionsDrawinglayer().IsAntiAliasing()) - { - // For AA, direct render has to be avoided since it uses XOR maskings which will not - // work with AA. Instead, the decompose which uses MaskPrimitive2D with fillings is - // used - process(rCandidate.get2DDecomposition(getViewInformation2D())); - } - else - { - // direct draw of gradient - RenderPolyPolygonGradientPrimitive2D(static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(rCandidate)); - } + // direct draw of gradient + RenderPolyPolygonGradientPrimitive2D(static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(rCandidate)); break; } case PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D : @@ -241,8 +233,17 @@ namespace drawinglayer mpOutputDevice->SetAntialiasing(nOldAntiAliase | ANTIALIASING_PIXELSNAPHAIRLINE); } - // direct draw of MetaFile - RenderMetafilePrimitive2D(static_cast< const primitive2d::MetafilePrimitive2D& >(rCandidate)); + static bool bTestMetaFilePrimitiveDecomposition(true); + if(bTestMetaFilePrimitiveDecomposition) + { + // use new Metafile decomposition + process(rCandidate.get2DDecomposition(getViewInformation2D())); + } + else + { + // direct draw of MetaFile + RenderMetafilePrimitive2D(static_cast< const primitive2d::MetafilePrimitive2D& >(rCandidate)); + } if(bForceLineSnap) { @@ -280,7 +281,7 @@ namespace drawinglayer const primitive2d::Primitive2DReference xReference(rContent[0]); const primitive2d::PolyPolygonColorPrimitive2D* pPoPoColor = dynamic_cast< const primitive2d::PolyPolygonColorPrimitive2D* >(xReference.get()); - if(pPoPoColor && PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D == pPoPoColor->getPrimitiveID()) + if(pPoPoColor && PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D == pPoPoColor->getPrimitive2DID()) { // single transparent PolyPolygon identified, use directly const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(pPoPoColor->getBColor())); @@ -528,7 +529,6 @@ namespace drawinglayer // restore AA setting mpOutputDevice->SetAntialiasing(nOriginalAA); - break; } case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D : @@ -545,23 +545,23 @@ namespace drawinglayer case PRIMITIVE2D_ID_INVERTPRIMITIVE2D : { // invert primitive (currently only used for HighContrast fallback for selection in SW and SC). - // Set OutDev to XOR + // Set OutDev to XOR and switch AA off (XOR does not work with AA) mpOutputDevice->Push(); mpOutputDevice->SetRasterOp( ROP_XOR ); - - // force paint color to white by using ColorModifierStack - const basegfx::BColor aColWhite(1.0, 1.0, 1.0); - const basegfx::BColorModifier aColorModifier(aColWhite, 0.0, basegfx::BCOLORMODIFYMODE_REPLACE); - maBColorModifierStack.push(aColorModifier); + const sal_uInt16 nAntiAliasing(mpOutputDevice->GetAntialiasing()); + mpOutputDevice->SetAntialiasing(nAntiAliasing & ~ANTIALIASING_ENABLE_B2DDRAW); // process content recursively process(rCandidate.get2DDecomposition(getViewInformation2D())); - // restore ColorModifierStack - maBColorModifierStack.pop(); - // restore OutDev mpOutputDevice->Pop(); + mpOutputDevice->SetAntialiasing(nAntiAliasing); + break; + } + case PRIMITIVE2D_ID_EPSPRIMITIVE2D : + { + RenderEpsPrimitive2D(static_cast< const primitive2d::EpsPrimitive2D& >(rCandidate)); break; } default : diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 3412b5db5598..bd9439ef9339 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -63,6 +63,8 @@ #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> #include <tools/diagnose_ex.h> #include <vcl/metric.hxx> +#include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> +#include <drawinglayer/primitive2d/epsprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// // control support @@ -99,34 +101,6 @@ namespace drawinglayer using ::com::sun::star::awt::XWindow; using ::com::sun::star::awt::PosSize::POSSIZE; - static FontUnderline mapTextLineStyle(primitive2d::FontUnderline eLineStyle) - { - switch(eLineStyle) - { - default: - DBG_WARNING1( "DrawingLayer: Unknown text line style attribute (%d)!", eLineStyle ); - // fall through - case primitive2d::FONT_UNDERLINE_NONE: return UNDERLINE_NONE; - case primitive2d::FONT_UNDERLINE_SINGLE: return UNDERLINE_SINGLE; - case primitive2d::FONT_UNDERLINE_DOUBLE: return UNDERLINE_DOUBLE; - case primitive2d::FONT_UNDERLINE_DOTTED: return UNDERLINE_DOTTED; - case primitive2d::FONT_UNDERLINE_DASH: return UNDERLINE_DASH; - case primitive2d::FONT_UNDERLINE_LONGDASH: return UNDERLINE_LONGDASH; - case primitive2d::FONT_UNDERLINE_DASHDOT: return UNDERLINE_DASHDOT; - case primitive2d::FONT_UNDERLINE_DASHDOTDOT: return UNDERLINE_DASHDOTDOT; - case primitive2d::FONT_UNDERLINE_SMALLWAVE: return UNDERLINE_SMALLWAVE; - case primitive2d::FONT_UNDERLINE_WAVE: return UNDERLINE_WAVE; - case primitive2d::FONT_UNDERLINE_DOUBLEWAVE: return UNDERLINE_DOUBLEWAVE; - case primitive2d::FONT_UNDERLINE_BOLD: return UNDERLINE_BOLD; - case primitive2d::FONT_UNDERLINE_BOLDDOTTED: return UNDERLINE_BOLDDOTTED; - case primitive2d::FONT_UNDERLINE_BOLDDASH: return UNDERLINE_BOLDDASH; - case primitive2d::FONT_UNDERLINE_BOLDLONGDASH: return UNDERLINE_LONGDASH; - case primitive2d::FONT_UNDERLINE_BOLDDASHDOT: return UNDERLINE_BOLDDASHDOT; - case primitive2d::FONT_UNDERLINE_BOLDDASHDOTDOT:return UNDERLINE_BOLDDASHDOT; - case primitive2d::FONT_UNDERLINE_BOLDWAVE: return UNDERLINE_BOLDWAVE; - } - } - ////////////////////////////////////////////////////////////////////////////// // rendering support @@ -157,8 +131,8 @@ namespace drawinglayer if(basegfx::fTools::more(aFontScaling.getX(), 0.0) && basegfx::fTools::more(aFontScaling.getY(), 0.0)) { // Get the VCL font (use FontHeight as FontWidth) - Font aFont(primitive2d::getVclFontFromFontAttributes( - rTextCandidate.getFontAttributes(), + Font aFont(primitive2d::getVclFontFromFontAttribute( + rTextCandidate.getFontAttribute(), aFontScaling.getX(), aFontScaling.getY(), fRotate, @@ -176,7 +150,7 @@ namespace drawinglayer mpOutputDevice->SetTextLineColor( Color(aTextlineColor) ); // set Overline attribute - FontUnderline eFontOverline = mapTextLineStyle( pTCPP->getFontOverline() ); + const FontUnderline eFontOverline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontOverline() )); if( eFontOverline != UNDERLINE_NONE ) { aFont.SetOverline( eFontOverline ); @@ -187,7 +161,7 @@ namespace drawinglayer } // set Underline attribute - FontUnderline eFontUnderline = mapTextLineStyle( pTCPP->getFontUnderline() ); + const FontUnderline eFontUnderline(primitive2d::mapTextLineToFontUnderline( pTCPP->getFontUnderline() )); if( eFontUnderline != UNDERLINE_NONE ) { aFont.SetUnderline( eFontUnderline ); @@ -198,35 +172,23 @@ namespace drawinglayer } // set Strikeout attribute - FontStrikeout eFontStrikeout = STRIKEOUT_NONE; - switch( pTCPP->getFontStrikeout() ) - { - default: - DBG_WARNING1( "DrawingLayer: Unknown strikeout attribute (%d)!", pTCPP->getFontStrikeout() ); - // fall through - case primitive2d::FONT_STRIKEOUT_NONE: eFontStrikeout = STRIKEOUT_NONE; break; - case primitive2d::FONT_STRIKEOUT_SINGLE: eFontStrikeout = STRIKEOUT_SINGLE; break; - case primitive2d::FONT_STRIKEOUT_DOUBLE: eFontStrikeout = STRIKEOUT_DOUBLE; break; - case primitive2d::FONT_STRIKEOUT_BOLD: eFontStrikeout = STRIKEOUT_BOLD; break; - case primitive2d::FONT_STRIKEOUT_SLASH: eFontStrikeout = STRIKEOUT_SLASH; break; - case primitive2d::FONT_STRIKEOUT_X: eFontStrikeout = STRIKEOUT_X; break; - } + const FontStrikeout eFontStrikeout(primitive2d::mapTextStrikeoutToFontStrikeout(pTCPP->getTextStrikeout())); if( eFontStrikeout != STRIKEOUT_NONE ) aFont.SetStrikeout( eFontStrikeout ); // set EmphasisMark attribute FontEmphasisMark eFontEmphasisMark = EMPHASISMARK_NONE; - switch( pTCPP->getFontEmphasisMark() ) + switch( pTCPP->getTextEmphasisMark() ) { default: - DBG_WARNING1( "DrawingLayer: Unknown EmphasisMark style (%d)!", pTCPP->getFontEmphasisMark() ); + DBG_WARNING1( "DrawingLayer: Unknown EmphasisMark style (%d)!", pTCPP->getTextEmphasisMark() ); // fall through - case primitive2d::FONT_EMPHASISMARK_NONE: eFontEmphasisMark = EMPHASISMARK_NONE; break; - case primitive2d::FONT_EMPHASISMARK_DOT: eFontEmphasisMark = EMPHASISMARK_DOT; break; - case primitive2d::FONT_EMPHASISMARK_CIRCLE: eFontEmphasisMark = EMPHASISMARK_CIRCLE; break; - case primitive2d::FONT_EMPHASISMARK_DISC: eFontEmphasisMark = EMPHASISMARK_DISC; break; - case primitive2d::FONT_EMPHASISMARK_ACCENT: eFontEmphasisMark = EMPHASISMARK_ACCENT; break; + case primitive2d::TEXT_EMPHASISMARK_NONE: eFontEmphasisMark = EMPHASISMARK_NONE; break; + case primitive2d::TEXT_EMPHASISMARK_DOT: eFontEmphasisMark = EMPHASISMARK_DOT; break; + case primitive2d::TEXT_EMPHASISMARK_CIRCLE: eFontEmphasisMark = EMPHASISMARK_CIRCLE; break; + case primitive2d::TEXT_EMPHASISMARK_DISC: eFontEmphasisMark = EMPHASISMARK_DISC; break; + case primitive2d::TEXT_EMPHASISMARK_ACCENT: eFontEmphasisMark = EMPHASISMARK_ACCENT; break; } if( eFontEmphasisMark != EMPHASISMARK_NONE ) @@ -242,14 +204,14 @@ namespace drawinglayer // set Relief attribute FontRelief eFontRelief = RELIEF_NONE; - switch( pTCPP->getFontRelief() ) + switch( pTCPP->getTextRelief() ) { default: - DBG_WARNING1( "DrawingLayer: Unknown Relief style (%d)!", pTCPP->getFontRelief() ); + DBG_WARNING1( "DrawingLayer: Unknown Relief style (%d)!", pTCPP->getTextRelief() ); // fall through - case primitive2d::FONT_RELIEF_NONE: eFontRelief = RELIEF_NONE; break; - case primitive2d::FONT_RELIEF_EMBOSSED: eFontRelief = RELIEF_EMBOSSED; break; - case primitive2d::FONT_RELIEF_ENGRAVED: eFontRelief = RELIEF_ENGRAVED; break; + case primitive2d::TEXT_RELIEF_NONE: eFontRelief = RELIEF_NONE; break; + case primitive2d::TEXT_RELIEF_EMBOSSED: eFontRelief = RELIEF_EMBOSSED; break; + case primitive2d::TEXT_RELIEF_ENGRAVED: eFontRelief = RELIEF_ENGRAVED; break; } if( eFontRelief != RELIEF_NONE ) @@ -282,7 +244,7 @@ namespace drawinglayer const Point aStartPoint(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())); const sal_uInt32 nOldLayoutMode(mpOutputDevice->GetLayoutMode()); - if(rTextCandidate.getFontAttributes().getRTL()) + if(rTextCandidate.getFontAttribute().getRTL()) { sal_uInt32 nRTLLayoutMode(nOldLayoutMode & ~(TEXT_LAYOUT_COMPLEX_DISABLED|TEXT_LAYOUT_BIDI_STRONG)); nRTLLayoutMode |= TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_TEXTORIGIN_LEFT; @@ -310,7 +272,7 @@ namespace drawinglayer rTextCandidate.getTextLength()); } - if(rTextCandidate.getFontAttributes().getRTL()) + if(rTextCandidate.getFontAttribute().getRTL()) { mpOutputDevice->SetLayoutMode(nOldLayoutMode); } @@ -428,7 +390,7 @@ namespace drawinglayer { // no shear or rotate, draw direct in pixel coordinates bPrimitiveAccepted = true; - BitmapEx aBitmapEx(rFillBitmapAttribute.getBitmap()); + BitmapEx aBitmapEx(rFillBitmapAttribute.getBitmapEx()); bool bPainted(false); if(maBColorModifierStack.count()) @@ -547,21 +509,32 @@ namespace drawinglayer basegfx::BColor aStartColor(maBColorModifierStack.getModifiedColor(rGradient.getStartColor())); basegfx::BColor aEndColor(maBColorModifierStack.getModifiedColor(rGradient.getEndColor())); basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon()); - aLocalPolyPolygon.transform(maCurrentTransformation); - if(aStartColor == aEndColor) - { - // no gradient at all, draw as polygon - mpOutputDevice->SetLineColor(); - mpOutputDevice->SetFillColor(Color(aStartColor)); - mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); - } - else + if(aLocalPolyPolygon.count()) { - impDrawGradientToOutDev( - *mpOutputDevice, aLocalPolyPolygon, rGradient.getStyle(), rGradient.getSteps(), - aStartColor, aEndColor, rGradient.getBorder(), - -rGradient.getAngle(), rGradient.getOffsetX(), rGradient.getOffsetY(), false); + aLocalPolyPolygon.transform(maCurrentTransformation); + + if(aStartColor == aEndColor) + { + // no gradient at all, draw as polygon in AA and non-AA case + mpOutputDevice->SetLineColor(); + mpOutputDevice->SetFillColor(Color(aStartColor)); + mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); + } + else if(getOptionsDrawinglayer().IsAntiAliasing()) + { + // For AA, direct render has to be avoided since it uses XOR maskings which will not + // work with AA. Instead, the decompose which uses MaskPrimitive2D with fillings is + // used + process(rPolygonCandidate.get2DDecomposition(getViewInformation2D())); + } + else + { + impDrawGradientToOutDev( + *mpOutputDevice, aLocalPolyPolygon, rGradient.getStyle(), rGradient.getSteps(), + aStartColor, aEndColor, rGradient.getBorder(), + -rGradient.getAngle(), rGradient.getOffsetX(), rGradient.getOffsetY(), false); + } } } @@ -574,9 +547,9 @@ namespace drawinglayer if(rPolyPolygon.count()) { const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPolygonCandidate.getFillBitmap(); - const Bitmap& rBitmap = rFillBitmapAttribute.getBitmap(); + const BitmapEx& rBitmapEx = rFillBitmapAttribute.getBitmapEx(); - if(rBitmap.IsEmpty()) + if(rBitmapEx.IsEmpty()) { // empty bitmap, done bDone = true; @@ -668,7 +641,9 @@ namespace drawinglayer aLocalPolyPolygon.transform(maCurrentTransformation); mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon); - if(mnPolygonStrokePrimitive2D && getOptionsDrawinglayer().IsAntiAliasing()) + if(mnPolygonStrokePrimitive2D + && getOptionsDrawinglayer().IsAntiAliasing() + && (mpOutputDevice->GetAntialiasing() & ANTIALIASING_ENABLE_B2DDRAW)) { // when AA is on and this filled polygons are the result of stroked line geometry, // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons @@ -1256,6 +1231,43 @@ namespace drawinglayer } } + void VclProcessor2D::RenderEpsPrimitive2D(const primitive2d::EpsPrimitive2D& rEpsPrimitive2D) + { + // The new decomposition of Metafiles made it necessary to add an Eps + // primitive to handle embedded Eps data. On some devices, this can be + // painted directly (mac, printer). + // To be able to handle the replacement correctly, i need to handle it myself + // since DrawEPS will not be able e.g. to rotate the replacement. To be able + // to do that, i added a boolean return to OutputDevice::DrawEPS(..) + // to know when EPS was handled directly already. + basegfx::B2DRange aRange(0.0, 0.0, 1.0, 1.0); + aRange.transform(maCurrentTransformation * rEpsPrimitive2D.getEpsTransform()); + + if(!aRange.isEmpty()) + { + const Rectangle aRectangle( + (sal_Int32)floor(aRange.getMinX()), (sal_Int32)floor(aRange.getMinY()), + (sal_Int32)ceil(aRange.getMaxX()), (sal_Int32)ceil(aRange.getMaxY())); + + if(!aRectangle.IsEmpty()) + { + // try to paint EPS directly without fallback visualisation + const bool bEPSPaintedDirectly(mpOutputDevice->DrawEPS( + aRectangle.TopLeft(), + aRectangle.GetSize(), + rEpsPrimitive2D.getGfxLink(), + 0)); + + if(!bEPSPaintedDirectly) + { + // use the decomposition which will correctly handle the + // fallback visualisation using full transformation (e.g. rotation) + process(rEpsPrimitive2D.get2DDecomposition(getViewInformation2D())); + } + } + } + } + void VclProcessor2D::adaptLineToFillDrawMode() const { const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode()); diff --git a/drawinglayer/source/processor3d/cutfindprocessor3d.cxx b/drawinglayer/source/processor3d/cutfindprocessor3d.cxx index 99f5801c60e3..42e2e1565803 100644 --- a/drawinglayer/source/processor3d/cutfindprocessor3d.cxx +++ b/drawinglayer/source/processor3d/cutfindprocessor3d.cxx @@ -73,8 +73,8 @@ namespace drawinglayer return; } - // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch - switch(rCandidate.getPrimitiveID()) + // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch + switch(rCandidate.getPrimitive3DID()) { case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D : { diff --git a/drawinglayer/source/processor3d/defaultprocessor3d.cxx b/drawinglayer/source/processor3d/defaultprocessor3d.cxx index d9194ca4b5eb..1be93d83b9a9 100644 --- a/drawinglayer/source/processor3d/defaultprocessor3d.cxx +++ b/drawinglayer/source/processor3d/defaultprocessor3d.cxx @@ -234,19 +234,19 @@ namespace drawinglayer texture::GeoTexSvx* pOldTex = mpGeoTexSvx; // create texture - const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPrimitive.getBitmap(); + const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPrimitive.getFillBitmapAttribute(); if(rFillBitmapAttribute.getTiling()) { mpGeoTexSvx = new texture::GeoTexSvxBitmapTiled( - rFillBitmapAttribute.getBitmap(), + rFillBitmapAttribute.getBitmapEx().GetBitmap(), rFillBitmapAttribute.getTopLeft() * rPrimitive.getTextureSize(), rFillBitmapAttribute.getSize() * rPrimitive.getTextureSize()); } else { mpGeoTexSvx = new texture::GeoTexSvxBitmap( - rFillBitmapAttribute.getBitmap(), + rFillBitmapAttribute.getBitmapEx().GetBitmap(), rFillBitmapAttribute.getTopLeft() * rPrimitive.getTextureSize(), rFillBitmapAttribute.getSize() * rPrimitive.getTextureSize()); } @@ -468,8 +468,8 @@ namespace drawinglayer void DefaultProcessor3D::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rBasePrimitive) { - // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch - switch(rBasePrimitive.getPrimitiveID()) + // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch + switch(rBasePrimitive.getPrimitive3DID()) { case PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D : { diff --git a/drawinglayer/source/processor3d/geometry2dextractor.cxx b/drawinglayer/source/processor3d/geometry2dextractor.cxx index 8c19a4a2e3b8..c2e1c73b5181 100644 --- a/drawinglayer/source/processor3d/geometry2dextractor.cxx +++ b/drawinglayer/source/processor3d/geometry2dextractor.cxx @@ -62,8 +62,8 @@ namespace drawinglayer // virtual render method when the primitive implementation is BasePrimitive3D-based. void Geometry2DExtractingProcessor::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate) { - // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch - switch(rCandidate.getPrimitiveID()) + // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch + switch(rCandidate.getPrimitive3DID()) { case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D : { diff --git a/drawinglayer/source/processor3d/shadow3dextractor.cxx b/drawinglayer/source/processor3d/shadow3dextractor.cxx index 66d3c073854f..5e6678fc3a8e 100644 --- a/drawinglayer/source/processor3d/shadow3dextractor.cxx +++ b/drawinglayer/source/processor3d/shadow3dextractor.cxx @@ -63,8 +63,8 @@ namespace drawinglayer // virtual render method when the primitive implementation is BasePrimitive3D-based. void Shadow3DExtractingProcessor::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate) { - // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch - switch(rCandidate.getPrimitiveID()) + // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch + switch(rCandidate.getPrimitive3DID()) { case PRIMITIVE3D_ID_SHADOWPRIMITIVE3D : { diff --git a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx index b5a59e10a119..48c1bee86575 100644 --- a/drawinglayer/source/processor3d/zbufferprocessor3d.cxx +++ b/drawinglayer/source/processor3d/zbufferprocessor3d.cxx @@ -486,8 +486,8 @@ namespace drawinglayer // the processing method for a single, known primitive void ZBufferProcessor3D::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rBasePrimitive) { - // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch - switch(rBasePrimitive.getPrimitiveID()) + // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch + switch(rBasePrimitive.getPrimitive3DID()) { case PRIMITIVE3D_ID_ALPHATEXTUREPRIMITIVE3D : { diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx index 4f784c71897f..1cc6730da33c 100644 --- a/drawinglayer/source/texture/texture.cxx +++ b/drawinglayer/source/texture/texture.cxx @@ -39,6 +39,7 @@ #include <drawinglayer/texture/texture.hxx> #include <basegfx/numeric/ftools.hxx> #include <basegfx/tools/gradienttools.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -596,9 +597,8 @@ namespace drawinglayer basegfx::B2DPoint aCenter(0.5, 0.5); aCenter *= maTextureTransform; - maTextureTransform.translate(-aCenter.getX(), -aCenter.getY()); - maTextureTransform.rotate(fAngle); - maTextureTransform.translate(aCenter.getX(), aCenter.getY()); + maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle) + * maTextureTransform; } // add object translate diff --git a/framework/inc/uielement/generictoolbarcontroller.hxx b/framework/inc/uielement/generictoolbarcontroller.hxx index f1f014fb7707..109e4f9bf69b 100644 --- a/framework/inc/uielement/generictoolbarcontroller.hxx +++ b/framework/inc/uielement/generictoolbarcontroller.hxx @@ -37,6 +37,9 @@ #include <svtools/toolboxcontroller.hxx> #include <vcl/toolbox.hxx> +#include <memory> + +class PopupMenu; namespace framework { @@ -64,7 +67,7 @@ class GenericToolbarController : public svt::ToolboxController DECL_STATIC_LINK( GenericToolbarController, ExecuteHdl_Impl, ExecuteInfo* ); - private: + protected: ToolBox* m_pToolbar; sal_uInt16 m_nID; sal_Bool m_bEnumCommand : 1, @@ -72,6 +75,28 @@ class GenericToolbarController : public svt::ToolboxController rtl::OUString m_aEnumCommand; }; +class MenuToolbarController : public GenericToolbarController +{ + com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > m_xMenuDesc; + PopupMenu* pMenu; + com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xMenuManager; + rtl::OUString m_aModuleIdentifier; + public: + MenuToolbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager, + const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, + ToolBox* pToolBar, + USHORT nID, + const rtl::OUString& aCommand, + const rtl::OUString& aModuleIdentifier, + const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xMenuDesc ); + + ~MenuToolbarController(); + // XToolbarController + virtual void SAL_CALL click() throw ( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createPopupWindow() throw (::com::sun::star::uno::RuntimeException); + +}; + } #endif // __FRAMEWORK_UIELEMENT_GENERICTOOLBARCONTROLLER_HXX_ diff --git a/framework/inc/uielement/toolbarmanager.hxx b/framework/inc/uielement/toolbarmanager.hxx index 553da978b8ce..5a835c1f1cf5 100644 --- a/framework/inc/uielement/toolbarmanager.hxx +++ b/framework/inc/uielement/toolbarmanager.hxx @@ -50,10 +50,12 @@ #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/frame/XModuleManager.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/frame/XUIControllerRegistration.hpp> #include <com/sun/star/ui/XImageManager.hpp> +#include <com/sun/star/ui/XUIConfigurationManager.hpp> #include <com/sun/star/frame/XStatusListener.hpp> #include <com/sun/star/frame/XSubToolbarController.hpp> #include <com/sun/star/frame/XToolbarController.hpp> @@ -200,6 +202,7 @@ class ToolBarManager : public ::com::sun::star::frame::XFrameActionListener typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XSubToolbarController > > SubToolBarControllerVector; typedef BaseHash< SubToolBarControllerVector > SubToolBarToSubToolBarControllerMap; + typedef ::std::hash_map< sal_uInt16, ::com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > > MenuDescriptionMap; sal_Bool m_bDisposed : 1, m_bIsHiContrast : 1, m_bSmallSymbols : 1, @@ -225,10 +228,14 @@ class ToolBarManager : public ::com::sun::star::frame::XFrameActionListener ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager > m_xModuleImageManager; ::com::sun::star::uno::Reference< ::com::sun::star::ui::XImageManager > m_xDocImageManager; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xImageOrientationListener; + ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xUICfgMgr; + ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationManager > m_xDocUICfgMgr; + CommandToInfoMap m_aCommandMap; SubToolBarToSubToolBarControllerMap m_aSubToolBarControllerMap; Timer m_aAsyncUpdateControllersTimer; sal_Int16 m_nSymbolsStyle; + MenuDescriptionMap m_aMenuMap; }; } diff --git a/framework/inc/xml/menuconfiguration.hxx b/framework/inc/xml/menuconfiguration.hxx index 954fc2ae5e3e..1ce511618112 100644 --- a/framework/inc/xml/menuconfiguration.hxx +++ b/framework/inc/xml/menuconfiguration.hxx @@ -85,6 +85,7 @@ class MenuConfiguration ::rtl::OUString aTargetFrame; ::rtl::OUString aImageId; ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProvider > xDispatchProvider; + sal_Int16 nStyle; }; MenuConfiguration( diff --git a/framework/inc/xml/menudocumenthandler.hxx b/framework/inc/xml/menudocumenthandler.hxx index a85a4c200086..cd73d4b8df66 100644 --- a/framework/inc/xml/menudocumenthandler.hxx +++ b/framework/inc/xml/menudocumenthandler.hxx @@ -109,13 +109,14 @@ class ReadMenuDocumentHandlerBase : public ThreadHelpBase, // Struct for right ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler> m_xReader; void initPropertyCommon( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > &rProps, const rtl::OUString &rCommandURL, const rtl::OUString &rHelpId, - const rtl::OUString &rLabel); + const rtl::OUString &rLabel, sal_Int16 nItemStyleBits ); private: rtl::OUString m_aType; rtl::OUString m_aLabel; rtl::OUString m_aContainer; rtl::OUString m_aHelpURL; rtl::OUString m_aCommandURL; + rtl::OUString m_aStyle; ::com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > m_aItemProp; }; @@ -306,7 +307,7 @@ class OWriteMenuDocumentHandler virtual void WriteMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rSubMenuContainer ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); - virtual void WriteMenuItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL ); + virtual void WriteMenuItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL, sal_Int16 nStyle = 0 ); virtual void WriteMenuSeparator(); com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xMenuBarContainer; diff --git a/framework/inc/xml/toolboxconfigurationdefines.hxx b/framework/inc/xml/toolboxconfigurationdefines.hxx index be8292ada8de..c3cd030f6213 100644 --- a/framework/inc/xml/toolboxconfigurationdefines.hxx +++ b/framework/inc/xml/toolboxconfigurationdefines.hxx @@ -29,6 +29,7 @@ #define ATTRIBUTE_WIDTH "width" #define ATTRIBUTE_USER "userdefined" #define ATTRIBUTE_HELPID "helpid" +#define ATTRIBUTE_TOOLTIP "tooltip" #define ATTRIBUTE_ITEMSTYLE "style" #define ATTRIBUTE_ID "id" @@ -78,6 +79,8 @@ #define ATTRIBUTE_ITEMSTYLE_AUTOSIZE "autosize" #define ATTRIBUTE_ITEMSTYLE_DROPDOWN "dropdown" #define ATTRIBUTE_ITEMSTYLE_REPEAT "repeat" +#define ATTRIBUTE_ITEMSTYLE_TEXT "text" #define ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY "dropdownonly" +#define ATTRIBUTE_ITEMSTYLE_IMAGE "image" #endif // __FRAMEWORK_XML_TOOLBOXCONFIGURATIONDEFINES_HXX_ diff --git a/framework/inc/xml/toolboxdocumenthandler.hxx b/framework/inc/xml/toolboxdocumenthandler.hxx index ccf64e6d0033..ae5231ed8b24 100644 --- a/framework/inc/xml/toolboxdocumenthandler.hxx +++ b/framework/inc/xml/toolboxdocumenthandler.hxx @@ -77,6 +77,7 @@ class OReadToolBoxDocumentHandler : private ThreadHelpBase, // Struct for right TB_ATTRIBUTE_HELPID, TB_ATTRIBUTE_STYLE, TB_ATTRIBUTE_UINAME, + TB_ATTRIBUTE_TOOLTIP, TB_XML_ENTRY_COUNT }; @@ -159,10 +160,13 @@ class OReadToolBoxDocumentHandler : private ThreadHelpBase, // Struct for right sal_Int32 m_nHashCode_Style_DropDown; sal_Int32 m_nHashCode_Style_Repeat; sal_Int32 m_nHashCode_Style_DropDownOnly; + sal_Int32 m_nHashCode_Style_Text; + sal_Int32 m_nHashCode_Style_Image; rtl::OUString m_aType; rtl::OUString m_aLabel; rtl::OUString m_aStyle; rtl::OUString m_aHelpURL; + rtl::OUString m_aTooltip; rtl::OUString m_aIsVisible; rtl::OUString m_aCommandURL; }; @@ -181,7 +185,7 @@ class OWriteToolBoxDocumentHandler : private ThreadHelpBase // Struct for right ::com::sun::star::uno::RuntimeException ); protected: - virtual void WriteToolBoxItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL, + virtual void WriteToolBoxItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL, const rtl::OUString& aTooltip, sal_Int16 nStyle, sal_Int16 nWidth, sal_Bool bVisible ) throw ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); diff --git a/framework/source/classes/menumanager.cxx b/framework/source/classes/menumanager.cxx index 588c59d8f323..3a8bbe8a66c1 100644 --- a/framework/source/classes/menumanager.cxx +++ b/framework/source/classes/menumanager.cxx @@ -171,6 +171,12 @@ MenuManager::MenuManager( for ( USHORT i = 0; i < nItemCount; i++ ) { USHORT nItemId = FillItemCommand(aItemCommand,pMenu, i ); + bool bShowMenuImages( m_bShowMenuImages ); + MenuItemBits nBits = pMenu->GetItemBits( nItemId ); + // overwrite the default? + if ( nBits ) + bShowMenuImages = ( ( nBits & MIB_ICON ) == MIB_ICON ); + PopupMenu* pPopupMenu = pMenu->GetPopupMenu( nItemId ); if ( pPopupMenu ) @@ -217,7 +223,7 @@ MenuManager::MenuManager( aQueryLabelItemIdVector.push_back( nItemId ); #endif // Set image for the addon popup menu item - if ( m_bShowMenuImages && !pPopupMenu->GetItemImage( ITEMID_ADDONLIST )) + if ( bShowMenuImages && !pPopupMenu->GetItemImage( ITEMID_ADDONLIST )) { Image aImage = GetImageFromURL( rFrame, aItemCommand, FALSE, m_bWasHiContrast ); if ( !!aImage ) @@ -249,7 +255,7 @@ MenuManager::MenuManager( aQueryLabelItemIdVector.push_back( nItemId ); #endif - if ( m_bShowMenuImages && !pMenu->GetItemImage( nItemId )) + if ( bShowMenuImages && !pMenu->GetItemImage( nItemId )) { Image aImage = GetImageFromURL( rFrame, aItemCommand, FALSE, m_bWasHiContrast ); if ( !!aImage ) @@ -274,7 +280,7 @@ MenuManager::MenuManager( aQueryLabelItemIdVector.push_back( nItemId ); #endif - if ( m_bShowMenuImages && !pMenu->GetItemImage( nItemId )) + if ( bShowMenuImages && !pMenu->GetItemImage( nItemId )) { Image aImage = GetImageFromURL( rFrame, aItemCommand, FALSE, m_bWasHiContrast ); if ( !!aImage ) @@ -283,7 +289,7 @@ MenuManager::MenuManager( } else if ( pMenu->GetItemType( i ) != MENUITEM_SEPARATOR ) { - if ( m_bShowMenuImages ) + if ( bShowMenuImages ) { if ( AddonMenuManager::IsAddonMenuId( nItemId )) { @@ -1131,7 +1137,13 @@ void MenuManager::FillMenuImages(Reference< XFrame >& _xFrame,Menu* _pMenu,sal_B USHORT nId = _pMenu->GetItemId( nPos ); if ( _pMenu->GetItemType( nPos ) != MENUITEM_SEPARATOR ) { - if ( bShowMenuImages ) + bool bTmpShowMenuImages( bShowMenuImages ); + MenuItemBits nBits = _pMenu->GetItemBits( nId ); + // overwrite the default? + if ( nBits ) + bTmpShowMenuImages = ( ( nBits & MIB_ICON ) == MIB_ICON ); + + if ( bTmpShowMenuImages ) { sal_Bool bImageSet = sal_False; ::rtl::OUString aImageId; diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 33f6aec7b424..3d8ae928e3ff 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -245,6 +245,7 @@ bool LayoutManager::UIElement::operator< ( const LayoutManager::UIElement& aUIEl LayoutManager::UIElement& LayoutManager::UIElement::operator= ( const LayoutManager::UIElement& rUIElement ) { + if (this == &rUIElement) { return *this; } m_aType = rUIElement.m_aType; m_aName = rUIElement.m_aName; m_aUIName = rUIElement.m_aUIName; diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index a354b01d3c32..3e9071052011 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -49,6 +49,7 @@ #include "comphelper/processfactory.hxx" #include "comphelper/sequenceashashmap.hxx" +#include "comphelper/configurationhelper.hxx" #include "rtl/strbuf.hxx" #include "rtl/ustrbuf.hxx" @@ -745,6 +746,41 @@ IMPL_LINK( BackingWindow, ToolboxHdl, void*, EMPTYARG ) Any value( xNameAccess->getByName(rtl::OUString::createFromAscii(pNode)) ); sURL = value.get<rtl::OUString> (); + // extend the URLs with Office locale argument + INetURLObject aURLObj( sURL ); + + rtl::OUString sParam = aURLObj.GetParam(); + rtl::OUStringBuffer aURLBuf( sParam ); + if ( sParam.getLength() > 0 ) + aURLBuf.appendAscii( "&" ); + aURLBuf.appendAscii( "lang=" ); + + // read locale from configuration + ::rtl::OUString sLocale; + ::rtl::OUString sPackage = ::rtl::OUString::createFromAscii("org.openoffice.Setup"); + ::rtl::OUString sRelPath = ::rtl::OUString::createFromAscii("L10N"); + ::rtl::OUString sKey = ::rtl::OUString::createFromAscii("ooLocale"); + + try + { + ::comphelper::ConfigurationHelper::readDirectKey(comphelper::getProcessServiceFactory(), + sPackage, + sRelPath, + sKey, + ::comphelper::ConfigurationHelper::E_READONLY) >>= sLocale; + } + catch(const com::sun::star::uno::RuntimeException& exRun) + { throw exRun; } + catch(const com::sun::star::uno::Exception&) + { sLocale = ::rtl::OUString::createFromAscii("en-US"); } + + aURLBuf.append(sLocale); + + sParam = aURLBuf.makeStringAndClear(); + + aURLObj.SetParam( sParam ); + sURL = aURLObj.GetMainURL( INetURLObject::NO_DECODE ); + Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute( comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.system.SystemShellExecute" ) ) ), diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx index 311776c1bdaf..d1c4d9d6c2da 100644 --- a/framework/source/uielement/generictoolbarcontroller.cxx +++ b/framework/source/uielement/generictoolbarcontroller.cxx @@ -68,6 +68,9 @@ #include <classes/fwkresid.hxx> #include <dispatch/uieventloghelper.hxx> +#include <xml/menuconfiguration.hxx> +#include <uielement/menubarmanager.hxx> + using namespace ::com::sun::star::awt; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -75,6 +78,7 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::frame::status; using namespace ::com::sun::star::util; +using namespace ::com::sun::star::container; namespace framework { @@ -326,5 +330,67 @@ IMPL_STATIC_LINK_NOINSTANCE( GenericToolbarController, ExecuteHdl_Impl, ExecuteI return 0; } +MenuToolbarController::MenuToolbarController( const Reference< XMultiServiceFactory >& rServiceManager, const Reference< XFrame >& rFrame, ToolBox* pToolBar, USHORT nID, const rtl::OUString& aCommand, const rtl::OUString& aModuleIdentifier, const Reference< XIndexAccess >& xMenuDesc ) : GenericToolbarController( rServiceManager, rFrame, pToolBar, nID, aCommand ), m_xMenuDesc( xMenuDesc ), pMenu( NULL ), m_aModuleIdentifier( aModuleIdentifier ) +{ +} + +MenuToolbarController::~MenuToolbarController() +{ + try + { + if ( m_xMenuManager.is() ) + m_xMenuManager->dispose(); + } + catch( Exception& ) {} + if ( pMenu ) + { + delete pMenu; + pMenu = NULL; + } + +} + +class Toolbarmenu : public PopupMenu +{ + public: + Toolbarmenu(); + ~Toolbarmenu(); +}; + +Toolbarmenu::Toolbarmenu() +{ + OSL_TRACE("**** contstructing Toolbarmenu 0x%x", this ); +} + +Toolbarmenu::~Toolbarmenu() +{ + OSL_TRACE("**** destructing Toolbarmenu 0x%x", this ); +} + +void SAL_CALL MenuToolbarController::click() throw (RuntimeException) +{ + createPopupWindow(); +} + +Reference< XWindow > SAL_CALL +MenuToolbarController::createPopupWindow() throw (::com::sun::star::uno::RuntimeException) +{ + if ( !pMenu ) + { + Reference< XDispatchProvider > xDispatch; + Reference< XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ))), UNO_QUERY ); + pMenu = new Toolbarmenu(); + m_xMenuManager.set( new MenuBarManager( m_xServiceManager, m_xFrame, xURLTransformer, xDispatch, m_aModuleIdentifier, pMenu, sal_True, sal_True ) ); + if ( m_xMenuManager.is() ) + { + MenuBarManager* pMgr = dynamic_cast< MenuBarManager* >( m_xMenuManager.get() ); + pMgr->SetItemContainer( m_xMenuDesc ); + } + } + + ::Rectangle aRect( m_pToolbar->GetItemRect( m_nID ) ); + pMenu->Execute( m_pToolbar, aRect, POPUPMENU_EXECUTE_DOWN ); + return NULL; +} } // namespace diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 0b26f96829d2..fd42de48ae84 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -74,6 +74,7 @@ #include <com/sun/star/frame/XModuleManager.hpp> #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> +#include <com/sun/star/ui/ItemStyle.hpp> #include <com/sun/star/frame/status/Visibility.hpp> //_________________________________________________________________________________________________________________ @@ -136,6 +137,7 @@ static const char ITEM_DESCRIPTOR_LABEL[] = "Label"; static const char ITEM_DESCRIPTOR_TYPE[] = "Type"; static const char ITEM_DESCRIPTOR_MODULEIDENTIFIER[] = "ModuleIdentifier"; static const char ITEM_DESCRIPTOR_DISPATCHPROVIDER[] = "DispatchProvider"; +static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; const sal_Int32 LEN_DESCRIPTOR_COMMANDURL = 10; const sal_Int32 LEN_DESCRIPTOR_HELPURL = 7; @@ -144,6 +146,7 @@ const sal_Int32 LEN_DESCRIPTOR_LABEL = 5; const sal_Int32 LEN_DESCRIPTOR_TYPE = 4; const sal_Int32 LEN_DESCRIPTOR_MODULEIDENTIFIER = 16; const sal_Int32 LEN_DESCRIPTOR_DISPATCHPROVIDER = 16; +static const sal_Int32 ITEM_DESCRIPTOR_STYLE_LEN = 5; const sal_uInt16 ADDONMENU_MERGE_ITEMID_START = 1500; @@ -1327,6 +1330,11 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF Reference< XDispatch > xDispatch; Reference< XStatusListener > xStatusListener; PopupMenu* pPopup = pMenu->GetPopupMenu( nItemId ); + bool bItemShowMenuImages = m_bShowMenuImages; + MenuItemBits nBits = pMenu->GetItemBits( nItemId ); + // overwrite the show icons on menu option? + if ( nBits ) + bItemShowMenuImages = ( ( nBits & MIB_ICON ) == MIB_ICON ); if ( pPopup ) { // Retrieve module identifier from Help Command entry @@ -1422,7 +1430,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF pSubMenuManager->m_aMenuItemCommand = ::rtl::OUString(); // Set image for the addon popup menu item - if ( m_bShowMenuImages && !pPopup->GetItemImage( ITEMID_ADDONLIST )) + if ( bItemShowMenuImages && !pPopup->GetItemImage( ITEMID_ADDONLIST )) { Reference< XFrame > xTemp( rFrame ); Image aImage = GetImageFromURL( xTemp, aItemCommand, FALSE, m_bWasHiContrast ); @@ -1441,7 +1449,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF } else if ( pMenu->GetItemType( i ) != MENUITEM_SEPARATOR ) { - if ( m_bShowMenuImages ) + if ( bItemShowMenuImages ) { if ( AddonMenuManager::IsAddonMenuId( nItemId )) { @@ -1752,7 +1760,7 @@ void MenuBarManager::FillMenu( sal_uInt16 nType = 0; Reference< XIndexAccess > xIndexContainer; Reference< XDispatchProvider > xDispatchProvider( rDispatchProvider ); - + sal_Int16 nStyle = 0; try { if ( rItemContainer->getByIndex( n ) >>= aProp ) @@ -1781,6 +1789,8 @@ void MenuBarManager::FillMenu( else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_DISPATCHPROVIDER, LEN_DESCRIPTOR_DISPATCHPROVIDER )) aProp[i].Value >>= xDispatchProvider; + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, ITEM_DESCRIPTOR_STYLE_LEN )) + aProp[i].Value >>= nStyle; } if ( nType == ::com::sun::star::ui::ItemType::DEFAULT ) @@ -1791,7 +1801,15 @@ void MenuBarManager::FillMenu( sal_Int32 nHelpId = aHelpURL.toInt32(); if ( nHelpId > 0 ) pMenu->SetHelpId( nId, (USHORT)nHelpId ); - + if ( nStyle ) + { + MenuItemBits nBits = pMenu->GetItemBits( nId ); + if ( nStyle & ::com::sun::star::ui::ItemStyle::ICON ) + nBits |= MIB_ICON; + if ( nStyle & ::com::sun::star::ui::ItemStyle::TEXT ) + nBits |= MIB_TEXT; + pMenu->SetItemBits( nId, nBits ); + } if ( xIndexContainer.is() ) { PopupMenu* pNewPopupMenu = new PopupMenu; diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 6463dd634c20..0d53206fc1c1 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -71,7 +71,6 @@ #include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/frame/XModuleManager.hpp> #include <com/sun/star/ui/XUIElementSettings.hpp> -#include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/ui/XUIConfigurationPersistence.hpp> #include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp> #include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp> @@ -122,6 +121,7 @@ namespace framework static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL"; static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL"; +static const char ITEM_DESCRIPTOR_TOOLTIP[] = "Tooltip"; static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer"; static const char ITEM_DESCRIPTOR_LABEL[] = "Label"; static const char ITEM_DESCRIPTOR_TYPE[] = "Type"; @@ -131,6 +131,7 @@ static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; static const sal_Int32 ITEM_DESCRIPTOR_COMMANDURL_LEN = 10; static const sal_Int32 ITEM_DESCRIPTOR_HELPURL_LEN = 7; +static const sal_Int32 ITEM_DESCRIPTOR_TOOLTIP_LEN = 7; static const sal_Int32 ITEM_DESCRIPTOR_CONTAINER_LEN = 23; static const sal_Int32 ITEM_DESCRIPTOR_LABEL_LEN = 5; static const sal_Int32 ITEM_DESCRIPTOR_TYPE_LEN = 4; @@ -143,6 +144,7 @@ static const char HELPID_PREFIX_TESTTOOL[] = ".HelpId:"; //static sal_Int32 HELPID_PREFIX_LENGTH = 7; static const USHORT STARTID_CUSTOMIZE_POPUPMENU = 1000; +#define MENUPREFIX "private:resource/menubar/" class ImageOrientationListener : public svt::FrameStatusListener { @@ -968,8 +970,13 @@ void ToolBarManager::CreateControllers() } else { + MenuDescriptionMap::iterator it = m_aMenuMap.find( nId ); + if ( it == m_aMenuMap.end() ) xController = Reference< XStatusListener >( new GenericToolbarController( m_xServiceManager, m_xFrame, m_pToolBar, nId, aCommandURL )); + else + xController = Reference< XStatusListener >( + new MenuToolbarController( m_xServiceManager, m_xFrame, m_pToolBar, nId, aCommandURL, m_aModuleIdentifier, m_aMenuMap[ nId ] )); } } else if ( pController ) @@ -1101,6 +1108,10 @@ sal_uInt16 ToolBarManager::ConvertStyleToToolboxItemBits( sal_Int32 nStyle ) nItemBits |= TIB_REPEAT; if ( nStyle & ::com::sun::star::ui::ItemStyle::DROPDOWN_ONLY ) nItemBits |= TIB_DROPDOWNONLY; + if ( nStyle & ::com::sun::star::ui::ItemStyle::TEXT ) + nItemBits |= TIB_TEXT_ONLY; + if ( nStyle & ::com::sun::star::ui::ItemStyle::ICON ) + nItemBits |= TIB_ICON_ONLY; return nItemBits; } @@ -1130,8 +1141,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine Reference< XUIConfigurationManagerSupplier > xSupplier( xModel, UNO_QUERY ); if ( xSupplier.is() ) { - Reference< XUIConfigurationManager > xDocUICfgMgr( xSupplier->getUIConfigurationManager(), UNO_QUERY ); - m_xDocImageManager = Reference< XImageManager >( xDocUICfgMgr->getImageManager(), UNO_QUERY ); + m_xDocUICfgMgr.set( xSupplier->getUIConfigurationManager(), UNO_QUERY ); + m_xDocImageManager = Reference< XImageManager >( m_xDocUICfgMgr->getImageManager(), UNO_QUERY ); m_xDocImageManager->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); @@ -1153,8 +1164,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier( m_xServiceManager->createInstance( SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER ), UNO_QUERY ); - Reference< XUIConfigurationManager > xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier ); - m_xModuleImageManager = Reference< XImageManager >( xUICfgMgr->getImageManager(), UNO_QUERY ); + m_xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier ); + m_xModuleImageManager = Reference< XImageManager >( m_xUICfgMgr->getImageManager(), UNO_QUERY ); m_xModuleImageManager->addConfigurationListener( Reference< XUIConfigurationListener >( static_cast< OWeakObject* >( this ), UNO_QUERY )); } @@ -1166,6 +1177,8 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine m_aControllerMap.clear(); m_aCommandMap.clear(); + m_aMenuMap.clear(); + CommandInfo aCmdInfo; for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ ) { @@ -1173,11 +1186,13 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine rtl::OUString aCommandURL; rtl::OUString aLabel; rtl::OUString aHelpURL; + rtl::OUString aTooltip; sal_uInt16 nType( ::com::sun::star::ui::ItemType::DEFAULT ); sal_uInt16 nWidth( 0 ); sal_Bool bIsVisible( sal_True ); sal_uInt32 nStyle( 0 ); + Reference< XIndexAccess > aMenuDesc; try { if ( rItemContainer->getByIndex( n ) >>= aProp ) @@ -1185,9 +1200,44 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine for ( int i = 0; i < aProp.getLength(); i++ ) { if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_COMMANDURL, ITEM_DESCRIPTOR_COMMANDURL_LEN )) + { aProp[i].Value >>= aCommandURL; + if ( aCommandURL.compareToAscii(MENUPREFIX, RTL_CONSTASCII_LENGTH(MENUPREFIX) ) == 0 ) + { + try + { + Reference< XIndexAccess > xMenuContainer; + if ( m_xDocUICfgMgr.is() ) + xMenuContainer = m_xDocUICfgMgr->getSettings( aCommandURL, sal_False ); + if ( !xMenuContainer.is() && m_xUICfgMgr.is() ) + xMenuContainer = m_xUICfgMgr->getSettings( aCommandURL, sal_False ); + if ( xMenuContainer.is() && xMenuContainer->getCount() ) + { + Sequence< PropertyValue > aProps; + // drop down menu info is currently + // the first ( and only ) menu + // in the menusettings container + xMenuContainer->getByIndex(0) >>= aProps; + for ( sal_Int32 index=0; index<aProps.getLength(); ++index ) + { + if ( aProps[ index ].Name.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER, ITEM_DESCRIPTOR_CONTAINER_LEN )) + + { + aProps[ index ].Value >>= aMenuDesc; + break; + } + } + } + } + catch( Exception& ) + { + } + } + } else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL, ITEM_DESCRIPTOR_HELPURL_LEN )) aProp[i].Value >>= aHelpURL; + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_TOOLTIP, ITEM_DESCRIPTOR_TOOLTIP_LEN )) + aProp[i].Value >>= aTooltip; else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_LABEL, ITEM_DESCRIPTOR_LABEL_LEN )) aProp[i].Value >>= aLabel; else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_TYPE, ITEM_DESCRIPTOR_TYPE_LEN )) @@ -1205,8 +1255,13 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine ::rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL )); sal_uInt16 nItemBits = ConvertStyleToToolboxItemBits( nStyle ); + if ( aMenuDesc.is() ) + m_aMenuMap[ nId ] = aMenuDesc; m_pToolBar->InsertItem( nId, aString, nItemBits ); m_pToolBar->SetItemCommand( nId, aCommandURL ); + if ( aTooltip.getLength() ) + m_pToolBar->SetQuickHelpText( nId, aTooltip ); + else m_pToolBar->SetQuickHelpText( nId, aString ); if ( aLabel.getLength() > 0 ) m_pToolBar->SetItemText( nId, aLabel ); diff --git a/framework/source/xml/menudocumenthandler.cxx b/framework/source/xml/menudocumenthandler.cxx index 2422d516d0ac..47d8c93f71e0 100644 --- a/framework/source/xml/menudocumenthandler.cxx +++ b/framework/source/xml/menudocumenthandler.cxx @@ -47,6 +47,7 @@ #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> #include <com/sun/star/lang/XSingleComponentFactory.hpp> #include <com/sun/star/ui/ItemType.hpp> +#include <com/sun/star/ui/ItemStyle.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -80,11 +81,13 @@ #define ATTRIBUTE_LABEL "http://openoffice.org/2001/menu^label" #define ATTRIBUTE_HELPID "http://openoffice.org/2001/menu^helpid" #define ATTRIBUTE_LINEBREAK "http://openoffice.org/2001/menu^linebreak" +#define ATTRIBUTE_STYLE "http://openoffice.org/2001/menu^style" #define ATTRIBUTE_NS_ID "menu:id" #define ATTRIBUTE_NS_LABEL "menu:label" #define ATTRIBUTE_NS_HELPID "menu:helpid" #define ATTRIBUTE_NS_LINEBREAK "menu:linebreak" +#define ATTRIBUTE_NS_STYLE "menu:style" #define ATTRIBUTE_XMLNS_MENU "xmlns:menu" @@ -92,12 +95,16 @@ #define MENUBAR_DOCTYPE "<!DOCTYPE menu:menubar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"menubar.dtd\">" +#define ATTRIBUTE_ITEMSTYLE_TEXT "text" +#define ATTRIBUTE_ITEMSTYLE_IMAGE "image" + // Property names of a menu/menu item ItemDescriptor static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL"; static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL"; static const char ITEM_DESCRIPTOR_CONTAINER[] = "ItemDescriptorContainer"; static const char ITEM_DESCRIPTOR_LABEL[] = "Label"; static const char ITEM_DESCRIPTOR_TYPE[] = "Type"; +static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; // special popup menus (filled during runtime) must be saved as an empty popup menu or menuitem!!! static const sal_Int32 CMD_PROTOCOL_SIZE = 5; @@ -121,12 +128,27 @@ using namespace ::com::sun::star::ui; namespace framework { +struct MenuStyleItem +{ + sal_Int16 nBit; + const char* attrName; +}; + +MenuStyleItem MenuItemStyles[ ] = { + { ::com::sun::star::ui::ItemStyle::ICON, ATTRIBUTE_ITEMSTYLE_IMAGE }, + { ::com::sun::star::ui::ItemStyle::TEXT, ATTRIBUTE_ITEMSTYLE_TEXT }, +}; + + +sal_Int32 nMenuStyleItemEntries = sizeof( MenuItemStyles ) / sizeof( MenuItemStyles[ 0 ] ); + static void ExtractMenuParameters( const Sequence< PropertyValue > rProp, ::rtl::OUString& rCommandURL, ::rtl::OUString& rLabel, ::rtl::OUString& rHelpURL, Reference< XIndexAccess >& rSubMenu, - sal_Int16& rType ) + sal_Int16& rType, + sal_Int16& rStyle ) { for ( sal_Int32 i = 0; i < rProp.getLength(); i++ ) { @@ -151,6 +173,10 @@ static void ExtractMenuParameters( const Sequence< PropertyValue > rProp, { rProp[i].Value >>= rType; } + else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE )) + { + rProp[i].Value >>= rStyle; + } } } @@ -165,7 +191,8 @@ ReadMenuDocumentHandlerBase::ReadMenuDocumentHandlerBase() : m_aLabel( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_LABEL )), m_aContainer( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_CONTAINER )), m_aHelpURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL )), - m_aCommandURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL )) + m_aCommandURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL )), + m_aStyle( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_STYLE )) { } @@ -207,20 +234,22 @@ throw( SAXException, RuntimeException ) void ReadMenuDocumentHandlerBase::initPropertyCommon( Sequence< PropertyValue > &rProps, const rtl::OUString &rCommandURL, - const rtl::OUString &rHelpId, const rtl::OUString &rLabel) + const rtl::OUString &rHelpId, const rtl::OUString &rLabel, sal_Int16 nItemStyleBits ) { rProps[0].Name = m_aCommandURL; rProps[1].Name = m_aHelpURL; rProps[2].Name = m_aContainer; rProps[3].Name = m_aLabel; - rProps[4].Name = m_aType; + rProps[4].Name = m_aStyle; + rProps[5].Name = m_aType; // Common values rProps[0].Value <<= rCommandURL.intern(); rProps[1].Value <<= rHelpId; rProps[2].Value <<= Reference< XIndexContainer >(); rProps[3].Value <<= rLabel; - rProps[4].Value <<= ::com::sun::star::ui::ItemType::DEFAULT; + rProps[4].Value <<= nItemStyleBits; + rProps[5].Value <<= ::com::sun::star::ui::ItemType::DEFAULT; } // ----------------------------------------------------------------------------- @@ -373,6 +402,7 @@ throw( SAXException, RuntimeException ) ::rtl::OUString aHelpId; ::rtl::OUString aCommandId; ::rtl::OUString aLabel; + sal_Int16 nItemBits(0); m_bMenuMode = sal_True; @@ -399,12 +429,29 @@ throw( SAXException, RuntimeException ) aLabel = aValue; else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_HELPID ))) aHelpId = aValue; + else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_STYLE ))) + { + ::rtl::OUString aTemp( aValue ); + sal_Int32 nIndex = 0; + do + { + ::rtl::OUString aToken = aTemp.getToken( 0, '+', nIndex ); + if ( aToken.getLength() > 0 ) + { + if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_TEXT ) ) ) + nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT; + if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) ) + nItemBits |= ::com::sun::star::ui::ItemStyle::ICON; + } + } + while ( nIndex >= 0 ); + } } if ( aCommandId.getLength() > 0 ) { - Sequence< PropertyValue > aSubMenuProp( 5 ); - initPropertyCommon( aSubMenuProp, aCommandId, aHelpId, aLabel ); + Sequence< PropertyValue > aSubMenuProp( 6 ); + initPropertyCommon( aSubMenuProp, aCommandId, aHelpId, aLabel, nItemBits ); aSubMenuProp[2].Value <<= xSubItemContainer; m_xMenuBarContainer->insertByIndex( m_xMenuBarContainer->getCount(), makeAny( aSubMenuProp ) ); @@ -589,6 +636,7 @@ throw( SAXException, RuntimeException ) ::rtl::OUString aHelpId; ::rtl::OUString aCommandId; ::rtl::OUString aLabel; + sal_Int16 nItemBits(0); m_bMenuMode = sal_True; @@ -614,12 +662,30 @@ throw( SAXException, RuntimeException ) aLabel = aValue; else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_HELPID ))) aHelpId = aValue; + else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_STYLE ))) + { + ::rtl::OUString aTemp( aValue ); + sal_Int32 nIndex = 0; + do + { + ::rtl::OUString aToken = aTemp.getToken( 0, '+', nIndex ); + if ( aToken.getLength() > 0 ) + { + if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_TEXT ) ) ) + nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT; + if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) ) + nItemBits |= ::com::sun::star::ui::ItemStyle::ICON; + } + } + while ( nIndex >= 0 ); + } + } if ( aCommandId.getLength() > 0 ) { - Sequence< PropertyValue > aSubMenuProp( 5 ); - initPropertyCommon( aSubMenuProp, aCommandId, aHelpId, aLabel ); + Sequence< PropertyValue > aSubMenuProp( 6 ); + initPropertyCommon( aSubMenuProp, aCommandId, aHelpId, aLabel, nItemBits ); aSubMenuProp[2].Value <<= xSubItemContainer; m_xMenuContainer->insertByIndex( m_xMenuContainer->getCount(), makeAny( aSubMenuProp ) ); @@ -639,7 +705,7 @@ throw( SAXException, RuntimeException ) ::rtl::OUString aHelpId; ::rtl::OUString aCommandId; ::rtl::OUString aLabel; - + sal_Int16 nItemBits(0); // read attributes for menu item for ( sal_Int16 i=0; i< xAttrList->getLength(); i++ ) { @@ -651,12 +717,30 @@ throw( SAXException, RuntimeException ) aLabel = aValue; else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_HELPID ))) aHelpId = aValue; + else if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_STYLE ))) + { + ::rtl::OUString aTemp( aValue ); + sal_Int32 nIndex = 0; + do + { + ::rtl::OUString aToken = aTemp.getToken( 0, '+', nIndex ); + if ( aToken.getLength() > 0 ) + { + if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_TEXT ) ) ) + nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT; + if ( aToken.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) ) + nItemBits |= ::com::sun::star::ui::ItemStyle::ICON; + } + } + while ( nIndex >= 0 ); + } + } if ( aCommandId.getLength() > 0 ) { - Sequence< PropertyValue > aMenuItem( 5 ); - initPropertyCommon( aMenuItem, aCommandId, aHelpId, aLabel ); + Sequence< PropertyValue > aMenuItem( 6 ); + initPropertyCommon( aMenuItem, aCommandId, aHelpId, aLabel, nItemBits ); aMenuItem[2].Value <<= Reference< XIndexContainer >(); m_xMenuContainer->insertByIndex( m_xMenuContainer->getCount(), makeAny( aMenuItem ) ); @@ -809,15 +893,16 @@ throw ( SAXException, RuntimeException ) ::rtl::OUString aLabel; ::rtl::OUString aHelpURL; sal_Int16 nType( ::com::sun::star::ui::ItemType::DEFAULT ); + sal_Int16 nItemBits( 0 ); Reference< XIndexAccess > xSubMenu; - ExtractMenuParameters( aProps, aCommandURL, aLabel, aHelpURL, xSubMenu, nType ); + ExtractMenuParameters( aProps, aCommandURL, aLabel, aHelpURL, xSubMenu, nType, nItemBits ); if ( xSubMenu.is() ) { if ( aCommandURL.equalsAscii( ADDDIRECT_CMD ) || aCommandURL.equalsAscii( AUTOPILOTMENU_CMD )) { - WriteMenuItem( aCommandURL, aLabel, aHelpURL ); + WriteMenuItem( aCommandURL, aLabel, aHelpURL, nItemBits ); bSeparator = sal_False; } else if (( aCommandURL.getLength() > 0 ) && !AddonPopupMenu::IsCommandURLPrefix ( aCommandURL )) @@ -857,7 +942,7 @@ throw ( SAXException, RuntimeException ) if ( aCommandURL.getLength() > 0 ) { bSeparator = FALSE; - WriteMenuItem( aCommandURL, aLabel, aHelpURL ); + WriteMenuItem( aCommandURL, aLabel, aHelpURL, nItemBits ); } } else if ( !bSeparator ) @@ -872,7 +957,7 @@ throw ( SAXException, RuntimeException ) } -void OWriteMenuDocumentHandler::WriteMenuItem( const ::rtl::OUString& aCommandURL, const ::rtl::OUString& aLabel, const ::rtl::OUString& aHelpURL) +void OWriteMenuDocumentHandler::WriteMenuItem( const ::rtl::OUString& aCommandURL, const ::rtl::OUString& aLabel, const ::rtl::OUString& aHelpURL, sal_Int16 nStyle ) { ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY ); @@ -894,6 +979,24 @@ void OWriteMenuDocumentHandler::WriteMenuItem( const ::rtl::OUString& aCommandUR m_aAttributeType, aLabel ); } + if (( nStyle > 0 ) && !( aCommandURL.copy( CMD_PROTOCOL_SIZE ).equalsAscii( CMD_PROTOCOL ))) + { + rtl::OUString aValue; + MenuStyleItem* pStyle = MenuItemStyles; + + for ( sal_Int32 nIndex = 0; nIndex < nMenuStyleItemEntries; ++nIndex, ++pStyle ) + { + if ( nStyle & pStyle->nBit ) + { + if ( aValue.getLength() ) + aValue = aValue.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("+") ) ); + aValue += rtl::OUString::createFromAscii( pStyle->attrName ); + } + } + pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_NS_STYLE )), + m_aAttributeType, + aValue ); + } m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_MENUITEM )), xList ); diff --git a/framework/source/xml/toolboxdocumenthandler.cxx b/framework/source/xml/toolboxdocumenthandler.cxx index 78d6f8158413..ba01284accdb 100644 --- a/framework/source/xml/toolboxdocumenthandler.cxx +++ b/framework/source/xml/toolboxdocumenthandler.cxx @@ -79,6 +79,7 @@ namespace framework // Property names of a menu/menu item ItemDescriptor static const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL"; static const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL"; +static const char ITEM_DESCRIPTOR_TOOLTIP[] = "Tooltip"; static const char ITEM_DESCRIPTOR_LABEL[] = "Label"; static const char ITEM_DESCRIPTOR_TYPE[] = "Type"; static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; @@ -89,6 +90,8 @@ static void ExtractToolbarParameters( const Sequence< PropertyValue > rProp, ::rtl::OUString& rCommandURL, ::rtl::OUString& rLabel, ::rtl::OUString& rHelpURL, + ::rtl::OUString& rTooltip, + sal_Int16& rStyle, sal_Int16& rWidth, sal_Bool& rVisible, sal_Int16& rType ) @@ -102,6 +105,8 @@ static void ExtractToolbarParameters( const Sequence< PropertyValue > rProp, } else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL )) rProp[i].Value >>= rHelpURL; + else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TOOLTIP )) + rProp[i].Value >>= rTooltip; else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_LABEL )) rProp[i].Value >>= rLabel; else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_TYPE )) @@ -110,9 +115,30 @@ static void ExtractToolbarParameters( const Sequence< PropertyValue > rProp, rProp[i].Value >>= rVisible; else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_WIDTH )) rProp[i].Value >>= rWidth; + else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE )) + rProp[i].Value >>= rStyle; } } +struct ToolboxStyleItem +{ + sal_Int16 nBit; + const char* attrName; +}; + +ToolboxStyleItem Styles[ ] = { + { ::com::sun::star::ui::ItemStyle::RADIO_CHECK, ATTRIBUTE_ITEMSTYLE_RADIO }, + { ::com::sun::star::ui::ItemStyle::ALIGN_LEFT, ATTRIBUTE_ITEMSTYLE_LEFT }, + { ::com::sun::star::ui::ItemStyle::AUTO_SIZE, ATTRIBUTE_ITEMSTYLE_AUTO }, + { ::com::sun::star::ui::ItemStyle::REPEAT, ATTRIBUTE_ITEMSTYLE_REPEAT }, + { ::com::sun::star::ui::ItemStyle::DROPDOWN_ONLY, ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY }, + { ::com::sun::star::ui::ItemStyle::DROP_DOWN, ATTRIBUTE_ITEMSTYLE_DROPDOWN }, + { ::com::sun::star::ui::ItemStyle::ICON, ATTRIBUTE_ITEMSTYLE_IMAGE }, + { ::com::sun::star::ui::ItemStyle::TEXT, ATTRIBUTE_ITEMSTYLE_TEXT }, +}; + +sal_Int32 nStyleItemEntries = sizeof( Styles ) / sizeof( Styles[ 0 ] ); + struct ToolBarEntryProperty { OReadToolBoxDocumentHandler::ToolBox_XML_Namespace nNamespace; @@ -135,7 +161,8 @@ ToolBarEntryProperty ToolBoxEntries[OReadToolBoxDocumentHandler::TB_XML_ENTRY_CO { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_USER }, { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_HELPID }, { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_ITEMSTYLE }, - { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_UINAME } + { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_UINAME }, + { OReadToolBoxDocumentHandler::TB_NS_TOOLBAR, ATTRIBUTE_TOOLTIP }, }; OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XIndexContainer >& rItemContainer ) : @@ -145,6 +172,7 @@ OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XInde m_aLabel( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_LABEL )), m_aStyle( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_STYLE )), m_aHelpURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL )), + m_aTooltip( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TOOLTIP )), m_aIsVisible( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_VISIBLE )), m_aCommandURL( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL )) { @@ -179,6 +207,8 @@ OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XInde m_nHashCode_Style_DropDown = ::rtl::OUString::createFromAscii( ATTRIBUTE_ITEMSTYLE_DROPDOWN ).hashCode(); m_nHashCode_Style_Repeat = ::rtl::OUString::createFromAscii( ATTRIBUTE_ITEMSTYLE_REPEAT ).hashCode(); m_nHashCode_Style_DropDownOnly = ::rtl::OUString::createFromAscii( ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY ).hashCode(); + m_nHashCode_Style_Text = ::rtl::OUString::createFromAscii( ATTRIBUTE_ITEMSTYLE_TEXT ).hashCode(); + m_nHashCode_Style_Image = ::rtl::OUString::createFromAscii( ATTRIBUTE_ITEMSTYLE_IMAGE ).hashCode(); m_bToolBarStartFound = sal_False; m_bToolBarEndFound = sal_False; @@ -298,6 +328,7 @@ throw( SAXException, RuntimeException ) ::rtl::OUString aLabel; ::rtl::OUString aCommandURL; ::rtl::OUString aHelpURL; + ::rtl::OUString aTooltip; ::rtl::OUString aBitmapName; sal_uInt16 nItemBits( 0 ); sal_uInt16 nWidth( 0 ); @@ -369,6 +400,12 @@ throw( SAXException, RuntimeException ) } break; + case TB_ATTRIBUTE_TOOLTIP: + { + aTooltip = xAttribs->getValueByIndex( n ); + } + break; + case TB_ATTRIBUTE_STYLE: { // read space seperated item style list @@ -393,6 +430,12 @@ throw( SAXException, RuntimeException ) nItemBits |= ::com::sun::star::ui::ItemStyle::REPEAT; else if ( nHashCode == m_nHashCode_Style_DropDownOnly ) nItemBits |= ::com::sun::star::ui::ItemStyle::DROPDOWN_ONLY; + else if ( nHashCode == m_nHashCode_Style_DropDown ) + nItemBits |= ::com::sun::star::ui::ItemStyle::DROP_DOWN; + else if ( nHashCode == m_nHashCode_Style_Text ) + nItemBits |= ::com::sun::star::ui::ItemStyle::TEXT; + else if ( nHashCode == m_nHashCode_Style_Image ) + nItemBits |= ::com::sun::star::ui::ItemStyle::ICON; } } while ( nIndex >= 0 ); @@ -414,13 +457,14 @@ throw( SAXException, RuntimeException ) if ( aCommandURL.getLength() > 0 ) { - Sequence< PropertyValue > aToolbarItemProp( 6 ); + Sequence< PropertyValue > aToolbarItemProp( 7 ); aToolbarItemProp[0].Name = m_aCommandURL; aToolbarItemProp[1].Name = m_aHelpURL; aToolbarItemProp[2].Name = m_aLabel; aToolbarItemProp[3].Name = m_aType; aToolbarItemProp[4].Name = m_aStyle; aToolbarItemProp[5].Name = m_aIsVisible; + aToolbarItemProp[6].Name = m_aTooltip; aToolbarItemProp[0].Value <<= aCommandURL; aToolbarItemProp[1].Value <<= aHelpURL; @@ -428,6 +472,7 @@ throw( SAXException, RuntimeException ) aToolbarItemProp[3].Value = makeAny( ::com::sun::star::ui::ItemType::DEFAULT ); aToolbarItemProp[4].Value <<= nItemBits; aToolbarItemProp[5].Value <<= bVisible; + aToolbarItemProp[6].Value <<= aTooltip; m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) ); } @@ -718,13 +763,15 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxDocument() throw ::rtl::OUString aCommandURL; ::rtl::OUString aLabel; ::rtl::OUString aHelpURL; + ::rtl::OUString aTooltip; sal_Bool bVisible( sal_True ); sal_Int16 nType( ::com::sun::star::ui::ItemType::DEFAULT ); sal_Int16 nWidth( 0 ); + sal_Int16 nStyle( 0 ); - ExtractToolbarParameters( aProps, aCommandURL, aLabel, aHelpURL, nWidth, bVisible, nType ); + ExtractToolbarParameters( aProps, aCommandURL, aLabel, aHelpURL, aTooltip, nStyle, nWidth, bVisible, nType ); if ( nType == ::com::sun::star::ui::ItemType::DEFAULT ) - WriteToolBoxItem( aCommandURL, aLabel, aHelpURL, nWidth, bVisible ); + WriteToolBoxItem( aCommandURL, aLabel, aHelpURL, aTooltip, nStyle, nWidth, bVisible ); else if ( nType == ::com::sun::star::ui::ItemType::SEPARATOR_SPACE ) WriteToolBoxSpace(); else if ( nType == ::com::sun::star::ui::ItemType::SEPARATOR_LINE ) @@ -748,6 +795,8 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxItem( const ::rtl::OUString& rCommandURL, const ::rtl::OUString& rLabel, const ::rtl::OUString& rHelpURL, + const ::rtl::OUString& rTooltip, + sal_Int16 nStyle, sal_Int16 nWidth, sal_Bool bVisible ) throw ( SAXException, RuntimeException ) @@ -785,6 +834,32 @@ throw ( SAXException, RuntimeException ) rHelpURL ); } + if ( rTooltip.getLength() > 0 ) + { + pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TOOLTIP )), + m_aAttributeType, + rTooltip ); + } + + if ( nStyle > 0 ) + { + rtl::OUString aValue; + ToolboxStyleItem* pStyle = Styles; + + for ( sal_Int32 nIndex = 0; nIndex < nStyleItemEntries; ++nIndex, ++pStyle ) + { + if ( nStyle & pStyle->nBit ) + { + if ( aValue.getLength() ) + aValue = aValue.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(" ") ) ); + aValue += rtl::OUString::createFromAscii( pStyle->attrName ); + } + } + pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ITEMSTYLE )), + m_aAttributeType, + aValue ); + } + if ( nWidth > 0 ) { pList->AddAttribute( m_aXMLToolbarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_WIDTH )), diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 2697d5880b80..49975ad6e626 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -578,7 +578,8 @@ void GrammarCheckingIterator::DequeueAndCheck() sal_Int32 nStartPos = aFPEntryItem.m_nStartIndex; sal_Int32 nSuggestedEnd = GetSuggestedEndOfSentence( aCurTxt, nStartPos, aCurLocale ); - DBG_ASSERT( nSuggestedEnd > nStartPos, "nSuggestedEndOfSentencePos calculation failed?" ); + DBG_ASSERT( (nSuggestedEnd == 0 && aCurTxt.getLength() == 0) || nSuggestedEnd > nStartPos, + "nSuggestedEndOfSentencePos calculation failed?" ); linguistic2::ProofreadingResult aRes; diff --git a/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu b/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu index 871ef6282299..7aa68980534d 100644 --- a/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu +++ b/officecfg/registry/data/org/openoffice/Office/DataAccess.xcu @@ -156,7 +156,7 @@ </node> </node> <node oor:name="RegisteredNames"> - <node oor:name="Bibliography" oor:op="replace"> + <node oor:name="org.openoffice.Bibliography" oor:op="replace"> <prop oor:name="Location" oor:type="xs:string"> <value>$(userurl)/database/biblio.odb</value> </prop> diff --git a/officecfg/registry/data/org/openoffice/Office/Math.xcu b/officecfg/registry/data/org/openoffice/Office/Math.xcu index 62867f50a6ee..c0fa17f767aa 100644 --- a/officecfg/registry/data/org/openoffice/Office/Math.xcu +++ b/officecfg/registry/data/org/openoffice/Office/Math.xcu @@ -33,7 +33,7 @@ <node oor:name="FontFormatList"> <node oor:name="Id1" oor:op="replace"> <prop oor:name="Name"> - <value>StarSymbol</value> + <value>OpenSymbol</value> </prop> <prop oor:name="CharSet"> <value>-1</value> @@ -53,10 +53,10 @@ </node> <node oor:name="Id2" oor:op="replace"> <prop oor:name="Name"> - <value>Times New Roman</value> + <value>OpenSymbol</value> </prop> <prop oor:name="CharSet"> - <value>0</value> + <value>-1</value> </prop> <prop oor:name="Family"> <value>0</value> @@ -75,7 +75,7 @@ <node oor:name="SymbolList"> <node oor:name="alpha" oor:op="replace"> <prop oor:name="Char"> - <value>57527</value> + <value>945</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -84,12 +84,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="ALPHA" oor:op="replace"> <prop oor:name="Char"> - <value>65</value> + <value>913</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -103,7 +103,7 @@ </node> <node oor:name="beta" oor:op="replace"> <prop oor:name="Char"> - <value>57528</value> + <value>946</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -112,12 +112,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="BETA" oor:op="replace"> <prop oor:name="Char"> - <value>66</value> + <value>914</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -131,7 +131,7 @@ </node> <node oor:name="gamma" oor:op="replace"> <prop oor:name="Char"> - <value>57529</value> + <value>947</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -140,12 +140,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="GAMMA" oor:op="replace"> <prop oor:name="Char"> - <value>57516</value> + <value>915</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -154,12 +154,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="delta" oor:op="replace"> <prop oor:name="Char"> - <value>57530</value> + <value>948</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -168,12 +168,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="DELTA" oor:op="replace"> <prop oor:name="Char"> - <value>57517</value> + <value>916</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -182,12 +182,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="epsilon" oor:op="replace"> <prop oor:name="Char"> - <value>57531</value> + <value>1013</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -196,12 +196,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="EPSILON" oor:op="replace"> <prop oor:name="Char"> - <value>69</value> + <value>917</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -215,7 +215,7 @@ </node> <node oor:name="zeta" oor:op="replace"> <prop oor:name="Char"> - <value>57532</value> + <value>950</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -224,12 +224,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="ZETA" oor:op="replace"> <prop oor:name="Char"> - <value>90</value> + <value>918</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -243,7 +243,7 @@ </node> <node oor:name="eta" oor:op="replace"> <prop oor:name="Char"> - <value>57533</value> + <value>951</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -252,12 +252,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="ETA" oor:op="replace"> <prop oor:name="Char"> - <value>72</value> + <value>919</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -271,7 +271,7 @@ </node> <node oor:name="theta" oor:op="replace"> <prop oor:name="Char"> - <value>57534</value> + <value>952</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -280,12 +280,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="THETA" oor:op="replace"> <prop oor:name="Char"> - <value>57518</value> + <value>920</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -294,12 +294,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="iota" oor:op="replace"> <prop oor:name="Char"> - <value>57535</value> + <value>953</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -308,12 +308,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="IOTA" oor:op="replace"> <prop oor:name="Char"> - <value>73</value> + <value>921</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -327,7 +327,7 @@ </node> <node oor:name="kappa" oor:op="replace"> <prop oor:name="Char"> - <value>57536</value> + <value>954</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -336,12 +336,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="KAPPA" oor:op="replace"> <prop oor:name="Char"> - <value>75</value> + <value>922</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -355,7 +355,7 @@ </node> <node oor:name="lambda" oor:op="replace"> <prop oor:name="Char"> - <value>57537</value> + <value>955</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -364,12 +364,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="LAMBDA" oor:op="replace"> <prop oor:name="Char"> - <value>57519</value> + <value>923</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -378,12 +378,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="mu" oor:op="replace"> <prop oor:name="Char"> - <value>57538</value> + <value>956</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -392,12 +392,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="MU" oor:op="replace"> <prop oor:name="Char"> - <value>77</value> + <value>924</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -411,7 +411,7 @@ </node> <node oor:name="nu" oor:op="replace"> <prop oor:name="Char"> - <value>57539</value> + <value>957</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -420,12 +420,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="NU" oor:op="replace"> <prop oor:name="Char"> - <value>78</value> + <value>925</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -439,7 +439,7 @@ </node> <node oor:name="xi" oor:op="replace"> <prop oor:name="Char"> - <value>57540</value> + <value>958</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -448,12 +448,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="XI" oor:op="replace"> <prop oor:name="Char"> - <value>57520</value> + <value>926</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -462,12 +462,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="omicron" oor:op="replace"> <prop oor:name="Char"> - <value>57541</value> + <value>959</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -476,12 +476,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="OMICRON" oor:op="replace"> <prop oor:name="Char"> - <value>79</value> + <value>927</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -495,7 +495,7 @@ </node> <node oor:name="pi" oor:op="replace"> <prop oor:name="Char"> - <value>57542</value> + <value>960</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -504,12 +504,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="PI" oor:op="replace"> <prop oor:name="Char"> - <value>57521</value> + <value>928</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -518,12 +518,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="rho" oor:op="replace"> <prop oor:name="Char"> - <value>57543</value> + <value>961</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -532,12 +532,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="RHO" oor:op="replace"> <prop oor:name="Char"> - <value>80</value> + <value>929</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -551,7 +551,7 @@ </node> <node oor:name="sigma" oor:op="replace"> <prop oor:name="Char"> - <value>57544</value> + <value>963</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -560,12 +560,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="SIGMA" oor:op="replace"> <prop oor:name="Char"> - <value>57522</value> + <value>931</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -574,12 +574,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="tau" oor:op="replace"> <prop oor:name="Char"> - <value>57545</value> + <value>964</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -588,12 +588,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="TAU" oor:op="replace"> <prop oor:name="Char"> - <value>84</value> + <value>932</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -607,7 +607,7 @@ </node> <node oor:name="upsilon" oor:op="replace"> <prop oor:name="Char"> - <value>57546</value> + <value>965</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -616,12 +616,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="UPSILON" oor:op="replace"> <prop oor:name="Char"> - <value>57523</value> + <value>933</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -630,12 +630,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="phi" oor:op="replace"> <prop oor:name="Char"> - <value>57547</value> + <value>981</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -644,12 +644,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="PHI" oor:op="replace"> <prop oor:name="Char"> - <value>57524</value> + <value>934</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -658,12 +658,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="chi" oor:op="replace"> <prop oor:name="Char"> - <value>57548</value> + <value>967</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -672,12 +672,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="CHI" oor:op="replace"> <prop oor:name="Char"> - <value>88</value> + <value>935</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -691,7 +691,7 @@ </node> <node oor:name="psi" oor:op="replace"> <prop oor:name="Char"> - <value>57549</value> + <value>968</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -700,12 +700,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="PSI" oor:op="replace"> <prop oor:name="Char"> - <value>57525</value> + <value>936</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -714,12 +714,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="omega" oor:op="replace"> <prop oor:name="Char"> - <value>57550</value> + <value>969</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -728,12 +728,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="OMEGA" oor:op="replace"> <prop oor:name="Char"> - <value>57526</value> + <value>937</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -742,12 +742,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="varepsilon" oor:op="replace"> <prop oor:name="Char"> - <value>57551</value> + <value>949</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -756,12 +756,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="vartheta" oor:op="replace"> <prop oor:name="Char"> - <value>57552</value> + <value>977</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -770,12 +770,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="varpi" oor:op="replace"> <prop oor:name="Char"> - <value>57553</value> + <value>982</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -784,7 +784,7 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="varrho" oor:op="replace"> @@ -798,12 +798,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="varsigma" oor:op="replace"> <prop oor:name="Char"> - <value>57555</value> + <value>962</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -812,12 +812,12 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="varphi" oor:op="replace"> <prop oor:name="Char"> - <value>57556</value> + <value>966</value> </prop> <prop oor:name="Set"> <value>Greek</value> @@ -826,7 +826,7 @@ <value>true</value> </prop> <prop oor:name="FontFormatId"> - <value>Id1</value> + <value>Id2</value> </prop> </node> <node oor:name="element" oor:op="replace"> @@ -915,7 +915,7 @@ </node> <node oor:name="tendto" oor:op="replace"> <prop oor:name="Char"> - <value>57484</value> + <value>8594</value> </prop> <prop oor:name="Set"> <value>Special</value> @@ -985,7 +985,7 @@ </node> <node oor:name="perthousand" oor:op="replace"> <prop oor:name="Char"> - <value>57472</value> + <value>8240</value> </prop> <prop oor:name="Set"> <value>Special</value> diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu index 0ba86ef6b1aa..fa0611e07041 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu @@ -77,14 +77,6 @@ <value xml:lang="en-US">Foote~r</value> </prop> </node> - <node oor:name=".uno:PreviewPrintOptions" oor:op="replace"> - <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">Print options page view</value> - </prop> - <prop oor:name="Properties" oor:type="xs:int"> - <value>1</value> - </prop> - </node> <node oor:name=".uno:PreviewZoom" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Preview Zoom</value> @@ -911,7 +903,7 @@ </node> <node oor:name=".uno:PrintPagePreView" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> - <value xml:lang="en-US">Print page view</value> + <value xml:lang="en-US">Print document</value> </prop> <prop oor:name="Properties" oor:type="xs:int"> <value>1</value> diff --git a/officecfg/registry/data/org/openoffice/VCL.xcu b/officecfg/registry/data/org/openoffice/VCL.xcu index 2a17b4ecdd55..10dced44e44e 100644 --- a/officecfg/registry/data/org/openoffice/VCL.xcu +++ b/officecfg/registry/data/org/openoffice/VCL.xcu @@ -48,6 +48,14 @@ <value>false</value> </prop> </node> + <node oor:name="PrintDialog" oor:op="replace"> + <prop oor:name="Collate" oor:op="replace" oor:type="xs:string"> + <value>true</value> + </prop> + <prop oor:name="CollateBox" oor:op="replace" oor:type="xs:string"> + <value>Default</value> + </prop> + </node> </node> <node oor:name="DefaultFonts"> <node oor:name="en" oor:op="replace"> diff --git a/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs b/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs index cb684017c7c3..3755945df3f6 100644 --- a/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/DataAccess.xcs @@ -38,9 +38,9 @@ <info> <author>OJ</author> </info> - <group oor:name="DatabaseNameSetting"> + <group oor:name="DatabaseDocumentRegistration"> <info> - <desc>Describes how to establish a database connection and how to filter and layout the database data.</desc> + <desc>describes a single database document registration.</desc> </info> <prop oor:name="Name" oor:type="xs:string"> <info> @@ -310,9 +310,9 @@ </set> </group> - <set oor:name="RegisteredNames" oor:node-type="DatabaseNameSetting"> + <set oor:name="RegisteredNames" oor:node-type="DatabaseDocumentRegistration"> <info> - <desc>Specifies all names which are registered.</desc> + <desc>Specifies the database documents registered within OpenOffice.org, for quick access by a programmatic name.</desc> </info> </set> diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx index 6a6b6dbbbb4a..097525bd372e 100644 --- a/scripting/source/dlgprov/dlgevtatt.cxx +++ b/scripting/source/dlgprov/dlgevtatt.cxx @@ -32,14 +32,13 @@ #include "precompiled_scripting.hxx" #include "dlgevtatt.hxx" -#ifndef SCRIPTING_DLGPROV_HXX #include "dlgprov.hxx" -#endif + #include <sfx2/sfx.hrc> #include <sfx2/app.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif +#include <tools/diagnose_ex.h> + #include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/awt/XDialogEventHandler.hpp> #include <com/sun/star/awt/XContainerWindowEventHandler.hpp> @@ -53,6 +52,7 @@ #include <com/sun/star/reflection/XIdlMethod.hpp> #include <com/sun/star/beans/MethodConcept.hpp> #include <com/sun/star/beans/XMaterialHolder.hpp> + #ifdef FAKE_VBA_EVENT_SUPPORT #include <ooo/vba/XVBAToOOEventDescGen.hpp> #endif @@ -134,7 +134,10 @@ namespace dlgprov { xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= msDialogCodeName; } - catch ( Exception& ) {} + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } } @@ -149,7 +152,10 @@ namespace dlgprov { mxListener->firing( aScriptEventCopy ); } - catch( Exception& ) {} + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } } #endif @@ -248,17 +254,9 @@ namespace dlgprov if ( xListener_.is() ) bSuccess = true; } - catch ( IllegalArgumentException& ) - { - } - catch ( IntrospectionException& ) - { - } - catch ( CannotCreateAdapterException& ) - { - } - catch ( ServiceNotRegisteredException& ) + catch ( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } try @@ -271,17 +269,9 @@ namespace dlgprov aDesc.AddListenerParam, aDesc.EventMethod ); } } - catch( IllegalArgumentException& ) - { - } - catch( IntrospectionException& ) - { - } - catch( CannotCreateAdapterException& ) - { - } - catch( ServiceNotRegisteredException& ) + catch ( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } } @@ -495,15 +485,9 @@ namespace dlgprov } } } - catch ( RuntimeException& e ) - { - OSL_TRACE( "DialogScriptListenerImpl::firing_impl: caught RuntimeException reason %s", - ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); - } - catch ( Exception& e ) + catch ( const Exception& ) { - OSL_TRACE( "DialogScriptListenerImpl::firing_impl: caught Exception reason %s", - ::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer ); + DBG_UNHANDLED_EXCEPTION(); } } @@ -512,21 +496,21 @@ namespace dlgprov ::rtl::OUString sScriptURL; ::rtl::OUString sScriptCode( aScriptEvent.ScriptCode ); - if ( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 ) - { - // StarBasic script: convert ScriptCode to scriptURL - sal_Int32 nIndex = sScriptCode.indexOf( ':' ); - if ( nIndex >= 0 && nIndex < sScriptCode.getLength() ) + if ( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 ) { - sScriptURL = ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" ); - sScriptURL += sScriptCode.copy( nIndex + 1 ); - sScriptURL += ::rtl::OUString::createFromAscii( "?language=Basic&location=" ); - sScriptURL += sScriptCode.copy( 0, nIndex ); + // StarBasic script: convert ScriptCode to scriptURL + sal_Int32 nIndex = sScriptCode.indexOf( ':' ); + if ( nIndex >= 0 && nIndex < sScriptCode.getLength() ) + { + sScriptURL = ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" ); + sScriptURL += sScriptCode.copy( nIndex + 1 ); + sScriptURL += ::rtl::OUString::createFromAscii( "?language=Basic&location=" ); + sScriptURL += sScriptCode.copy( 0, nIndex ); + } + ScriptEvent aSFScriptEvent( aScriptEvent ); + aSFScriptEvent.ScriptCode = sScriptURL; + DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet ); } - ScriptEvent aSFScriptEvent( aScriptEvent ); - aSFScriptEvent.ScriptCode = sScriptURL; - DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet ); - } } void DialogUnoScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet ) @@ -603,12 +587,10 @@ namespace dlgprov bHandled = true; } } - catch( com::sun::star::lang::IllegalArgumentException& ) - {} - catch( com::sun::star::lang::NoSuchMethodException& ) - {} - catch( com::sun::star::reflection::InvocationTargetException& ) - {} + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } if( bHandled ) diff --git a/scripting/source/pyprov/mailmerge.py b/scripting/source/pyprov/mailmerge.py index 75d2db533708..c8f7b6765261 100644 --- a/scripting/source/pyprov/mailmerge.py +++ b/scripting/source/pyprov/mailmerge.py @@ -85,8 +85,8 @@ class PyMailSMTPService(unohelper.Base, XSmtpService): self.server.starttls() self.server.ehlo() - user = xAuthenticator.getUserName() - password = xAuthenticator.getPassword() + user = xAuthenticator.getUserName().encode('ascii') + password = xAuthenticator.getPassword().encode('ascii') if user != '': if dbg: print >> sys.stderr, 'Logging in, username of', user @@ -234,8 +234,8 @@ class PyMailIMAPService(unohelper.Base, XMailService): self.server = imaplib.IMAP4(server, port) print >> sys.stderr, "AFTER" - user = xAuthenticator.getUserName() - password = xAuthenticator.getPassword() + user = xAuthenticator.getUserName().encode('ascii') + password = xAuthenticator.getPassword().encode('ascii') if user != '': if dbg: print >> sys.stderr, 'Logging in, username of', user @@ -302,8 +302,8 @@ class PyMailPOP3Service(unohelper.Base, XMailService): self.server = poplib.POP3(server, port) print >> sys.stderr, "AFTER" - user = xAuthenticator.getUserName() - password = xAuthenticator.getPassword() + user = xAuthenticator.getUserName().encode('ascii') + password = xAuthenticator.getPassword().encode('ascii') if dbg: print >> sys.stderr, 'Logging in, username of', user self.server.user(user) diff --git a/sfx2/inc/sfx2/event.hxx b/sfx2/inc/sfx2/event.hxx index 10e586030f52..79f1d34ee82c 100644 --- a/sfx2/inc/sfx2/event.hxx +++ b/sfx2/inc/sfx2/event.hxx @@ -102,30 +102,21 @@ class PrintDialog; class Printer; class SfxPrintingHint : public SfxHint { - PrintDialog* pDialog; - Printer* pPrinter; sal_Int32 nWhich; com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aOpts; public: TYPEINFO(); - SfxPrintingHint( sal_Int32 nEvent, PrintDialog* pDlg, Printer* pPrt, const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& rOpts ) - : pDialog( pDlg ) - , pPrinter( pPrt ) - , nWhich( nEvent ) + SfxPrintingHint( sal_Int32 nEvent, const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& rOpts ) + : nWhich( nEvent ) , aOpts( rOpts ) {} - SfxPrintingHint( sal_Int32 nEvent, PrintDialog* pDlg, Printer* pPrt ) - : pDialog( pDlg ) - , pPrinter( pPrt ) - , nWhich( nEvent ) + SfxPrintingHint( sal_Int32 nEvent ) + : nWhich( nEvent ) {} - - Printer* GetPrinter() const { return pPrinter; } - PrintDialog* GetPrintDialog() const { return pDialog; } sal_Int32 GetWhich() const { return nWhich; } - const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& GetAdditionalOptions() { return aOpts; } + const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& GetOptions() { return aOpts; } }; #endif diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 880494057714..1dab10abb842 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -592,7 +592,7 @@ public: sal_uInt16 nIdx2 = INDEX_IGNORE, sal_uInt16 nIdx3 = INDEX_IGNORE); - virtual sal_Bool Print( Printer &rPrt, + sal_Bool Print( Printer &rPrt, sal_uInt16 nIdx1, sal_uInt16 nIdx2 = INDEX_IGNORE, sal_uInt16 nIdx3 = INDEX_IGNORE, diff --git a/sfx2/inc/sfx2/prnmon.hxx b/sfx2/inc/sfx2/prnmon.hxx index ad47f6ce2633..376a599edef4 100644 --- a/sfx2/inc/sfx2/prnmon.hxx +++ b/sfx2/inc/sfx2/prnmon.hxx @@ -33,17 +33,13 @@ #include "sal/config.h" #include "sfx2/dllapi.h" -#ifndef _BUTTON_HXX //autogen #include <vcl/button.hxx> -#endif -#ifndef _DIALOG_HXX //autogen #include <vcl/dialog.hxx> -#endif #include <sfx2/printer.hxx> -#include <sfx2/progress.hxx> +//#include <sfx2/progress.hxx> class SfxViewShell; -class SfxProgress; +//class SfxProgress; struct SfxPrintProgress_Impl; // ------------------------------------------------------------------------ @@ -51,7 +47,7 @@ struct SfxPrintProgress_Impl; #define PAGE_MAX 9999 //max. Anzahl der Seiten die gedruckt werden //-------------------------------------------------------------------- - +/* class SFX2_DLLPUBLIC SfxPrintProgress: public SfxProgress { SfxPrintProgress_Impl* pImp; @@ -78,7 +74,7 @@ public: void SetCancelHdl( const Link& aCancelHdl ); BOOL IsAborted() const; }; - +*/ // ------------------------------------------------------------------------ struct SfxPrintOptDlg_Impl; diff --git a/sfx2/inc/sfx2/sfxbasecontroller.hxx b/sfx2/inc/sfx2/sfxbasecontroller.hxx index c952e550996e..3debe10f001d 100644 --- a/sfx2/inc/sfx2/sfxbasecontroller.hxx +++ b/sfx2/inc/sfx2/sfxbasecontroller.hxx @@ -493,7 +493,9 @@ public: virtual void SAL_CALL removeTitleChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTitleChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); //#if 0 // _SOLAR__PRIVATE - SAL_DLLPRIVATE SfxViewShell* GetViewShell_Impl() const; + // FIXME: TL needs this in sw/source/ui/uno/unotxdoc.cxx now; + // either the _Impl name should vanish or there should be an "official" API + SfxViewShell* GetViewShell_Impl() const; SAL_DLLPRIVATE BOOL HandleEvent_Impl( NotifyEvent& rEvent ); SAL_DLLPRIVATE BOOL HasKeyListeners_Impl(); SAL_DLLPRIVATE BOOL HasMouseClickListeners_Impl(); diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index cfb3c6824447..dcbed691e668 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -806,7 +806,7 @@ #define SID_HELP_PI (SID_SFX_START + 962) #define SID_BASIC_ENABLED (SID_SFX_START + 964) #define SID_EXPORT_DIALOG (SID_SFX_START + 965) -#define SID_IMPORT_DIALOG (SID_SFX_START + 966)
+#define SID_IMPORT_DIALOG (SID_SFX_START + 966) #define SID_BASICBREAK (SID_SFX_START +1521) diff --git a/sfx2/inc/sfx2/viewfrm.hxx b/sfx2/inc/sfx2/viewfrm.hxx index 0fa9b92de7fc..396a948a03cc 100644 --- a/sfx2/inc/sfx2/viewfrm.hxx +++ b/sfx2/inc/sfx2/viewfrm.hxx @@ -212,7 +212,7 @@ public: const Point &rPos, const Size &rSize ); void Hide(); void Show(); - BOOL IsVisible_Impl() const; + BOOL IsVisible() const; void ToTop(); void Enable( BOOL bEnable ); virtual BOOL Close(); diff --git a/sfx2/inc/sfx2/viewsh.hxx b/sfx2/inc/sfx2/viewsh.hxx index 83ac73dbdd80..e3a5ae5adb8e 100644 --- a/sfx2/inc/sfx2/viewsh.hxx +++ b/sfx2/inc/sfx2/viewsh.hxx @@ -35,6 +35,7 @@ #include "sal/types.h" #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/view/XRenderable.hpp> #include <com/sun/star/uno/Reference.h> #include <svl/lstner.hxx> #include <com/sun/star/ui/XContextMenuInterceptor.hpp> @@ -43,6 +44,7 @@ #include "shell.hxx" #include <tools/gen.hxx> #include <tools/errcode.hxx> +#include <vcl/jobset.hxx> class SfxBaseController; class Size; class Fraction; @@ -269,6 +271,7 @@ public: virtual PrintDialog* CreatePrintDialog( Window *pParent ); void LockPrinter( BOOL bLock = TRUE ); BOOL IsPrinterLocked() const; + virtual JobSetup GetJobSetup() const; // Workingset virtual void WriteUserData( String&, BOOL bBrowse = FALSE ); @@ -289,6 +292,11 @@ public: */ void SetCurrentDocument() const; + /** get an XRenderable instance that can render this docuement + */ + virtual com::sun::star::uno::Reference< com::sun::star::view::XRenderable > GetRenderable(); + + virtual void MarginChanged(); const Size& GetMargin() const; void SetMargin( const Size& ); @@ -305,6 +313,7 @@ public: BOOL TryContextMenuInterception( Menu& rIn, const ::rtl::OUString& rMenuIdentifier, Menu*& rpOut, ::com::sun::star::ui::ContextMenuExecuteEvent aEvent ); void SetAdditionalPrintOptions( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& ); + void ExecPrint( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, sal_Bool, sal_Bool ); void AddRemoveClipboardListener( const com::sun::star::uno::Reference < com::sun::star::datatransfer::clipboard::XClipboardListener>&, BOOL ); diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx index bf3cb633cf6a..469a198db64e 100644 --- a/sfx2/source/appl/appopen.cxx +++ b/sfx2/source/appl/appopen.cxx @@ -216,7 +216,7 @@ SfxObjectShellRef SfxApplication::DocAlreadyLoaded SfxTopViewFrame *pFrame; for( pFrame = (SfxTopViewFrame*) SfxViewFrame::GetFirst( xDoc, TYPE(SfxTopViewFrame) ); - pFrame && !pFrame->IsVisible_Impl(); + pFrame && !pFrame->IsVisible(); pFrame = (SfxTopViewFrame*) SfxViewFrame::GetNext( *pFrame, xDoc, TYPE(SfxTopViewFrame) ) ) ; if ( pFrame ) diff --git a/sfx2/source/control/shell.cxx b/sfx2/source/control/shell.cxx index 7c88c4bef24a..aee76353f1f3 100644 --- a/sfx2/source/control/shell.cxx +++ b/sfx2/source/control/shell.cxx @@ -1260,7 +1260,7 @@ long DispatcherUpdate_Impl( void*, void* pArg ) void SfxShell::UIFeatureChanged() { SfxViewFrame *pFrame = GetFrame(); - if ( pFrame && pFrame->IsVisible_Impl() ) + if ( pFrame && pFrame->IsVisible() ) { // Auch dann Update erzwingen, wenn Dispatcher schon geupdated ist, // sonst bleibt evtl. irgendwas in den gebunkerten Tools stecken. diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 683aedcbf32f..f8a77e721533 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -801,7 +801,9 @@ IMPL_LINK( FileDialogHelper_Impl, TimeOutHdl_Impl, Timer*, EMPTYARG ) aData << aBmp; - Sequence < sal_Int8 > aBuffer( (sal_Int8*) aData.GetData(), aData.GetSize() ); + const Sequence < sal_Int8 > aBuffer( + static_cast< const sal_Int8* >(aData.GetData()), + aData.GetEndOfData() ); aAny <<= aBuffer; } diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx index 5273f1b27779..9f4f489c836c 100644 --- a/sfx2/source/doc/objcont.cxx +++ b/sfx2/source/doc/objcont.cxx @@ -62,6 +62,7 @@ #include <unotools/useroptions.hxx> #include <unotools/localfilehelper.hxx> #include <vcl/virdev.hxx> +#include <vcl/oldprintadaptor.hxx> #include <sfx2/app.hxx> #include "sfxresid.hxx" @@ -1018,26 +1019,18 @@ BOOL SfxObjectShell::Print if ( !pStyle ) return TRUE; - if ( !rPrt.StartJob(String(SfxResId(STR_STYLES))) ) - { - delete pIter; - return FALSE; - } - if ( !rPrt.StartPage() ) - { - delete pIter; - return FALSE; - } - Reference< task::XStatusIndicator > xStatusIndicator; - xStatusIndicator = SFX_APP()->GetStatusIndicator(); - if ( xStatusIndicator.is() ) - xStatusIndicator->start( String(SfxResId(STR_PRINT_STYLES)), nStyles ); + // pepare adaptor for old style StartPage/EndPage printing + boost::shared_ptr< Printer > pPrinter( new Printer( rPrt.GetJobSetup() ) ); + vcl::OldStylePrintAdaptor* pAdaptor = new vcl::OldStylePrintAdaptor( pPrinter ); + boost::shared_ptr< vcl::PrinterController > pController( pAdaptor ); - rPrt.SetMapMode(MapMode(MAP_10TH_MM)); + pAdaptor->StartPage(); + + pPrinter->SetMapMode(MapMode(MAP_10TH_MM)); Font aFont( DEFINE_CONST_UNICODE( "Arial" ), Size(0, 64)); // 18pt aFont.SetWeight(WEIGHT_BOLD); - rPrt.SetFont(aFont); - const Size aPageSize(rPrt.GetOutputSize()); + pPrinter->SetFont(aFont); + const Size aPageSize(pPrinter->GetOutputSize()); const USHORT nXIndent = 200; USHORT nYIndent = 200; Point aOutPos(nXIndent, nYIndent); @@ -1046,68 +1039,66 @@ BOOL SfxObjectShell::Print aHeader += *pObjectName; else aHeader += GetTitle(); - long nTextHeight( rPrt.GetTextHeight() ); - rPrt.DrawText(aOutPos, aHeader); + long nTextHeight( pPrinter->GetTextHeight() ); + pPrinter->DrawText(aOutPos, aHeader); aOutPos.Y() += nTextHeight; aOutPos.Y() += nTextHeight/2; aFont.SetSize(Size(0, 35)); // 10pt nStyles = 1; while(pStyle) { - if ( xStatusIndicator.is() ) - xStatusIndicator->setValue( nStyles++ ); - // Ausgabe des Vorlagennamens + // print template name String aStr(pStyle->GetName()); aFont.SetWeight(WEIGHT_BOLD); - rPrt.SetFont(aFont); - nTextHeight = rPrt.GetTextHeight(); - // Seitenwechsel + pPrinter->SetFont(aFont); + nTextHeight = pPrinter->GetTextHeight(); + // check for new page if ( aOutPos.Y() + nTextHeight*2 > aPageSize.Height() - (long) nYIndent ) { - rPrt.EndPage(); - rPrt.StartPage(); + pAdaptor->EndPage(); + pAdaptor->StartPage(); aOutPos.Y() = nYIndent; } - rPrt.DrawText(aOutPos, aStr); + pPrinter->DrawText(aOutPos, aStr); aOutPos.Y() += nTextHeight; - // Ausgabe der Vorlagenbeschreibung + // print template description aFont.SetWeight(WEIGHT_NORMAL); - rPrt.SetFont(aFont); + pPrinter->SetFont(aFont); aStr = pStyle->GetDescription(); const char cDelim = ' '; USHORT nStart = 0, nIdx = 0; - nTextHeight = rPrt.GetTextHeight(); - // wie viele Worte passen auf eine Zeile + nTextHeight = pPrinter->GetTextHeight(); + // break text into lines while(nIdx < aStr.Len()) { USHORT nOld = nIdx; long nTextWidth; nIdx = aStr.Search(cDelim, nStart); - nTextWidth = rPrt.GetTextWidth(aStr, nStart, nIdx-nStart); + nTextWidth = pPrinter->GetTextWidth(aStr, nStart, nIdx-nStart); while(nIdx != STRING_NOTFOUND && aOutPos.X() + nTextWidth < aPageSize.Width() - (long) nXIndent) { nOld = nIdx; nIdx = aStr.Search(cDelim, nIdx+1); - nTextWidth = rPrt.GetTextWidth(aStr, nStart, nIdx-nStart); + nTextWidth = pPrinter->GetTextWidth(aStr, nStart, nIdx-nStart); } String aTmp(aStr, nStart, nIdx == STRING_NOTFOUND? STRING_LEN : nOld-nStart); if ( aTmp.Len() ) { - nStart = nOld+1; // wegen trailing space + nStart = nOld+1; // trailing space } else { USHORT nChar = 1; while( nStart + nChar < aStr.Len() && - aOutPos.X() + rPrt.GetTextWidth( + aOutPos.X() + pPrinter->GetTextWidth( aStr, nStart, nChar) < aPageSize.Width() - nXIndent) ++nChar; @@ -1118,19 +1109,19 @@ BOOL SfxObjectShell::Print if ( aOutPos.Y() + nTextHeight*2 > aPageSize.Height() - nYIndent ) { - rPrt.EndPage(); - rPrt.StartPage(); + pAdaptor->EndPage(); + pAdaptor->StartPage(); aOutPos.Y() = nYIndent; } - rPrt.DrawText(aOutPos, aTmp); - aOutPos.Y() += rPrt.GetTextHeight(); + pPrinter->DrawText(aOutPos, aTmp); + aOutPos.Y() += pPrinter->GetTextHeight(); } pStyle = pIter->Next(); } - rPrt.EndPage(); - rPrt.EndJob(); - if ( xStatusIndicator.is() ) - xStatusIndicator->end(); + pAdaptor->EndPage(); + + Printer::PrintJob( pController, rPrt.GetJobSetup() ); + delete pIter; break; } diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx index d61bd4701e1b..103dcf505846 100755 --- a/sfx2/source/doc/printhelper.cxx +++ b/sfx2/source/doc/printhelper.cxx @@ -42,6 +42,7 @@ #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/lang/EventObject.hpp> +#include <com/sun/star/view/DuplexMode.hpp> #include <svl/lstner.hxx> #include <svl/stritem.hxx> @@ -148,8 +149,9 @@ Reference< ::com::sun::star::view::XPrintable > SAL_CALL SfxPrintJob_Impl::getPr void SAL_CALL SfxPrintJob_Impl::cancelJob() throw (RuntimeException) { + // FIXME: how to cancel PrintJob via API?! if( m_pData->m_pObjectShell.Is() ) - m_pData->m_pObjectShell->Broadcast( SfxPrintingHint( -2, NULL, NULL ) ); + m_pData->m_pObjectShell->Broadcast( SfxPrintingHint( -2 ) ); } SfxPrintHelper::SfxPrintHelper() @@ -590,7 +592,7 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& if ( !pView ) return; - SfxAllItemSet aArgs( pView->GetPool() ); +// SfxAllItemSet aArgs( pView->GetPool() ); sal_Bool bMonitor = sal_False; // We need this information at the end of this method, if we start the vcl printer // by executing the slot. Because if it is a ucb relevant URL we must wait for @@ -601,7 +603,10 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& String sUcbUrl; ::utl::TempFile* pUCBPrintTempFile = NULL; - sal_Bool bWaitUntilEnd = sal_False; + uno::Sequence < beans::PropertyValue > aCheckedArgs( rOptions.getLength() ); + sal_Int32 nProps = 0; + sal_Bool bWaitUntilEnd = sal_False; + sal_Int16 nDuplexMode = ::com::sun::star::view::DuplexMode::UNKNOWN; for ( int n = 0; n < rOptions.getLength(); ++n ) { // get Property-Value from options @@ -634,10 +639,15 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& // converted its not an URL nor a system path. Then we can't accept // this parameter and have to throw an exception. ::rtl::OUString sSystemPath(sTemp); - ::rtl::OUString sFileURL ; + ::rtl::OUString sFileURL; if (::osl::FileBase::getFileURLFromSystemPath(sSystemPath,sFileURL)!=::osl::FileBase::E_None) throw ::com::sun::star::lang::IllegalArgumentException(); - aArgs.Put( SfxStringItem(SID_FILE_NAME,sTemp) ); + aCheckedArgs[nProps].Name = rProp.Name; + aCheckedArgs[nProps++].Value <<= sFileURL; + // and append the local filename + aCheckedArgs.realloc( aCheckedArgs.getLength()+1 ); + aCheckedArgs[nProps].Name = rtl::OUString::createFromAscii("LocalFileName"); + aCheckedArgs[nProps++].Value <<= ::rtl::OUString( sTemp ); } else // It's a valid URL. but now we must know, if it is a local one or not. @@ -648,7 +658,12 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& // And we have to use the system notation of the incoming URL. // But it into the descriptor and let the slot be executed at // the end of this method. - aArgs.Put( SfxStringItem(SID_FILE_NAME,sPath) ); + aCheckedArgs[nProps].Name = rProp.Name; + aCheckedArgs[nProps++].Value <<= sTemp; + // and append the local filename + aCheckedArgs.realloc( aCheckedArgs.getLength()+1 ); + aCheckedArgs[nProps].Name = rtl::OUString::createFromAscii("LocalFileName"); + aCheckedArgs[nProps++].Value <<= ::rtl::OUString( sPath ); } else { @@ -663,7 +678,10 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& // a slot ... pUCBPrintTempFile = new ::utl::TempFile(); pUCBPrintTempFile->EnableKillingFile(); - aArgs.Put( SfxStringItem(SID_FILE_NAME,pUCBPrintTempFile->GetFileName()) ); + + //FIXME: does it work? + aCheckedArgs[nProps].Name = rtl::OUString::createFromAscii("LocalFileName"); + aCheckedArgs[nProps++].Value <<= ::rtl::OUString( pUCBPrintTempFile->GetFileName() ); sUcbUrl = sURL; } } @@ -674,25 +692,22 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& sal_Int32 nCopies = 0; if ( ( rProp.Value >>= nCopies ) == sal_False ) throw ::com::sun::star::lang::IllegalArgumentException(); - aArgs.Put( SfxInt16Item( SID_PRINT_COPIES, (USHORT) nCopies ) ); + + aCheckedArgs[nProps].Name = rProp.Name; + aCheckedArgs[nProps++].Value <<= nCopies; } // Collate-Property - else if ( rProp.Name.compareToAscii( "Collate" ) == 0 ) + // Sort-Property (deprecated) + else if ( rProp.Name.compareToAscii( "Collate" ) == 0 || + ( rProp.Name.compareToAscii( "Sort" ) == 0 ) ) { sal_Bool bTemp = sal_Bool(); if ( rProp.Value >>= bTemp ) - aArgs.Put( SfxBoolItem( SID_PRINT_COLLATE, bTemp ) ); - else - throw ::com::sun::star::lang::IllegalArgumentException(); - } - - // Sort-Property - else if ( rProp.Name.compareToAscii( "Sort" ) == 0 ) - { - sal_Bool bTemp = sal_Bool(); - if( rProp.Value >>= bTemp ) - aArgs.Put( SfxBoolItem( SID_PRINT_SORT, bTemp ) ); + { + aCheckedArgs[nProps].Name = rtl::OUString::createFromAscii("Collate"); + aCheckedArgs[nProps++].Value <<= bTemp; + } else throw ::com::sun::star::lang::IllegalArgumentException(); } @@ -702,7 +717,10 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& { OUSTRING sTemp; if( rProp.Value >>= sTemp ) - aArgs.Put( SfxStringItem( SID_PRINT_PAGES, String( sTemp ) ) ); + { + aCheckedArgs[nProps].Name = rProp.Name; + aCheckedArgs[nProps++].Value <<= sTemp; + } else throw ::com::sun::star::lang::IllegalArgumentException(); } @@ -712,26 +730,36 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >& { if( !(rProp.Value >>= bMonitor) ) throw ::com::sun::star::lang::IllegalArgumentException(); + aCheckedArgs[nProps].Name = rProp.Name; + aCheckedArgs[nProps++].Value <<= bMonitor; } - // MonitorVisible + // Wait else if ( rProp.Name.compareToAscii( "Wait" ) == 0 ) { if ( !(rProp.Value >>= bWaitUntilEnd) ) throw ::com::sun::star::lang::IllegalArgumentException(); + aCheckedArgs[nProps].Name = rProp.Name; + aCheckedArgs[nProps++].Value <<= bWaitUntilEnd; + } + + else if ( rProp.Name.compareToAscii( "DuplexMode" ) == 0 ) + { + if ( !(rProp.Value >>= nDuplexMode ) ) + throw ::com::sun::star::lang::IllegalArgumentException(); + aCheckedArgs[nProps].Name = rProp.Name; + aCheckedArgs[nProps++].Value <<= nDuplexMode; } } + if ( nProps != aCheckedArgs.getLength() ) + aCheckedArgs.realloc(nProps); + // Execute the print request every time. // It doesn'tmatter if it is a real printer used or we print to a local file // nor if we print to a temp file and move it afterwards by using the ucb. // That will be handled later. see pUCBPrintFile below! - aArgs.Put( SfxBoolItem( SID_SILENT, !bMonitor ) ); - if ( bWaitUntilEnd ) - aArgs.Put( SfxBoolItem( SID_ASYNCHRON, sal_False ) ); - SfxRequest aReq( SID_PRINTDOC, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_API, pView->GetPool() ); - aReq.SetArgs( aArgs ); - pView->ExecuteSlot( aReq ); + pView->ExecPrint( aCheckedArgs, sal_True, sal_False ); // Ok - may be execution before has finished (or started!) printing. // And may it was a printing to a file. @@ -764,11 +792,11 @@ void IMPL_PrintListener_DataContainer::Notify( SfxBroadcaster& rBC, const SfxHin SfxPrintingHint* pPrintHint = PTR_CAST( SfxPrintingHint, &rHint ); if ( pPrintHint ) { - if ( pPrintHint->GetWhich() == -1 ) // -1 : Initialisation of PrintOptions + if ( pPrintHint->GetWhich() == com::sun::star::view::PrintableState_JOB_STARTED ) { if ( !m_xPrintJob.is() ) m_xPrintJob = new SfxPrintJob_Impl( this ); - +/* PrintDialog* pDlg = pPrintHint->GetPrintDialog(); Printer* pPrinter = pPrintHint->GetPrinter(); ::rtl::OUString aPrintFile ( ( pPrinter && pPrinter->IsPrintFileEnabled() ) ? pPrinter->GetPrintFile() : String() ); @@ -805,7 +833,10 @@ void IMPL_PrintListener_DataContainer::Notify( SfxBroadcaster& rBC, const SfxHin m_aPrintOptions[nArgs-1].Name = DEFINE_CONST_UNICODE("FileName"); m_aPrintOptions[nArgs-1].Value <<= aPrintFile; } +*/ + m_aPrintOptions = pPrintHint->GetOptions(); } +/* else if ( pPrintHint->GetWhich() == -3 ) // -3 : AdditionalPrintOptions { uno::Sequence < beans::PropertyValue >& lOldOpts = m_aPrintOptions; @@ -839,6 +870,7 @@ void IMPL_PrintListener_DataContainer::Notify( SfxBroadcaster& rBC, const SfxHin // at least one new options has overwritten an old one, so we allocated too much lOldOpts.realloc( nTotal ); } +*/ else if ( pPrintHint->GetWhich() != -2 ) // -2 : CancelPrintJob { view::PrintJobEvent aEvent; diff --git a/sfx2/source/view/makefile.mk b/sfx2/source/view/makefile.mk index 98d34215e097..cad12052720c 100644 --- a/sfx2/source/view/makefile.mk +++ b/sfx2/source/view/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite @@ -54,7 +54,6 @@ SLOFILES = \ $(SLO)$/frmload.obj \ $(SLO)$/frame.obj \ $(SLO)$/printer.obj \ - $(SLO)$/prnmon.obj \ $(SLO)$/viewprn.obj \ $(SLO)$/viewfac.obj \ $(SLO)$/orgmgr.obj \ diff --git a/sfx2/source/view/printer.cxx b/sfx2/source/view/printer.cxx index 1ea49ecd879b..2b7f89eac7c4 100644 --- a/sfx2/source/view/printer.cxx +++ b/sfx2/source/view/printer.cxx @@ -546,14 +546,17 @@ SfxPrintOptionsDialog::SfxPrintOptionsDialog( Window *pParent, // TabPage einh"angen pPage = pViewSh->CreatePrintOptionsPage( this, *pOptions ); DBG_ASSERT( pPage, "CreatePrintOptions != SFX_VIEW_HAS_PRINTOPTIONS" ); - pPage->Reset( *pOptions ); - SetHelpId( pPage->GetHelpId() ); - pPage->Show(); + if( pPage ) + { + pPage->Reset( *pOptions ); + SetHelpId( pPage->GetHelpId() ); + pPage->Show(); + } // Dialoggr"o\se bestimmen Size a6Sz = LogicToPixel( Size( 6, 6 ), MAP_APPFONT ); Size aBtnSz = LogicToPixel( Size( 50, 14 ), MAP_APPFONT ); - Size aOutSz( pPage->GetSizePixel() ); + Size aOutSz( pPage ? pPage->GetSizePixel() : Size() ); aOutSz.Height() += 6; long nWidth = aBtnSz.Width(); nWidth += a6Sz.Width(); @@ -589,6 +592,9 @@ SfxPrintOptionsDialog::~SfxPrintOptionsDialog() short SfxPrintOptionsDialog::Execute() { + if( ! pPage ) + return RET_CANCEL; + short nRet = ModalDialog::Execute(); if ( nRet == RET_OK ) pPage->FillItemSet( *pOptions ); diff --git a/sfx2/source/view/prnmon.cxx b/sfx2/source/view/prnmon.cxx index f875143bfab0..de075647ab48 100644 --- a/sfx2/source/view/prnmon.cxx +++ b/sfx2/source/view/prnmon.cxx @@ -274,10 +274,12 @@ SfxPrintProgress::SfxPrintProgress( SfxViewShell* pViewSh, FASTBOOL bShow ) String(SfxResId(STR_PRINTING)), 1, FALSE ), pImp( new SfxPrintProgress_Impl( pViewSh, pViewSh->GetPrinter() ) ) { + #if 0 pImp->pPrinter->SetEndPrintHdl( LINK( this, SfxPrintProgress, EndPrintNotify ) ); pImp->pPrinter->SetErrorHdl( LINK( this, SfxPrintProgress, PrintErrorNotify ) ); pImp->pPrinter->SetStartPrintHdl( LINK( this, SfxPrintProgress, StartPrintNotify ) ); pImp->bCallbacks = TRUE; + #endif SfxObjectShell* pDoc = pViewSh->GetObjectShell(); SFX_ITEMSET_ARG( pDoc->GetMedium()->GetItemSet(), pItem, SfxBoolItem, SID_HIDDEN, FALSE ); @@ -307,7 +309,7 @@ SfxPrintProgress::~SfxPrintProgress() // ggf. Callbacks entfermen if ( pImp->bCallbacks ) { - pImp->pPrinter->SetEndPrintHdl( Link() ); + // pImp->pPrinter->SetEndPrintHdl( Link() ); pImp->pPrinter->SetErrorHdl( Link() ); pImp->bCallbacks = FALSE; } @@ -410,7 +412,7 @@ IMPL_LINK( SfxPrintProgress, EndPrintNotify, void *, EMPTYARG ) //! if( pMDI->IsPrinterChanged() ) pMDI->Changed( 0L ); // Callbacks rausnehmen - pImp->pPrinter->SetEndPrintHdl( Link() ); + // pImp->pPrinter->SetEndPrintHdl( Link() ); pImp->pPrinter->SetErrorHdl( Link() ); pImp->bCallbacks = FALSE; diff --git a/sfx2/source/view/topfrm.cxx b/sfx2/source/view/topfrm.cxx index f3596de6b1c2..6f5c2ffcc3eb 100644 --- a/sfx2/source/view/topfrm.cxx +++ b/sfx2/source/view/topfrm.cxx @@ -370,7 +370,7 @@ void SfxTopViewWin_Impl::StateChanged( StateChangedType nStateChange ) if ( nStateChange == STATE_CHANGE_INITSHOW ) { SfxObjectShell* pDoc = pFrame->GetObjectShell(); - if ( pDoc && !pFrame->IsVisible_Impl() ) + if ( pDoc && !pFrame->IsVisible() ) pFrame->Show(); pFrame->Resize(); diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx index 945419189b78..ba87f0fc33ca 100644 --- a/sfx2/source/view/viewfrm.cxx +++ b/sfx2/source/view/viewfrm.cxx @@ -1331,7 +1331,7 @@ String SfxViewFrame::UpdateTitle() // Name des SbxObjects String aSbxName = pObjSh->SfxShell::GetName(); - if ( IsVisible_Impl() ) + if ( IsVisible() ) { aSbxName += ':'; aSbxName += String::CreateFromInt32(pImp->nDocViewNo); @@ -1801,7 +1801,7 @@ sal_uInt16 SfxViewFrame::Count(TypeId aType) { SfxViewFrame *pFrame = rFrames[i]; if ( ( !aType || pFrame->IsA(aType) ) && - pFrame->IsVisible_Impl() ) + pFrame->IsVisible() ) ++nFound; } return nFound; @@ -1825,7 +1825,7 @@ SfxViewFrame* SfxViewFrame::GetFirst SfxViewFrame *pFrame = rFrames.GetObject(nPos); if ( ( !pDoc || pDoc == pFrame->GetObjectShell() ) && ( !aType || pFrame->IsA(aType) ) && - ( !bOnlyIfVisible || pFrame->IsVisible_Impl()) ) + ( !bOnlyIfVisible || pFrame->IsVisible()) ) return pFrame; } @@ -1857,7 +1857,7 @@ SfxViewFrame* SfxViewFrame::GetNext SfxViewFrame *pFrame = rFrames.GetObject(nPos); if ( ( !pDoc || pDoc == pFrame->GetObjectShell() ) && ( !aType || pFrame->IsA(aType) ) && - ( !bOnlyIfVisible || pFrame->IsVisible_Impl()) ) + ( !bOnlyIfVisible || pFrame->IsVisible()) ) return pFrame; } return 0; @@ -1870,7 +1870,7 @@ void SfxViewFrame::CloseHiddenFrames_Impl() for ( sal_uInt16 nPos=0; nPos<rFrames.Count(); ) { SfxViewFrame *pFrame = rFrames.GetObject(nPos); - if ( !pFrame->IsVisible_Impl() ) + if ( !pFrame->IsVisible() ) pFrame->DoClose(); else nPos++; @@ -2142,7 +2142,7 @@ void SfxViewFrame::Show() } //-------------------------------------------------------------------- -sal_Bool SfxViewFrame::IsVisible_Impl() const +sal_Bool SfxViewFrame::IsVisible() const { //Window *pWin = pImp->bInCtor ? 0 : &GetWindow(); //return GetFrame()->HasComponent() || pImp->bObjLocked || ( pWin && pWin->IsVisible() ); @@ -2172,7 +2172,7 @@ void SfxViewFrame::MakeActive_Impl( BOOL bGrabFocus ) { if ( GetViewShell() && !GetFrame()->IsClosing_Impl() ) { - if ( IsVisible_Impl() ) + if ( IsVisible() ) { if ( GetViewShell() ) { diff --git a/sfx2/source/view/viewimp.hxx b/sfx2/source/view/viewimp.hxx index 97f86ee1f395..9e3791340daa 100644 --- a/sfx2/source/view/viewimp.hxx +++ b/sfx2/source/view/viewimp.hxx @@ -58,6 +58,7 @@ typedef SfxShell* SfxShellPtr_Impl; SV_DECL_PTRARR( SfxShellArr_Impl, SfxShellPtr_Impl, 4, 4 ) // struct SfxViewShell_Impl ---------------------------------------------- +#if 0 class SfxAsyncPrintExec_Impl : public SfxListener { SfxViewShell* pView; @@ -72,6 +73,7 @@ public: void AddRequest( SfxRequest& rReq ); }; +#endif class SfxClipboardChangeListener; @@ -98,7 +100,7 @@ struct SfxViewShell_Impl USHORT nFamily; SfxBaseController* pController; ::svt::AcceleratorExecute* pAccExec; - SfxAsyncPrintExec_Impl* pPrinterCommandQueue; +// SfxAsyncPrintExec_Impl* pPrinterCommandQueue; com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > aPrintOpts; ::rtl::Reference< SfxClipboardChangeListener > xClipboardListener; diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index e4a53a8a6e7a..24d31337a662 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -33,16 +33,12 @@ #include <com/sun/star/document/XDocumentProperties.hpp> #include <com/sun/star/view/PrintableState.hpp> +#include "com/sun/star/view/XRenderable.hpp" + #include <svl/itempool.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif -#ifndef _SV_PRINTDLG_HXX //autogen #include <svtools/printdlg.hxx> -#endif -#ifndef _SV_PRNSETUP_HXX //autogen #include <svtools/prnsetup.hxx> -#endif #include <svl/flagitem.hxx> #include <svl/stritem.hxx> #include <svl/intitem.hxx> @@ -51,9 +47,9 @@ #include <unotools/useroptions.hxx> #include <unotools/printwarningoptions.hxx> #include <tools/datetime.hxx> - +#include <sfx2/bindings.hxx> +#include <sfx2/objface.hxx> #include <sfx2/viewsh.hxx> -#include <sfx2/dispatch.hxx> #include "viewimp.hxx" #include <sfx2/viewfrm.hxx> #include <sfx2/prnmon.hxx> @@ -65,50 +61,282 @@ #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> +#include "toolkit/awt/vclxdevice.hxx" + #include "view.hrc" #include "helpid.hrc" +using namespace com::sun::star; +using namespace com::sun::star::uno; + TYPEINIT1(SfxPrintingHint, SfxHint); // ----------------------------------------------------------------------- +class SfxPrinterController : public vcl::PrinterController, public SfxListener +{ + Any maCompleteSelection; + Any maSelection; + Reference< view::XRenderable > mxRenderable; + mutable Printer* mpLastPrinter; + mutable Reference<awt::XDevice> mxDevice; + SfxViewShell* mpViewShell; + SfxObjectShell* mpObjectShell; + sal_Bool m_bOrigStatus; + sal_Bool m_bNeedsChange; + sal_Bool m_bApi; + util::DateTime m_aLastPrinted; + ::rtl::OUString m_aLastPrintedBy; -void SfxAsyncPrintExec_Impl::AddRequest( SfxRequest& rReq ) + Sequence< beans::PropertyValue > getMergedOptions() const; + const Any& getSelectionObject() const; +public: + SfxPrinterController( const Any& i_rComplete, + const Any& i_rSelection, + const Any& i_rViewProp, + const Reference< view::XRenderable >& i_xRender, + sal_Bool i_bApi, sal_Bool i_bDirect, + SfxViewShell* pView, + const uno::Sequence< beans::PropertyValue >& rProps + ); + + virtual ~SfxPrinterController(); + virtual void Notify( SfxBroadcaster&, const SfxHint& ); + + virtual int getPageCount() const; + virtual Sequence< beans::PropertyValue > getPageParameters( int i_nPage ) const; + virtual void printPage( int i_nPage ) const; + virtual void jobStarted(); + virtual void jobFinished( com::sun::star::view::PrintableState ); +}; + +SfxPrinterController::SfxPrinterController( const Any& i_rComplete, + const Any& i_rSelection, + const Any& i_rViewProp, + const Reference< view::XRenderable >& i_xRender, + sal_Bool i_bApi, sal_Bool i_bDirect, + SfxViewShell* pView, + const uno::Sequence< beans::PropertyValue >& rProps + ) + : maCompleteSelection( i_rComplete ) + , maSelection( i_rSelection ) + , mxRenderable( i_xRender ) + , mpLastPrinter( NULL ) + , mpViewShell( pView ) + , mpObjectShell(0) + , m_bOrigStatus( sal_False ) + , m_bNeedsChange( sal_False ) + , m_bApi(i_bApi) { - if ( rReq.GetArgs() ) + if ( mpViewShell ) { - // only queue API requests - if ( aReqs.empty() ) - StartListening( *pView->GetObjectShell() ); + StartListening( *mpViewShell ); + mpObjectShell = mpViewShell->GetObjectShell(); + StartListening( *mpObjectShell ); + m_bOrigStatus = mpObjectShell->IsEnableSetModified(); + + // check configuration: shall update of printing information in DocInfo set the document to "modified"? + if ( m_bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() ) + { + mpObjectShell->EnableSetModified( sal_False ); + m_bNeedsChange = sal_True; + } + + // refresh document info + uno::Reference<document::XDocumentProperties> xDocProps(mpObjectShell->getDocProperties()); + m_aLastPrintedBy = xDocProps->getPrintedBy(); + m_aLastPrinted = xDocProps->getPrintDate(); + + xDocProps->setPrintedBy( mpObjectShell->IsUseUserData() + ? ::rtl::OUString( SvtUserOptions().GetFullName() ) + : ::rtl::OUString() ); + ::DateTime now; + + xDocProps->setPrintDate( util::DateTime( + now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(), + now.GetDay(), now.GetMonth(), now.GetYear() ) ); + } - aReqs.push( new SfxRequest( rReq ) ); + // initialize extra ui options + if( mxRenderable.is() ) + { + for (sal_Int32 nProp=0; nProp<rProps.getLength(); nProp++) + setValue( rProps[nProp].Name, rProps[nProp].Value ); + + Sequence< beans::PropertyValue > aRenderOptions( 3 ); + aRenderOptions[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ExtraPrintUIOptions" ) ); + aRenderOptions[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "View" ) ); + aRenderOptions[1].Value = i_rViewProp; + aRenderOptions[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsPrinter" ) ); + aRenderOptions[2].Value <<= sal_True; + Sequence< beans::PropertyValue > aRenderParms( mxRenderable->getRenderer( 0 , getSelectionObject(), aRenderOptions ) ); + int nProps = aRenderParms.getLength(); + for( int i = 0; i < nProps; i++ ) + { + if( aRenderParms[i].Name.equalsAscii( "ExtraPrintUIOptions" ) ) + { + Sequence< beans::PropertyValue > aUIProps; + aRenderParms[i].Value >>= aUIProps; + setUIOptions( aUIProps ); + break; + } + } } + + // set some job parameters + setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsApi" ) ), makeAny( i_bApi ) ); + setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsDirect" ) ), makeAny( i_bDirect ) ); + setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsPrinter" ) ), makeAny( sal_True ) ); + setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "View" ) ), i_rViewProp ); } -void SfxAsyncPrintExec_Impl::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) +void SfxPrinterController::Notify( SfxBroadcaster& , const SfxHint& rHint ) { - if ( &rBC == pView->GetObjectShell() ) + if ( rHint.IsA(TYPE(SfxSimpleHint)) ) { - SfxPrintingHint* pPrintHint = PTR_CAST( SfxPrintingHint, &rHint ); - if ( pPrintHint && pPrintHint->GetWhich() == com::sun::star::view::PrintableState_JOB_COMPLETED ) + if ( ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) { - while ( aReqs.front() ) + EndListening(*mpViewShell); + EndListening(*mpObjectShell); + mpViewShell = 0; + mpObjectShell = 0; + } + } +} + +SfxPrinterController::~SfxPrinterController() +{ +} + +const Any& SfxPrinterController::getSelectionObject() const +{ + sal_Int32 nChoice = 0; + sal_Bool bSel = sal_False; + const beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ) ); + if( pVal ) + pVal->Value >>= nChoice; + pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelectionOnly" ) ) ); + if( pVal ) + pVal->Value >>= bSel; + return (nChoice > 1 || bSel) ? maSelection : maCompleteSelection; +} + +Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const +{ + boost::shared_ptr<Printer> pPrinter( getPrinter() ); + if( pPrinter.get() != mpLastPrinter ) + { + mpLastPrinter = pPrinter.get(); + VCLXDevice* pXDevice = new VCLXDevice(); + pXDevice->SetOutputDevice( mpLastPrinter ); + mxDevice = Reference< awt::XDevice >( pXDevice ); + } + + Sequence< beans::PropertyValue > aRenderOptions( 1 ); + aRenderOptions[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ); + aRenderOptions[ 0 ].Value <<= mxDevice; + + aRenderOptions = getJobProperties( aRenderOptions ); + return aRenderOptions; +} + +int SfxPrinterController::getPageCount() const +{ + int nPages = 0; + boost::shared_ptr<Printer> pPrinter( getPrinter() ); + if( mxRenderable.is() && pPrinter ) + { + Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() ); + nPages = mxRenderable->getRendererCount( getSelectionObject(), aJobOptions ); + } + return nPages; +} + +Sequence< beans::PropertyValue > SfxPrinterController::getPageParameters( int i_nPage ) const +{ + boost::shared_ptr<Printer> pPrinter( getPrinter() ); + Sequence< beans::PropertyValue > aResult; + + if( mxRenderable.is() && pPrinter ) + { + Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() ); + aResult = mxRenderable->getRenderer( i_nPage, getSelectionObject(), aJobOptions ); + } + return aResult; +} + +void SfxPrinterController::printPage( int i_nPage ) const +{ + boost::shared_ptr<Printer> pPrinter( getPrinter() ); + if( mxRenderable.is() && pPrinter ) + { + Sequence< beans::PropertyValue > aJobOptions( getMergedOptions() ); + try + { + mxRenderable->render( i_nPage, getSelectionObject(), aJobOptions ); + } + catch( lang::IllegalArgumentException& ) + { + // don't care enough about nonexistant page here + // to provoke a crash + } + } +} + +void SfxPrinterController::jobStarted() +{ + if ( mpObjectShell ) + { + // FIXME: how to get all print options incl. AdditionalOptions easily? + uno::Sequence < beans::PropertyValue > aOpts; + mpObjectShell->Broadcast( SfxPrintingHint( view::PrintableState_JOB_STARTED, aOpts ) ); + } +} + +void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nState ) +{ + if ( mpObjectShell ) + { + mpObjectShell->Broadcast( SfxPrintingHint( nState ) ); + switch ( nState ) + { + case view::PrintableState_JOB_FAILED : { - SfxRequest* pReq = aReqs.front(); - aReqs.pop(); - pView->GetViewFrame()->GetDispatcher()->Execute( pReq->GetSlot(), SFX_CALLMODE_ASYNCHRON, *pReq->GetArgs() ); - USHORT nSlot = pReq->GetSlot(); - delete pReq; - if ( nSlot == SID_PRINTDOC || nSlot == SID_PRINTDOCDIRECT ) - // print jobs must be executed before the next command can be dispatched - break; + // "real" problem (not simply printing cancelled by user) + String aMsg( SfxResId( STR_NOSTARTPRINTER ) ); + if ( !m_bApi ) + ErrorBox( mpViewShell->GetWindow(), WB_OK | WB_DEF_OK, aMsg ).Execute(); + // intentionally no break + } + case view::PrintableState_JOB_ABORTED : + { + // printing not succesful, reset DocInfo + uno::Reference<document::XDocumentProperties> xDocProps(mpObjectShell->getDocProperties()); + xDocProps->setPrintedBy(m_aLastPrintedBy); + xDocProps->setPrintDate(m_aLastPrinted); + break; } - if ( aReqs.empty() ) - EndListening( *pView->GetObjectShell() ); + case view::PrintableState_JOB_SPOOLED : + case view::PrintableState_JOB_COMPLETED : + { + SfxBindings& rBind = mpViewShell->GetViewFrame()->GetBindings(); + rBind.Invalidate( SID_PRINTDOC ); + rBind.Invalidate( SID_PRINTDOCDIRECT ); + rBind.Invalidate( SID_SETUPPRINTER ); + break; + } + + default: + break; } + + if ( m_bNeedsChange ) + mpObjectShell->EnableSetModified( m_bOrigStatus ); } } +// ----------------------------------------------------------------------- + void DisableRanges( PrintDialog& rDlg, SfxPrinter* pPrinter ) /* [Beschreibung] @@ -391,68 +619,137 @@ SfxPrinter* SfxViewShell::SetPrinter_Impl( SfxPrinter *pNewPrinter ) #pragma optimize ( "", off ) #endif -class SfxPrintGuard_Impl +void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rProps, sal_Bool bIsAPI, sal_Bool bIsDirect ) { - SfxObjectShell* m_pObjectShell; - sal_Bool m_bOrigStatus; - sal_Bool m_bNeedsChange; - -public: - SfxPrintGuard_Impl( SfxObjectShell* pObjectShell ) - : m_pObjectShell( pObjectShell ) - , m_bOrigStatus( sal_False ) - , m_bNeedsChange( sal_False ) - { - if ( m_pObjectShell ) - { - m_bOrigStatus = m_pObjectShell->IsEnableSetModified(); + // get the current selection; our controller should know it + Reference< frame::XController > xController( GetController() ); + Reference< view::XSelectionSupplier > xSupplier( xController, UNO_QUERY ); - // check configuration: shall update of printing information in DocInfo set the document to "modified"? - if ( m_bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() ) - { - m_pObjectShell->EnableSetModified( sal_False ); - m_bNeedsChange = sal_True; - } - } - } - - ~SfxPrintGuard_Impl() - { - if ( m_pObjectShell && m_bNeedsChange ) - m_pObjectShell->EnableSetModified( m_bOrigStatus ); - } -}; + Any aSelection; + if( xSupplier.is() ) + aSelection = xSupplier->getSelection(); + else + aSelection <<= GetObjectShell()->GetModel(); + Any aComplete( makeAny( GetObjectShell()->GetModel() ) ); + Any aViewProp( makeAny( xController ) ); + + boost::shared_ptr<vcl::PrinterController> pController( new SfxPrinterController( aComplete, + aSelection, + aViewProp, + GetRenderable(), + bIsAPI, + bIsDirect, + this, + rProps + ) ); + SfxObjectShell *pObjShell = GetObjectShell(); + pController->setValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobName" ) ), + makeAny( rtl::OUString( pObjShell->GetTitle(0) ) ) ); + + // FIXME: job setup + SfxPrinter* pDocPrt = GetPrinter(FALSE); + JobSetup aJobSetup = pDocPrt ? pDocPrt->GetJobSetup() : GetJobSetup(); + if( bIsDirect ) + aJobSetup.SetValue( String( RTL_CONSTASCII_USTRINGPARAM( "IsQuickJob" ) ), + String( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) ); + + Printer::PrintJob( pController, aJobSetup ); +} void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) { - USHORT nCopies=1; + // USHORT nCopies=1; USHORT nDialogRet = RET_CANCEL; - BOOL bCollate=TRUE; + // BOOL bCollate=FALSE; SfxPrinter* pPrinter = 0; PrintDialog* pPrintDlg = 0; SfxDialogExecutor_Impl* pExecutor = 0; bool bSilent = false; BOOL bIsAPI = rReq.GetArgs() && rReq.GetArgs()->Count(); - - if ( bIsAPI && GetPrinter( FALSE ) && GetPrinter( FALSE )->IsPrinting() ) + if ( bIsAPI ) { - pImp->pPrinterCommandQueue->AddRequest( rReq ); - return; + SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, FALSE); + bSilent = pSilentItem && pSilentItem->GetValue(); } + //FIXME: how to transport "bPrintOnHelp"? + + // no help button in dialogs if called from the help window + // (pressing help button would exchange the current page inside the help document that is going to be printed!) + String aHelpFilterName( DEFINE_CONST_UNICODE("writer_web_HTML_help") ); + SfxMedium* pMedium = GetViewFrame()->GetObjectShell()->GetMedium(); + const SfxFilter* pFilter = pMedium ? pMedium->GetFilter() : NULL; + sal_Bool bPrintOnHelp = ( pFilter && pFilter->GetFilterName() == aHelpFilterName ); + const USHORT nId = rReq.GetSlot(); switch( nId ) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case SID_PRINTDOC: - case SID_SETUPPRINTER: - case SID_PRINTER_NAME : + case SID_PRINTDOCDIRECT: { - // quiet mode (AppEvent, API call) - SFX_REQUEST_ARG(rReq, pSilentItem, SfxBoolItem, SID_SILENT, FALSE); - bSilent = pSilentItem && pSilentItem->GetValue(); + SfxObjectShell* pDoc = GetObjectShell(); + bool bDetectHidden = ( !bSilent && pDoc ); + if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES ) + break; + + SFX_REQUEST_ARG(rReq, pSelectItem, SfxBoolItem, SID_SELECTION, FALSE); + sal_Bool bSelection = pSelectItem && pSelectItem->GetValue(); + if( pSelectItem && rReq.GetArgs()->Count() == 1 ) + bIsAPI = FALSE; + + uno::Sequence < beans::PropertyValue > aProps; + if ( bIsAPI ) + { + // supported properties: + // String PrinterName + // String FileName + // Int16 From + // Int16 To + // In16 Copies + // String RangeText + // bool Selection + // bool Asynchron + // bool Collate + // bool Silent + TransformItems( nId, *rReq.GetArgs(), aProps, GetInterface()->GetSlot(nId) ); + for ( sal_Int32 nProp=0; nProp<aProps.getLength(); nProp++ ) + { + if ( aProps[nProp].Name.equalsAscii("Copies") ) + aProps[nProp]. Name = rtl::OUString::createFromAscii("CopyCount"); + else if ( aProps[nProp].Name.equalsAscii("RangeText") ) + aProps[nProp]. Name = rtl::OUString::createFromAscii("Pages"); + if ( aProps[nProp].Name.equalsAscii("Asynchron") ) + { + aProps[nProp]. Name = rtl::OUString::createFromAscii("Wait"); + sal_Bool bAsynchron = sal_False; + aProps[nProp].Value >>= bAsynchron; + aProps[nProp].Value <<= (sal_Bool) (!bAsynchron); + } + if ( aProps[nProp].Name.equalsAscii("Silent") ) + { + aProps[nProp]. Name = rtl::OUString::createFromAscii("MonitorVisible"); + sal_Bool bPrintSilent = sal_False; + aProps[nProp].Value >>= bPrintSilent; + aProps[nProp].Value <<= (sal_Bool) (!bPrintSilent); + } + } + } + sal_Int32 nLen = aProps.getLength(); + aProps.realloc( nLen + 1 ); + aProps[nLen].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelectionOnly" ) ); + aProps[nLen].Value = makeAny( bSelection ); + + ExecPrint( aProps, bIsAPI, (nId == SID_PRINTDOCDIRECT) ); + + // FIXME: Recording + rReq.Done(); + break; + } + case SID_SETUPPRINTER : + case SID_PRINTER_NAME : // only for recorded macros + { // get printer and printer settings from the document SfxPrinter *pDocPrinter = GetPrinter(TRUE); @@ -473,7 +770,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) // just set a recorded printer name if ( pPrinter ) SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); - return; + break; } // no PrinterName parameter in ItemSet or the PrinterName points to an unknown printer @@ -487,7 +784,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) if ( bSilent ) { rReq.SetReturnValue(SfxBoolItem(0,FALSE)); - return; + break; } else ErrorBox( NULL, WB_OK | WB_DEF_OK, String( SfxResId( STR_NODEFPRINTER ) ) ).Execute(); @@ -497,112 +794,57 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) { // printer is not available, but standard printer should not be used rReq.SetReturnValue(SfxBoolItem(0,FALSE)); - return; + break; } + // FIXME: printer isn't used for printing anymore! if( pPrinter->IsPrinting() ) { // if printer is busy, abort printing if ( !bSilent ) InfoBox( NULL, String( SfxResId( STR_ERROR_PRINTER_BUSY ) ) ).Execute(); rReq.SetReturnValue(SfxBoolItem(0,FALSE)); - return; + break; } - // the print dialog shouldn't use a help button if it is called from the help window - // (pressing help button would exchange the current page inside the help document that is going to be printed!) - String aHelpFilterName( DEFINE_CONST_UNICODE("writer_web_HTML_help") ); - SfxMedium* pMedium = GetViewFrame()->GetObjectShell()->GetMedium(); - const SfxFilter* pFilter = pMedium ? pMedium->GetFilter() : NULL; - sal_Bool bPrintOnHelp = ( pFilter && pFilter->GetFilterName() == aHelpFilterName ); - - SfxObjectShell* pDoc = NULL; - if ( SID_PRINTDOC == nId ) - pDoc = GetObjectShell(); - - // Let the document stay nonmodified during the printing if the configuration says to do so - SfxPrintGuard_Impl aGuard( pDoc ); - // if no arguments are given, retrieve them from a dialog if ( !bIsAPI ) { // PrinterDialog needs a temporary printer SfxPrinter* pDlgPrinter = pPrinter->Clone(); nDialogRet = 0; - if ( SID_PRINTDOC == nId ) + + // execute PrinterSetupDialog + PrinterSetupDialog* pPrintSetupDlg = new PrinterSetupDialog( GetWindow() ); + + if ( pImp->bHasPrintOptions ) { - bool bDetectHidden = ( !bSilent && !bPrintOnHelp && pDoc ); - if ( !bDetectHidden - || pDoc->QueryHiddenInformation( WhenPrinting, NULL ) == RET_YES ) - { - // execute PrintDialog - pPrintDlg = CreatePrintDialog( NULL ); - if ( bPrintOnHelp ) - pPrintDlg->DisableHelp(); - - if ( pImp->bHasPrintOptions ) - { - // additional controls for dialog - pExecutor = new SfxDialogExecutor_Impl( this, pPrintDlg ); - if ( bPrintOnHelp ) - pExecutor->DisableHelp(); - pPrintDlg->SetOptionsHdl( pExecutor->GetLink() ); - pPrintDlg->ShowOptionsButton(); - } - - // set printer on dialog and execute - pPrintDlg->SetPrinter( pDlgPrinter ); - ::DisableRanges( *pPrintDlg, pDlgPrinter ); - nDialogRet = pPrintDlg->Execute(); - if ( pExecutor && pExecutor->GetOptions() ) - { - if ( nDialogRet == RET_OK ) - // remark: have to be recorded if possible! - pDlgPrinter->SetOptions( *pExecutor->GetOptions() ); - else - { - pPrinter->SetOptions( *pExecutor->GetOptions() ); - SetPrinter( pPrinter, SFX_PRINTER_OPTIONS ); - } - } - - DELETEZ( pExecutor ); - } + // additional controls for dialog + pExecutor = new SfxDialogExecutor_Impl( this, pPrintSetupDlg ); + if ( bPrintOnHelp ) + pExecutor->DisableHelp(); + pPrintSetupDlg->SetOptionsHdl( pExecutor->GetLink() ); } - else - { - // execute PrinterSetupDialog - PrinterSetupDialog* pPrintSetupDlg = new PrinterSetupDialog( GetWindow() ); - - if ( pImp->bHasPrintOptions ) - { - // additional controls for dialog - pExecutor = new SfxDialogExecutor_Impl( this, pPrintSetupDlg ); - if ( bPrintOnHelp ) - pExecutor->DisableHelp(); - pPrintSetupDlg->SetOptionsHdl( pExecutor->GetLink() ); - } - pPrintSetupDlg->SetPrinter( pDlgPrinter ); - nDialogRet = pPrintSetupDlg->Execute(); + pPrintSetupDlg->SetPrinter( pDlgPrinter ); + nDialogRet = pPrintSetupDlg->Execute(); - if ( pExecutor && pExecutor->GetOptions() ) + if ( pExecutor && pExecutor->GetOptions() ) + { + if ( nDialogRet == RET_OK ) + // remark: have to be recorded if possible! + pDlgPrinter->SetOptions( *pExecutor->GetOptions() ); + else { - if ( nDialogRet == RET_OK ) - // remark: have to be recorded if possible! - pDlgPrinter->SetOptions( *pExecutor->GetOptions() ); - else - { - pPrinter->SetOptions( *pExecutor->GetOptions() ); - SetPrinter( pPrinter, SFX_PRINTER_OPTIONS ); - } + pPrinter->SetOptions( *pExecutor->GetOptions() ); + SetPrinter( pPrinter, SFX_PRINTER_OPTIONS ); } + } - DELETEZ( pPrintSetupDlg ); + DELETEZ( pPrintSetupDlg ); - // no recording of PrinterSetup except printer name (is printer dependent) - rReq.Ignore(); - } + // no recording of PrinterSetup except printer name (is printer dependent) + rReq.Ignore(); if ( nDialogRet == RET_OK ) { @@ -623,14 +865,6 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) /* Now lets reset the Dialog printer, since its freed */ if (pPrintDlg) pPrintDlg->SetPrinter (pPrinter); - - if ( SID_PRINTDOC == nId ) - { - nCopies = pPrintDlg->GetCopyCount(); - bCollate = pPrintDlg->IsCollateChecked(); - } - else - break; } else { @@ -641,226 +875,11 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) rReq.Ignore(); if ( SID_PRINTDOC == nId ) rReq.SetReturnValue(SfxBoolItem(0,FALSE)); - break; - } - - // recording - rReq.AppendItem( SfxBoolItem( SID_PRINT_COLLATE, bCollate ) ); - rReq.AppendItem( SfxInt16Item( SID_PRINT_COPIES, (INT16) pPrintDlg->GetCopyCount() ) ); - if ( pPrinter->IsPrintFileEnabled() ) - rReq.AppendItem( SfxStringItem( SID_FILE_NAME, pPrinter->GetPrintFile() ) ); - if ( pPrintDlg->IsRangeChecked(PRINTDIALOG_SELECTION) ) - rReq.AppendItem( SfxBoolItem( SID_SELECTION, TRUE ) ); - else if ( pPrintDlg->IsRangeChecked(PRINTDIALOG_RANGE) ) - rReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, pPrintDlg->GetRangeText() ) ); - else if ( pPrintDlg->IsRangeChecked(PRINTDIALOG_FROMTO) ) - { - // currently this doesn't seem to work -> return values of dialog are always 0 - // seems to be encoded as range string like "1-3" - rReq.AppendItem( SfxInt16Item( SID_PRINT_FIRST_PAGE, (INT16) pPrintDlg->GetFirstPage() ) ); - rReq.AppendItem( SfxInt16Item( SID_PRINT_LAST_PAGE, (INT16) pPrintDlg->GetLastPage() ) ); } } - else if ( rReq.GetArgs() ) - { - if ( SID_PRINTDOC != nId ) - { - DBG_ERROR("Wrong slotid!"); - break; - } - - // PrinterDialog is used to transfer information on printing - pPrintDlg = CreatePrintDialog( GetWindow() ); - if ( bPrintOnHelp ) - pPrintDlg->DisableHelp(); - pPrintDlg->SetPrinter( pPrinter ); - ::DisableRanges( *pPrintDlg, pPrinter ); - - // PrintToFile requested? - SFX_REQUEST_ARG(rReq, pFileItem, SfxStringItem, SID_FILE_NAME, FALSE); - if ( pFileItem ) - { - pPrinter->EnablePrintFile(TRUE); - pPrinter->SetPrintFile( pFileItem->GetValue() ); - } - - // Collate - SFX_REQUEST_ARG(rReq, pCollateItem, SfxBoolItem, SID_PRINT_COLLATE, FALSE); - if ( pCollateItem ) - { - bCollate = pCollateItem->GetValue(); - pPrintDlg->CheckCollate( bCollate ); - } - - // Selection - SFX_REQUEST_ARG(rReq, pSelectItem, SfxBoolItem, SID_SELECTION, FALSE); - - // Pages (as String) - SFX_REQUEST_ARG(rReq, pPagesItem, SfxStringItem, SID_PRINT_PAGES, FALSE); - - // FirstPage - SFX_REQUEST_ARG(rReq, pFirstPgItem, SfxInt16Item, SID_PRINT_FIRST_PAGE, FALSE); - USHORT nFrom = 1; - if ( pFirstPgItem ) - nFrom = pFirstPgItem->GetValue(); - - // LastPage - SFX_REQUEST_ARG(rReq, pLastPgItem, SfxInt16Item, SID_PRINT_LAST_PAGE, FALSE); - USHORT nTo = 9999; - if ( pLastPgItem ) - nTo = pLastPgItem->GetValue(); - - // CopyCount - SFX_REQUEST_ARG(rReq, pCopyItem, SfxInt16Item, SID_PRINT_COPIES, FALSE); - if ( pCopyItem ) - { - nCopies = pCopyItem->GetValue(); - pPrintDlg->SetCopyCount( nCopies ); - } - - // does the view support ranges? - if ( pSelectItem && pSelectItem->GetValue() ) - { - // print selection only - pPrintDlg->CheckRange(PRINTDIALOG_SELECTION); - } - else if ( pPagesItem ) - { - // get range text from parameter - // enable ranges - pPrintDlg->CheckRange(PRINTDIALOG_RANGE); - pPrintDlg->SetRangeText( pPagesItem->GetValue() ); - } - else if ( pPrintDlg->IsRangeEnabled(PRINTDIALOG_RANGE) ) - { - // enable ranges - // construct range text from page range - pPrintDlg->CheckRange(PRINTDIALOG_RANGE); - String aRange = String::CreateFromInt32( nFrom ); - aRange += '-'; - aRange += String::CreateFromInt32( nTo ); - pPrintDlg->SetRangeText( aRange ); - } - else - { - // print page rage - pPrintDlg->CheckRange(PRINTDIALOG_FROMTO); - pPrintDlg->SetFirstPage( nFrom ); - pPrintDlg->SetLastPage( nTo ); - } - } - - // intentionally no break for SID_PRINTDOC - // printing now proceeds like SID_PRINTDOCDIRECT } - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case SID_PRINTDOCDIRECT: - { - if ( SID_PRINTDOCDIRECT == nId ) - { - SfxObjectShell* pDoc = GetObjectShell(); - bool bDetectHidden = ( !bSilent && pDoc ); - if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES ) - return; - - // if no printer was selected before - if ( !pPrinter ) - pPrinter = GetPrinter(TRUE); - - if( !pPrinter->IsValid() ) - { - // redirect slot to call the print dialog if the document's printer is not valid! - rReq.SetSlot( SID_PRINTDOC ); - ExecPrint_Impl( rReq ); - return; - } - - if( pPrinter->IsOriginal() && pPrinter->GetName() != Printer::GetDefaultPrinterName() ) - { - // redirect slot to call the print dialog - // if the document's printer is available but not system default - rReq.SetSlot( SID_PRINTDOC ); - ExecPrint_Impl( rReq ); - return; - } - - pPrinter->SetNextJobIsQuick(); - } - - // if "Collate" was checked, the SfxPrinter must handle the CopyCount itself, - // usually this is handled by the printer driver - if( bCollate ) - // set printer to default, handle multiple copies explicitly - pPrinter->SetCopyCount( 1 ); - else - pPrinter->SetCopyCount( nCopies ); - - // enable background printing - pPrinter->SetPageQueueSize( 1 ); - - // refresh document info - using namespace ::com::sun::star; - SfxObjectShell *pObjSh = GetObjectShell(); - uno::Reference<document::XDocumentProperties> xDocProps( - pObjSh->getDocProperties()); - ::rtl::OUString aLastPrintedBy = xDocProps->getPrintedBy(); - util::DateTime aLastPrinted = xDocProps->getPrintDate(); - - // Let the document stay nonmodified during the printing if the configuration says to do so - SfxPrintGuard_Impl aGuard( pObjSh ); - - xDocProps->setPrintedBy( GetObjectShell()->IsUseUserData() - ? ::rtl::OUString( SvtUserOptions().GetFullName() ) - : ::rtl::OUString() ); - ::DateTime now; - xDocProps->setPrintDate( util::DateTime( - now.Get100Sec(), now.GetSec(), now.GetMin(), now.GetHour(), - now.GetDay(), now.GetMonth(), now.GetYear() ) ); - - GetObjectShell()->Broadcast( SfxPrintingHint( -1, pPrintDlg, pPrinter ) ); - ErrCode nError = DoPrint( pPrinter, pPrintDlg, bSilent, bIsAPI ); - if ( nError == PRINTER_OK ) - { - Invalidate( SID_PRINTDOC ); - Invalidate( SID_PRINTDOCDIRECT ); - Invalidate( SID_SETUPPRINTER ); - rReq.SetReturnValue(SfxBoolItem(0,TRUE)); - - SFX_REQUEST_ARG(rReq, pAsyncItem, SfxBoolItem, SID_ASYNCHRON, FALSE); - if ( pAsyncItem && !pAsyncItem->GetValue() ) - { - // synchronous execution wanted - wait for end of printing - while ( pPrinter->IsPrinting()) - Application::Yield(); - } - - rReq.Done(); - } - else - { - // printing not succesful, reset DocInfo - xDocProps->setPrintedBy(aLastPrintedBy); - xDocProps->setPrintDate(aLastPrinted); - - if ( nError != PRINTER_ABORT ) - { - // "real" problem (not simply printing cancelled by user) - String aMsg( SfxResId( STR_NOSTARTPRINTER ) ); - if ( !bIsAPI ) - ErrorBox( NULL, WB_OK | WB_DEF_OK, aMsg ).Execute(); - rReq.SetReturnValue(SfxBoolItem(0,FALSE)); - } - - rReq.Ignore(); - } - - pPrinter->SetNextJobIsQuick( false ); - - delete pPrintDlg; - break; - } + break; } } @@ -871,7 +890,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) //-------------------------------------------------------------------- -PrintDialog* SfxViewShell::CreatePrintDialog( Window* pParent ) +PrintDialog* SfxViewShell::CreatePrintDialog( Window* /*pParent*/ ) /* [Beschreibung] @@ -881,11 +900,15 @@ PrintDialog* SfxViewShell::CreatePrintDialog( Window* pParent ) */ { + #if 0 PrintDialog *pDlg = new PrintDialog( pParent, false ); pDlg->SetFirstPage( 1 ); pDlg->SetLastPage( 9999 ); pDlg->EnableCollate(); return pDlg; + #else + return NULL; + #endif } //-------------------------------------------------------------------- @@ -897,10 +920,11 @@ void SfxViewShell::PreparePrint( PrintDialog * ) //-------------------------------------------------------------------- -ErrCode SfxViewShell::DoPrint( SfxPrinter *pPrinter, - PrintDialog *pPrintDlg, - BOOL bSilent, BOOL bIsAPI ) +ErrCode SfxViewShell::DoPrint( SfxPrinter* /*pPrinter*/, + PrintDialog* /*pPrintDlg*/, + BOOL /*bSilent*/, BOOL /*bIsAPI*/ ) { + #if 0 // Printer-Dialogbox waehrend des Ausdrucks mu\s schon vor // StartJob erzeugt werden, da SV bei einem Quit-Event h"angt SfxPrintProgress *pProgress = new SfxPrintProgress( this, !bSilent ); @@ -910,11 +934,8 @@ ErrCode SfxViewShell::DoPrint( SfxPrinter *pPrinter, else if ( pDocPrinter != pPrinter ) { pProgress->RestoreOnEndPrint( pDocPrinter->Clone() ); - USHORT nError = SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); - if ( nError != SFX_PRINTERROR_NONE ) - return PRINTER_ACCESSDENIED; + SetPrinter( pPrinter, SFX_PRINTER_PRINTER ); } - pProgress->SetWaitMode(FALSE); // Drucker starten @@ -935,6 +956,10 @@ ErrCode SfxViewShell::DoPrint( SfxPrinter *pPrinter, } return pPrinter->GetError(); + #else + DBG_ERROR( "DoPrint called, dead code !" ); + return ERRCODE_IO_NOTSUPPORTED; + #endif } //-------------------------------------------------------------------- @@ -990,23 +1015,12 @@ SfxTabPage* SfxViewShell::CreatePrintOptionsPage Window* /*pParent*/, const SfxItemSet& /*rOptions*/ ) - -/* [Beschreibung] - - Diese Factory-Methode wird vom SFx verwendet, um die TabPage mit den - Print-Optionen, welche "uber das <SfxItemSet> am <SfxPrinter> - transportiert werden, zu erzeugen. - - Abgeleitete Klassen k"onnen diese Methode also "uberladen um die zu - ihren SfxPrinter passenden Einstellungen vorzunehmen. Dieses sollte - genau die <SfxTabPage> sein, die auch unter Extras/Einstellungen - verwendet wird. - - Die Basisimplementierung liefert einen 0-Pointer. -*/ - { return 0; } +JobSetup SfxViewShell::GetJobSetup() const +{ + return JobSetup(); +} diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 86c9ba0bb70e..4ee90289347e 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -1261,7 +1261,7 @@ SfxViewShell::SfxViewShell { DBG_CTOR(SfxViewShell, 0); - pImp->pPrinterCommandQueue = new SfxAsyncPrintExec_Impl( this ); + //pImp->pPrinterCommandQueue = new SfxAsyncPrintExec_Impl( this ); pImp->pController = 0; pImp->bIsShowView = !(SFX_VIEW_NO_SHOW == (nFlags & SFX_VIEW_NO_SHOW)); @@ -1322,7 +1322,7 @@ SfxViewShell::~SfxViewShell() DELETEZ( pImp->pAccExec ); } - DELETEZ( pImp->pPrinterCommandQueue ); + //DELETEZ( pImp->pPrinterCommandQueue ); DELETEZ( pImp ); DELETEZ( pIPClientList ); } @@ -1578,7 +1578,7 @@ SfxViewShell* SfxViewShell::GetFirst if ( pFrame == pShell->GetViewFrame() ) { // only ViewShells with a valid ViewFrame will be returned - if ( ( !bOnlyVisible || pFrame->IsVisible_Impl() ) && ( !pType || pShell->IsA(*pType) ) ) + if ( ( !bOnlyVisible || pFrame->IsVisible() ) && ( !pType || pShell->IsA(*pType) ) ) return pShell; break; } @@ -1620,7 +1620,7 @@ SfxViewShell* SfxViewShell::GetNext if ( pFrame == pShell->GetViewFrame() ) { // only ViewShells with a valid ViewFrame will be returned - if ( ( !bOnlyVisible || pFrame->IsVisible_Impl() ) && ( !pType || pShell->IsA(*pType) ) ) + if ( ( !bOnlyVisible || pFrame->IsVisible() ) && ( !pType || pShell->IsA(*pType) ) ) return pShell; break; } @@ -2211,7 +2211,7 @@ BOOL SfxViewShell::HasMouseClickListeners_Impl() void SfxViewShell::SetAdditionalPrintOptions( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >& rOpts ) { pImp->aPrintOpts = rOpts; - GetObjectShell()->Broadcast( SfxPrintingHint( -3, NULL, NULL, rOpts ) ); +// GetObjectShell()->Broadcast( SfxPrintingHint( -3, NULL, NULL, rOpts ) ); } BOOL SfxViewShell::Escape() @@ -2219,6 +2219,19 @@ BOOL SfxViewShell::Escape() return GetViewFrame()->GetBindings().Execute( SID_TERMINATE_INPLACEACTIVATION ); } +Reference< view::XRenderable > SfxViewShell::GetRenderable() +{ + Reference< view::XRenderable >xRender; + SfxObjectShell* pObj = GetObjectShell(); + if( pObj ) + { + Reference< frame::XModel > xModel( pObj->GetModel() ); + if( xModel.is() ) + xRender = Reference< view::XRenderable >( xModel, UNO_QUERY ); + } + return xRender; +} + void SfxViewShell::AddRemoveClipboardListener( const uno::Reference < datatransfer::clipboard::XClipboardListener >& rClp, BOOL bAdd ) { try diff --git a/shell/source/backends/localebe/localebackend.cxx b/shell/source/backends/localebe/localebackend.cxx index d8e2f05c0332..1496f426d3c6 100644 --- a/shell/source/backends/localebe/localebackend.cxx +++ b/shell/source/backends/localebe/localebackend.cxx @@ -39,7 +39,7 @@ #include <stdio.h> -#if defined(LINUX) || defined(SOLARIS) || defined(IRIX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2) +#if defined(LINUX) || defined(SOLARIS) || defined(NETBSD) || defined(FREEBSD) || defined(OS2) #include <rtl/ustrbuf.hxx> #include <locale.h> @@ -256,7 +256,7 @@ LocaleBackend* LocaleBackend::createInstance( rtl::OUString LocaleBackend::getLocale(void) { -#if defined(LINUX) || defined(SOLARIS) || defined(IRIX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2) +#if defined(LINUX) || defined(SOLARIS) || defined(NETBSD) || defined(FREEBSD) || defined(OS2) return ImplGetLocale(LC_CTYPE); #elif defined (MACOSX) return ImplGetLocale("AppleLocale"); @@ -269,7 +269,7 @@ rtl::OUString LocaleBackend::getLocale(void) rtl::OUString LocaleBackend::getUILocale(void) { -#if defined(LINUX) || defined(SOLARIS) || defined(IRIX) || defined(NETBSD) || defined(FREEBSD) || defined(OS2) +#if defined(LINUX) || defined(SOLARIS) || defined(NETBSD) || defined(FREEBSD) || defined(OS2) return ImplGetLocale(LC_MESSAGES); #elif defined(MACOSX) return ImplGetLocale("AppleLanguages"); diff --git a/svx/inc/fmhelp.hrc b/svx/inc/fmhelp.hrc index 5c3acad950e6..ef445ab11f82 100644 --- a/svx/inc/fmhelp.hrc +++ b/svx/inc/fmhelp.hrc @@ -33,6 +33,10 @@ // include ----------------------------------------------------------- #include <svl/solar.hrc> +// in solar.hrc +//#define HID_FORMS_START (HID_LIB_START+4000) +//#define HID_FORMS_END (HID_LIB_START+4999) + // Help-Ids -------------------------------------------------------------- #define HID_DLG_DBMSG ( HID_FORMS_START + 1) #define HID_FORM_NAVIGATOR ( HID_FORMS_START + 2) diff --git a/svx/inc/pch/precompiled_svx.hxx b/svx/inc/pch/precompiled_svx.hxx index 31df878ba804..59160d19c9f0 100644 --- a/svx/inc/pch/precompiled_svx.hxx +++ b/svx/inc/pch/precompiled_svx.hxx @@ -57,7 +57,7 @@ #include "basic/sbxvar.hxx" #include "boost/scoped_ptr.hpp" #include "boost/shared_ptr.hpp" -#include "boost/spirit/core.hpp" +#include "boost/spirit/include/classic_core.hpp" #include "bootstrp/sstring.hxx" #include "com/sun/star/accessibility/AccessibleEventId.hpp" #include "com/sun/star/accessibility/AccessibleEventObject.hpp" @@ -263,7 +263,7 @@ #include "com/sun/star/form/XDatabaseParameterListener.hpp" #include "com/sun/star/form/XForm.hpp" #include "com/sun/star/form/XFormComponent.hpp" -#include "com/sun/star/form/XFormController.hpp" +#include "com/sun/star/form/runtime/XFormController.hpp" #include "com/sun/star/form/XFormControllerListener.hpp" #include "com/sun/star/form/XFormsSupplier.hpp" #include "com/sun/star/form/XFormsSupplier2.hpp" diff --git a/svx/inc/svx/fmdpage.hxx b/svx/inc/svx/fmdpage.hxx index f71cc4751a63..a9f2783d643a 100644 --- a/svx/inc/svx/fmdpage.hxx +++ b/svx/inc/svx/fmdpage.hxx @@ -31,11 +31,6 @@ #define _SVX_FMDPAGE_HXX #include <com/sun/star/form/XFormsSupplier2.hpp> -#include <com/sun/star/form/XForm.hpp> -#include <com/sun/star/form/XImageProducerSupplier.hpp> -#include <com/sun/star/form/XFormController.hpp> -#include <com/sun/star/form/XFormComponent.hpp> -#include <com/sun/star/form/XFormControllerListener.hpp> #include <svx/unopage.hxx> #include <comphelper/uno3.hxx> #include "svx/svxdllapi.h" diff --git a/svx/inc/svx/fmgridcl.hxx b/svx/inc/svx/fmgridcl.hxx index f6b533513784..f8e04c4c405c 100644 --- a/svx/inc/svx/fmgridcl.hxx +++ b/svx/inc/svx/fmgridcl.hxx @@ -31,13 +31,8 @@ #define _SVX_FMGRIDCL_HXX #include <com/sun/star/container/XIndexContainer.hpp> - -#ifndef _COM_SUN_STAR_FORM_XINDEXCONTAINER_HPP_ -#include <com/sun/star/container/XIndexContainer.hpp> -#endif #include <com/sun/star/container/XNameContainer.hpp> -// alles nur fuer stl #include <svx/gridctrl.hxx> #include <svtools/transfer.hxx> #include "svx/svxdllapi.h" diff --git a/svx/inc/svx/fmshell.hxx b/svx/inc/svx/fmshell.hxx index f5d1c7b0c615..9f180156367f 100644 --- a/svx/inc/svx/fmshell.hxx +++ b/svx/inc/svx/fmshell.hxx @@ -58,7 +58,9 @@ class SdrUnoObj; namespace com { namespace sun { namespace star { namespace form { class XForm; - class XFormController; + namespace runtime { + class XFormController; + } } } } } //======================================================================== @@ -147,7 +149,7 @@ public: const OutputDevice& _rDevice, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _out_rxControl ) const; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > GetFormController( + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > GetFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const SdrView& _rView, const OutputDevice& _rDevice diff --git a/svx/inc/svx/fmtools.hxx b/svx/inc/svx/fmtools.hxx index 02e063e0314d..b74f00aa236c 100644 --- a/svx/inc/svx/fmtools.hxx +++ b/svx/inc/svx/fmtools.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmtools.hxx,v $ - * $Revision: 1.27 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -30,6 +27,8 @@ #ifndef _SVX_FMTOOLS_HXX #define _SVX_FMTOOLS_HXX +#include "svx/svxdllapi.h" + #include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> #include <com/sun/star/sdbcx/Privilege.hpp> @@ -48,7 +47,6 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XDispatchProviderInterception.hpp> #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> -#include <com/sun/star/frame/XInterceptorInfo.hpp> #include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/frame/XStatusListener.hpp> @@ -66,38 +64,18 @@ #include <com/sun/star/awt/FontStrikeout.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <vcl/wintypes.hxx> -#include <vos/mutex.hxx> - -#ifndef _SVSTDARR_ULONGS -#define _SVSTDARR_ULONGS -#include <svl/svstdarr.hxx> -#endif -#include <sfx2/ctrlitem.hxx> -#include <tools/link.hxx> -#include <tools/date.hxx> -#include <tools/time.hxx> -#include <tools/datetime.hxx> - -//#include "fmprop.hrc" #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/io/XObjectInputStream.hpp> #include <com/sun/star/io/XObjectOutputStream.hpp> #include <com/sun/star/io/XPersistObject.hpp> #include <com/sun/star/util/XNumberFormatter.hpp> #include <com/sun/star/util/XNumberFormats.hpp> -#include <cppuhelper/interfacecontainer.h> -#include <cppuhelper/compbase2.hxx> -#include <cppuhelper/compbase3.hxx> + +#include <vcl/wintypes.hxx> #include <cppuhelper/weakref.hxx> #include <comphelper/uno3.hxx> #include <comphelper/stl_types.hxx> #include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> -#include <cppuhelper/component.hxx> - -#include <svx/svxdllapi.h> #include <set> @@ -114,24 +92,7 @@ SVX_DLLPUBLIC void displayException(const ::com::sun::star::sdb::SQLContext&, Wi void displayException(const ::com::sun::star::sdb::SQLErrorEvent&, Window* _pParent = NULL); void displayException(const ::com::sun::star::uno::Any&, Window* _pParent = NULL); -#define DATA_MODE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) -#define FILTER_MODE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) - -// Kopieren von Persistenten Objecten -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> cloneUsingProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject>& _xObj); - -sal_Int32 findPos(const ::rtl::OUString& aStr, const ::com::sun::star::uno::Sequence< ::rtl::OUString>& rList); - -// Suchen in einer Indexliste nach einem Element -sal_Bool searchElement(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& xCont, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElement); - sal_Int32 getElementPos(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& xCont, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xElement); -String getFormComponentAccessPath(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xElement); -String getFormComponentAccessPath(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xElement, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rTopLevelElement); -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> getElementFromAccessPath(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xParent, const String& _rRelativePath); - - -::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel> getXModel(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xIface); SVX_DLLPUBLIC ::rtl::OUString getLabelName(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& xControlModel); @@ -236,10 +197,8 @@ protected: void setAdapter(FmXDisposeMultiplexer* pAdapter); }; -typedef ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener> FmXDisposeMultiplexer_x; //============================================================================== - class FmXDisposeMultiplexer :public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener> { ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> m_xObject; @@ -258,119 +217,10 @@ public: // ================================================================== -//======================================================================== -//= dispatch interception helper classes -//======================================================================== - -//------------------------------------------------------------------------ -//- FmDispatchInterceptor -//------------------------------------------------------------------------ -class FmDispatchInterceptor -{ -public: - FmDispatchInterceptor() { } - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> interceptedQueryDispatch(sal_uInt16 _nId, - const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException ) = 0; - - virtual ::osl::Mutex* getInterceptorMutex() = 0; -}; - -//------------------------------------------------------------------------ -//- FmXDispatchInterceptorImpl -//------------------------------------------------------------------------ -typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::frame::XDispatchProviderInterceptor - , ::com::sun::star::lang::XEventListener - , ::com::sun::star::frame::XInterceptorInfo - > FmXDispatchInterceptorImpl_BASE; - -class FmXDispatchInterceptorImpl : public FmXDispatchInterceptorImpl_BASE -{ - ::osl::Mutex m_aFallback; - - // the component which's dispatches we're intercepting - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProviderInterception> - m_xIntercepted; - sal_Bool m_bListening; - - // the real interceptor - FmDispatchInterceptor* m_pMaster; - - // chaining - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xSlaveDispatcher; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xMasterDispatcher; - - // our id - sal_Int16 m_nId; - - ::com::sun::star::uno::Sequence< ::rtl::OUString > - m_aInterceptedURLSchemes; - - virtual ~FmXDispatchInterceptorImpl(); - -public: - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception> getIntercepted() const { return m_xIntercepted; } - -public: - FmXDispatchInterceptorImpl( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _rToIntercept, - FmDispatchInterceptor* _pMaster, - sal_Int16 _nId, - ::com::sun::star::uno::Sequence< ::rtl::OUString > _rInterceptedSchemes /// if not empty, this will be used for getInterceptedURLs - ); - - // StarOne - DECLARE_UNO3_DEFAULTS(FmXDispatchInterceptorImpl, FmXDispatchInterceptorImpl_BASE); - // virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - // ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - - - // ::com::sun::star::frame::XDispatchProvider - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::frame::XDispatchProviderInterceptor - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewDispatchProvider ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSupplier ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::frame::XInterceptorInfo - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getInterceptedURLs( ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::lang::XEventListener - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); - - // OComponentHelper - virtual void SAL_CALL disposing(); - -protected: - void ImplDetach(); - - ::osl::Mutex& getAccessSafety() - { - if (m_pMaster && m_pMaster->getInterceptorMutex()) - return *m_pMaster->getInterceptorMutex(); - return m_aFallback; - } -}; - -//================================================================== -// ... -//================================================================== -::rtl::OUString getServiceNameByControlType(sal_Int16 nType); - // get a service name to create a model of the given type (OBJ_FM_...) sal_Int16 getControlTypeByObject(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>& _rxObject); // get the object type (OBJ_FM_...) from the services the object supports -void TransferEventScripts(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& xModel, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, - const ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor>& rTransferIfAvailable); - -sal_Int16 GridView2ModelPos(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& rColumns, sal_Int16 nViewPos); - //================================================================== -sal_Bool isLoadable(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& xLoad); sal_Bool isRowSetAlive(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _rxRowSet); // checks if the ::com::sun::star::sdbcx::XColumnsSupplier provided by _rxRowSet supllies any columns diff --git a/svx/inc/svx/fmview.hxx b/svx/inc/svx/fmview.hxx index c79748ddb94f..3b965967ed42 100644 --- a/svx/inc/svx/fmview.hxx +++ b/svx/inc/svx/fmview.hxx @@ -54,7 +54,9 @@ namespace svx { class SdrUnoObj; namespace com { namespace sun { namespace star { namespace form { class XForm; - class XFormController; + namespace runtime { + class XFormController; + } } } } } class SVX_DLLPUBLIC FmFormView : public E3dView @@ -125,7 +127,7 @@ public: /** returns the form controller for a given form and a given device */ - SVX_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > + SVX_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > GetFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const; // SdrView diff --git a/svx/inc/svx/gridctrl.hxx b/svx/inc/svx/gridctrl.hxx index 632ca6ea0805..834ea17eaa1f 100644 --- a/svx/inc/svx/gridctrl.hxx +++ b/svx/inc/svx/gridctrl.hxx @@ -584,9 +584,10 @@ protected: sal_Int32 GetSeekPos() const {return m_nSeekPos;} sal_Int32 GetTotalCount() const {return m_nTotalCount;} - const DbGridRowRef& GetEmptyRow() const {return m_xEmptyRow;} - const DbGridRowRef& GetSeekRow() const {return m_xSeekRow;} - CursorWrapper* GetSeekCursor() const {return m_pSeekCursor;} + const DbGridRowRef& GetEmptyRow() const { return m_xEmptyRow; } + const DbGridRowRef& GetSeekRow() const { return m_xSeekRow; } + const DbGridRowRef& GetPaintRow() const { return m_xPaintRow; } + CursorWrapper* GetSeekCursor() const { return m_pSeekCursor; } void ConnectToFields(); void DisconnectFromFields(); diff --git a/svx/inc/svx/sdr/contact/objectcontact.hxx b/svx/inc/svx/sdr/contact/objectcontact.hxx index 3990c48695a3..c0388f152643 100644 --- a/svx/inc/svx/sdr/contact/objectcontact.hxx +++ b/svx/inc/svx/sdr/contact/objectcontact.hxx @@ -90,8 +90,7 @@ namespace sdr sdr::event::TimerEventHandler* mpEventHandler; // The redirector. If set it is used to pipe all supported calls - // to the redirector. When one is set at the ViewContact too, the one at - // the ViewContact will win. + // to the redirector ViewObjectContactRedirector* mpViewObjectContactRedirector; // the Primitive2DParameters containing view information diff --git a/svx/inc/svx/sdr/contact/viewobjectcontactofunocontrol.hxx b/svx/inc/svx/sdr/contact/viewobjectcontactofunocontrol.hxx index f6cc2abf32f6..109f86fe458b 100644 --- a/svx/inc/svx/sdr/contact/viewobjectcontactofunocontrol.hxx +++ b/svx/inc/svx/sdr/contact/viewobjectcontactofunocontrol.hxx @@ -99,6 +99,11 @@ namespace sdr { namespace contact { */ virtual void ActionChanged(); + /** to be called when any aspect of the control which requires view updates changed + */ + struct ImplAccess { friend class ViewObjectContactOfUnoControl_Impl; friend class ViewObjectContactOfUnoControl; private: ImplAccess() { } }; + void onControlChangedOrModified( ImplAccess ) { impl_onControlChangedOrModified(); } + protected: ~ViewObjectContactOfUnoControl(); @@ -107,6 +112,8 @@ namespace sdr { namespace contact { // visibility check virtual bool isPrimitiveVisible( const DisplayInfo& _rDisplayInfo ) const; + /// to be called when any aspect of the control which requires view updates changed + void impl_onControlChangedOrModified(); private: ViewObjectContactOfUnoControl(); // never implemented diff --git a/svx/inc/svx/sdr/overlay/overlaytools.hxx b/svx/inc/svx/sdr/overlay/overlaytools.hxx index d9a1b34dd8f6..830f3dc12586 100644 --- a/svx/inc/svx/sdr/overlay/overlaytools.hxx +++ b/svx/inc/svx/sdr/overlay/overlaytools.hxx @@ -58,7 +58,7 @@ namespace drawinglayer sal_uInt16 mnCenterY; protected: - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: OverlayBitmapExPrimitive( @@ -99,7 +99,7 @@ namespace drawinglayer double mfDiscreteDashLength; protected: - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: OverlayCrosshairPrimitive( @@ -148,7 +148,7 @@ namespace drawinglayer double mfRotation; protected: - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: OverlayHatchRectanglePrimitive( @@ -206,7 +206,7 @@ namespace drawinglayer double mfDiscreteDashLength; protected: - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: OverlayHelplineStripedPrimitive( @@ -251,7 +251,7 @@ namespace drawinglayer double mfDiscreteDashLength; protected: - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; public: OverlayRollingRectanglePrimitive( diff --git a/svx/inc/svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx index 01bb7794e9f3..177c42bfff17 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx @@ -46,7 +46,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrCaptionPrimitive2D : public BasePrimitive2D + class SdrCaptionPrimitive2D : public BufferedDecompositionPrimitive2D { private: ::basegfx::B2DHomMatrix maTransform; @@ -57,7 +57,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrCaptionPrimitive2D( diff --git a/svx/inc/svx/sdr/primitive2d/sdrconnectorprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrconnectorprimitive2d.hxx index ba7cc7fed9c8..5523480f1f51 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrconnectorprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrconnectorprimitive2d.hxx @@ -45,7 +45,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrConnectorPrimitive2D : public BasePrimitive2D + class SdrConnectorPrimitive2D : public BufferedDecompositionPrimitive2D { private: attribute::SdrLineShadowTextAttribute maSdrLSTAttribute; @@ -53,7 +53,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrConnectorPrimitive2D( diff --git a/svx/inc/svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx index 8f7f0eb23cb3..72035eb99569 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx @@ -45,7 +45,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrCustomShapePrimitive2D : public BasePrimitive2D + class SdrCustomShapePrimitive2D : public BufferedDecompositionPrimitive2D { private: attribute::SdrShadowTextAttribute maSdrSTAttribute; @@ -57,16 +57,16 @@ namespace drawinglayer // that the text needs to be block formatted unsigned mbWordWrap : 1; - // #SJ# Allow text clipping against TextBox in special cases (used for SC) - unsigned mbForceTextClipToTextRange : 1; - // defines that the object contains/is a 3D AutoShape. Needed for // making exceptions with shadow generation unsigned mb3DShape : 1; + // #SJ# Allow text clipping against TextBox in special cases (used for SC)
+ unsigned mbForceTextClipToTextRange : 1;
+ protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrCustomShapePrimitive2D( @@ -74,16 +74,16 @@ namespace drawinglayer const Primitive2DSequence& rSubPrimitives, const basegfx::B2DHomMatrix& rTextBox, bool bWordWrap, - bool bForceTextClipToTextRange, - bool b3DShape); + bool b3DShape, + bool bForceTextClipToTextRange); // data access const attribute::SdrShadowTextAttribute& getSdrSTAttribute() const { return maSdrSTAttribute; } const Primitive2DSequence& getSubPrimitives() const { return maSubPrimitives; } const basegfx::B2DHomMatrix& getTextBox() const { return maTextBox; } bool getWordWrap() const { return mbWordWrap; } + bool get3DShape() const { return mb3DShape; } bool isForceTextClipToTextRange() const { return mbForceTextClipToTextRange; } - bool get3DShape() const { return mb3DShape; } // compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; diff --git a/svx/inc/svx/sdr/primitive2d/sdrellipseprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrellipseprimitive2d.hxx index 1ef6d0864a3a..1d11c27ede71 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrellipseprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrellipseprimitive2d.hxx @@ -45,7 +45,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrEllipsePrimitive2D : public BasePrimitive2D + class SdrEllipsePrimitive2D : public BufferedDecompositionPrimitive2D { private: ::basegfx::B2DHomMatrix maTransform; @@ -53,7 +53,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrEllipsePrimitive2D( @@ -91,7 +91,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrEllipseSegmentPrimitive2D( diff --git a/svx/inc/svx/sdr/primitive2d/sdrgrafprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrgrafprimitive2d.hxx index c8d68b8307e3..926e977e20af 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrgrafprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrgrafprimitive2d.hxx @@ -47,7 +47,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrGrafPrimitive2D : public BasePrimitive2D + class SdrGrafPrimitive2D : public BufferedDecompositionPrimitive2D { private: ::basegfx::B2DHomMatrix maTransform; @@ -57,7 +57,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrGrafPrimitive2D( diff --git a/svx/inc/svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx index a7084993b5f2..3e998f23fd2b 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrmeasureprimitive2d.hxx @@ -59,7 +59,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrMeasurePrimitive2D : public BasePrimitive2D + class SdrMeasurePrimitive2D : public BufferedDecompositionPrimitive2D { private: attribute::SdrLineShadowTextAttribute maSdrLSTAttribute; @@ -89,7 +89,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrMeasurePrimitive2D( diff --git a/svx/inc/svx/sdr/primitive2d/sdrole2primitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrole2primitive2d.hxx index 7c7081720034..2deaf474e12e 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrole2primitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrole2primitive2d.hxx @@ -32,7 +32,7 @@ #ifndef INCLUDED_SDR_PRIMITIVE2D_SDROLE2PRIMITIVE2D_HXX #define INCLUDED_SDR_PRIMITIVE2D_SDROLE2PRIMITIVE2D_HXX -#include <drawinglayer/primitive2d/groupprimitive2d.hxx> +#include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <drawinglayer/attribute/sdrattribute.hxx> #include <svx/sdr/attribute/sdrallattribute.hxx> @@ -46,29 +46,30 @@ namespace drawinglayer { namespace primitive2d { - class SdrOle2Primitive2D : public GroupPrimitive2D + class SdrOle2Primitive2D : public BasePrimitive2D { private: - ::basegfx::B2DHomMatrix maTransform; + Primitive2DSequence maOLEContent; + basegfx::B2DHomMatrix maTransform; attribute::SdrLineFillShadowTextAttribute maSdrLFSTAttribute; - protected: - // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; - public: SdrOle2Primitive2D( - const Primitive2DSequence& rChildren, - const ::basegfx::B2DHomMatrix& rTransform, + const Primitive2DSequence& rOLEContent, + const basegfx::B2DHomMatrix& rTransform, const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute); // data access - const ::basegfx::B2DHomMatrix& getTransform() const { return maTransform; } + const Primitive2DSequence& getOLEContent() const { return maOLEContent; } + const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } const attribute::SdrLineFillShadowTextAttribute& getSdrLFSTAttribute() const { return maSdrLFSTAttribute; } // compare operator virtual bool operator==(const BasePrimitive2D& rPrimitive) const; + // local decomposition. + virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + // provide unique ID DeclPrimitrive2DIDBlock() }; diff --git a/svx/inc/svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx index 9ee4f3f69417..ff04a6a5e79b 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx @@ -47,7 +47,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrOleContentPrimitive2D : public BasePrimitive2D + class SdrOleContentPrimitive2D : public BufferedDecompositionPrimitive2D { private: SdrObjectWeakRef mpSdrOle2Obj; @@ -63,7 +63,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrOleContentPrimitive2D( diff --git a/svx/inc/svx/sdr/primitive2d/sdrpathprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrpathprimitive2d.hxx index 97b12b72d4a5..d6de666d901f 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrpathprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrpathprimitive2d.hxx @@ -46,7 +46,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrPathPrimitive2D : public BasePrimitive2D + class SdrPathPrimitive2D : public BufferedDecompositionPrimitive2D { private: basegfx::B2DHomMatrix maTransform; @@ -55,7 +55,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrPathPrimitive2D( diff --git a/svx/inc/svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx index 23bbc2676f22..816956b188fe 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx @@ -46,7 +46,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrRectanglePrimitive2D : public BasePrimitive2D + class SdrRectanglePrimitive2D : public BufferedDecompositionPrimitive2D { private: basegfx::B2DHomMatrix maTransform; @@ -60,7 +60,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrRectanglePrimitive2D( diff --git a/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx b/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx index 90da2877fb76..deec999eefa2 100644 --- a/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx +++ b/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx @@ -52,7 +52,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrTextPrimitive2D : public BasePrimitive2D + class SdrTextPrimitive2D : public BufferedDecompositionPrimitive2D { private: // The text model data; this sould later just be the OutlinerParaObject or @@ -131,7 +131,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrContourTextPrimitive2D( @@ -173,7 +173,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrPathTextPrimitive2D( @@ -223,7 +223,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrBlockTextPrimitive2D( @@ -277,7 +277,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrStretchTextPrimitive2D( diff --git a/svx/inc/svx/svdograf.hxx b/svx/inc/svx/svdograf.hxx index 0b9280f55d53..ed15118b0758 100644 --- a/svx/inc/svx/svdograf.hxx +++ b/svx/inc/svx/svdograf.hxx @@ -144,6 +144,7 @@ public: void SetGraphicObject( const GraphicObject& rGrfObj ); const GraphicObject& GetGraphicObject( bool bForceSwapIn = false) const; + void NbcSetGraphic(const Graphic& rGrf); void SetGraphic(const Graphic& rGrf); const Graphic& GetGraphic() const; diff --git a/svx/inc/svx/svdpage.hxx b/svx/inc/svx/svdpage.hxx index 6f2753c4e896..3523308b6e8f 100644 --- a/svx/inc/svx/svdpage.hxx +++ b/svx/inc/svx/svdpage.hxx @@ -563,6 +563,9 @@ public: const sdr::contact::DisplayInfo& rDisplayInfo, bool bEdit ); + /** Check if page is the HandoutMasterPage (in SVX, no PK_HANDOUT available) */ + bool isHandoutMasterPage() const; + ////////////////////////////////////////////////////////////////////////////// // sdr::Comment interface private: diff --git a/svx/inc/svx/svdpntv.hxx b/svx/inc/svx/svdpntv.hxx index 940133da5568..014afacb0706 100644..100755 --- a/svx/inc/svx/svdpntv.hxx +++ b/svx/inc/svx/svdpntv.hxx @@ -215,10 +215,11 @@ protected: // is this a preview renderer? unsigned mbPreviewRenderer : 1; - // flags for calc for suppressing OLE, CHART or DRAW objects + // flags for calc and sw for suppressing OLE, CHART or DRAW objects unsigned mbHideOle : 1; unsigned mbHideChart : 1; - unsigned mbHideDraw : 1; + unsigned mbHideDraw : 1; // hide draw objects other than form controls + unsigned mbHideFormControl : 1; // hide form controls only public: // #114898# @@ -433,13 +434,15 @@ public: sal_Bool IsPreviewRenderer() const { return (sal_Bool )mbPreviewRenderer; } void SetPreviewRenderer(bool bOn) { if((unsigned)bOn != mbPreviewRenderer) { mbPreviewRenderer=bOn; }} - // access methods for calc hide object modes + // access methods for calc and sw hide object modes bool getHideOle() const { return mbHideOle; } bool getHideChart() const { return mbHideChart; } bool getHideDraw() const { return mbHideDraw; } + bool getHideFormControl() const { return mbHideFormControl; } void setHideOle(bool bNew) { if(bNew != (bool)mbHideOle) mbHideOle = bNew; } void setHideChart(bool bNew) { if(bNew != (bool)mbHideChart) mbHideChart = bNew; } void setHideDraw(bool bNew) { if(bNew != (bool)mbHideDraw) mbHideDraw = bNew; } + void setHideFormControl(bool bNew) { if(bNew != (bool)mbHideFormControl) mbHideFormControl = bNew; } void SetGridCoarse(const Size& rSiz) { aGridBig=rSiz; } void SetGridFine(const Size& rSiz) { aGridFin=rSiz; if (aGridFin.Height()==0) aGridFin.Height()=aGridFin.Width(); if (bGridVisible) InvalidateAllWin(); } // #40479# diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx index 58455f48589e..513a3aa57a80 100644 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -33,7 +33,7 @@ // include --------------------------------------------------------------- #include <sfx2/viewsh.hxx> // SfxViewShell -#include <sfx2/printer.hxx> // SfxPrinter +#include <sfx2/printer.hxx> // Printer #include <vcl/metric.hxx> #include <vcl/svapp.hxx> #include <unicode/uchar.h> diff --git a/svx/source/engine3d/helperminimaldepth3d.cxx b/svx/source/engine3d/helperminimaldepth3d.cxx index 85ba97f1a826..35ebb4dec0f6 100644 --- a/svx/source/engine3d/helperminimaldepth3d.cxx +++ b/svx/source/engine3d/helperminimaldepth3d.cxx @@ -70,8 +70,8 @@ namespace drawinglayer void MinimalDephInViewExtractor::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rCandidate) { - // it is a BasePrimitive3D implementation, use getPrimitiveID() call for switch - switch(rCandidate.getPrimitiveID()) + // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch + switch(rCandidate.getPrimitive3DID()) { case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D : { diff --git a/svx/source/engine3d/view3d.cxx b/svx/source/engine3d/view3d.cxx index 922ceda87a6e..132dbce95892 100644 --- a/svx/source/engine3d/view3d.cxx +++ b/svx/source/engine3d/view3d.cxx @@ -77,6 +77,7 @@ #include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx> #include <svx/sdr/overlay/overlayprimitive2dsequenceobject.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> #define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue() @@ -185,9 +186,8 @@ void Impl3DMirrorConstructOverlay::SetMirrorAxis(Point aMirrorAxisA, Point aMirr // buld transfoprmation: translate and rotate so that given edge is // on x axis, them mirror in y and translate back const basegfx::B2DVector aEdge(aMirrorAxisB.X() - aMirrorAxisA.X(), aMirrorAxisB.Y() - aMirrorAxisA.Y()); - basegfx::B2DHomMatrix aMatrixTransform; - - aMatrixTransform.translate(-aMirrorAxisA.X(), -aMirrorAxisA.Y()); + basegfx::B2DHomMatrix aMatrixTransform(basegfx::tools::createTranslateB2DHomMatrix( + -aMirrorAxisA.X(), -aMirrorAxisA.Y())); aMatrixTransform.rotate(-atan2(aEdge.getY(), aEdge.getX())); aMatrixTransform.scale(1.0, -1.0); aMatrixTransform.rotate(atan2(aEdge.getY(), aEdge.getX())); @@ -932,9 +932,8 @@ void E3dView::ConvertMarkedObjTo3D(BOOL bExtrude, basegfx::B2DPoint aPnt1, baseg if(fRot3D != 0.0) { - aLatheMat.translate(-aPnt2.getX(), -aPnt2.getY()); - aLatheMat.rotate(-fRot3D); - aLatheMat.translate(aPnt2.getX(), aPnt2.getY()); + aLatheMat = basegfx::tools::createRotateAroundPoint(aPnt2, -fRot3D) + * aLatheMat; } } diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index 7a710c19cbad..35506d7d5ef4 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -35,6 +35,7 @@ #include "fmgridif.hxx" #include "fmitems.hxx" #include "fmprop.hrc" +#include "svx/fmtools.hxx" #include "fmresids.hrc" #include "fmservs.hxx" #include "fmurl.hxx" @@ -435,6 +436,7 @@ IMPL_LINK( FmGridHeader, OnAsyncExecuteDrop, void*, /*NOTINTERESTEDIN*/ ) // diese Datentypen koennen im Gridcontrol nicht verarbeitet werden switch (nDataType) { + case DataType::BLOB: case DataType::LONGVARBINARY: case DataType::BINARY: case DataType::VARBINARY: @@ -1724,6 +1726,7 @@ void FmGridControl::InitColumnByField( sal_Bool bIllegalType = sal_False; switch ( nDataType ) { + case DataType::BLOB: case DataType::LONGVARBINARY: case DataType::BINARY: case DataType::VARBINARY: @@ -1768,14 +1771,18 @@ void FmGridControl::InitColumnsByFields(const Reference< ::com::sun::star::conta Reference< XIndexContainer > xColumns( GetPeer()->getColumns() ); Reference< XNameAccess > xFieldsAsNames( _rxFields, UNO_QUERY ); - // Einfuegen mu� sich an den Column Positionen orientieren + // Einfuegen muss sich an den Column Positionen orientieren for (sal_Int32 i = 0; i < xColumns->getCount(); i++) { DbGridColumn* pCol = GetColumns().GetObject(i); - Reference< XPropertySet > xColumnModel; - ::cppu::extractInterface( xColumnModel, xColumns->getByIndex( i ) ); + OSL_ENSURE(pCol,"No grid column!"); + if ( pCol ) + { + Reference< XPropertySet > xColumnModel; + ::cppu::extractInterface( xColumnModel, xColumns->getByIndex( i ) ); - InitColumnByField( pCol, xColumnModel, xFieldsAsNames, _rxFields ); + InitColumnByField( pCol, xColumnModel, xFieldsAsNames, _rxFields ); + } } } diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index 7a0c7c0378bb..ba35a289b893 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -42,6 +42,7 @@ #include "svx/fmgridcl.hxx" #include "svx/svxids.hrc" +/** === begin UNO includes === **/ #include <com/sun/star/awt/PosSize.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/form/FormComponentType.hpp> @@ -52,6 +53,8 @@ #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> #include <com/sun/star/util/XURLTransformer.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/sdbcx/XRowLocate.hpp> +/** === end UNO includes === **/ #include <comphelper/container.hxx> #include <comphelper/enumhelper.hxx> @@ -66,6 +69,7 @@ using namespace ::svxform; using namespace ::com::sun::star::container; +using namespace ::com::sun::star::sdb; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::view; @@ -1118,7 +1122,7 @@ namespace fmgridif { const ::rtl::OUString getDataModeIdentifier() { - static ::rtl::OUString s_sDataModeIdentifier = DATA_MODE; + static ::rtl::OUString s_sDataModeIdentifier = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ); return s_sDataModeIdentifier; } } @@ -1390,8 +1394,8 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type // don't use GetCurrentRow as this isn't affected by the above SeekRow // FS - 30.09.99 - 68644 - DbGridRowRef aRow = pGrid->GetSeekRow(); - DBG_ASSERT(aRow.Is(), "FmXGridPeer::queryFieldData : invalid current Row !"); + DbGridRowRef xPaintRow = pGrid->GetPaintRow(); + ENSURE_OR_THROW( xPaintRow.Is(), "invalid paint row" ); // die Columns des Controls brauche ich fuer GetFieldText DbGridColumns aColumns = pGrid->GetColumns(); @@ -1413,39 +1417,40 @@ Sequence< Any > SAL_CALL FmXGridPeer::queryFieldData( sal_Int32 nRow, const Type // don't use GetCurrentFieldValue to determine the field content as this isn't affected by the above SeekRow // FS - 30.09.99 - 68644 pCol = aColumns.GetObject(nModelPos); - const DbGridRowRef xRow = pGrid->GetSeekRow(); - xFieldContent = (xRow.Is() && xRow->HasField(pCol->GetFieldPos())) ? xRow->GetField(pCol->GetFieldPos()).getColumn() : Reference< ::com::sun::star::sdb::XColumn > (); + xFieldContent = xPaintRow->HasField( pCol->GetFieldPos() ) + ? xPaintRow->GetField( pCol->GetFieldPos() ).getColumn() + : Reference< XColumn > (); + + if ( !xFieldContent.is() ) + continue; - if (xFieldContent.is()) + if (bRequestedAsAny) { - if (bRequestedAsAny) - { - Reference< XPropertySet > xFieldSet(xFieldContent, UNO_QUERY); - pReturnArray[i] = xFieldSet->getPropertyValue(FM_PROP_VALUE); - } - else + Reference< XPropertySet > xFieldSet(xFieldContent, UNO_QUERY); + pReturnArray[i] = xFieldSet->getPropertyValue(FM_PROP_VALUE); + } + else + { + switch (xType.getTypeClass()) { - switch (xType.getTypeClass()) + // Strings werden direkt ueber das GetFieldText abgehandelt + case TypeClass_STRING : { - // Strings werden direkt ueber das GetFieldText abgehandelt - case TypeClass_STRING : - { - String sText = aColumns.GetObject(nModelPos)->GetCellText(aRow, pGrid->getNumberFormatter()); - pReturnArray[i] <<= ::rtl::OUString(sText); - } - break; - // alles andere wird an der DatabaseVariant erfragt - case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break; - case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break; - case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break; - case TypeClass_LONG : pReturnArray[i] <<= (sal_Int32)xFieldContent->getLong(); break; - case TypeClass_UNSIGNED_SHORT: pReturnArray[i] <<= (sal_uInt16)xFieldContent->getShort(); break; - case TypeClass_UNSIGNED_LONG : pReturnArray[i] <<= (sal_uInt32)xFieldContent->getLong(); break; - case TypeClass_BOOLEAN : ::comphelper::setBOOL(pReturnArray[i],xFieldContent->getBoolean()); break; - default: - { - throw IllegalArgumentException(); - } + String sText = aColumns.GetObject(nModelPos)->GetCellText( xPaintRow, pGrid->getNumberFormatter() ); + pReturnArray[i] <<= ::rtl::OUString(sText); + } + break; + // alles andere wird an der DatabaseVariant erfragt + case TypeClass_FLOAT : pReturnArray[i] <<= xFieldContent->getFloat(); break; + case TypeClass_DOUBLE : pReturnArray[i] <<= xFieldContent->getDouble(); break; + case TypeClass_SHORT : pReturnArray[i] <<= (sal_Int16)xFieldContent->getShort(); break; + case TypeClass_LONG : pReturnArray[i] <<= (sal_Int32)xFieldContent->getLong(); break; + case TypeClass_UNSIGNED_SHORT : pReturnArray[i] <<= (sal_uInt16)xFieldContent->getShort(); break; + case TypeClass_UNSIGNED_LONG : pReturnArray[i] <<= (sal_uInt32)xFieldContent->getLong(); break; + case TypeClass_BOOLEAN : ::comphelper::setBOOL(pReturnArray[i],xFieldContent->getBoolean()); break; + default: + { + throw IllegalArgumentException(); } } } @@ -1724,6 +1729,8 @@ void FmXGridPeer::removeColumnListeners(const Reference< XPropertySet >& xCol) //------------------------------------------------------------------------------ void FmXGridPeer::setColumns(const Reference< XIndexContainer >& Columns) throw( RuntimeException ) { + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + FmGridControl* pGrid = static_cast< FmGridControl* >( GetWindow() ); if (m_xColumns.is()) @@ -2457,7 +2464,7 @@ void FmXGridPeer::setMode(const ::rtl::OUString& Mode) throw( NoSupportException m_aMode = Mode; FmGridControl* pGrid = (FmGridControl*) GetWindow(); - if (Mode == FILTER_MODE) + if ( Mode == ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) ) pGrid->SetFilterMode(sal_True); else { @@ -2480,8 +2487,8 @@ void FmXGridPeer::setMode(const ::rtl::OUString& Mode) throw( NoSupportException { aModes.realloc(2); ::rtl::OUString* pModes = aModes.getArray(); - pModes[0] = DATA_MODE; - pModes[1] = FILTER_MODE; + pModes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ); + pModes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ); } return aModes; } diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index f4229b1bcb0c..c94a63c853f4 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -679,7 +679,15 @@ sal_Bool DbCellControl::Commit() // lock the listening for value property changes lockValueProperty(); // commit the content of the control into the model's value property - sal_Bool bReturn = commitControl(); + sal_Bool bReturn = sal_False; + try + { + bReturn = commitControl(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } // unlock the listening for value property changes unlockValueProperty(); // outta here diff --git a/svx/source/fmcomp/gridcols.cxx b/svx/source/fmcomp/gridcols.cxx index f56f8e0c7e86..a6ab95d28981 100644 --- a/svx/source/fmcomp/gridcols.cxx +++ b/svx/source/fmcomp/gridcols.cxx @@ -35,6 +35,7 @@ #include <comphelper/types.hxx> #include "fmservs.hxx" #include "svx/fmtools.hxx" +using namespace ::com::sun::star::uno; //------------------------------------------------------------------------------ const ::comphelper::StringSequence& getColumnTypes() @@ -57,6 +58,36 @@ const ::comphelper::StringSequence& getColumnTypes() return aColumnTypes; } +//------------------------------------------------------------------ +// Vergleichen von PropertyInfo +extern "C" int +#if defined( WNT ) + __cdecl +#endif +#if defined( ICC ) && defined( OS2 ) +_Optlink +#endif + NameCompare(const void* pFirst, const void* pSecond) +{ + return ((::rtl::OUString*)pFirst)->compareTo(*(::rtl::OUString*)pSecond); +} + +namespace +{ + //------------------------------------------------------------------------------ + sal_Int32 lcl_findPos(const ::rtl::OUString& aStr, const Sequence< ::rtl::OUString>& rList) + { + const ::rtl::OUString* pStrList = rList.getConstArray(); + ::rtl::OUString* pResult = (::rtl::OUString*) bsearch(&aStr, (void*)pStrList, rList.getLength(), sizeof(::rtl::OUString), + &NameCompare); + + if (pResult) + return (pResult - pStrList); + else + return -1; + } +} + //------------------------------------------------------------------------------ sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName) { @@ -79,7 +110,7 @@ sal_Int32 getColumnTypeByModelName(const ::rtl::OUString& aModelName) : aModelName.copy(aCompatibleModelPrefix.getLength()); const ::comphelper::StringSequence& rColumnTypes = getColumnTypes(); - nTypeId = findPos(aColumnType, rColumnTypes); + nTypeId = lcl_findPos(aColumnType, rColumnTypes); } return nTypeId; } diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index 49f0bdfafda0..173354958150 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -874,7 +874,7 @@ void DbGridRow::SetState(CursorWrapper* pCur, sal_Bool bPaintCursor) } catch(SQLException&) { - OSL_ENSURE(0,"SQLException catched while getting the bookmark"); + DBG_UNHANDLED_EXCEPTION(); m_aBookmark = Any(); m_eStatus = GRS_INVALID; m_bIsNew = sal_False; @@ -1787,30 +1787,32 @@ void DbGridControl::ColumnMoved(sal_uInt16 nId) sal_Bool DbGridControl::SeekRow(long nRow) { // in filter mode or in insert only mode we don't have any cursor! - if (SeekCursor(nRow)) + if ( !SeekCursor( nRow ) ) + return sal_False; + + if ( IsFilterMode() ) { - if (m_pSeekCursor) - { - // on the current position we have to take the current row for display as we want - // to have the most recent values for display - if ((nRow == m_nCurrentPos) && getDisplaySynchron()) - m_xPaintRow = m_xCurrentRow; - // seek to the empty insert row - else if (IsInsertionRow(nRow)) - m_xPaintRow = m_xEmptyRow; - else - { - m_xSeekRow->SetState(m_pSeekCursor, sal_True); - m_xPaintRow = m_xSeekRow; - } - } - else if (IsFilterMode()) - { - DBG_ASSERT(IsFilterRow(nRow), "DbGridControl::SeekRow(): No filter row, wrong mode"); + DBG_ASSERT( IsFilterRow( nRow ), "DbGridControl::SeekRow(): No filter row, wrong mode" ); + m_xPaintRow = m_xEmptyRow; + } + else + { + // on the current position we have to take the current row for display as we want + // to have the most recent values for display + if ( ( nRow == m_nCurrentPos ) && getDisplaySynchron() ) + m_xPaintRow = m_xCurrentRow; + // seek to the empty insert row + else if ( IsInsertionRow( nRow ) ) m_xPaintRow = m_xEmptyRow; + else + { + m_xSeekRow->SetState( m_pSeekCursor, sal_True ); + m_xPaintRow = m_xSeekRow; } - DbGridControl_Base::SeekRow(nRow); } + + DbGridControl_Base::SeekRow(nRow); + return m_nSeekPos >= 0; } //------------------------------------------------------------------------------ @@ -2382,7 +2384,7 @@ sal_Bool DbGridControl::SeekCursor(long nRow, sal_Bool bAbsolute) // da der letzte Datensatz bereits erreicht wurde! if (nRow == m_nCurrentPos) { - // auf die aktuelle Zeile bewegt, dann mu� kein abgleich gemacht werden, wenn + // auf die aktuelle Zeile bewegt, dann muß kein abgleich gemacht werden, wenn // gerade ein Datensatz eingefuegt wird m_nSeekPos = nRow; } diff --git a/svx/source/form/confirmdelete.cxx b/svx/source/form/confirmdelete.cxx deleted file mode 100644 index 819677c3f495..000000000000 --- a/svx/source/form/confirmdelete.cxx +++ /dev/null @@ -1,138 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: confirmdelete.cxx,v $ - * $Revision: 1.10 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svx.hxx" -#include "confirmdelete.hxx" -#include <svx/dialmgr.hxx> -#ifndef _SVX_FMHELP_HRC -#include "fmhelp.hrc" -#endif -#ifndef _SVX_FMRESIDS_HRC -#include "fmresids.hrc" -#endif -#include <unotools/configmgr.hxx> -#include <vcl/msgbox.hxx> - -//........................................................................ -namespace svxform -{ -//........................................................................ - -#define BORDER_HEIGHT 6 // default distance control-dialog -#define BORDER_WIDTH 6 // default distance control-dialog - - using namespace ::com::sun::star::uno; - - //==================================================================== - //= class ConfirmDeleteDialog - //==================================================================== - //------------------------------------------------------------------------------ - ConfirmDeleteDialog::ConfirmDeleteDialog(Window* pParent, const String& _rTitle) - :ButtonDialog(pParent, WB_HORZ | WB_STDDIALOG) - ,m_aInfoImage (this) - ,m_aTitle (this, WB_WORDBREAK | WB_LEFT) - ,m_aMessage (this, WB_WORDBREAK | WB_LEFT) - { - String sMessage(SVX_RES(RID_STR_DELETECONFIRM)); - - // Changed as per BugID 79541 Branding/Configuration - Any aProductName = ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTNAME); - ::rtl::OUString sProductName; - aProductName >>= sProductName; - - String aTitle = sProductName; - aProductName = ::utl::ConfigManager::GetDirectConfigProperty(::utl::ConfigManager::PRODUCTVERSION); - aProductName >>= sProductName; - aTitle.AppendAscii(" "); - aTitle += String(sProductName); - SetText(aTitle); - - SetHelpId(HID_DLG_DBMSG); - SetSizePixel(LogicToPixel(Size(220, 30),MAP_APPFONT)); - - m_aInfoImage.SetPosSizePixel(LogicToPixel(Point(6, 6),MAP_APPFONT), - LogicToPixel(Size(20, 20),MAP_APPFONT)); - m_aInfoImage.Show(); - - m_aTitle.SetPosSizePixel(LogicToPixel(Point(45, 6),MAP_APPFONT), - LogicToPixel(Size(169, 20),MAP_APPFONT)); - - Font aFont = m_aTitle.GetFont(); - aFont.SetWeight(WEIGHT_SEMIBOLD); - m_aTitle.SetFont(aFont); - m_aTitle.Show(); - - m_aMessage.SetPosSizePixel(LogicToPixel(Point(45, 29),MAP_APPFONT), - LogicToPixel(Size(169, 1),MAP_APPFONT)); - m_aMessage.Show(); - - // Image festlegen - m_aInfoImage.SetImage(WarningBox::GetStandardImage()); - - // Title setzen - m_aTitle.SetText(_rTitle); - - // Ermitteln der Hoehe des Textfeldes und des Dialogs - Size aBorderSize = LogicToPixel(Size(BORDER_WIDTH, BORDER_HEIGHT),MAP_APPFONT); - Rectangle aDlgRect(GetPosPixel(),GetSizePixel()); - Rectangle aMessageRect(m_aMessage.GetPosPixel(),m_aMessage.GetSizePixel()); - Rectangle aTextRect = - GetTextRect(aMessageRect, sMessage, TEXT_DRAW_WORDBREAK | TEXT_DRAW_MULTILINE | TEXT_DRAW_LEFT); - - long nHText = aTextRect.Bottom() > aMessageRect.Bottom() ? aTextRect.Bottom() - aMessageRect.Bottom() : 0; - - aDlgRect.Bottom() += nHText + 2 * aBorderSize.Height(); - aMessageRect.Bottom() += nHText; - - // Dialog anpassen - SetSizePixel(aDlgRect.GetSize()); - SetPageSizePixel(aDlgRect.GetSize()); - - // Message Text anpassen und setzen - m_aMessage.SetSizePixel(aMessageRect.GetSize()); - m_aMessage.SetText(sMessage); - - // Buttons anlegen - AddButton(BUTTON_YES, BUTTONID_YES, 0); - AddButton(BUTTON_NO, BUTTONID_NO, BUTTONDIALOG_DEFBUTTON | BUTTONDIALOG_FOCUSBUTTON); - } - - //------------------------------------------------------------------------------ - ConfirmDeleteDialog::~ConfirmDeleteDialog() - { - } - -//........................................................................ -} // namespace svxform -//........................................................................ - - - diff --git a/svx/source/form/delayedevent.cxx b/svx/source/form/delayedevent.cxx index c6bce8efec98..a185ef04d389 100644 --- a/svx/source/form/delayedevent.cxx +++ b/svx/source/form/delayedevent.cxx @@ -5,10 +5,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * -* $RCSfile: delayedevent.cxx,v $ -* -* $Revision: 1.1.2.1 $ -* * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx index b9ef8224a9ef..f3a5a67d39e6 100644 --- a/svx/source/form/filtnav.cxx +++ b/svx/source/form/filtnav.cxx @@ -30,50 +30,41 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#ifndef _SVX_FMRESIDS_HRC -#include "fmresids.hrc" -#endif -#include "fmctrler.hxx" -#include "filtnav.hxx" -#include <com/sun/star/util/XNumberFormatter.hpp> -#include <com/sun/star/form/XFormController.hpp> -#include <fmexch.hxx> -#include "fmitems.hxx" -#ifndef _SVX_SVXIDS_HRC -#include <svx/svxids.hrc> -#endif -#ifndef _SVX_FMPROP_HRC +#include "filtnav.hxx" +#include "fmexch.hxx" +#include "fmhelp.hrc" +#include "fmitems.hxx" #include "fmprop.hrc" -#endif +#include "fmresids.hrc" +#include "gridcell.hxx" -#ifndef _SVX_FMHELP_HRC -#include "fmhelp.hrc" -#endif -#include <svx/dialmgr.hxx> -#include <sfx2/dispatch.hxx> -#include <sfx2/objsh.hxx> -#include <sfx2/objitem.hxx> -#include <sfx2/request.hxx> -#include <tools/shl.hxx> +/** === begin UNO includes === **/ +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/util/XNumberFormatter.hpp> +/** === end UNO includes === **/ -#ifndef _WRKWIN_HXX //autogen -#include <vcl/wrkwin.hxx> -#endif -#include <svx/fmshell.hxx> -#include <fmshimp.hxx> -#include <fmservs.hxx> +#include <comphelper/processfactory.hxx> #include <svx/fmtools.hxx> -#include <cppuhelper/implbase1.hxx> #include <comphelper/property.hxx> +#include <comphelper/sequence.hxx> #include <comphelper/uno3.hxx> #include <connectivity/dbtools.hxx> -#include <comphelper/processfactory.hxx> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <comphelper/sequence.hxx> -#include "gridcell.hxx" +#include <cppuhelper/implbase1.hxx> +#include <fmservs.hxx> +#include <fmshimp.hxx> #include <rtl/logfile.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objitem.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> +#include <svx/dialmgr.hxx> +#include <svx/fmshell.hxx> +#include <svx/svxids.hrc> +#include <tools/shl.hxx> +#include <vcl/wrkwin.hxx> #include <functional> @@ -85,11 +76,6 @@ #define DROP_ACTION_TIMER_TICK_BASE 10 // das ist die Basis, mit der beide Angaben multipliziert werden (in ms) -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::beans; using namespace ::svxform; using namespace ::connectivity::simple; using namespace ::connectivity; @@ -100,6 +86,37 @@ namespace svxform { //........................................................................ + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::awt::TextEvent; + using ::com::sun::star::container::XIndexAccess; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::form::runtime::XFormController; + using ::com::sun::star::form::runtime::XFilterController; + using ::com::sun::star::form::runtime::XFilterControllerListener; + using ::com::sun::star::form::runtime::FilterEvent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::form::XForm; + using ::com::sun::star::container::XChild; + using ::com::sun::star::awt::XControl; + using ::com::sun::star::sdbc::XConnection; + using ::com::sun::star::util::XNumberFormatsSupplier; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::util::XNumberFormatter; + using ::com::sun::star::sdbc::XRowSet; + using ::com::sun::star::lang::Locale; + using ::com::sun::star::sdb::SQLContext; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::awt::XTextComponent; + using ::com::sun::star::uno::Sequence; + /** === end UNO using === **/ + //======================================================================== OFilterItemExchange::OFilterItemExchange() { @@ -141,8 +158,8 @@ TYPEINIT1(FmParentData, FmFilterData); //------------------------------------------------------------------------ FmParentData::~FmParentData() { - for (::std::vector<FmFilterData*>::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) + for (::std::vector<FmFilterData*>::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end(); i++) delete (*i); } @@ -168,16 +185,17 @@ Image FmFormItem::GetImage( BmpColorMode _eMode ) const //======================================================================== TYPEINIT1(FmFilterItems, FmParentData); //------------------------------------------------------------------------ -FmFilterItem* FmFilterItems::Find(const Reference< ::com::sun::star::awt::XTextComponent > & _xText) const +FmFilterItem* FmFilterItems::Find( const ::sal_Int32 _nFilterComponentIndex ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterItems::Find" ); - for (::std::vector<FmFilterData*>::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); ++i) + for ( ::std::vector< FmFilterData* >::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end(); + ++i + ) { - FmFilterItem* pCond = PTR_CAST(FmFilterItem, *i); - DBG_ASSERT(pCond, "Wrong element in container"); - if (_xText == pCond->GetTextComponent()) - return pCond; + FmFilterItem* pCondition = PTR_CAST( FmFilterItem, *i ); + DBG_ASSERT( pCondition, "FmFilterItems::Find: Wrong element in container!" ); + if ( _nFilterComponentIndex == pCondition->GetComponentIndex() ) + return pCondition; } return NULL; } @@ -185,7 +203,6 @@ FmFilterItem* FmFilterItems::Find(const Reference< ::com::sun::star::awt::XTextC //------------------------------------------------------------------------ Image FmFilterItems::GetImage( BmpColorMode _eMode ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterItems::GetImage" ); static Image aImage; static Image aImage_HC; @@ -203,16 +220,15 @@ Image FmFilterItems::GetImage( BmpColorMode _eMode ) const //======================================================================== TYPEINIT1(FmFilterItem, FmFilterData); //------------------------------------------------------------------------ -FmFilterItem::FmFilterItem(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory, - FmFilterItems* pParent, - const ::rtl::OUString& aFieldName, - const ::rtl::OUString& aText, - const Reference< ::com::sun::star::awt::XTextComponent > & _xText) +FmFilterItem::FmFilterItem( const Reference< XMultiServiceFactory >& _rxFactory, + FmFilterItems* pParent, + const ::rtl::OUString& aFieldName, + const ::rtl::OUString& aText, + const sal_Int32 _nComponentIndex ) :FmFilterData(_rxFactory,pParent, aText) ,m_aFieldName(aFieldName) - ,m_xText(_xText) + ,m_nComponentIndex( _nComponentIndex ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterItems::FmFilterItem" ); } //------------------------------------------------------------------------ @@ -262,17 +278,6 @@ public: TYPEINIT1( FmFilterInsertedHint, FmFilterHint ); //======================================================================== -class FmFilterReplacedHint : public FmFilterHint -{ -public: - TYPEINFO(); - FmFilterReplacedHint(FmFilterData* pData) - :FmFilterHint(pData){} - -}; -TYPEINIT1( FmFilterReplacedHint, FmFilterHint ); - -//======================================================================== class FmFilterRemovedHint : public FmFilterHint { public: @@ -315,243 +320,240 @@ TYPEINIT1( FmFilterCurrentChangedHint, SfxHint ); //======================================================================== // class FmFilterAdapter, Listener an den FilterControls //======================================================================== -class FmFilterAdapter : public ::cppu::WeakImplHelper1< ::com::sun::star::awt::XTextListener > +class FmFilterAdapter : public ::cppu::WeakImplHelper1< XFilterControllerListener > { - FmFilterControls m_aFilterControls; - FmFilterModel* m_pModel; + FmFilterModel* m_pModel; + Reference< XIndexAccess > m_xControllers; public: - FmFilterAdapter(FmFilterModel* pModel, const Reference< ::com::sun::star::container::XIndexAccess >& xControllers); + FmFilterAdapter(FmFilterModel* pModel, const Reference< XIndexAccess >& xControllers); -// ::com::sun::star::lang::XEventListener - virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( RuntimeException ); +// XEventListener + virtual void SAL_CALL disposing(const EventObject& Source) throw( RuntimeException ); -// ::com::sun::star::awt::XTextListener - virtual void SAL_CALL textChanged(const ::com::sun::star::awt::TextEvent& e) throw( ::com::sun::star::uno::RuntimeException ); +// XFilterControllerListener + virtual void SAL_CALL predicateExpressionChanged( const FilterEvent& _Event ) throw (RuntimeException); + virtual void SAL_CALL disjunctiveTermRemoved( const FilterEvent& _Event ) throw (RuntimeException); + virtual void SAL_CALL disjunctiveTermAdded( const FilterEvent& _Event ) throw (RuntimeException); // helpers void dispose() throw( RuntimeException ); - void InsertElements(const Reference< ::com::sun::star::container::XIndexAccess >& xControllers); - void RemoveElement(const Reference< ::com::sun::star::awt::XTextComponent > & xText); + void AddOrRemoveListener( const Reference< XIndexAccess >& _rxControllers, const bool _bAdd ); - Reference< ::com::sun::star::beans::XPropertySet > getField(const Reference< ::com::sun::star::awt::XTextComponent > & xText) const; void setText(sal_Int32 nPos, const FmFilterItem* pFilterItem, const ::rtl::OUString& rText); - void DeleteItemsByText(::std::vector<FmFilterData*>& rItems, const Reference< ::com::sun::star::awt::XTextComponent > & xText); - Reference< ::com::sun::star::form::XForm > findForm(const Reference< ::com::sun::star::container::XChild >& xChild); }; //------------------------------------------------------------------------ -FmFilterAdapter::FmFilterAdapter(FmFilterModel* pModel, const Reference< ::com::sun::star::container::XIndexAccess >& xControllers) - :m_pModel(pModel) +FmFilterAdapter::FmFilterAdapter(FmFilterModel* pModel, const Reference< XIndexAccess >& xControllers) + :m_pModel( pModel ) + ,m_xControllers( xControllers ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::FmFilterAdapter" ); - InsertElements(xControllers); - - // listen on all controls as text listener - for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); iter++) - (*iter).first->addTextListener(this); + AddOrRemoveListener( m_xControllers, true ); } //------------------------------------------------------------------------ void FmFilterAdapter::dispose() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::dispose" ); - // clear the filter control map - for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); iter++) - (*iter).first->removeTextListener(this); - - m_aFilterControls.clear(); + AddOrRemoveListener( m_xControllers, false ); } -//------------------------------------------------------------------------------ -// delete all items relate to the control -void FmFilterAdapter::DeleteItemsByText(::std::vector<FmFilterData*>& _rItems, - const Reference< ::com::sun::star::awt::XTextComponent > & xText) +//------------------------------------------------------------------------ +void FmFilterAdapter::AddOrRemoveListener( const Reference< XIndexAccess >& _rxControllers, const bool _bAdd ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::DeleteItemsByText" ); - for (::std::vector<FmFilterData*>::reverse_iterator i = _rItems.rbegin(); - // link problems with operator == - i.base() != _rItems.rend().base(); i++) + for (sal_Int32 i = 0, nLen = _rxControllers->getCount(); i < nLen; ++i) { - FmFilterItems* pFilterItems = PTR_CAST(FmFilterItems, *i); - if (pFilterItems) - { - FmFilterItem* pFilterItem = pFilterItems->Find(xText); - if (pFilterItem) - { - // remove the condition - ::std::vector<FmFilterData*>& rItems = pFilterItems->GetChilds(); - ::std::vector<FmFilterData*>::iterator j = ::std::find(rItems.begin(), rItems.end(), pFilterItem); - if (j != rItems.end()) - m_pModel->Remove(j, pFilterItem); - } - continue; - } - FmFormItem* pFormItem = PTR_CAST(FmFormItem, *i); - if (pFormItem) - DeleteItemsByText(pFormItem->GetChilds(), xText); + Reference< XIndexAccess > xElement( _rxControllers->getByIndex(i), UNO_QUERY ); + + // step down + AddOrRemoveListener( xElement, _bAdd ); + + // handle this particular controller + Reference< XFilterController > xController( xElement, UNO_QUERY ); + OSL_ENSURE( xController.is(), "FmFilterAdapter::InsertElements: no XFilterController, cannot sync data!" ); + if ( xController.is() ) + if ( _bAdd ) + xController->addFilterControllerListener( this ); + else + xController->removeFilterControllerListener( this ); } } //------------------------------------------------------------------------ -void FmFilterAdapter::InsertElements(const Reference< ::com::sun::star::container::XIndexAccess >& xControllers) +void FmFilterAdapter::setText(sal_Int32 nRowPos, + const FmFilterItem* pFilterItem, + const ::rtl::OUString& rText) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::InsertElements" ); - for (sal_Int32 i = 0, nLen = xControllers->getCount(); i < nLen; ++i) - { - Reference< ::com::sun::star::container::XIndexAccess > xElement; - xControllers->getByIndex(i) >>= xElement; + FmFormItem* pFormItem = PTR_CAST( FmFormItem, pFilterItem->GetParent()->GetParent() ); - // Insert the Elements of the controller - InsertElements(xElement); + try + { + Reference< XFilterController > xController( pFormItem->GetController(), UNO_QUERY_THROW ); + xController->setPredicateExpression( pFilterItem->GetComponentIndex(), nRowPos, rText ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} - // store the filter controls - FmXFormController* pController = FmXFormController::getImplementation( xElement.get() ); - DBG_ASSERT( pController, "FmFilterAdapter::InsertElements: no controller!" ); - const FmFilterControls& rControls = pController->getFilterControls(); - for (FmFilterControls::const_iterator iter = rControls.begin(); iter != rControls.end(); ++iter ) - m_aFilterControls.insert(*iter); - } +// XEventListener +//------------------------------------------------------------------------ +void SAL_CALL FmFilterAdapter::disposing(const EventObject& /*e*/) throw( RuntimeException ) +{ } -//------------------------------------------------------------------------------ -void FmFilterAdapter::RemoveElement(const Reference< ::com::sun::star::awt::XTextComponent > & xText) +//------------------------------------------------------------------------ +namespace { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::RemoveElement" ); - if (xText.is()) + ::rtl::OUString lcl_getLabelName_nothrow( const Reference< XControl >& _rxControl ) { - // alle Level durchlaufen und eintraege entfernen - if (m_pModel) - DeleteItemsByText(m_pModel->GetChilds(), xText); + ::rtl::OUString sLabelName; + try + { + Reference< XControl > xControl( _rxControl, UNO_SET_THROW ); + Reference< XPropertySet > xModel( xControl->getModel(), UNO_QUERY_THROW ); + sLabelName = getLabelName( xModel ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sLabelName; + } - FmFilterControls::iterator iter = m_aFilterControls.find(xText); - if (iter != m_aFilterControls.end()) - m_aFilterControls.erase(iter); + Reference< XPropertySet > lcl_getBoundField_nothrow( const Reference< XControl >& _rxControl ) + { + Reference< XPropertySet > xField; + try + { + Reference< XControl > xControl( _rxControl, UNO_SET_THROW ); + Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW ); + xField.set( xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + return xField; } } +// XFilterControllerListener //------------------------------------------------------------------------ -Reference< ::com::sun::star::beans::XPropertySet > FmFilterAdapter::getField(const Reference< ::com::sun::star::awt::XTextComponent > & xText) const +void FmFilterAdapter::predicateExpressionChanged( const FilterEvent& _Event ) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::getField" ); - Reference< ::com::sun::star::beans::XPropertySet > xField; - FmFilterControls::const_iterator i = m_aFilterControls.find(xText); - if (i != m_aFilterControls.end()) - xField = (*i).second; + ::vos::OGuard aGuard( Application::GetSolarMutex() ); - return xField; -} + if ( !m_pModel ) + return; -//------------------------------------------------------------------------ -void FmFilterAdapter::setText(sal_Int32 nRowPos, - const FmFilterItem* pFilterItem, - const ::rtl::OUString& rText) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::setText" ); - // set the text for the text component - Reference< ::com::sun::star::awt::XTextComponent > xText(pFilterItem->GetTextComponent()); - xText->setText(rText); + // the controller which sent the event + Reference< XFormController > xController( _Event.Source, UNO_QUERY_THROW ); + Reference< XFilterController > xFilterController( _Event.Source, UNO_QUERY_THROW ); + Reference< XForm > xForm( xController->getModel(), UNO_QUERY_THROW ); - // get the controller of the text component and its filter rows - FmFormItem* pFormItem = PTR_CAST(FmFormItem,pFilterItem->GetParent()->GetParent()); - FmXFormController* pController = FmXFormController::getImplementation( pFormItem->GetController().get() ); - DBG_ASSERT( pController, "FmFilterAdapter::setText: no controller!" ); - FmFilterRows& rRows = pController->getFilterRows(); + FmFormItem* pFormItem = m_pModel->Find( m_pModel->m_aChildren, xForm ); + OSL_ENSURE( pFormItem, "FmFilterAdapter::predicateExpressionChanged: don't know this form!" ); + if ( !pFormItem ) + return; - DBG_ASSERT(nRowPos < (sal_Int32)rRows.size(), "wrong row pos"); - // Suchen der aktuellen Row - FmFilterRow& rRow = rRows[nRowPos]; + const sal_Int32 nActiveTerm( xFilterController->getActiveTerm() ); - // do we have a new filter - if (rText.getLength()) - rRow[xText] = rText; - else + FmFilterItems* pFilter = PTR_CAST( FmFilterItems, pFormItem->GetChildren()[ nActiveTerm ] ); + FmFilterItem* pFilterItem = pFilter->Find( _Event.FilterComponent ); + if ( pFilterItem ) { - // do we have the control in the row - FmFilterRow::iterator iter = rRow.find(xText); - // erase the entry out of the row - if (iter != rRow.end()) - rRow.erase(iter); + if ( _Event.PredicateExpression.getLength()) + { + pFilterItem->SetText( _Event.PredicateExpression ); + // UI benachrichtigen + FmFilterTextChangedHint aChangeHint(pFilterItem); + m_pModel->Broadcast( aChangeHint ); + } + else + { + // no text anymore so remove the condition + m_pModel->Remove(pFilterItem); + } } -} + else + { + // searching the component by field name + ::rtl::OUString aFieldName( lcl_getLabelName_nothrow( xFilterController->getFilterComponent( _Event.FilterComponent ) ) ); + pFilterItem = new FmFilterItem( m_pModel->getORB(), pFilter, aFieldName, _Event.PredicateExpression, _Event.FilterComponent ); + m_pModel->Insert(pFilter->GetChildren().end(), pFilterItem); + } -// ::com::sun::star::lang::XEventListener -//------------------------------------------------------------------------ -void SAL_CALL FmFilterAdapter::disposing(const ::com::sun::star::lang::EventObject& e) throw( RuntimeException ) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::disposing" ); - Reference< ::com::sun::star::awt::XTextComponent > xText(e.Source,UNO_QUERY); - if (xText.is()) - RemoveElement(xText); + // ensure there's one empty term in the filter, just in case the active term was previously empty + m_pModel->EnsureEmptyFilterRows( *pFormItem ); } -// XTextListener //------------------------------------------------------------------------ -Reference< ::com::sun::star::form::XForm > FmFilterAdapter::findForm(const Reference< ::com::sun::star::container::XChild >& xChild) +void SAL_CALL FmFilterAdapter::disjunctiveTermRemoved( const FilterEvent& _Event ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::findForm" ); - Reference< ::com::sun::star::form::XForm > xForm; - if (xChild.is()) + ::vos::OGuard aGuard( Application::GetSolarMutex() ); + + Reference< XFormController > xController( _Event.Source, UNO_QUERY_THROW ); + Reference< XFilterController > xFilterController( _Event.Source, UNO_QUERY_THROW ); + Reference< XForm > xForm( xController->getModel(), UNO_QUERY_THROW ); + + FmFormItem* pFormItem = m_pModel->Find( m_pModel->m_aChildren, xForm ); + OSL_ENSURE( pFormItem, "FmFilterAdapter::disjunctiveTermRemoved: don't know this form!" ); + if ( !pFormItem ) + return; + + ::std::vector< FmFilterData* >& rTermItems = pFormItem->GetChildren(); + const bool bValidIndex = ( _Event.DisjunctiveTerm >= 0 ) && ( (size_t)_Event.DisjunctiveTerm < rTermItems.size() ); + OSL_ENSURE( bValidIndex, "FmFilterAdapter::disjunctiveTermRemoved: invalid term index!" ); + if ( !bValidIndex ) + return; + + // if the first term was removed, then the to-be first term needs its text updated + if ( _Event.DisjunctiveTerm == 0 ) { - xForm = Reference< ::com::sun::star::form::XForm >(xChild->getParent(), UNO_QUERY); - if (!xForm.is()) - xForm = findForm(Reference< ::com::sun::star::container::XChild >(xChild->getParent(), UNO_QUERY)); + rTermItems[1]->SetText( String( SVX_RES( RID_STR_FILTER_FILTER_FOR ) ) ); + FmFilterTextChangedHint aChangeHint( rTermItems[1] ); + m_pModel->Broadcast( aChangeHint ); } - return xForm; + + // finally remove the entry from the model + m_pModel->Remove( rTermItems.begin() + _Event.DisjunctiveTerm ); + + // ensure there's one empty term in the filter, just in case the currently removed one was the last empty one + m_pModel->EnsureEmptyFilterRows( *pFormItem ); } -// XTextListener //------------------------------------------------------------------------ -void FmFilterAdapter::textChanged(const ::com::sun::star::awt::TextEvent& e) throw( ::com::sun::star::uno::RuntimeException ) +void SAL_CALL FmFilterAdapter::disjunctiveTermAdded( const FilterEvent& _Event ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterAdapter::textChanged" ); - // Find the according formitem in the - Reference< ::com::sun::star::awt::XControl > xControl(e.Source, UNO_QUERY); - if (!m_pModel || !xControl.is()) - return; + ::vos::OGuard aGuard( Application::GetSolarMutex() ); - Reference< ::com::sun::star::form::XForm > xForm(findForm(Reference< ::com::sun::star::container::XChild >(xControl->getModel(), UNO_QUERY))); - if (!xForm.is()) + Reference< XFormController > xController( _Event.Source, UNO_QUERY_THROW ); + Reference< XFilterController > xFilterController( _Event.Source, UNO_QUERY_THROW ); + Reference< XForm > xForm( xController->getModel(), UNO_QUERY_THROW ); + + FmFormItem* pFormItem = m_pModel->Find( m_pModel->m_aChildren, xForm ); + OSL_ENSURE( pFormItem, "FmFilterAdapter::disjunctiveTermAdded: don't know this form!" ); + if ( !pFormItem ) return; - FmFormItem* pFormItem = m_pModel->Find(m_pModel->m_aChilds, xForm); - if (pFormItem) + const sal_Int32 nInsertPos = _Event.DisjunctiveTerm; + bool bValidIndex = ( nInsertPos >= 0 ) && ( (size_t)nInsertPos <= pFormItem->GetChildren().size() ); + if ( !bValidIndex ) { - Reference< ::com::sun::star::awt::XTextComponent > xText(e.Source, UNO_QUERY); - FmFilterItems* pFilter = PTR_CAST(FmFilterItems, pFormItem->GetChilds()[pFormItem->GetCurrentPosition()]); - FmFilterItem* pFilterItem = pFilter->Find(xText); - if (pFilterItem) - { - if (xText->getText().getLength()) - { - pFilterItem->SetText(xText->getText()); - // UI benachrichtigen - FmFilterTextChangedHint aChangeHint(pFilterItem); - m_pModel->Broadcast( aChangeHint ); - } - else - { - // no text anymore so remove the condition - m_pModel->Remove(pFilterItem); - } - } - else - { - // searching the component by field name - ::rtl::OUString aFieldName = getLabelName(Reference< ::com::sun::star::beans::XPropertySet > (Reference< ::com::sun::star::awt::XControl > (xText, UNO_QUERY)->getModel(),UNO_QUERY)); - - pFilterItem = new FmFilterItem(m_pModel->getORB(),pFilter, aFieldName, xText->getText(), xText); - m_pModel->Insert(pFilter->GetChilds().end(), pFilterItem); - } - m_pModel->CheckIntegrity(pFormItem); + OSL_ENSURE( false, "FmFilterAdapter::disjunctiveTermAdded: invalid index!" ); + return; } + + const ::std::vector< FmFilterData* >::iterator insertPos = pFormItem->GetChildren().begin() + nInsertPos; + + FmFilterItems* pFilterItems = new FmFilterItems( m_pModel->getORB(), pFormItem, String( SVX_RES( RID_STR_FILTER_FILTER_OR ) ) ); + m_pModel->Insert( insertPos, pFilterItems ); } //======================================================================== @@ -559,14 +561,13 @@ void FmFilterAdapter::textChanged(const ::com::sun::star::awt::TextEvent& e) thr //======================================================================== TYPEINIT1(FmFilterModel, FmParentData); //------------------------------------------------------------------------ -FmFilterModel::FmFilterModel(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) +FmFilterModel::FmFilterModel(const Reference< XMultiServiceFactory >& _rxFactory) :FmParentData(_rxFactory,NULL, ::rtl::OUString()) ,OSQLParserClient(_rxFactory) ,m_xORB(_rxFactory) ,m_pAdapter(NULL) ,m_pCurrentItems(NULL) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::FmFilterModel" ); } //------------------------------------------------------------------------ @@ -578,7 +579,6 @@ FmFilterModel::~FmFilterModel() //------------------------------------------------------------------------ void FmFilterModel::Clear() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Clear" ); // notify FilterClearingHint aClearedHint; Broadcast( aClearedHint ); @@ -595,18 +595,17 @@ void FmFilterModel::Clear() m_xController = NULL; m_xControllers = NULL; - for (::std::vector<FmFilterData*>::const_iterator i = m_aChilds.begin(); - i != m_aChilds.end(); i++) + for (::std::vector<FmFilterData*>::const_iterator i = m_aChildren.begin(); + i != m_aChildren.end(); i++) delete (*i); - m_aChilds.clear(); + m_aChildren.clear(); } //------------------------------------------------------------------------ -void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const Reference< ::com::sun::star::form::XFormController > & xCurrent) +void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, const Reference< XFormController > & xCurrent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Update" ); - if ((::com::sun::star::form::XFormController*) xCurrent.get() == (::com::sun::star::form::XFormController*) m_xController.get()) + if ( xCurrent == m_xController ) return; if (!xControllers.is()) @@ -616,7 +615,7 @@ void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexA } // there is only a new current controller - if ((::com::sun::star::container::XIndexAccess*)m_xControllers.get() != (::com::sun::star::container::XIndexAccess*)xControllers.get()) + if ( m_xControllers != xControllers ) { Clear(); @@ -630,77 +629,95 @@ void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexA m_pAdapter->acquire(); SetCurrentController(xCurrent); - CheckIntegrity(this); + EnsureEmptyFilterRows( *this ); } else SetCurrentController(xCurrent); } //------------------------------------------------------------------------ -void FmFilterModel::Update(const Reference< ::com::sun::star::container::XIndexAccess > & xControllers, FmParentData* pParent) +void FmFilterModel::Update(const Reference< XIndexAccess > & xControllers, FmParentData* pParent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Update" ); - sal_Int32 nCount = xControllers->getCount(); - for (sal_Int32 i = 0; i < nCount; i++) + try { - Reference< ::com::sun::star::form::XFormController > xController; - xControllers->getByIndex(i) >>= xController; - Reference< ::com::sun::star::beans::XPropertySet > xModelAsSet(xController->getModel(), UNO_QUERY); - ::rtl::OUString aName = ::comphelper::getString(xModelAsSet->getPropertyValue(FM_PROP_NAME)); + sal_Int32 nCount = xControllers->getCount(); + for ( sal_Int32 i = 0; i < nCount; ++i ) + { + Reference< XFormController > xController( xControllers->getByIndex(i), UNO_QUERY_THROW ); - // Insert a new ::com::sun::star::form - FmFormItem* pFormItem = new FmFormItem(m_xORB,pParent, xController, aName); - Insert(pParent->GetChilds().end(), pFormItem); + Reference< XPropertySet > xFormProperties( xController->getModel(), UNO_QUERY_THROW ); + ::rtl::OUString aName; + OSL_VERIFY( xFormProperties->getPropertyValue( FM_PROP_NAME ) >>= aName ); - // And now insert the filters for the form - FmXFormController* pController = FmXFormController::getImplementation( pFormItem->GetController().get() ); - DBG_ASSERT( pController, "FmFilterAdapter::Update: no controller!" ); + // Insert a new item for the form + FmFormItem* pFormItem = new FmFormItem( m_xORB, pParent, xController, aName ); + Insert( pParent->GetChildren().end(), pFormItem ); - INT32 nPos = pController->getCurrentFilterPosition(); - pFormItem->SetCurrentPosition(nPos); + Reference< XFilterController > xFilterController( pFormItem->GetFilterController(), UNO_SET_THROW ); - String aTitle(SVX_RES(RID_STR_FILTER_FILTER_FOR)); - const FmFilterRows& rRows = pController->getFilterRows(); - for (FmFilterRows::const_iterator iter = rRows.begin(); iter != rRows.end(); ++iter) - { - const FmFilterRow& rRow = *iter; - // now add the filter rows - // One Row always exists + // insert the existing filters for the form + String aTitle( SVX_RES( RID_STR_FILTER_FILTER_FOR ) ); - FmFilterItems* pFilterItems = new FmFilterItems(m_xORB,pFormItem, aTitle); - Insert(pFormItem->GetChilds().end(), pFilterItems); - for (FmFilterRow::const_iterator iter1 = rRow.begin(); iter1 != rRow.end(); ++iter1) + Sequence< Sequence< ::rtl::OUString > > aExpressions = xFilterController->getPredicateExpressions(); + for ( const Sequence< ::rtl::OUString >* pConjunctionTerm = aExpressions.getConstArray(); + pConjunctionTerm != aExpressions.getConstArray() + aExpressions.getLength(); + ++pConjunctionTerm + ) { - // insert new and conditons - ::rtl::OUString aFieldName = getLabelName(Reference< ::com::sun::star::beans::XPropertySet > (Reference< ::com::sun::star::awt::XControl > ((*iter1).first, UNO_QUERY)->getModel(),UNO_QUERY)); - FmFilterItem* pANDCondition = new FmFilterItem(m_xORB,pFilterItems, aFieldName, (*iter1).second, (*iter1).first); - Insert(pFilterItems->GetChilds().end(), pANDCondition); + // we always display one row, even if there's no term to be displayed + FmFilterItems* pFilterItems = new FmFilterItems( m_xORB, pFormItem, aTitle ); + Insert( pFormItem->GetChildren().end(), pFilterItems ); + + const Sequence< ::rtl::OUString >& rDisjunction( *pConjunctionTerm ); + for ( const ::rtl::OUString* pDisjunctiveTerm = rDisjunction.getConstArray(); + pDisjunctiveTerm != rDisjunction.getConstArray() + rDisjunction.getLength(); + ++pDisjunctiveTerm + ) + { + if ( pDisjunctiveTerm->getLength() == 0 ) + // no condition for this particular component in this particular conjunction term + continue; + + const sal_Int32 nComponentIndex = pDisjunctiveTerm - rDisjunction.getConstArray(); + + // determine the display name of the control + const Reference< XControl > xFilterControl( xFilterController->getFilterComponent( nComponentIndex ) ); + const ::rtl::OUString sDisplayName( lcl_getLabelName_nothrow( xFilterControl ) ); + + // insert a new entry + FmFilterItem* pANDCondition = new FmFilterItem( m_xORB, pFilterItems, sDisplayName, *pDisjunctiveTerm, nComponentIndex ); + Insert( pFilterItems->GetChildren().end(), pANDCondition ); + } + + // title for the next conditions + aTitle = SVX_RES( RID_STR_FILTER_FILTER_OR ); } - // title for the next conditions - aTitle = SVX_RES(RID_STR_FILTER_FILTER_OR); - } - // now add dependent controllers - Reference< ::com::sun::star::container::XIndexAccess > xControllerAsIndex(xController, UNO_QUERY); - Update(xControllerAsIndex, pFormItem); + // now add dependent controllers + Reference< XIndexAccess > xControllerAsIndex( xController, UNO_QUERY ); + Update( xControllerAsIndex, pFormItem ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } //------------------------------------------------------------------------ -FmFormItem* FmFilterModel::Find(const ::std::vector<FmFilterData*>& rItems, const Reference< ::com::sun::star::form::XFormController > & xController) const +FmFormItem* FmFilterModel::Find(const ::std::vector<FmFilterData*>& rItems, const Reference< XFormController > & xController) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Find" ); for (::std::vector<FmFilterData*>::const_iterator i = rItems.begin(); i != rItems.end(); i++) { FmFormItem* pForm = PTR_CAST(FmFormItem,*i); if (pForm) { - if ((::com::sun::star::form::XFormController*)xController.get() == (::com::sun::star::form::XFormController*)pForm->GetController().get()) + if ( xController == pForm->GetController() ) return pForm; else { - pForm = Find(pForm->GetChilds(), xController); + pForm = Find(pForm->GetChildren(), xController); if (pForm) return pForm; } @@ -710,9 +727,8 @@ FmFormItem* FmFilterModel::Find(const ::std::vector<FmFilterData*>& rItems, cons } //------------------------------------------------------------------------ -FmFormItem* FmFilterModel::Find(const ::std::vector<FmFilterData*>& rItems, const Reference< ::com::sun::star::form::XForm >& xForm) const +FmFormItem* FmFilterModel::Find(const ::std::vector<FmFilterData*>& rItems, const Reference< XForm >& xForm) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Find" ); for (::std::vector<FmFilterData*>::const_iterator i = rItems.begin(); i != rItems.end(); i++) { @@ -723,7 +739,7 @@ FmFormItem* FmFilterModel::Find(const ::std::vector<FmFilterData*>& rItems, cons return pForm; else { - pForm = Find(pForm->GetChilds(), xForm); + pForm = Find(pForm->GetChildren(), xForm); if (pForm) return pForm; } @@ -733,58 +749,64 @@ FmFormItem* FmFilterModel::Find(const ::std::vector<FmFilterData*>& rItems, cons } //------------------------------------------------------------------------ -void FmFilterModel::SetCurrentController(const Reference< ::com::sun::star::form::XFormController > & xCurrent) +void FmFilterModel::SetCurrentController(const Reference< XFormController > & xCurrent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::SetCurrentController" ); - if ((::com::sun::star::form::XFormController*) xCurrent.get() == (::com::sun::star::form::XFormController*) m_xController.get()) + if ( xCurrent == m_xController ) return; m_xController = xCurrent; - FmFormItem* pItem = Find(m_aChilds, xCurrent); - if (pItem) + FmFormItem* pItem = Find( m_aChildren, xCurrent ); + if ( !pItem ) + return; + + try + { + Reference< XFilterController > xFilterController( m_xController, UNO_QUERY_THROW ); + const sal_Int32 nActiveTerm( xFilterController->getActiveTerm() ); + if ( pItem->GetChildren().size() > (size_t)nActiveTerm ) + { + SetCurrentItems( static_cast< FmFilterItems* >( pItem->GetChildren()[ nActiveTerm ] ) ); + } + } + catch( const Exception& ) { - if ( (USHORT)pItem->GetChilds().size() > pItem->GetCurrentPosition() ) - SetCurrentItems( static_cast< FmFilterItems* >( pItem->GetChilds()[ pItem->GetCurrentPosition() ] ) ); + DBG_UNHANDLED_EXCEPTION(); } } //------------------------------------------------------------------------ -void FmFilterModel::AppendFilterItems(FmFormItem* pFormItem) +void FmFilterModel::AppendFilterItems( FmFormItem& _rFormItem ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::AppendFilterItems" ); - DBG_ASSERT(pFormItem, "AppendFilterItems(): no form item present"); - - FmFilterItems* pFilterItems = new FmFilterItems(m_xORB,pFormItem, ::rtl::OUString(String(SVX_RES(RID_STR_FILTER_FILTER_OR)))); // insert the condition behind the last filter items ::std::vector<FmFilterData*>::reverse_iterator iter; - for (iter = pFormItem->GetChilds().rbegin(); - // link problems with operator == - iter.base() != pFormItem->GetChilds().rend().base(); iter++) + for ( iter = _rFormItem.GetChildren().rbegin(); + iter != _rFormItem.GetChildren().rend(); + ++iter + ) { if ((*iter)->ISA(FmFilterItems)) break; } - sal_Int32 nInsertPos = iter.base() - pFormItem->GetChilds().rend().base(); - ::std::vector<FmFilterData*>::iterator i = pFormItem->GetChilds().begin() + nInsertPos; - Insert(i, pFilterItems); - - // do we need a new row - FmXFormController* pController = FmXFormController::getImplementation( pFormItem->GetController().get() ); - DBG_ASSERT( pController, "FmFilterAdapter::AppendFilterItems: no controller!" ); - FmFilterRows& rRows = pController->getFilterRows(); - - // determine the filter position - if (nInsertPos >= (sal_Int32)rRows.size()) - rRows.push_back(FmFilterRow()); + sal_Int32 nInsertPos = iter.base() - _rFormItem.GetChildren().begin(); + // delegate this to the FilterController, it will notify us, which will let us update our model + try + { + Reference< XFilterController > xFilterController( _rFormItem.GetFilterController(), UNO_SET_THROW ); + if ( nInsertPos >= xFilterController->getDisjunctiveTerms() ) + xFilterController->appendEmptyDisjunctiveTerm(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //------------------------------------------------------------------------ void FmFilterModel::Insert(const ::std::vector<FmFilterData*>::iterator& rPos, FmFilterData* pData) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Insert" ); - ::std::vector<FmFilterData*>& rItems = pData->GetParent()->GetChilds(); + ::std::vector<FmFilterData*>& rItems = pData->GetParent()->GetChildren(); sal_Int32 nPos = rPos == rItems.end() ? LIST_APPEND : rPos - rItems.begin(); rItems.insert(rPos, pData); @@ -796,9 +818,8 @@ void FmFilterModel::Insert(const ::std::vector<FmFilterData*>::iterator& rPos, F //------------------------------------------------------------------------ void FmFilterModel::Remove(FmFilterData* pData) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Remove" ); FmParentData* pParent = pData->GetParent(); - ::std::vector<FmFilterData*>& rItems = pParent->GetChilds(); + ::std::vector<FmFilterData*>& rItems = pParent->GetChildren(); // erase the item from the model ::std::vector<FmFilterData*>::iterator i = ::std::find(rItems.begin(), rItems.end(), pData); @@ -808,80 +829,32 @@ void FmFilterModel::Remove(FmFilterData* pData) if (pData->ISA(FmFilterItems)) { FmFormItem* pFormItem = (FmFormItem*)pParent; - FmXFormController* pController = FmXFormController::getImplementation( pFormItem->GetController().get() ); - DBG_ASSERT( pController, "FmFilterAdapter::Remove: no controller!" ); - FmFilterRows& rRows = pController->getFilterRows(); - // how many entries do we have - // it's the last row than we just empty it - if (nPos == (sal_Int32)(rRows.size() - 1)) - { - // remove all childs and stay current - ::std::vector<FmFilterData*>& rChilds = ((FmFilterItems*)pData)->GetChilds(); - while (!rChilds.empty()) - { - ::std::vector<FmFilterData*>::iterator j = rChilds.end(); - j--; - - // we stay on the level so delete each item explizit to clean the controls - sal_Int32 nParentPos = j - rChilds.begin(); - // EmptyText removes the filter - FmFilterItem* pFilterItem = PTR_CAST(FmFilterItem, *j); - m_pAdapter->setText(nParentPos, pFilterItem, ::rtl::OUString()); - Remove(j, pFilterItem); - } - } - else // delete the row + try { - // if the row is on the current position we have to away from that position. - // than we can delete it - if (nPos == pFormItem->GetCurrentPosition()) - { - ::std::vector<FmFilterData*>::iterator j = i; - - // give a new current postion - if (nPos < (sal_Int32)(rRows.size() - 1)) - // set it to the next row - ++j; - else - // set it to the previous row - --j; - - // if necessary we have the formItem for the current controller - // than we have to adjust the data displayed in the form - pFormItem->SetCurrentPosition(j - rItems.begin()); - pController->setCurrentFilterPosition(j - rItems.begin()); - - // Keep the view consistent and force and new painting - FmFilterTextChangedHint aChangeHint(*j); - Broadcast( aChangeHint ); - } + Reference< XFilterController > xFilterController( pFormItem->GetFilterController(), UNO_SET_THROW ); - // now delete the entry - // before deleting we have to shift the current position of the form if necessary - if (nPos < pFormItem->GetCurrentPosition()) + bool bEmptyLastTerm = ( ( nPos == 0 ) && xFilterController->getDisjunctiveTerms() == 1 ); + if ( bEmptyLastTerm ) { - pFormItem->SetCurrentPosition(pFormItem->GetCurrentPosition() - 1); - pController->decrementCurrentFilterPosition(); - - // is it the first row, than the nex row has to recieve a different name - if (nPos == 0) + // remove all children (by setting an empty predicate expression) + ::std::vector< FmFilterData* >& rChildren = ((FmFilterItems*)pData)->GetChildren(); + while ( !rChildren.empty() ) { - // ensure that the text labels are consistent - rItems[1]->SetText(String(SVX_RES(RID_STR_FILTER_FILTER_FOR))); - FmFilterTextChangedHint aChangeHint(rItems[1]); - Broadcast( aChangeHint ); + ::std::vector< FmFilterData* >::iterator removePos = rChildren.end() - 1; + FmFilterItem* pFilterItem = PTR_CAST( FmFilterItem, *removePos ); + m_pAdapter->setText( nPos, pFilterItem, ::rtl::OUString() ); + Remove( removePos ); } } - - // delete it - rRows.erase(rRows.begin() + nPos); - - // and keep the controller consistent - DBG_ASSERT(rRows.size() != 0, "wrong row size"); - - // and remove it from the model - Remove(i, pData); + else + { + xFilterController->removeDisjunctiveTerm( nPos ); + } + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } else // FormItems can not be deleted @@ -894,26 +867,26 @@ void FmFilterModel::Remove(FmFilterData* pData) else { // find the position of the father within his father - ::std::vector<FmFilterData*>& rParentParentItems = pData->GetParent()->GetParent()->GetChilds(); + ::std::vector<FmFilterData*>& rParentParentItems = pData->GetParent()->GetParent()->GetChildren(); ::std::vector<FmFilterData*>::iterator j = ::std::find(rParentParentItems.begin(), rParentParentItems.end(), pFilterItem->GetParent()); DBG_ASSERT(j != rParentParentItems.end(), "FmFilterModel::Remove(): unknown Item"); sal_Int32 nParentPos = j - rParentParentItems.begin(); // EmptyText removes the filter m_pAdapter->setText(nParentPos, pFilterItem, ::rtl::OUString()); - Remove(i, pData); + Remove( i ); } } } //------------------------------------------------------------------------ -void FmFilterModel::Remove(const ::std::vector<FmFilterData*>::iterator& rPos, FmFilterData* pData) +void FmFilterModel::Remove( const ::std::vector<FmFilterData*>::iterator& rPos ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Remove" ); - ::std::vector<FmFilterData*>& rItems = pData->GetParent()->GetChilds(); - rItems.erase(rPos); + // remove from parent's child list + FmFilterData* pData = *rPos; + pData->GetParent()->GetChildren().erase( rPos ); - // UI benachrichtigen + // notify the view, this will remove the actual SvLBoxEntry FmFilterRemovedHint aRemoveHint( pData ); Broadcast( aRemoveHint ); @@ -923,46 +896,58 @@ void FmFilterModel::Remove(const ::std::vector<FmFilterData*>::iterator& rPos, F //------------------------------------------------------------------------ sal_Bool FmFilterModel::ValidateText(FmFilterItem* pItem, UniString& rText, UniString& rErrorMsg) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::ValidateText" ); - // check the input - Reference< XPropertySet > xField(m_pAdapter->getField(pItem->GetTextComponent())); - - OStaticDataAccessTools aStaticTools; - Reference< XConnection > xConnection(aStaticTools.getRowSetConnection(Reference< XRowSet > (m_xController->getModel(), UNO_QUERY))); - Reference< ::com::sun::star::util::XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, sal_True); - - Reference< ::com::sun::star::util::XNumberFormatter > xFormatter(m_xORB->createInstance(FM_NUMBER_FORMATTER), UNO_QUERY); - xFormatter->attachNumberFormatsSupplier(xFormatSupplier); - - ::rtl::OUString aErr, aTxt(rText); - ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree(aErr, aTxt, xFormatter, xField); - rErrorMsg = aErr; - rText = aTxt; - if (xParseNode.is()) + FmFormItem* pFormItem = PTR_CAST( FmFormItem, pItem->GetParent()->GetParent() ); + try { - ::rtl::OUString aPreparedText; - ::com::sun::star::lang::Locale aAppLocale = Application::GetSettings().GetUILocale(); - xParseNode->parseNodeToPredicateStr( - aPreparedText, xConnection, xFormatter, xField, aAppLocale, '.', getParseContext() ); - rText = aPreparedText; - return sal_True; + Reference< XFormController > xFormController( pFormItem->GetController() ); + // obtain the connection of the form belonging to the controller + OStaticDataAccessTools aStaticTools; + Reference< XRowSet > xRowSet( xFormController->getModel(), UNO_QUERY_THROW ); + Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( xRowSet ) ); + + // obtain a number formatter for this connection + // TODO: shouldn't this be cached? + Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats( xConnection, sal_True ); + Reference< XNumberFormatter > xFormatter( m_xORB->createInstance( FM_NUMBER_FORMATTER ), UNO_QUERY ); + xFormatter->attachNumberFormatsSupplier( xFormatSupplier ); + + // get the field (database column) which the item is responsible for + Reference< XFilterController > xFilterController( xFormController, UNO_QUERY_THROW ); + Reference< XPropertySet > xField( lcl_getBoundField_nothrow( xFilterController->getFilterComponent( pItem->GetComponentIndex() ) ), UNO_SET_THROW ); + + // parse the given text as filter predicate + ::rtl::OUString aErr, aTxt( rText ); + ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( aErr, aTxt, xFormatter, xField ); + rErrorMsg = aErr; + rText = aTxt; + if ( xParseNode.is() ) + { + ::rtl::OUString aPreparedText; + Locale aAppLocale = Application::GetSettings().GetUILocale(); + xParseNode->parseNodeToPredicateStr( + aPreparedText, xConnection, xFormatter, xField, aAppLocale, '.', getParseContext() ); + rText = aPreparedText; + return sal_True; + } } - else - return sal_False; + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + return sal_False; } //------------------------------------------------------------------------ void FmFilterModel::Append(FmFilterItems* pItems, FmFilterItem* pFilterItem) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::Append" ); - Insert(pItems->GetChilds().end(), pFilterItem); + Insert(pItems->GetChildren().end(), pFilterItem); } //------------------------------------------------------------------------ void FmFilterModel::SetTextForItem(FmFilterItem* pItem, const ::rtl::OUString& rText) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::SetTextForItem" ); - ::std::vector<FmFilterData*>& rItems = pItem->GetParent()->GetParent()->GetChilds(); + ::std::vector<FmFilterData*>& rItems = pItem->GetParent()->GetParent()->GetChildren(); ::std::vector<FmFilterData*>::iterator i = ::std::find(rItems.begin(), rItems.end(), pItem->GetParent()); sal_Int32 nParentPos = i - rItems.begin(); @@ -982,7 +967,6 @@ void FmFilterModel::SetTextForItem(FmFilterItem* pItem, const ::rtl::OUString& r //------------------------------------------------------------------------ void FmFilterModel::SetCurrentItems(FmFilterItems* pCurrent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::SetCurrentItems" ); if (m_pCurrentItems == pCurrent) return; @@ -990,21 +974,26 @@ void FmFilterModel::SetCurrentItems(FmFilterItems* pCurrent) if (pCurrent) { FmFormItem* pFormItem = (FmFormItem*)pCurrent->GetParent(); - ::std::vector<FmFilterData*>& rItems = pFormItem->GetChilds(); + ::std::vector<FmFilterData*>& rItems = pFormItem->GetChildren(); ::std::vector<FmFilterData*>::const_iterator i = ::std::find(rItems.begin(), rItems.end(), pCurrent); if (i != rItems.end()) { // determine the filter position sal_Int32 nPos = i - rItems.begin(); - FmXFormController* pController = FmXFormController::getImplementation( pFormItem->GetController().get() ); - DBG_ASSERT( pController, "FmFilterAdapter::SetCurrentItems: no controller!" ); - pController->setCurrentFilterPosition(nPos); - pFormItem->SetCurrentPosition(nPos); + try + { + Reference< XFilterController > xFilterController( pFormItem->GetFilterController(), UNO_SET_THROW ); + xFilterController->setActiveTerm( nPos ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } - if ((::com::sun::star::form::XFormController*)m_xController.get() != (::com::sun::star::form::XFormController*)pFormItem->GetController().get()) + if ( m_xController != pFormItem->GetController() ) // calls SetCurrentItems again - SetCurrentController(pFormItem->GetController()); + SetCurrentController( pFormItem->GetController() ); else m_pCurrentItems = pCurrent; } @@ -1021,33 +1010,39 @@ void FmFilterModel::SetCurrentItems(FmFilterItems* pCurrent) } //------------------------------------------------------------------------ -void FmFilterModel::CheckIntegrity(FmParentData* pItem) +void FmFilterModel::EnsureEmptyFilterRows( FmParentData& _rItem ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterModel::CheckIntegrity" ); // checks whether for each form there's one free level for input + ::std::vector< FmFilterData* >& rChildren = _rItem.GetChildren(); + sal_Bool bAppendLevel = _rItem.ISA( FmFormItem ); - ::std::vector<FmFilterData*>& rItems = pItem->GetChilds(); - sal_Bool bAppendLevel = sal_False; - - for (::std::vector<FmFilterData*>::iterator i = rItems.begin(); - i != rItems.end(); i++) + for ( ::std::vector<FmFilterData*>::iterator i = rChildren.begin(); + i != rChildren.end(); + ++i + ) { FmFilterItems* pItems = PTR_CAST(FmFilterItems, *i); - if (pItems) + if ( pItems && pItems->GetChildren().empty() ) { - bAppendLevel = !pItems->GetChilds().empty(); - continue; + bAppendLevel = sal_False; + break; } FmFormItem* pFormItem = PTR_CAST(FmFormItem, *i); if (pFormItem) { - CheckIntegrity(pFormItem); + EnsureEmptyFilterRows( *pFormItem ); continue; } } - if (bAppendLevel) - AppendFilterItems((FmFormItem*)pItem); + + if ( bAppendLevel ) + { + FmFormItem* pFormItem = PTR_CAST( FmFormItem, &_rItem ); + OSL_ENSURE( pFormItem, "FmFilterModel::EnsureEmptyFilterRows: no FmFormItem, but a FmFilterItems child?" ); + if ( pFormItem ) + AppendFilterItems( *pFormItem ); + } } //======================================================================== @@ -1069,25 +1064,31 @@ void FmFilterItemsString::Paint(const Point& rPos, SvLBox& rDev, sal_uInt16 /*nF { FmFilterItems* pRow = (FmFilterItems*)pEntry->GetUserData(); FmFormItem* pForm = (FmFormItem*)pRow->GetParent(); + // current filter is significant painted - if (pForm->GetChilds()[pForm->GetCurrentPosition()] == pRow) + const bool bIsCurrentFilter = pForm->GetChildren()[ pForm->GetFilterController()->getActiveTerm() ] == pRow; + if ( bIsCurrentFilter ) { - Color aLineColor(rDev.GetLineColor()); - Rectangle aRect(rPos, GetSize(&rDev, pEntry )); - Point aFirst(rPos.X(), aRect.Bottom() - 6); - Point aSecond(aFirst.X() + 2, aFirst.Y() + 3); + rDev.Push( PUSH_LINECOLOR ); + + rDev.SetLineColor( rDev.GetTextColor() ); - rDev.SetLineColor(rDev.GetTextColor()); - rDev.DrawLine(aFirst, aSecond); + Rectangle aRect( rPos, GetSize( &rDev, pEntry ) ); + Point aFirst( rPos.X(), aRect.Bottom() - 6 ); + Point aSecond(aFirst .X() + 2, aFirst.Y() + 3 ); + + rDev.DrawLine( aFirst, aSecond ); aFirst = aSecond; aFirst.X() += 1; aSecond.X() += 6; aSecond.Y() -= 5; - rDev.DrawLine(aFirst, aSecond); - rDev.SetLineColor( aLineColor ); + rDev.DrawLine( aFirst, aSecond ); + + rDev.Pop(); } + rDev.DrawText( Point(rPos.X() + nxDBmp, rPos.Y()), GetText() ); } @@ -1168,7 +1169,6 @@ FmFilterNavigator::FmFilterNavigator( Window* pParent ) ,m_aTimerCounter( 0 ) ,m_aDropActionType( DA_SCROLLUP ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::FmFilterNavigator" ); SetHelpId( HID_FILTER_NAVIGATOR ); { @@ -1211,14 +1211,12 @@ FmFilterNavigator::~FmFilterNavigator() //------------------------------------------------------------------------ void FmFilterNavigator::Clear() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Clear" ); m_pModel->Clear(); } //------------------------------------------------------------------------ -void FmFilterNavigator::UpdateContent(const Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const Reference< ::com::sun::star::form::XFormController > & xCurrent) +void FmFilterNavigator::UpdateContent(const Reference< XIndexAccess > & xControllers, const Reference< XFormController > & xCurrent) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::UpdateContent" ); if (xCurrent == m_pModel->GetCurrentController()) return; @@ -1246,7 +1244,6 @@ void FmFilterNavigator::UpdateContent(const Reference< ::com::sun::star::contain //------------------------------------------------------------------------ sal_Bool FmFilterNavigator::EditingEntry( SvLBoxEntry* pEntry, Selection& rSelection ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::EditingEntry" ); m_pEditingCurrently = pEntry; if (!SvTreeListBox::EditingEntry( pEntry, rSelection )) return sal_False; @@ -1257,7 +1254,6 @@ sal_Bool FmFilterNavigator::EditingEntry( SvLBoxEntry* pEntry, Selection& rSelec //------------------------------------------------------------------------ sal_Bool FmFilterNavigator::EditedEntry( SvLBoxEntry* pEntry, const XubString& rNewText ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::EditedEntry" ); DBG_ASSERT(pEntry == m_pEditingCurrently, "FmFilterNavigator::EditedEntry: suspicious entry!"); m_pEditingCurrently = NULL; @@ -1293,7 +1289,6 @@ sal_Bool FmFilterNavigator::EditedEntry( SvLBoxEntry* pEntry, const XubString& r else { // display the error and return sal_False - SQLContext aError; aError.Message = String(SVX_RES(RID_STR_SYNTAXERROR)); aError.Details = aErrorMsg; @@ -1350,7 +1345,6 @@ IMPL_LINK( FmFilterNavigator, OnDropActionTimer, void*, EMPTYARG ) //------------------------------------------------------------------------ sal_Int8 FmFilterNavigator::AcceptDrop( const AcceptDropEvent& rEvt ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::AcceptDrop" ); Point aDropPos = rEvt.maPosPixel; // kuemmern wir uns erst mal um moeglich DropActions (Scrollen und Aufklappen) @@ -1378,7 +1372,7 @@ sal_Int8 FmFilterNavigator::AcceptDrop( const AcceptDropEvent& rEvt ) bNeedTrigger = sal_True; } else - { // auf einem Entry mit Childs, der nicht aufgeklappt ist ? + { // is it an entry whith children, and not yet expanded? SvLBoxEntry* pDropppedOn = GetEntry(aDropPos); if (pDropppedOn && (GetChildCount(pDropppedOn) > 0) && !IsExpanded(pDropppedOn)) { @@ -1457,7 +1451,6 @@ namespace //------------------------------------------------------------------------ sal_Int8 FmFilterNavigator::ExecuteDrop( const ExecuteDropEvent& rEvt ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::ExecuteDrop" ); // ware schlecht, wenn nach dem Droppen noch gescrollt wird ... if (m_aDropActionTimer.IsActive()) m_aDropActionTimer.Stop(); @@ -1491,7 +1484,6 @@ void FmFilterNavigator::InitEntry(SvLBoxEntry* pEntry, const Image& rImg2, SvLBoxButtonKind eButtonKind) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::InitEntry" ); SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind ); SvLBoxString* pString = NULL; @@ -1507,7 +1499,6 @@ void FmFilterNavigator::InitEntry(SvLBoxEntry* pEntry, //------------------------------------------------------------------------ sal_Bool FmFilterNavigator::Select( SvLBoxEntry* pEntry, sal_Bool bSelect ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Select" ); if (bSelect == IsSelected(pEntry)) // das passiert manchmal, ich glaube, die Basisklasse geht zu sehr auf Nummer sicher ;) return sal_True; @@ -1543,7 +1534,6 @@ sal_Bool FmFilterNavigator::Select( SvLBoxEntry* pEntry, sal_Bool bSelect ) //------------------------------------------------------------------------ void FmFilterNavigator::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Notify" ); if (rHint.ISA(FmFilterInsertedHint)) { FmFilterInsertedHint* pHint = (FmFilterInsertedHint*)&rHint; @@ -1577,7 +1567,6 @@ void FmFilterNavigator::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) //------------------------------------------------------------------------ SvLBoxEntry* FmFilterNavigator::FindEntry(const FmFilterData* pItem) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::FindEntry" ); SvLBoxEntry* pEntry = NULL; if (pItem) { @@ -1594,23 +1583,23 @@ SvLBoxEntry* FmFilterNavigator::FindEntry(const FmFilterData* pItem) const //------------------------------------------------------------------------ void FmFilterNavigator::Insert(FmFilterData* pItem, sal_Int32 nPos) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Insert" ); const FmParentData* pParent = pItem->GetParent() ? pItem->GetParent() : GetFilterModel(); // insert the item - SvLBoxEntry* pParentEntry = FindEntry(pParent); + SvLBoxEntry* pParentEntry = FindEntry( pParent ); SvLBoxEntry* pNewEntry = InsertEntry(pItem->GetText(), pItem->GetImage(), pItem->GetImage(), pParentEntry, sal_False, nPos, pItem ); if ( pNewEntry ) { SetExpandedEntryBmp( pNewEntry, pItem->GetImage( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST ); SetCollapsedEntryBmp( pNewEntry, pItem->GetImage( BMP_COLOR_HIGHCONTRAST ), BMP_COLOR_HIGHCONTRAST ); } + if ( pParentEntry ) + Expand( pParentEntry ); } //------------------------------------------------------------------------ void FmFilterNavigator::Remove(FmFilterData* pItem) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Remove" ); // der Entry zu den Daten SvLBoxEntry* pEntry = FindEntry(pItem); @@ -1624,7 +1613,6 @@ void FmFilterNavigator::Remove(FmFilterData* pItem) // ----------------------------------------------------------------------------- FmFormItem* FmFilterNavigator::getSelectedFilterItems(::std::vector<FmFilterItem*>& _rItemList) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::getSelectedFilterItems" ); // be sure that the data is only used within only one form! FmFormItem* pFirstItem = NULL; @@ -1659,35 +1647,37 @@ FmFormItem* FmFilterNavigator::getSelectedFilterItems(::std::vector<FmFilterItem // ----------------------------------------------------------------------------- void FmFilterNavigator::insertFilterItem(const ::std::vector<FmFilterItem*>& _rFilterList,FmFilterItems* _pTargetItems,sal_Bool _bCopy) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::insertFilterItem" ); ::std::vector<FmFilterItem*>::const_iterator aEnd = _rFilterList.end(); - for (::std::vector<FmFilterItem*>::const_iterator i = _rFilterList.begin(); i != aEnd; ++i) + for ( ::std::vector< FmFilterItem* >::const_iterator i = _rFilterList.begin(); + i != aEnd; + ++i + ) { - if ((*i)->GetParent() == _pTargetItems) + FmFilterItem* pLookupItem( *i ); + if ( pLookupItem->GetParent() == _pTargetItems ) continue; - else + + FmFilterItem* pFilterItem = _pTargetItems->Find( pLookupItem->GetComponentIndex() ); + String aText = pLookupItem->GetText(); + if ( !pFilterItem ) { - FmFilterItem* pFilterItem = _pTargetItems->Find((*i)->GetTextComponent()); - String aText = (*i)->GetText(); - if ( !pFilterItem ) - { - pFilterItem = new FmFilterItem(m_pModel->getORB(),_pTargetItems, (*i)->GetFieldName(), aText, (*i)->GetTextComponent()); - m_pModel->Append(_pTargetItems, pFilterItem); - } + pFilterItem = new FmFilterItem( m_pModel->getORB(), _pTargetItems, pLookupItem->GetFieldName(), aText, pLookupItem->GetComponentIndex() ); + m_pModel->Append( _pTargetItems, pFilterItem ); + } - if ( !_bCopy ) - m_pModel->Remove(*i); + if ( !_bCopy ) + m_pModel->Remove( pLookupItem ); - // now set the text for the new dragged item - m_pModel->SetTextForItem(pFilterItem, aText); - } + // now set the text for the new dragged item + m_pModel->SetTextForItem( pFilterItem, aText ); } - m_pModel->CheckIntegrity((FmFormItem*)_pTargetItems->GetParent()); + + m_pModel->EnsureEmptyFilterRows( *_pTargetItems->GetParent() ); } + //------------------------------------------------------------------------------ void FmFilterNavigator::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPixel*/ ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::StartDrag" ); EndSelection(); // be sure that the data is only used within a only one form! @@ -1705,7 +1695,6 @@ void FmFilterNavigator::StartDrag( sal_Int8 /*_nAction*/, const Point& /*_rPosPi //------------------------------------------------------------------------------ void FmFilterNavigator::Command( const CommandEvent& rEvt ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::Command" ); sal_Bool bHandled = sal_False; switch (rEvt.GetCommand()) { @@ -1750,8 +1739,8 @@ void FmFilterNavigator::Command( const CommandEvent& rEvt ) { // don't delete the only empty row of a form FmFilterItems* pFilterItems = PTR_CAST(FmFilterItems, aSelectList[0]); - if (pFilterItems && pFilterItems->GetChilds().empty() - && pFilterItems->GetParent()->GetChilds().size() == 1) + if (pFilterItems && pFilterItems->GetChildren().empty() + && pFilterItems->GetParent()->GetChildren().size() == 1) aSelectList.clear(); } @@ -1808,7 +1797,6 @@ void FmFilterNavigator::Command( const CommandEvent& rEvt ) // ----------------------------------------------------------------------------- SvLBoxEntry* FmFilterNavigator::getNextEntry(SvLBoxEntry* _pStartWith) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::getNextEntry" ); SvLBoxEntry* pEntry = _pStartWith ? _pStartWith : LastSelected(); pEntry = Next(pEntry); // we need the next filter entry @@ -1819,7 +1807,6 @@ SvLBoxEntry* FmFilterNavigator::getNextEntry(SvLBoxEntry* _pStartWith) // ----------------------------------------------------------------------------- SvLBoxEntry* FmFilterNavigator::getPrevEntry(SvLBoxEntry* _pStartWith) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::getPrevEntry" ); SvLBoxEntry* pEntry = _pStartWith ? _pStartWith : FirstSelected(); pEntry = Prev(pEntry); // check if the previous entry is a filter, if so get the next prev @@ -1835,81 +1822,90 @@ SvLBoxEntry* FmFilterNavigator::getPrevEntry(SvLBoxEntry* _pStartWith) //------------------------------------------------------------------------ void FmFilterNavigator::KeyInput(const KeyEvent& rKEvt) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::KeyInput" ); const KeyCode& rKeyCode = rKEvt.GetKeyCode(); - if ( rKeyCode.IsMod1() - && rKeyCode.IsMod2() - && !rKeyCode.IsShift() - && ( rKeyCode.GetCode() == KEY_UP || rKeyCode.GetCode() == KEY_DOWN ) - ) + + switch ( rKeyCode.GetCode() ) + { + case KEY_UP: + case KEY_DOWN: { + if ( !rKeyCode.IsMod1() || !rKeyCode.IsMod2() || rKeyCode.IsShift() ) + break; + ::std::vector<FmFilterItem*> aItemList; - if ( getSelectedFilterItems(aItemList) ) - { - ::std::mem_fun1_t<SvLBoxEntry*,FmFilterNavigator,SvLBoxEntry*> aGetEntry = ::std::mem_fun(&FmFilterNavigator::getNextEntry); - if ( rKeyCode.GetCode() == KEY_UP ) - aGetEntry = ::std::mem_fun(&FmFilterNavigator::getPrevEntry); + if ( !getSelectedFilterItems( aItemList ) ) + break; - SvLBoxEntry* pTarget = aGetEntry(this,NULL); + ::std::mem_fun1_t<SvLBoxEntry*,FmFilterNavigator,SvLBoxEntry*> getter = ::std::mem_fun(&FmFilterNavigator::getNextEntry); + if ( rKeyCode.GetCode() == KEY_UP ) + getter = ::std::mem_fun(&FmFilterNavigator::getPrevEntry); - if ( pTarget ) + SvLBoxEntry* pTarget = getter( this, NULL ); + if ( !pTarget ) + break; + + FmFilterItems* pTargetItems = getTargetItems( pTarget ); + if ( !pTargetItems ) + break; + + ::std::vector<FmFilterItem*>::const_iterator aEnd = aItemList.end(); + sal_Bool bNextTargetItem = sal_True; + while ( bNextTargetItem ) + { + ::std::vector<FmFilterItem*>::const_iterator i = aItemList.begin(); + for (; i != aEnd; ++i) { - FmFilterItems* pTargetItems = getTargetItems(pTarget); - if ( pTargetItems ) + if ( (*i)->GetParent() == pTargetItems ) { - ::std::vector<FmFilterItem*>::const_iterator aEnd = aItemList.end(); - sal_Bool bNextTargetItem = sal_True; - while ( bNextTargetItem ) - { - ::std::vector<FmFilterItem*>::const_iterator i = aItemList.begin(); - for (; i != aEnd; ++i) - { - if ( (*i)->GetParent() == pTargetItems ) - { - pTarget = aGetEntry(this,pTarget); - if ( !pTarget ) - return; - pTargetItems = getTargetItems(pTarget); - break; - } - else - { - FmFilterItem* pFilterItem = pTargetItems->Find((*i)->GetTextComponent()); - // we found the text component so jump above - if ( pFilterItem ) - { - pTarget = aGetEntry(this,pTarget); - if ( !pTarget ) - return; - pTargetItems = getTargetItems(pTarget); - break; - } - } - } - bNextTargetItem = i != aEnd && pTargetItems; - } - if ( pTargetItems ) - { - insertFilterItem(aItemList,pTargetItems); + pTarget = getter(this,pTarget); + if ( !pTarget ) return; + pTargetItems = getTargetItems( pTarget ); + break; + } + else + { + FmFilterItem* pFilterItem = pTargetItems->Find( (*i)->GetComponentIndex() ); + // we found the text component so jump above + if ( pFilterItem ) + { + pTarget = getter( this, pTarget ); + if ( !pTarget ) + return; + + pTargetItems = getTargetItems( pTarget ); + break; } } } + bNextTargetItem = i != aEnd && pTargetItems; + } + + if ( pTargetItems ) + { + insertFilterItem( aItemList, pTargetItems ); + return; } } - else if (rKeyCode.GetCode() == KEY_DELETE && !rKeyCode.GetModifier()) + break; + + case KEY_DELETE: { - if (!IsSelected(First()) || GetEntryCount() > 1) + if ( rKeyCode.GetModifier() ) + break; + + if ( !IsSelected( First() ) || GetEntryCount() > 1 ) DeleteSelection(); return; } + } + SvTreeListBox::KeyInput(rKEvt); } //------------------------------------------------------------------------------ void FmFilterNavigator::DeleteSelection() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigator::DeleteSelection" ); // to avoid the deletion of an entry twice (e.g. deletion of a parent and afterward // the deletion of it's child, i have to shrink the selecton list ::std::vector<SvLBoxEntry*> aEntryList; @@ -1935,9 +1931,6 @@ void FmFilterNavigator::DeleteSelection() { m_pModel->Remove((FmFilterData*)(*i)->GetUserData()); } - - // now check if we need to insert new items - m_pModel->CheckIntegrity(m_pModel); } // ----------------------------------------------------------------------------- @@ -1949,7 +1942,6 @@ FmFilterNavigatorWin::FmFilterNavigatorWin( SfxBindings* _pBindings, SfxChildWin :SfxDockingWindow( _pBindings, _pMgr, _pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_ROLLABLE|WB_3DLOOK|WB_DOCKABLE) ) ,SfxControllerItem( SID_FM_FILTER_NAVIGATOR_CONTROL, *_pBindings ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::FmFilterNavigatorWin" ); SetHelpId( HID_FILTER_NAVIGATOR_WIN ); m_pNavigator = new FmFilterNavigator( this ); @@ -1967,22 +1959,21 @@ FmFilterNavigatorWin::~FmFilterNavigatorWin() //----------------------------------------------------------------------- void FmFilterNavigatorWin::UpdateContent(FmFormShell* pFormShell) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::UpdateContent" ); if (!pFormShell) m_pNavigator->UpdateContent( NULL, NULL ); else { - Reference< ::com::sun::star::form::XFormController > xController(pFormShell->GetImpl()->getActiveInternalController()); - Reference< ::com::sun::star::container::XIndexAccess > xContainer; + Reference< XFormController > xController(pFormShell->GetImpl()->getActiveInternalController()); + Reference< XIndexAccess > xContainer; if (xController.is()) { - Reference< ::com::sun::star::container::XChild > xChild(xController, UNO_QUERY); + Reference< XChild > xChild(xController, UNO_QUERY); for (Reference< XInterface > xParent(xChild->getParent()); xParent.is(); xParent = xChild.is() ? xChild->getParent() : Reference< XInterface > ()) { - xContainer = Reference< ::com::sun::star::container::XIndexAccess > (xParent, UNO_QUERY); - xChild = Reference< ::com::sun::star::container::XChild > (xParent, UNO_QUERY); + xContainer = Reference< XIndexAccess > (xParent, UNO_QUERY); + xChild = Reference< XChild > (xParent, UNO_QUERY); } } m_pNavigator->UpdateContent(xContainer, xController); @@ -1992,7 +1983,6 @@ void FmFilterNavigatorWin::UpdateContent(FmFormShell* pFormShell) //----------------------------------------------------------------------- void FmFilterNavigatorWin::StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::StateChanged" ); if( !pState || SID_FM_FILTER_NAVIGATOR_CONTROL != nSID ) return; @@ -2008,7 +1998,6 @@ void FmFilterNavigatorWin::StateChanged( sal_uInt16 nSID, SfxItemState eState, c //----------------------------------------------------------------------- sal_Bool FmFilterNavigatorWin::Close() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::Close" ); if ( m_pNavigator && m_pNavigator->IsEditingActive() ) m_pNavigator->EndEditing(); @@ -2023,7 +2012,6 @@ sal_Bool FmFilterNavigatorWin::Close() //----------------------------------------------------------------------- void FmFilterNavigatorWin::FillInfo( SfxChildWinInfo& rInfo ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::FillInfo" ); SfxDockingWindow::FillInfo( rInfo ); rInfo.bVisible = sal_False; } @@ -2031,7 +2019,6 @@ void FmFilterNavigatorWin::FillInfo( SfxChildWinInfo& rInfo ) const //----------------------------------------------------------------------- Size FmFilterNavigatorWin::CalcDockingSize( SfxChildAlignment eAlign ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::CalcDockingSize" ); if ( ( eAlign == SFX_ALIGN_TOP ) || ( eAlign == SFX_ALIGN_BOTTOM ) ) return Size(); @@ -2041,7 +2028,6 @@ Size FmFilterNavigatorWin::CalcDockingSize( SfxChildAlignment eAlign ) //----------------------------------------------------------------------- SfxChildAlignment FmFilterNavigatorWin::CheckAlignment( SfxChildAlignment eActAlign, SfxChildAlignment eAlign ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::CheckAlignment" ); switch (eAlign) { case SFX_ALIGN_LEFT: @@ -2058,7 +2044,6 @@ SfxChildAlignment FmFilterNavigatorWin::CheckAlignment( SfxChildAlignment eActAl //------------------------------------------------------------------------ void FmFilterNavigatorWin::Resize() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::Resize" ); SfxDockingWindow::Resize(); Size aLogOutputSize = PixelToLogic( GetOutputSizePixel(), MAP_APPFONT ); @@ -2074,7 +2059,6 @@ void FmFilterNavigatorWin::Resize() // ----------------------------------------------------------------------------- void FmFilterNavigatorWin::GetFocus() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmFilterNavigatorWin::GetFocus" ); // oj #97405# if ( m_pNavigator ) m_pNavigator->GrabFocus(); diff --git a/svx/source/form/fmcontrolbordermanager.cxx b/svx/source/form/fmcontrolbordermanager.cxx index 17bd10346302..5c6397662844 100644 --- a/svx/source/form/fmcontrolbordermanager.cxx +++ b/svx/source/form/fmcontrolbordermanager.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrolbordermanager.cxx,v $ - * $Revision: 1.8 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/fmcontrollayout.cxx b/svx/source/form/fmcontrollayout.cxx index 9fb7bd9b8f90..82227d8015ee 100644 --- a/svx/source/form/fmcontrollayout.cxx +++ b/svx/source/form/fmcontrollayout.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrollayout.cxx,v $ - * $Revision: 1.8 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx index 542154e3ca68..4a2cb4b418d4 100644 --- a/svx/source/form/fmobj.cxx +++ b/svx/source/form/fmobj.cxx @@ -30,35 +30,35 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include <tools/resmgr.hxx> -#include <tools/diagnose_ex.h> #include "fmobj.hxx" #include "fmprop.hrc" #include "fmvwimp.hxx" -#include <editeng/editeng.hxx> -#include <svx/svdovirt.hxx> +#include "fmpgeimp.hxx" +#include "fmresids.hrc" +#include "svx/fmview.hxx" +#include "svx/fmglob.hxx" +#include "svx/fmpage.hxx" +#include "editeng/editeng.hxx" +#include "svx/svdovirt.hxx" +#include "svx/fmmodel.hxx" +#include "svx/dialmgr.hxx" /** === begin UNO includes === **/ #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/script/XEventAttacherManager.hpp> #include <com/sun/star/io/XPersistObject.hpp> #include <com/sun/star/awt/XControlContainer.hpp> +#include <com/sun/star/util/XCloneable.hpp> /** === end UNO includes === **/ -#include <svx/fmmodel.hxx> #include "svx/fmtools.hxx" -#include <tools/shl.hxx> -#include <svx/dialmgr.hxx> - -#include "fmresids.hrc" -#include <svx/fmview.hxx> -#include <svx/fmglob.hxx> -#include "fmpgeimp.hxx" -#include <svx/fmpage.hxx> +#include <tools/shl.hxx> #include <comphelper/property.hxx> #include <comphelper/processfactory.hxx> #include <toolkit/awt/vclxdevice.hxx> #include <vcl/svapp.hxx> +#include <tools/resmgr.hxx> +#include <tools/diagnose_ex.h> using namespace ::com::sun::star::io; using namespace ::com::sun::star::uno; @@ -437,10 +437,48 @@ void FmFormObj::operator= (const SdrObject& rObj) } //------------------------------------------------------------------ +namespace +{ + String lcl_getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement) + { + Reference< ::com::sun::star::form::XFormComponent> xChild(_xElement, UNO_QUERY); + Reference< ::com::sun::star::container::XIndexAccess> xParent; + if (xChild.is()) + xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY); + + // while the current content is a form + String sReturn; + String sCurrentIndex; + while (xChild.is()) + { + // get the content's relative pos within it's parent container + sal_Int32 nPos = getElementPos(xParent, xChild); + + // prepend this current relaive pos + sCurrentIndex = String::CreateFromInt32(nPos); + if (sReturn.Len() != 0) + { + sCurrentIndex += '\\'; + sCurrentIndex += sReturn; + } + + sReturn = sCurrentIndex; + + // travel up + if (::comphelper::query_interface((Reference< XInterface >)xParent,xChild)) + xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY); + } + + _rTopLevelElement = xParent; + return sReturn; + } +} + +//------------------------------------------------------------------ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > & _rSourceContainer, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > _rTopLevelDestContainer) { Reference< XInterface > xTopLevelSouce; - String sAccessPath = getFormComponentAccessPath(_rSourceContainer, xTopLevelSouce); + String sAccessPath = lcl_getFormComponentAccessPath(_rSourceContainer, xTopLevelSouce); if (!xTopLevelSouce.is()) // somthing went wrong, maybe _rSourceContainer isn't part of a valid forms hierarchy return Reference< XInterface > (); @@ -547,8 +585,8 @@ Reference< XInterface > FmFormObj::ensureModelEnv(const Reference< XInterface > DBG_ASSERT(xSourcePersist.is(), "FmFormObj::ensureModelEnv : invalid form (no persist object) !"); // create and insert (into the destination) a clone of the form - xCurrentDestForm = Reference< XPropertySet > (cloneUsingProperties(xSourcePersist), UNO_QUERY); - DBG_ASSERT(xCurrentDestForm.is(), "FmFormObj::ensureModelEnv : invalid cloned form !"); + Reference< XCloneable > xCloneable( xSourcePersist, UNO_QUERY_THROW ); + xCurrentDestForm.set( xCloneable->createClone(), UNO_QUERY_THROW ); DBG_ASSERT(nCurrentDestIndex == xDestContainer->getCount(), "FmFormObj::ensureModelEnv : something went wrong with the numbers !"); xDestContainer->insertByIndex(nCurrentDestIndex, makeAny(xCurrentDestForm)); diff --git a/svx/source/form/fmservs.cxx b/svx/source/form/fmservs.cxx index b9f40b6ddda2..a69a541f3606 100644 --- a/svx/source/form/fmservs.cxx +++ b/svx/source/form/fmservs.cxx @@ -49,7 +49,8 @@ DECL_SERVICE( FmXGridControl ) - DECL_SERVICE( FmXFormController ) + DECL_SERVICE( FormController ) + DECL_SERVICE( LegacyFormController ) // ------------------------------------------------------------------------ @@ -91,7 +92,8 @@ namespace svxform // ------------------------------------------------------------------------ // FormController - REGISTER_SERVICE(FmXFormController, FM_FORM_CONTROLLER); + REGISTER_SERVICE( FormController, FM_FORM_CONTROLLER ); + REGISTER_SERVICE( LegacyFormController, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ) ); // ------------------------------------------------------------------------ // FormController @@ -102,9 +104,6 @@ namespace svxform REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRID); // compatibility REGISTER_SERVICE(FmXGridControl, FM_CONTROL_GRIDCONTROL); REGISTER_SERVICE(FmXGridControl, FM_SUN_CONTROL_GRIDCONTROL); - - }; - } // namespace svxform diff --git a/svx/source/form/fmshell.cxx b/svx/source/form/fmshell.cxx index 2819045c237d..93cf9c1778af 100644 --- a/svx/source/form/fmshell.cxx +++ b/svx/source/form/fmshell.cxx @@ -685,7 +685,7 @@ void FmFormShell::Execute(SfxRequest &rReq) case SID_FM_FILTER_NAVIGATOR: case SID_FM_SHOW_DATANAVIGATOR : { - GetViewShell()->GetViewFrame()->ChildWindowExecute(rReq); + GetViewShell()->GetViewFrame()->ChildWindowExecute( rReq ); rReq.Done(); } break; case SID_FM_SHOW_FMEXPLORER: @@ -827,7 +827,7 @@ void FmFormShell::Execute(SfxRequest &rReq) bReopenNavigator = sal_True; } - Reference< XFormController > xController( GetImpl()->getActiveController() ); + Reference< runtime::XFormController > xController( GetImpl()->getActiveController() ); if ( GetViewShell()->GetViewFrame()->HasChildWindow( SID_FM_FILTER_NAVIGATOR ) // closing the window was denied, for instance because of a invalid criterion @@ -857,6 +857,11 @@ void FmFormShell::Execute(SfxRequest &rReq) { GetImpl()->startFiltering(); rReq.Done(); + + // initially open the filter navigator, the whole form based filter is pretty useless without it + SfxBoolItem aIdentifierItem( SID_FM_FILTER_NAVIGATOR, TRUE ); + GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( SID_FM_FILTER_NAVIGATOR, SFX_CALLMODE_ASYNCHRON, + &aIdentifierItem, NULL ); } break; } } @@ -1400,7 +1405,7 @@ SdrUnoObj* FmFormShell::GetFormControl( const Reference< XControlModel >& _rxMod } //------------------------------------------------------------------------ -Reference< XFormController > FmFormShell::GetFormController( const Reference< XForm >& _rxForm, const SdrView& _rView, const OutputDevice& _rDevice ) const +Reference< runtime::XFormController > FmFormShell::GetFormController( const Reference< XForm >& _rxForm, const SdrView& _rView, const OutputDevice& _rDevice ) const { const FmFormView* pFormView = dynamic_cast< const FmFormView* >( &_rView ); if ( !pFormView ) diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 4d265d324820..38df41896f13 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -30,89 +30,88 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "gridcols.hxx" -#include <svx/obj3d.hxx> -#include "fmvwimp.hxx" -#include "fmshimp.hxx" -#include "fmtextcontrolshell.hxx" -#include <svx/svdpagv.hxx> -#include <svx/fmpage.hxx> -#include <svx/dialmgr.hxx> -#ifndef _SVX_FMRESIDS_HRC -#include "fmresids.hrc" -#endif + #include "fmitems.hxx" #include "fmobj.hxx" -#include "formtoolbars.hxx" -#include <svx/fmglob.hxx> -#include "svditer.hxx" -#include "fmservs.hxx" #include "fmpgeimp.hxx" #include "svx/fmtools.hxx" -#ifndef _SVX_FMPROP_HRC #include "fmprop.hrc" -#endif -#include <svx/fmshell.hxx> -#ifndef _SVX_SVXIDS_HRC -#include <svx/svxids.hrc> -#endif -#include <svx/fmmodel.hxx> +#include "fmresids.hrc" +#include "fmservs.hxx" +#include "fmshimp.hxx" +#include "fmtextcontrolshell.hxx" #include "fmundo.hxx" #include "fmurl.hxx" -#include "formcontrolling.hxx" -#include <svx/svxdlg.hxx> -#include <svx/dialogs.hrc> -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <com/sun/star/form/XLoadable.hpp> -#include <com/sun/star/container/XNamed.hpp> +#include "fmvwimp.hxx" +#include "formtoolbars.hxx" +#include "gridcols.hxx" +#include "svditer.hxx" +#include "svx/dialmgr.hxx" +#include "svx/dialogs.hrc" +#include "svx/fmglob.hxx" +#include "svx/fmmodel.hxx" +#include "svx/fmpage.hxx" +#include "svx/fmshell.hxx" +#include "svx/obj3d.hxx" +#include "svx/sdrpagewindow.hxx" +#include "svx/svdpagv.hxx" +#include "svx/svxdlg.hxx" +#include "svx/svxids.hrc" + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/XCheckBox.hpp> +#include <com/sun/star/awt/XListBox.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/container/XContainer.hpp> #include <com/sun/star/container/XEnumeration.hpp> -#include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <com/sun/star/awt/XTextComponent.hpp> -#include <com/sun/star/awt/XListBox.hpp> -#include <com/sun/star/awt/XCheckBox.hpp> -#include <com/sun/star/form/XBoundComponent.hpp> +#include <com/sun/star/container/XIndexAccess.hpp> +#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/form/ListSourceType.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/script/XEventAttacherManager.hpp> +#include <com/sun/star/form/XBoundComponent.hpp> #include <com/sun/star/form/XBoundControl.hpp> -#include <com/sun/star/form/XReset.hpp> #include <com/sun/star/form/XGrid.hpp> #include <com/sun/star/form/XGridPeer.hpp> -#include <com/sun/star/util/XNumberFormatter.hpp> -#include <com/sun/star/util/XModeSelector.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> -#include <com/sun/star/util/XCancellable.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/form/XLoadable.hpp> +#include <com/sun/star/form/XReset.hpp> #include <com/sun/star/form/binding/XBindableValue.hpp> -#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/form/binding/XListEntrySink.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/script/XEventAttacherManager.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/util/XCancellable.hpp> +#include <com/sun/star/util/XModeSelector.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <com/sun/star/util/XNumberFormatter.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/beans/XIntrospection.hpp> +/** === end UNO includes === **/ + +#include <comphelper/extract.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/property.hxx> +#include <comphelper/stl_types.hxx> +#include <connectivity/dbtools.hxx> +#include <cppuhelper/servicefactory.hxx> #include <osl/mutex.hxx> -#include <sfx2/viewsh.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/frame.hxx> -#include <vcl/waitobj.hxx> -#include <tools/shl.hxx> -#include <tools/diagnose_ex.h> -#include <vcl/msgbox.hxx> +#include <rtl/logfile.hxx> #include <sfx2/dispatch.hxx> -#include <sfx2/objsh.hxx> #include <sfx2/docfile.hxx> +#include <sfx2/frame.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/viewsh.hxx> +#include <toolkit/helper/vclunohelper.hxx> #include <tools/color.hxx> +#include <tools/diagnose_ex.h> +#include <tools/shl.hxx> #include <tools/urlobj.hxx> -#include <comphelper/property.hxx> -#include <connectivity/dbtools.hxx> -#include <comphelper/stl_types.hxx> -#include <comphelper/processfactory.hxx> -#include <cppuhelper/servicefactory.hxx> -#include <comphelper/extract.hxx> -#include <toolkit/helper/vclunohelper.hxx> -#include <svx/sdrpagewindow.hxx> -#include <rtl/logfile.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/waitobj.hxx> +#include <vos/mutex.hxx> #include <algorithm> #include <functional> @@ -281,6 +280,7 @@ using namespace ::com::sun::star::view; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::util; using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::script; using namespace ::svxform; using namespace ::svx; @@ -289,7 +289,7 @@ using namespace ::svx; //============================================================================== namespace { - //.................................................................... + //.......................................................................... void collectInterfacesFromMarkList( const SdrMarkList& _rMarkList, InterfaceBag& /* [out] */ _rInterfaces ) { _rInterfaces.clear(); @@ -327,6 +327,198 @@ namespace } } + //.......................................................................... + sal_Int16 GridView2ModelPos(const Reference< XIndexAccess>& rColumns, sal_Int16 nViewPos) + { + try + { + if (rColumns.is()) + { + // loop through all columns + sal_Int16 i; + Reference< XPropertySet> xCur; + for (i=0; i<rColumns->getCount(); ++i) + { + rColumns->getByIndex(i) >>= xCur; + if (!::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN))) + { + // for every visible col : if nViewPos is greater zero, decrement it, else we + // have found the model position + if (!nViewPos) + break; + else + --nViewPos; + } + } + if (i<rColumns->getCount()) + return i; + } + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + return (sal_Int16)-1; + } + + //.......................................................................... + Sequence< ::rtl::OUString> getEventMethods(const Type& type) + { + typelib_InterfaceTypeDescription *pType=0; + type.getDescription( (typelib_TypeDescription**)&pType); + + if(!pType) + return Sequence< ::rtl::OUString>(); + + Sequence< ::rtl::OUString> aNames(pType->nMembers); + ::rtl::OUString* pNames = aNames.getArray(); + for(sal_Int32 i=0;i<pType->nMembers;i++,++pNames) + { + // the decription reference + typelib_TypeDescriptionReference* pMemberDescriptionReference = pType->ppMembers[i]; + // the description for the reference + typelib_TypeDescription* pMemberDescription = NULL; + typelib_typedescriptionreference_getDescription(&pMemberDescription, pMemberDescriptionReference); + if (pMemberDescription) + { + typelib_InterfaceMemberTypeDescription* pRealMemberDescription = + reinterpret_cast<typelib_InterfaceMemberTypeDescription*>(pMemberDescription); + *pNames = pRealMemberDescription->pMemberName; + } + } + typelib_typedescription_release( (typelib_TypeDescription *)pType ); + return aNames; + } + + //.......................................................................... + void TransferEventScripts(const Reference< XControlModel>& xModel, const Reference< XControl>& xControl, + const Sequence< ScriptEventDescriptor>& rTransferIfAvailable) + { + // first check if we have a XEventAttacherManager for the model + Reference< XChild> xModelChild(xModel, UNO_QUERY); + if (!xModelChild.is()) + return; // nothing to do + + Reference< XEventAttacherManager> xEventManager(xModelChild->getParent(), UNO_QUERY); + if (!xEventManager.is()) + return; // nothing to do + + if (!rTransferIfAvailable.getLength()) + return; // nothing to do + + // check for the index of the model within it's parent + Reference< XIndexAccess> xParentIndex(xModelChild->getParent(), UNO_QUERY); + if (!xParentIndex.is()) + return; // nothing to do + sal_Int32 nIndex = getElementPos(xParentIndex, xModel); + if (nIndex<0 || nIndex>=xParentIndex->getCount()) + return; // nothing to do + + // then we need informations about the listeners supported by the control and the model + Sequence< Type> aModelListeners; + Sequence< Type> aControlListeners; + + Reference< XIntrospection> xModelIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY); + Reference< XIntrospection> xControlIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY); + + if (xModelIntrospection.is() && xModel.is()) + { + Any aModel(makeAny(xModel)); + aModelListeners = xModelIntrospection->inspect(aModel)->getSupportedListeners(); + } + + if (xControlIntrospection.is() && xControl.is()) + { + Any aControl(makeAny(xControl)); + aControlListeners = xControlIntrospection->inspect(aControl)->getSupportedListeners(); + } + + sal_Int32 nMaxNewLen = aModelListeners.getLength() + aControlListeners.getLength(); + if (!nMaxNewLen) + return; // the model and the listener don't support any listeners (or we were unable to retrieve these infos) + + Sequence< ScriptEventDescriptor> aTransferable(nMaxNewLen); + ScriptEventDescriptor* pTransferable = aTransferable.getArray(); + + const ScriptEventDescriptor* pCurrent = rTransferIfAvailable.getConstArray(); + sal_Int32 i,j,k; + for (i=0; i<rTransferIfAvailable.getLength(); ++i, ++pCurrent) + { + // search the model/control idl classes for the event described by pCurrent + for ( Sequence< Type>* pCurrentArray = &aModelListeners; + pCurrentArray; + pCurrentArray = (pCurrentArray == &aModelListeners) ? &aControlListeners : NULL + ) + { + const Type* pCurrentListeners = pCurrentArray->getConstArray(); + for (j=0; j<pCurrentArray->getLength(); ++j, ++pCurrentListeners) + { + UniString aListener = (*pCurrentListeners).getTypeName(); + xub_StrLen nTokens = aListener.GetTokenCount('.'); + if (nTokens) + aListener = aListener.GetToken(nTokens - 1, '.'); + + if (aListener == pCurrent->ListenerType.getStr()) + // the current ScriptEventDescriptor doesn't match the current listeners class + continue; + + // now check the methods + Sequence< ::rtl::OUString> aMethodsNames = getEventMethods(*pCurrentListeners); + const ::rtl::OUString* pMethodsNames = aMethodsNames.getConstArray(); + for (k=0; k<aMethodsNames.getLength(); ++k, ++pMethodsNames) + { + if ((*pMethodsNames).compareTo(pCurrent->EventMethod) != COMPARE_EQUAL) + // the current ScriptEventDescriptor doesn't match the current listeners current method + continue; + + // we can transfer the script event : the model (control) supports it + *pTransferable = *pCurrent; + ++pTransferable; + break; + } + if (k<aMethodsNames.getLength()) + break; + } + } + } + + sal_Int32 nRealNewLen = pTransferable - aTransferable.getArray(); + aTransferable.realloc(nRealNewLen); + + xEventManager->registerScriptEvents(nIndex, aTransferable); + } + + //------------------------------------------------------------------------------ + ::rtl::OUString getServiceNameByControlType(sal_Int16 nType) + { + switch (nType) + { + case OBJ_FM_EDIT : return FM_COMPONENT_TEXTFIELD; + case OBJ_FM_BUTTON : return FM_COMPONENT_COMMANDBUTTON; + case OBJ_FM_FIXEDTEXT : return FM_COMPONENT_FIXEDTEXT; + case OBJ_FM_LISTBOX : return FM_COMPONENT_LISTBOX; + case OBJ_FM_CHECKBOX : return FM_COMPONENT_CHECKBOX; + case OBJ_FM_RADIOBUTTON : return FM_COMPONENT_RADIOBUTTON; + case OBJ_FM_GROUPBOX : return FM_COMPONENT_GROUPBOX; + case OBJ_FM_COMBOBOX : return FM_COMPONENT_COMBOBOX; + case OBJ_FM_GRID : return FM_COMPONENT_GRIDCONTROL; + case OBJ_FM_IMAGEBUTTON : return FM_COMPONENT_IMAGEBUTTON; + case OBJ_FM_FILECONTROL : return FM_COMPONENT_FILECONTROL; + case OBJ_FM_DATEFIELD : return FM_COMPONENT_DATEFIELD; + case OBJ_FM_TIMEFIELD : return FM_COMPONENT_TIMEFIELD; + case OBJ_FM_NUMERICFIELD : return FM_COMPONENT_NUMERICFIELD; + case OBJ_FM_CURRENCYFIELD : return FM_COMPONENT_CURRENCYFIELD; + case OBJ_FM_PATTERNFIELD : return FM_COMPONENT_PATTERNFIELD; + case OBJ_FM_HIDDEN : return FM_COMPONENT_HIDDENCONTROL; + case OBJ_FM_IMAGECONTROL : return FM_COMPONENT_IMAGECONTROL; + case OBJ_FM_FORMATTEDFIELD : return FM_COMPONENT_FORMATTEDFIELD; + case OBJ_FM_SCROLLBAR : return FM_SUN_COMPONENT_SCROLLBAR; + case OBJ_FM_SPINBUTTON : return FM_SUN_COMPONENT_SPINBUTTON; + case OBJ_FM_NAVIGATIONBAR : return FM_SUN_COMPONENT_NAVIGATIONBAR; + } + return ::rtl::OUString(); + } + } //------------------------------------------------------------------------------ @@ -504,7 +696,6 @@ FmXFormShell::FmXFormShell( FmFormShell& _rShell, SfxViewFrame* _pViewFrame ) ,m_pTextShell( new ::svx::FmTextControlShell( _pViewFrame ) ) ,m_aActiveControllerFeatures( ::comphelper::getProcessServiceFactory(), this ) ,m_aNavControllerFeatures( ::comphelper::getProcessServiceFactory(), this ) - ,m_pExternalViewInterceptor( NULL ) ,m_eDocumentType( eUnknownDocumentType ) ,m_nLockSlotInvalidation( 0 ) ,m_bHadPropertyBrowserInDesignMode( sal_False ) @@ -675,7 +866,8 @@ void SAL_CALL FmXFormShell::disposing(const EventObject& e) throw( RuntimeExcept if (e.Source == m_xExternalViewController) { - Reference< XFormController> xFormController(m_xExternalViewController, UNO_QUERY); + Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY ); + OSL_ENSURE( xFormController.is(), "FmXFormShell::disposing: invalid external view controller!" ); if (xFormController.is()) xFormController->removeActivateListener((XFormControllerListener*)this); @@ -765,7 +957,7 @@ void SAL_CALL FmXFormShell::formActivated(const EventObject& rEvent) throw( Runt if ( impl_checkDisposed() ) return; - Reference< XFormController > xController( rEvent.Source, UNO_QUERY_THROW ); + Reference< runtime::XFormController > xController( rEvent.Source, UNO_QUERY_THROW ); m_pTextShell->formActivated( xController ); setActiveController( xController ); } @@ -777,7 +969,7 @@ void SAL_CALL FmXFormShell::formDeactivated(const EventObject& rEvent) throw( Ru if ( impl_checkDisposed() ) return; - Reference< XFormController > xController( rEvent.Source, UNO_QUERY_THROW ); + Reference< runtime::XFormController > xController( rEvent.Source, UNO_QUERY_THROW ); m_pTextShell->formDeactivated( xController ); } @@ -798,14 +990,6 @@ void FmXFormShell::disposing() // are still uncommitted changes, the user explicitly wanted this. // 2002-11-11 - 104702 - fs@openoffice.org - // dispose our interceptor helpers - if (m_pExternalViewInterceptor) - { - m_pExternalViewInterceptor->dispose(); - m_pExternalViewInterceptor->release(); - m_pExternalViewInterceptor = NULL; - } - m_pTextShell->dispose(); m_xAttachedFrame = NULL; @@ -1703,7 +1887,7 @@ Reference< XResultSet> FmXFormShell::getInternalForm(const Reference< XResultSet if ( impl_checkDisposed() ) return NULL; - Reference< XFormController> xExternalCtrlr(m_xExternalViewController, UNO_QUERY); + Reference< runtime::XFormController> xExternalCtrlr(m_xExternalViewController, UNO_QUERY); if (xExternalCtrlr.is() && (_xForm == xExternalCtrlr->getModel())) { DBG_ASSERT(m_xExternalDisplayedForm.is(), "FmXFormShell::getInternalForm : invalid external form !"); @@ -1719,7 +1903,7 @@ Reference< XForm> FmXFormShell::getInternalForm(const Reference< XForm>& _xForm) if ( impl_checkDisposed() ) return NULL; - Reference< XFormController> xExternalCtrlr(m_xExternalViewController, UNO_QUERY); + Reference< runtime::XFormController > xExternalCtrlr(m_xExternalViewController, UNO_QUERY); if (xExternalCtrlr.is() && (_xForm == xExternalCtrlr->getModel())) { DBG_ASSERT(m_xExternalDisplayedForm.is(), "FmXFormShell::getInternalForm : invalid external form !"); @@ -1808,7 +1992,7 @@ void FmXFormShell::impl_switchActiveControllerListening( const bool _bListen ) } //------------------------------------------------------------------------------ -void FmXFormShell::setActiveController( const Reference< XFormController>& xController, sal_Bool _bNoSaveOldContent ) +void FmXFormShell::setActiveController( const Reference< runtime::XFormController >& xController, sal_Bool _bNoSaveOldContent ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::setActiveController" ); if ( impl_checkDisposed() ) @@ -2103,11 +2287,11 @@ void FmXFormShell::startListening() { // suchen des Controllers, ueber den eine Navigation moeglich ist Reference< XChild> xChild(m_xActiveController, UNO_QUERY); - Reference< XFormController> xParent; + Reference< runtime::XFormController > xParent; while (xChild.is()) { xChild = Reference< XChild>(xChild->getParent(), UNO_QUERY); - xParent = Reference< XFormController>(xChild, UNO_QUERY); + xParent = Reference< runtime::XFormController >(xChild, UNO_QUERY); Reference< XPropertySet> xParentSet; if (xParent.is()) xParentSet = Reference< XPropertySet>(xParent->getModel(), UNO_QUERY); @@ -2936,31 +3120,39 @@ void FmXFormShell::startFiltering() FmWinRecList::iterator i = pXView->findWindow(xContainer); if (i != pXView->getWindowList().end()) { - const ::std::vector< Reference< XFormController> >& rControllerList = (*i)->GetList(); - for (::std::vector< Reference< XFormController> >::const_iterator j = rControllerList.begin(); + const ::std::vector< Reference< runtime::XFormController> >& rControllerList = (*i)->GetList(); + for (::std::vector< Reference< runtime::XFormController> >::const_iterator j = rControllerList.begin(); j != rControllerList.end(); ++j) { Reference< XModeSelector> xModeSelector(*j, UNO_QUERY); if (xModeSelector.is()) - xModeSelector->setMode(FILTER_MODE); + xModeSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) ); } } m_bFilterMode = sal_True; m_pShell->UIFeatureChanged(); - m_pShell->GetViewShell()->GetViewFrame()->GetBindings().InvalidateShell(*m_pShell); + SfxViewFrame* pViewFrame = m_pShell->GetViewShell()->GetViewFrame(); + pViewFrame->GetBindings().InvalidateShell( *m_pShell ); + + if ( pViewFrame->KnowsChildWindow( SID_FM_FILTER_NAVIGATOR ) + && !pViewFrame->HasChildWindow( SID_FM_FILTER_NAVIGATOR ) + ) + { + pViewFrame->ToggleChildWindow( SID_FM_FILTER_NAVIGATOR ); + } } //------------------------------------------------------------------------------ -void saveFilter(const Reference< XFormController>& _rxController) +void saveFilter(const Reference< runtime::XFormController >& _rxController) { Reference< XPropertySet> xFormAsSet(_rxController->getModel(), UNO_QUERY); Reference< XPropertySet> xControllerAsSet(_rxController, UNO_QUERY); Reference< XIndexAccess> xControllerAsIndex(_rxController, UNO_QUERY); // call the subcontroller - Reference< XFormController> xController; + Reference< runtime::XFormController > xController; for (sal_Int32 i = 0, nCount = xControllerAsIndex->getCount(); i < nCount; ++i) { xControllerAsIndex->getByIndex(i) >>= xController; @@ -2995,7 +3187,7 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) Reference< XControlContainer> xContainer; if (getActiveController() == m_xExternalViewController) { - DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::startFiltering : inconsistent : active external controller, but noone triggered this !"); + DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::stopFiltering : inconsistent : active external controller, but noone triggered this !"); xContainer = m_xExtViewTriggerController->getContainer(); } else @@ -3004,13 +3196,13 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) FmWinRecList::iterator i = pXView->findWindow(xContainer); if (i != pXView->getWindowList().end()) { - const ::std::vector< Reference< XFormController> >& rControllerList = (*i)->GetList(); + const ::std::vector< Reference< runtime::XFormController > >& rControllerList = (*i)->GetList(); ::std::vector < ::rtl::OUString > aOriginalFilters; ::std::vector < sal_Bool > aOriginalApplyFlags; if (bSave) { - for (::std::vector< Reference< XFormController> > ::const_iterator j = rControllerList.begin(); + for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin(); j != rControllerList.end(); ++j) { if (bSave) @@ -3035,18 +3227,18 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) saveFilter(*j); } } - for (::std::vector< Reference< XFormController> > ::const_iterator j = rControllerList.begin(); + for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin(); j != rControllerList.end(); ++j) { Reference< XModeSelector> xModeSelector(*j, UNO_QUERY); if (xModeSelector.is()) - xModeSelector->setMode(DATA_MODE); + xModeSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) ); } if (bSave) // execute the filter { - const ::std::vector< Reference< XFormController> > & rControllers = (*i)->GetList(); - for (::std::vector< Reference< XFormController> > ::const_iterator j = rControllers.begin(); + const ::std::vector< Reference< runtime::XFormController > > & rControllers = (*i)->GetList(); + for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllers.begin(); j != rControllers.end(); ++j) { Reference< XLoadable> xReload((*j)->getModel(), UNO_QUERY); @@ -3087,13 +3279,13 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) } //------------------------------------------------------------------------------ -void clearFilter(const Reference< XFormController>& _rxController) +void clearFilter(const Reference< runtime::XFormController >& _rxController) { Reference< XPropertySet> xControllerAsSet(_rxController, UNO_QUERY); Reference< XIndexAccess> xControllerAsIndex(_rxController, UNO_QUERY); // call the subcontroller - Reference< XFormController> xController; + Reference< runtime::XFormController > xController; for (sal_Int32 i = 0, nCount = xControllerAsIndex->getCount(); i < nCount; i++) { @@ -3132,7 +3324,7 @@ void FmXFormShell::clearFilter() Reference< XControlContainer> xContainer; if (getActiveController() == m_xExternalViewController) { - DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::startFiltering : inconsistent : active external controller, but noone triggered this !"); + DBG_ASSERT(m_xExtViewTriggerController.is(), "FmXFormShell::clearFilter : inconsistent : active external controller, but noone triggered this !"); xContainer = m_xExtViewTriggerController->getContainer(); } else @@ -3141,8 +3333,8 @@ void FmXFormShell::clearFilter() FmWinRecList::iterator i = pXView->findWindow(xContainer); if (i != pXView->getWindowList().end()) { - const ::std::vector< Reference< XFormController> > & rControllerList = (*i)->GetList(); - for (::std::vector< Reference< XFormController> > ::const_iterator j = rControllerList.begin(); + const ::std::vector< Reference< runtime::XFormController > > & rControllerList = (*i)->GetList(); + for (::std::vector< Reference< runtime::XFormController > > ::const_iterator j = rControllerList.begin(); j != rControllerList.end(); ++j) { ::clearFilter(*j); @@ -3253,7 +3445,7 @@ void FmXFormShell::restoreControlLocks() } //------------------------------------------------------------------------------ -void FmXFormShell::DoAsyncCursorAction(const Reference< XFormController>& _xController, CURSOR_ACTION _eWhat) +void FmXFormShell::DoAsyncCursorAction(const Reference< runtime::XFormController >& _xController, CURSOR_ACTION _eWhat) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::DoAsyncCursorAction" ); if ( impl_checkDisposed() ) @@ -3329,7 +3521,7 @@ sal_Bool FmXFormShell::HasPendingCursorAction(const Reference< XResultSet>& _xFo } //------------------------------------------------------------------------------ -sal_Bool FmXFormShell::HasPendingCursorAction(const Reference< XFormController>& xController) const +sal_Bool FmXFormShell::HasPendingCursorAction(const Reference< runtime::XFormController >& xController) const { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormShell::HasPendingCursorAction" ); if ( impl_checkDisposed() ) @@ -3471,7 +3663,7 @@ void FmXFormShell::CreateExternalView() ::rtl::OUString sFrameName = ::rtl::OUString::createFromAscii("_beamer"); sal_Int32 nSearchFlags = ::com::sun::star::frame::FrameSearchFlag::CHILDREN | ::com::sun::star::frame::FrameSearchFlag::CREATE; - Reference< XFormController> xCurrentNavController( getNavController()); + Reference< runtime::XFormController > xCurrentNavController( getNavController()); // the creation of the "partwindow" may cause a deactivate of the document which will result in our nav controller to be set to NULL // _first_ check if we have any valid fields we can use for the grid view @@ -3538,12 +3730,12 @@ void FmXFormShell::CreateExternalView() { if ( m_xExternalViewController == getActiveController() ) { - Reference< XFormController > xAsFormController( m_xExternalViewController, UNO_QUERY ); + Reference< runtime::XFormController > xAsFormController( m_xExternalViewController, UNO_QUERY ); ControllerFeatures aHelper( ::comphelper::getProcessServiceFactory(), xAsFormController, NULL ); aHelper->commitCurrentControl(); } - Reference< XFormController> xNewController(m_xExtViewTriggerController); + Reference< runtime::XFormController > xNewController(m_xExtViewTriggerController); CloseExternalFormViewer(); setActiveController(xNewController); return; @@ -3557,28 +3749,8 @@ void FmXFormShell::CreateExternalView() xClear->dispatch(aClearURL, Sequence< PropertyValue>()); } - // interception of slots of the external view - if (m_pExternalViewInterceptor) - { // already intercepting ... - if (m_pExternalViewInterceptor->getIntercepted() != xExternalViewFrame) - { // ... but another frame -> create a new interceptor - m_pExternalViewInterceptor->dispose(); - m_pExternalViewInterceptor->release(); - m_pExternalViewInterceptor = NULL; - } - } - - if (!m_pExternalViewInterceptor) - { - Reference< ::com::sun::star::frame::XDispatchProviderInterception> xSupplier(xExternalViewFrame, UNO_QUERY); - ::rtl::OUString sInterceptorScheme = FMURL_FORMSLOTS_PREFIX; - sInterceptorScheme += ::rtl::OUString::createFromAscii("*"); -// m_pExternalViewInterceptor = new FmXDispatchInterceptorImpl(xSupplier, this, 1, Sequence< ::rtl::OUString >(&sInterceptorScheme, 1)); -// m_pExternalViewInterceptor->acquire(); - // TODO: re-implement this in a easier way than before: We need an interceptor at the xSupplier, which - // forwards all queryDispatch requests to the FormController instance for which this "external view" - // was triggered - } + // TODO: We need an interceptor at the xSupplier, which forwards all queryDispatch requests to the FormController + // instance for which this "external view" was triggered // get the dispatch interface of the frame so we can communicate (interceptable) with the controller Reference< ::com::sun::star::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY); @@ -3876,7 +4048,8 @@ void FmXFormShell::CreateExternalView() // we want to know modifications done in the external view // if the external controller is a XFormController we can use all our default handlings for it - Reference< XFormController> xFormController(m_xExternalViewController, UNO_QUERY); + Reference< runtime::XFormController > xFormController( m_xExternalViewController, UNO_QUERY ); + OSL_ENSURE( xFormController.is(), "FmXFormShell::CreateExternalView:: invalid external view controller!" ); if (xFormController.is()) xFormController->addActivateListener((XFormControllerListener*)this); } @@ -4162,6 +4335,44 @@ IMPL_LINK( FmXFormShell, OnLoadForms, FmFormPage*, /*_pPage*/ ) return 0L; } +//------------------------------------------------------------------------------ +namespace +{ + sal_Bool lcl_isLoadable( const Reference< XInterface >& _rxLoadable ) + { + // determines whether a form should be loaded or not + // if there is no datasource or connection there is no reason to load a form + Reference< XPropertySet > xSet( _rxLoadable, UNO_QUERY ); + if ( !xSet.is() ) + return sal_False; + try + { + Reference< XConnection > xConn; + if ( OStaticDataAccessTools().isEmbeddedInDatabase( _rxLoadable.get(), xConn ) ) + return sal_True; + + // is there already a active connection + xSet->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConn; + if ( xConn.is() ) + return sal_True; + + ::rtl::OUString sPropertyValue; + OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DATASOURCE ) >>= sPropertyValue ); + if ( sPropertyValue.getLength() ) + return sal_True; + + OSL_VERIFY( xSet->getPropertyValue( FM_PROP_URL ) >>= sPropertyValue ); + if ( sPropertyValue.getLength() ) + return sal_True; + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + return sal_False; + } +} + //------------------------------------------------------------------------ void FmXFormShell::loadForms( FmFormPage* _pPage, const sal_uInt16 _nBehaviour /* FORMS_LOAD | FORMS_SYNC */ ) { @@ -4206,7 +4417,7 @@ void FmXFormShell::loadForms( FmFormPage* _pPage, const sal_uInt16 _nBehaviour / { if ( 0 == ( _nBehaviour & FORMS_UNLOAD ) ) { - if ( ::isLoadable( xForm ) && !xForm->isLoaded() ) + if ( lcl_isLoadable( xForm ) && !xForm->isLoaded() ) xForm->load(); } else diff --git a/svx/source/form/fmstring.src b/svx/source/form/fmstring.src index 8b42ccadc6a6..da9b47de43cf 100644 --- a/svx/source/form/fmstring.src +++ b/svx/source/form/fmstring.src @@ -130,7 +130,7 @@ String RID_STR_DELETECONFIRM_RECORDS }; String RID_STR_DELETECONFIRM { - Text [ en-US ] = "If you click Yes, you won't be able to undo this operation!\nDo you want to continue anyway?"; + Text [ en-US ] = "If you click Yes, you won't be able to undo this operation.\nDo you want to continue anyway?"; }; String RID_ERR_NO_ELEMENT diff --git a/svx/source/form/fmtextcontrolshell.cxx b/svx/source/form/fmtextcontrolshell.cxx index f0bc81865401..7854de20bcf5 100644 --- a/svx/source/form/fmtextcontrolshell.cxx +++ b/svx/source/form/fmtextcontrolshell.cxx @@ -89,6 +89,7 @@ namespace svx using namespace ::com::sun::star::uno; using namespace ::com::sun::star::awt; using namespace ::com::sun::star::form; + using namespace ::com::sun::star::form::runtime; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::frame; using namespace ::com::sun::star::util; diff --git a/svx/source/form/fmtools.cxx b/svx/source/form/fmtools.cxx index 0a97bdd981b7..ad4fb46e2a0c 100644 --- a/svx/source/form/fmtools.cxx +++ b/svx/source/form/fmtools.cxx @@ -30,83 +30,74 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/io/XPersistObject.hpp> -#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> -#include <com/sun/star/sdb/XCompletedConnection.hpp> -#include <com/sun/star/sdbcx/Privilege.hpp> -#include <com/sun/star/lang/Locale.hpp> + +#include "fmprop.hrc" +#include "fmservs.hxx" #include "svx/fmtools.hxx" #include "svx/dbtoolsclient.hxx" -#include "fmservs.hxx" -#include <svx/fmglob.hxx> -#include <vcl/stdtext.hxx> -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ -#include <toolkit/unohlp.hxx> -#endif +#include "svx/fmglob.hxx" -#include <stdlib.h> -#include <stdio.h> -#include <wchar.h> -#include <com/sun/star/uno/XNamingService.hpp> -#include <com/sun/star/sdbc/XDataSource.hpp> +/** === begin UNO includes === **/ +#include <com/sun/star/awt/LineEndFormat.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XIntrospection.hpp> +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/form/XGridColumnFactory.hpp> +#include <com/sun/star/io/XActiveDataSink.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/io/XObjectInputStream.hpp> +#include <com/sun/star/io/XObjectOutputStream.hpp> +#include <com/sun/star/io/XPersistObject.hpp> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/sdb/CommandType.hpp> -#include <com/sun/star/sdb/XQueriesSupplier.hpp> +#include <com/sun/star/sdb/ErrorCondition.hpp> #include <com/sun/star/sdb/SQLContext.hpp> -#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/sdb/XCompletedConnection.hpp> +#include <com/sun/star/sdb/XQueriesSupplier.hpp> #include <com/sun/star/sdb/XResultSetAccess.hpp> -#include <com/sun/star/sdb/ErrorCondition.hpp> #include <com/sun/star/sdbc/DataType.hpp> -#include <com/sun/star/util/NumberFormat.hpp> -#include <com/sun/star/io/XActiveDataSink.hpp> -#include <com/sun/star/io/XActiveDataSource.hpp> -#include <com/sun/star/script/XEventAttacherManager.hpp> -#include <com/sun/star/form/XForm.hpp> -#include <com/sun/star/form/XFormComponent.hpp> -#include <com/sun/star/util/XNumberFormatter.hpp> -#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/sdbc/XDataSource.hpp> +#include <com/sun/star/sdbcx/Privilege.hpp> +#include <com/sun/star/sdbcx/XTablesSupplier.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/uno/XNamingService.hpp> #include <com/sun/star/util/Language.hpp> -#include <com/sun/star/util/XNumberFormats.hpp> -#include <com/sun/star/util/XNumberFormatTypes.hpp> +#include <com/sun/star/util/NumberFormat.hpp> #include <com/sun/star/util/XCloneable.hpp> -#include <com/sun/star/io/XObjectInputStream.hpp> -#include <com/sun/star/io/XObjectOutputStream.hpp> -#include <com/sun/star/reflection/XIdlClass.hpp> -#include <com/sun/star/reflection/XIdlMethod.hpp> -#include <com/sun/star/beans/XIntrospection.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/task/XInteractionHandler.hpp> -#include <com/sun/star/awt/LineEndFormat.hpp> -#include <com/sun/star/form/XGridColumnFactory.hpp> - +#include <com/sun/star/util/XNumberFormatTypes.hpp> +#include <com/sun/star/util/XNumberFormats.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> +#include <com/sun/star/util/XNumberFormatter.hpp> +/** === end UNO includes === **/ -#include <tools/debug.hxx> -#include <tools/string.hxx> #include <basic/sbxvar.hxx> -#include <rtl/math.hxx> -#include <vcl/svapp.hxx> - -#ifndef _SVX_FMPROP_HRC -#include "fmprop.hrc" -#endif -#include <sfx2/bindings.hxx> -#include <svl/eitem.hxx> -#include <svl/stritem.hxx> -#include <cppuhelper/servicefactory.hxx> -#include <comphelper/types.hxx> -#include <comphelper/property.hxx> #include <comphelper/container.hxx> -#include <connectivity/dbtools.hxx> +#include <comphelper/extract.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/property.hxx> #include <comphelper/sequence.hxx> -#include <comphelper/extract.hxx> +#include <comphelper/types.hxx> #include <comphelper/uno3.hxx> #include <connectivity/dbexception.hxx> -#include <comphelper/extract.hxx> +#include <connectivity/dbtools.hxx> +#include <cppuhelper/servicefactory.hxx> #include <cppuhelper/typeprovider.hxx> -#include <algorithm> #include <rtl/logfile.hxx> +#include <rtl/math.hxx> +#include <sfx2/bindings.hxx> +#include <svl/eitem.hxx> +#include <svl/stritem.hxx> +#include <toolkit/unohlp.hxx> +#include <tools/debug.hxx> +#include <tools/string.hxx> +#include <vcl/stdtext.hxx> +#include <vcl/svapp.hxx> + +#include <algorithm> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; @@ -204,106 +195,8 @@ void displayException(const ::com::sun::star::sdb::SQLErrorEvent& _rEvent, Windo } //------------------------------------------------------------------------------ -Reference< XInterface > cloneUsingProperties(const Reference< ::com::sun::star::io::XPersistObject>& _xObj) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::cloneUsingProperties" ); - if (!_xObj.is()) - return Reference< XInterface >(); - - // create a new object - ::rtl::OUString aObjectService = _xObj->getServiceName(); - Reference< ::com::sun::star::beans::XPropertySet> xDestSet(::comphelper::getProcessServiceFactory()->createInstance(aObjectService), UNO_QUERY); - if (!xDestSet.is()) - { - DBG_ERROR("cloneUsingProperties : could not instantiate an object of the given type !"); - return Reference< XInterface >(); - } - // transfer properties - Reference< XPropertySet > xSourceSet(_xObj, UNO_QUERY); - Reference< XPropertySetInfo > xSourceInfo( xSourceSet->getPropertySetInfo()); - Sequence< Property> aSourceProperties = xSourceInfo->getProperties(); - Reference< XPropertySetInfo > xDestInfo( xDestSet->getPropertySetInfo()); - Sequence< Property> aDestProperties = xDestInfo->getProperties(); - int nDestLen = aDestProperties.getLength(); - - Property* pSourceProps = aSourceProperties.getArray(); - Property* pSourceEnd = pSourceProps + aSourceProperties.getLength(); - Property* pDestProps = aDestProperties.getArray(); - - for (; pSourceProps != pSourceEnd; ++pSourceProps) - { - ::com::sun::star::beans::Property* pResult = ::std::lower_bound( - pDestProps, - pDestProps + nDestLen, - pSourceProps->Name, - ::comphelper::PropertyStringLessFunctor() - ); - - if ( ( pResult != pDestProps + nDestLen ) - && ( pResult->Name == pSourceProps->Name ) - && ( pResult->Attributes == pSourceProps->Attributes ) - && ( (pResult->Attributes & PropertyAttribute::READONLY ) == 0 ) - && ( pResult->Type.equals( pSourceProps->Type ) ) - ) - { // Attribute/type are the same and the prop isn't readonly - try - { - xDestSet->setPropertyValue(pResult->Name, xSourceSet->getPropertyValue(pResult->Name)); - } - catch(IllegalArgumentException e) - { - (void)e; -#ifdef DBG_UTIL - ::rtl::OString sMessage("cloneUsingProperties : could not transfer the value for property \""); - sMessage = sMessage + ::rtl::OString(pResult->Name.getStr(), pResult->Name.getLength(), RTL_TEXTENCODING_ASCII_US); - sMessage = sMessage + '\"'; - DBG_ERROR(sMessage); -#endif - } - - } - } - - return xDestSet.get(); -} - -//------------------------------------------------------------------------------ -sal_Bool searchElement(const Reference< ::com::sun::star::container::XIndexAccess>& xCont, const Reference< XInterface >& xElement) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::searchElement" ); - if (!xCont.is() || !xElement.is()) - return sal_False; - - sal_Int32 nCount = xCont->getCount(); - Reference< XInterface > xComp; - for (sal_Int32 i = 0; i < nCount; i++) - { - try - { - xCont->getByIndex(i) >>= xComp; - if (xComp.is()) - { - if ( xElement == xComp ) - return sal_True; - else - { - Reference< ::com::sun::star::container::XIndexAccess> xCont2(xComp, UNO_QUERY); - if (xCont2.is() && searchElement(xCont2, xElement)) - return sal_True; - } - } - } - catch(Exception&) - { - } - } - return sal_False; -} - -//------------------------------------------------------------------------------ sal_Int32 getElementPos(const Reference< ::com::sun::star::container::XIndexAccess>& xCont, const Reference< XInterface >& xElement) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getElementPos" ); sal_Int32 nIndex = -1; if (!xCont.is()) return nIndex; @@ -336,127 +229,6 @@ sal_Int32 getElementPos(const Reference< ::com::sun::star::container::XIndexAcce } //------------------------------------------------------------------ -String getFormComponentAccessPath(const Reference< XInterface >& _xElement, Reference< XInterface >& _rTopLevelElement) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getFormComponentAccessPath" ); - Reference< ::com::sun::star::form::XFormComponent> xChild(_xElement, UNO_QUERY); - Reference< ::com::sun::star::container::XIndexAccess> xParent; - if (xChild.is()) - xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY); - - // while the current content is a form - String sReturn; - String sCurrentIndex; - while (xChild.is()) - { - // get the content's relative pos within it's parent container - sal_Int32 nPos = getElementPos(xParent, xChild); - - // prepend this current relaive pos - sCurrentIndex = String::CreateFromInt32(nPos); - if (sReturn.Len() != 0) - { - sCurrentIndex += '\\'; - sCurrentIndex += sReturn; - } - - sReturn = sCurrentIndex; - - // travel up - if (::comphelper::query_interface((Reference< XInterface >)xParent,xChild)) - xParent = Reference< ::com::sun::star::container::XIndexAccess>(xChild->getParent(), UNO_QUERY); - } - - _rTopLevelElement = xParent; - return sReturn; -} - -//------------------------------------------------------------------ -String getFormComponentAccessPath(const Reference< XInterface >& _xElement) -{ - Reference< XInterface > xDummy; - return getFormComponentAccessPath(_xElement, xDummy); -} - -//------------------------------------------------------------------------------ -Reference< XInterface > getElementFromAccessPath(const Reference< ::com::sun::star::container::XIndexAccess>& _xParent, const String& _rRelativePath) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getElementFromAccessPath" ); - if (!_xParent.is()) - return Reference< XInterface >(); - Reference< ::com::sun::star::container::XIndexAccess> xContainer(_xParent); - Reference< XInterface > xElement( _xParent); - - String sPath(_rRelativePath); - while (sPath.Len() && xContainer.is()) - { - xub_StrLen nSepPos = sPath.Search((sal_Unicode)'\\'); - - String sIndex(sPath.Copy(0, (nSepPos == STRING_NOTFOUND) ? sPath.Len() : nSepPos)); - // DBG_ASSERT(sIndex.IsNumeric(), "getElementFromAccessPath : invalid path !"); - - sPath = sPath.Copy((nSepPos == STRING_NOTFOUND) ? sPath.Len() : nSepPos+1); - - ::cppu::extractInterface(xElement, xContainer->getByIndex(sIndex.ToInt32())); - xContainer = Reference< ::com::sun::star::container::XIndexAccess>::query(xElement); - } - - if (sPath.Len() != 0) - // the loop terminated because an element wasn't a container, but we stil have a path -> the path is invalid - xElement = NULL; - - return xElement; -} - -//------------------------------------------------------------------ -// Vergleichen von PropertyInfo -extern "C" int -#if defined( WNT ) - __cdecl -#endif -#if defined( ICC ) && defined( OS2 ) -_Optlink -#endif - NameCompare(const void* pFirst, const void* pSecond) -{ - return ((::rtl::OUString*)pFirst)->compareTo(*(::rtl::OUString*)pSecond); -} - -//------------------------------------------------------------------------------ -sal_Int32 findPos(const ::rtl::OUString& aStr, const Sequence< ::rtl::OUString>& rList) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::findPos" ); - const ::rtl::OUString* pStrList = rList.getConstArray(); - ::rtl::OUString* pResult = (::rtl::OUString*) bsearch(&aStr, (void*)pStrList, rList.getLength(), sizeof(::rtl::OUString), - &NameCompare); - - if (pResult) - return (pResult - pStrList); - else - return -1; -} - -//------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XModel> getXModel(const Reference< XInterface >& xIface) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getXModel" ); - Reference< ::com::sun::star::frame::XModel> xModel(xIface, UNO_QUERY); - if (xModel.is()) - return xModel; - else - { - Reference< ::com::sun::star::container::XChild> xChild(xIface, UNO_QUERY); - if (xChild.is()) - { - Reference< XInterface > xParent( xChild->getParent()); - return getXModel(xParent); - } - else - return NULL; - } -} - -//------------------------------------------------------------------ ::rtl::OUString getLabelName(const Reference< ::com::sun::star::beans::XPropertySet>& xControlModel) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getLabelName" ); @@ -690,412 +462,6 @@ sal_Int16 getControlTypeByObject(const Reference< ::com::sun::star::lang::XServi } //------------------------------------------------------------------------------ -::rtl::OUString getServiceNameByControlType(sal_Int16 nType) -{ - switch (nType) - { - case OBJ_FM_EDIT : return FM_COMPONENT_TEXTFIELD; - case OBJ_FM_BUTTON : return FM_COMPONENT_COMMANDBUTTON; - case OBJ_FM_FIXEDTEXT : return FM_COMPONENT_FIXEDTEXT; - case OBJ_FM_LISTBOX : return FM_COMPONENT_LISTBOX; - case OBJ_FM_CHECKBOX : return FM_COMPONENT_CHECKBOX; - case OBJ_FM_RADIOBUTTON : return FM_COMPONENT_RADIOBUTTON; - case OBJ_FM_GROUPBOX : return FM_COMPONENT_GROUPBOX; - case OBJ_FM_COMBOBOX : return FM_COMPONENT_COMBOBOX; - case OBJ_FM_GRID : return FM_COMPONENT_GRIDCONTROL; - case OBJ_FM_IMAGEBUTTON : return FM_COMPONENT_IMAGEBUTTON; - case OBJ_FM_FILECONTROL : return FM_COMPONENT_FILECONTROL; - case OBJ_FM_DATEFIELD : return FM_COMPONENT_DATEFIELD; - case OBJ_FM_TIMEFIELD : return FM_COMPONENT_TIMEFIELD; - case OBJ_FM_NUMERICFIELD : return FM_COMPONENT_NUMERICFIELD; - case OBJ_FM_CURRENCYFIELD : return FM_COMPONENT_CURRENCYFIELD; - case OBJ_FM_PATTERNFIELD : return FM_COMPONENT_PATTERNFIELD; - case OBJ_FM_HIDDEN : return FM_COMPONENT_HIDDENCONTROL; - case OBJ_FM_IMAGECONTROL : return FM_COMPONENT_IMAGECONTROL; - case OBJ_FM_FORMATTEDFIELD : return FM_COMPONENT_FORMATTEDFIELD; - case OBJ_FM_SCROLLBAR : return FM_SUN_COMPONENT_SCROLLBAR; - case OBJ_FM_SPINBUTTON : return FM_SUN_COMPONENT_SPINBUTTON; - case OBJ_FM_NAVIGATIONBAR : return FM_SUN_COMPONENT_NAVIGATIONBAR; - } - return ::rtl::OUString(); -} -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString> getEventMethods(const Type& type) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getEventMethods" ); - typelib_InterfaceTypeDescription *pType=0; - type.getDescription( (typelib_TypeDescription**)&pType); - - if(!pType) - return Sequence< ::rtl::OUString>(); - - Sequence< ::rtl::OUString> aNames(pType->nMembers); - ::rtl::OUString* pNames = aNames.getArray(); - for(sal_Int32 i=0;i<pType->nMembers;i++,++pNames) - { - // the decription reference - typelib_TypeDescriptionReference* pMemberDescriptionReference = pType->ppMembers[i]; - // the description for the reference - typelib_TypeDescription* pMemberDescription = NULL; - typelib_typedescriptionreference_getDescription(&pMemberDescription, pMemberDescriptionReference); - if (pMemberDescription) - { - typelib_InterfaceMemberTypeDescription* pRealMemberDescription = - reinterpret_cast<typelib_InterfaceMemberTypeDescription*>(pMemberDescription); - *pNames = pRealMemberDescription->pMemberName; - } - } - typelib_typedescription_release( (typelib_TypeDescription *)pType ); - return aNames; -} - - -//------------------------------------------------------------------------------ -void TransferEventScripts(const Reference< ::com::sun::star::awt::XControlModel>& xModel, const Reference< ::com::sun::star::awt::XControl>& xControl, - const Sequence< ::com::sun::star::script::ScriptEventDescriptor>& rTransferIfAvailable) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::TransferEventScripts" ); - // first check if we have a XEventAttacherManager for the model - Reference< ::com::sun::star::container::XChild> xModelChild(xModel, UNO_QUERY); - if (!xModelChild.is()) - return; // nothing to do - - Reference< ::com::sun::star::script::XEventAttacherManager> xEventManager(xModelChild->getParent(), UNO_QUERY); - if (!xEventManager.is()) - return; // nothing to do - - if (!rTransferIfAvailable.getLength()) - return; // nothing to do - - // check for the index of the model within it's parent - Reference< ::com::sun::star::container::XIndexAccess> xParentIndex(xModelChild->getParent(), UNO_QUERY); - if (!xParentIndex.is()) - return; // nothing to do - sal_Int32 nIndex = getElementPos(xParentIndex, xModel); - if (nIndex<0 || nIndex>=xParentIndex->getCount()) - return; // nothing to do - - // then we need informations about the listeners supported by the control and the model - Sequence< Type> aModelListeners; - Sequence< Type> aControlListeners; - - Reference< ::com::sun::star::beans::XIntrospection> xModelIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY); - Reference< ::com::sun::star::beans::XIntrospection> xControlIntrospection(::comphelper::getProcessServiceFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.beans.Introspection")), UNO_QUERY); - - if (xModelIntrospection.is() && xModel.is()) - { - Any aModel(makeAny(xModel)); - aModelListeners = xModelIntrospection->inspect(aModel)->getSupportedListeners(); - } - - if (xControlIntrospection.is() && xControl.is()) - { - Any aControl(makeAny(xControl)); - aControlListeners = xControlIntrospection->inspect(aControl)->getSupportedListeners(); - } - - sal_Int32 nMaxNewLen = aModelListeners.getLength() + aControlListeners.getLength(); - if (!nMaxNewLen) - return; // the model and the listener don't support any listeners (or we were unable to retrieve these infos) - - Sequence< ::com::sun::star::script::ScriptEventDescriptor> aTransferable(nMaxNewLen); - ::com::sun::star::script::ScriptEventDescriptor* pTransferable = aTransferable.getArray(); - - const ::com::sun::star::script::ScriptEventDescriptor* pCurrent = rTransferIfAvailable.getConstArray(); - sal_Int32 i,j,k; - for (i=0; i<rTransferIfAvailable.getLength(); ++i, ++pCurrent) - { - // search the model/control idl classes for the event described by pCurrent - for ( Sequence< Type>* pCurrentArray = &aModelListeners; - pCurrentArray; - pCurrentArray = (pCurrentArray == &aModelListeners) ? &aControlListeners : NULL - ) - { - const Type* pCurrentListeners = pCurrentArray->getConstArray(); - for (j=0; j<pCurrentArray->getLength(); ++j, ++pCurrentListeners) - { - UniString aListener = (*pCurrentListeners).getTypeName(); - xub_StrLen nTokens = aListener.GetTokenCount('.'); - if (nTokens) - aListener = aListener.GetToken(nTokens - 1, '.'); - - if (aListener == pCurrent->ListenerType.getStr()) - // the current ::com::sun::star::script::ScriptEventDescriptor doesn't match the current listeners class - continue; - - // now check the methods - Sequence< ::rtl::OUString> aMethodsNames = getEventMethods(*pCurrentListeners); - const ::rtl::OUString* pMethodsNames = aMethodsNames.getConstArray(); - for (k=0; k<aMethodsNames.getLength(); ++k, ++pMethodsNames) - { - if ((*pMethodsNames).compareTo(pCurrent->EventMethod) != COMPARE_EQUAL) - // the current ::com::sun::star::script::ScriptEventDescriptor doesn't match the current listeners current method - continue; - - // we can transfer the script event : the model (control) supports it - *pTransferable = *pCurrent; - ++pTransferable; - break; - } - if (k<aMethodsNames.getLength()) - break; - } - } - } - - sal_Int32 nRealNewLen = pTransferable - aTransferable.getArray(); - aTransferable.realloc(nRealNewLen); - - xEventManager->registerScriptEvents(nIndex, aTransferable); -} - -//------------------------------------------------------------------------------ -sal_Int16 GridView2ModelPos(const Reference< ::com::sun::star::container::XIndexAccess>& rColumns, sal_Int16 nViewPos) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::GridView2ModelPos" ); - try - { - if (rColumns.is()) - { - // loop through all columns - sal_Int16 i; - Reference< ::com::sun::star::beans::XPropertySet> xCur; - for (i=0; i<rColumns->getCount(); ++i) - { - rColumns->getByIndex(i) >>= xCur; - if (!::comphelper::getBOOL(xCur->getPropertyValue(FM_PROP_HIDDEN))) - { - // for every visible col : if nViewPos is greater zero, decrement it, else we - // have found the model position - if (!nViewPos) - break; - else - --nViewPos; - } - } - if (i<rColumns->getCount()) - return i; - } - } - catch(const Exception&) - { - DBG_ERROR("GridView2ModelPos Exception occured!"); - } - return (sal_Int16)-1; -} - -//======================================================================== -//= FmXDispatchInterceptorImpl -//======================================================================== - -DBG_NAME(FmXDispatchInterceptorImpl); -//------------------------------------------------------------------------ -FmXDispatchInterceptorImpl::FmXDispatchInterceptorImpl( - const Reference< XDispatchProviderInterception >& _rxToIntercept, FmDispatchInterceptor* _pMaster, - sal_Int16 _nId, Sequence< ::rtl::OUString > _rInterceptedSchemes) - :FmXDispatchInterceptorImpl_BASE(_pMaster && _pMaster->getInterceptorMutex() ? *_pMaster->getInterceptorMutex() : m_aFallback) - ,m_xIntercepted(_rxToIntercept) - ,m_bListening(sal_False) - ,m_pMaster(_pMaster) - ,m_nId(_nId) - ,m_aInterceptedURLSchemes(_rInterceptedSchemes) -{ - DBG_CTOR(FmXDispatchInterceptorImpl,NULL); - - ::osl::MutexGuard aGuard(getAccessSafety()); - ::comphelper::increment(m_refCount); - if (_rxToIntercept.is()) - { - _rxToIntercept->registerDispatchProviderInterceptor((::com::sun::star::frame::XDispatchProviderInterceptor*)this); - // this should make us the top-level dispatch-provider for the component, via a call to our - // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill - Reference< ::com::sun::star::lang::XComponent> xInterceptedComponent(_rxToIntercept, UNO_QUERY); - if (xInterceptedComponent.is()) - { - xInterceptedComponent->addEventListener(this); - m_bListening = sal_True; - } - } - ::comphelper::decrement(m_refCount); -} - -//------------------------------------------------------------------------ -FmXDispatchInterceptorImpl::~FmXDispatchInterceptorImpl() -{ - if (!rBHelper.bDisposed) - dispose(); - - DBG_DTOR(FmXDispatchInterceptorImpl,NULL); -} - -//------------------------------------------------------------------------------ -Sequence< sal_Int8 > SAL_CALL FmXDispatchInterceptorImpl::getImplementationId() throw(RuntimeException) -{ - static ::cppu::OImplementationId* pId = 0; - if (! pId) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if (! pId) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} - -//------------------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XDispatch > SAL_CALL FmXDispatchInterceptorImpl::queryDispatch( const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - Reference< ::com::sun::star::frame::XDispatch> xResult; - // ask our 'real' interceptor - if (m_pMaster) - xResult = m_pMaster->interceptedQueryDispatch(m_nId, aURL, aTargetFrameName, nSearchFlags); - - // ask our slave provider - if (!xResult.is() && m_xSlaveDispatcher.is()) - xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags); - - return xResult; -} - -//------------------------------------------------------------------------------ -Sequence< Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL -FmXDispatchInterceptorImpl::queryDispatches( const Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - Sequence< Reference< ::com::sun::star::frame::XDispatch> > aReturn(aDescripts.getLength()); - Reference< ::com::sun::star::frame::XDispatch>* pReturn = aReturn.getArray(); - const ::com::sun::star::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray(); - for (sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts) - { - *pReturn = queryDispatch(pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags); - } - return aReturn; -} - -//------------------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL FmXDispatchInterceptorImpl::getSlaveDispatchProvider( ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - return m_xSlaveDispatcher; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FmXDispatchInterceptorImpl::setSlaveDispatchProvider(const Reference< ::com::sun::star::frame::XDispatchProvider>& xNewDispatchProvider) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - m_xSlaveDispatcher = xNewDispatchProvider; -} - -//------------------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XDispatchProvider> SAL_CALL FmXDispatchInterceptorImpl::getMasterDispatchProvider(void) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - return m_xMasterDispatcher; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FmXDispatchInterceptorImpl::setMasterDispatchProvider(const Reference< ::com::sun::star::frame::XDispatchProvider>& xNewSupplier) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - m_xMasterDispatcher = xNewSupplier; -} - -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString > SAL_CALL FmXDispatchInterceptorImpl::getInterceptedURLs( ) throw(RuntimeException) -{ - return m_aInterceptedURLSchemes; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FmXDispatchInterceptorImpl::disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ) -{ - if (m_bListening) - { - Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); - if (Source.Source == xIntercepted) - ImplDetach(); - } -} - -//------------------------------------------------------------------------------ -void FmXDispatchInterceptorImpl::ImplDetach() -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - OSL_ENSURE(m_bListening, "FmXDispatchInterceptorImpl::ImplDetach: invalid call!"); - - // deregister ourself from the interception component - Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); - if (xIntercepted.is()) - xIntercepted->releaseDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this)); - -// m_xIntercepted = Reference< XDispatchProviderInterception >(); - // Don't reset m_xIntercepted: It may be needed by our owner to check for which object we were - // responsible. As we hold the object with a weak reference only, this should be no problem. - // 88936 - 23.07.2001 - frank.schoenheit@sun.com - m_pMaster = NULL; - m_bListening = sal_False; -} - -//------------------------------------------------------------------------------ -void FmXDispatchInterceptorImpl::disposing() -{ - // remove ourself as event listener from the interception component - if (m_bListening) - { - Reference< ::com::sun::star::lang::XComponent> xInterceptedComponent(m_xIntercepted.get(), UNO_QUERY); - if (xInterceptedComponent.is()) - xInterceptedComponent->removeEventListener(static_cast<XEventListener*>(this)); - - // detach from the interception component - ImplDetach(); - } -} - -//============================================================================== -//============================================================================== - -//------------------------------------------------------------------------------ -sal_Bool isLoadable( const Reference< XInterface >& _rxLoadable ) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::isLoadable" ); - // determines whether a form should be loaded or not - // if there is no datasource or connection there is no reason to load a form - Reference< XPropertySet > xSet( _rxLoadable, UNO_QUERY ); - if ( xSet.is() ) - { - try - { - Reference< XConnection > xConn; - if ( OStaticDataAccessTools().isEmbeddedInDatabase( _rxLoadable.get(), xConn ) ) - return sal_True; - - // is there already a active connection - xSet->getPropertyValue(FM_PROP_ACTIVE_CONNECTION) >>= xConn; - if ( xConn.is() ) - return sal_True; - - ::rtl::OUString sPropertyValue; - OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DATASOURCE ) >>= sPropertyValue ); - if ( sPropertyValue.getLength() ) - return sal_True; - - OSL_VERIFY( xSet->getPropertyValue( FM_PROP_URL ) >>= sPropertyValue ); - if ( sPropertyValue.getLength() ) - return sal_True; - } - catch(Exception&) - { - DBG_ERROR( "isLoadable: caught an exception!" ); - } - - } - return sal_False; -} - -//------------------------------------------------------------------------------ void setConnection(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet, const Reference< ::com::sun::star::sdbc::XConnection>& _rxConn) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::setConnection" ); diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index b88bf659418c..66d16674a2b7 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -30,12 +30,22 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" + #include "fmundo.hxx" +#include "fmpgeimp.hxx" +#include "svx/dbtoolsclient.hxx" +#include "svditer.hxx" +#include "fmobj.hxx" +#include "fmprop.hrc" +#include "fmresids.hrc" +#include "svx/fmglob.hxx" +#include "svx/dialmgr.hxx" +#include "svx/fmmodel.hxx" +#include "svx/fmpage.hxx" /** === begin UNO includes === **/ #include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/form/XFormController.hpp> #include <com/sun/star/container/XContainer.hpp> #include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/script/XEventAttacherManager.hpp> @@ -44,18 +54,8 @@ #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp> /** === end UNO includes === **/ -#ifndef _FM_FMMODEL_HXX -#include <svx/fmmodel.hxx> -#endif #include "svx/fmtools.hxx" -#include <svx/fmpage.hxx> -#ifndef _SVX_FMRESIDS_HRC -#include "fmresids.hrc" -#endif #include <rtl/logfile.hxx> -#include <svx/dialmgr.hxx> -#include "fmpgeimp.hxx" -#include "svx/dbtoolsclient.hxx" #include <svl/macitem.hxx> #include <tools/shl.hxx> #include <tools/diagnose_ex.h> @@ -64,13 +64,8 @@ #include <sfx2/app.hxx> #include <sfx2/sfx.hrc> #include <sfx2/event.hxx> -#include "svditer.hxx" -#include "fmobj.hxx" #include <osl/mutex.hxx> -#include <svx/fmglob.hxx> -#ifndef _SVX_FMPROP_HRC -#include "fmprop.hrc" -#endif +#include <vos/mutex.hxx> #include <comphelper/property.hxx> #include <comphelper/uno3.hxx> #include <comphelper/stl_types.hxx> @@ -301,6 +296,42 @@ void FmXUndoEnvironment::Inserted(SdrObject* pObj) } //------------------------------------------------------------------------------ +namespace +{ + sal_Bool lcl_searchElement(const Reference< XIndexAccess>& xCont, const Reference< XInterface >& xElement) + { + if (!xCont.is() || !xElement.is()) + return sal_False; + + sal_Int32 nCount = xCont->getCount(); + Reference< XInterface > xComp; + for (sal_Int32 i = 0; i < nCount; i++) + { + try + { + xCont->getByIndex(i) >>= xComp; + if (xComp.is()) + { + if ( xElement == xComp ) + return sal_True; + else + { + Reference< XIndexAccess> xCont2(xComp, UNO_QUERY); + if (xCont2.is() && lcl_searchElement(xCont2, xElement)) + return sal_True; + } + } + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + return sal_False; + } +} + +//------------------------------------------------------------------------------ void FmXUndoEnvironment::Inserted(FmFormObj* pObj) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXUndoEnvironment::Inserted" ); @@ -326,7 +357,7 @@ void FmXUndoEnvironment::Inserted(FmFormObj* pObj) Reference< XIndexContainer > xNewParent; Reference< XForm > xForm; sal_Int32 nPos = -1; - if ( searchElement( xForms, xObjectParent ) ) + if ( lcl_searchElement( xForms, xObjectParent ) ) { // the form which was the parent of the object when it was removed is still // part of the form component hierachy of the current page diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx index fff345413296..b4e4b46561e0 100644 --- a/svx/source/form/fmview.cxx +++ b/svx/source/form/fmview.cxx @@ -626,7 +626,7 @@ void FmFormView::createControlLabelPair( OutputDevice* _pOutDev, sal_Int32 _nXOf ); } // ----------------------------------------------------------------------------- -Reference< XFormController > FmFormView::GetFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const +Reference< runtime::XFormController > FmFormView::GetFormController( const Reference< XForm >& _rxForm, const OutputDevice& _rDevice ) const { return pImpl->getFormController( _rxForm, _rDevice ); } diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx index 0e7592d4b3a0..2206d8b59928 100644 --- a/svx/source/form/fmvwimp.cxx +++ b/svx/source/form/fmvwimp.cxx @@ -31,7 +31,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "fmctrler.hxx" #include "fmdocumentclassification.hxx" #include "fmobj.hxx" #include "fmpgeimp.hxx" @@ -84,68 +83,88 @@ #include <com/sun/star/sdbcx/XTablesSupplier.hpp> #include <com/sun/star/sdbc/XPreparedStatement.hpp> #include <com/sun/star/sdb/XQueriesSupplier.hpp> +#include <com/sun/star/container/XContainer.hpp> /** === end UNO includes === **/ #include <comphelper/enumhelper.hxx> #include <comphelper/extract.hxx> +#include <comphelper/namedvaluecollection.hxx> #include <comphelper/numbers.hxx> #include <comphelper/property.hxx> +#include <cppuhelper/exc_hlp.hxx> #include <unotools/moduleoptions.hxx> #include <tools/diagnose_ex.h> #include <vcl/msgbox.hxx> #include <vcl/stdtext.hxx> +#include <vos/mutex.hxx> #include <rtl/logfile.hxx> #include <algorithm> -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::form; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::script; -using namespace ::com::sun::star::style; -using namespace ::com::sun::star::task; -using namespace ::com::sun::star::ui::dialogs; using namespace ::comphelper; -using namespace ::svxform; using namespace ::svx; -using com::sun::star::style::VerticalAlignment_MIDDLE; -using ::com::sun::star::form::binding::XValueBinding; -using ::com::sun::star::form::binding::XBindableValue; - -namespace svxform -{ - //======================================================================== - class OAutoDispose - { - protected: - Reference< XComponent > m_xComp; - - public: - OAutoDispose( const Reference< XInterface > _rxObject ); - ~OAutoDispose(); - }; +using namespace ::svxform; - //------------------------------------------------------------------------ - OAutoDispose::OAutoDispose( const Reference< XInterface > _rxObject ) - :m_xComp(_rxObject, UNO_QUERY) - { - } - - //------------------------------------------------------------------------ - OAutoDispose::~OAutoDispose() - { - if (m_xComp.is()) - m_xComp->dispose(); - } -} + using namespace ::com::sun::star; + /** === begin UNO using === **/ + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Type; + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::style::VerticalAlignment_MIDDLE; + using ::com::sun::star::form::FormButtonType_SUBMIT; + using ::com::sun::star::form::binding::XValueBinding; + using ::com::sun::star::form::binding::XBindableValue; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::container::XIndexAccess; + using ::com::sun::star::form::XForm; + using ::com::sun::star::form::runtime::XFormController; + using ::com::sun::star::script::XEventAttacherManager; + using ::com::sun::star::awt::XTabControllerModel; + using ::com::sun::star::container::XChild; + using ::com::sun::star::container::XEnumeration; + using ::com::sun::star::task::XInteractionHandler; + using ::com::sun::star::lang::XInitialization; + using ::com::sun::star::awt::XTabController; + using ::com::sun::star::lang::XUnoTunnel; + using ::com::sun::star::awt::XControlContainer; + using ::com::sun::star::awt::XControl; + using ::com::sun::star::form::XFormComponent; + using ::com::sun::star::form::XForm; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::lang::WrappedTargetException; + using ::com::sun::star::container::XContainer; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::beans::NamedValue; + using ::com::sun::star::sdb::SQLErrorEvent; + using ::com::sun::star::sdbc::XRowSet; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::container::XElementAccess; + using ::com::sun::star::awt::XWindow; + using ::com::sun::star::awt::FocusEvent; + using ::com::sun::star::ui::dialogs::XExecutableDialog; + using ::com::sun::star::sdbc::XDataSource; + using ::com::sun::star::container::XIndexContainer; + using ::com::sun::star::sdbc::XConnection; + using ::com::sun::star::container::XNameAccess; + using ::com::sun::star::sdb::SQLContext; + using ::com::sun::star::sdbc::SQLWarning; + using ::com::sun::star::sdbc::SQLException; + using ::com::sun::star::util::XNumberFormatsSupplier; + using ::com::sun::star::util::XNumberFormats; + using ::com::sun::star::beans::XPropertySetInfo; + /** === end UNO using === **/ + namespace FormComponentType = ::com::sun::star::form::FormComponentType; + namespace CommandType = ::com::sun::star::sdb::CommandType; + namespace DataType = ::com::sun::star::sdbc::DataType; //------------------------------------------------------------------------------ class FmXFormView::ObjectRemoveListener : public SfxListener @@ -181,7 +200,7 @@ FmXPageViewWinRec::FmXPageViewWinRec( const ::comphelper::ComponentContext& _rCo { Reference< XForm > xForm( xForms->getByIndex(i), UNO_QUERY ); if ( xForm.is() ) - setController( xForm ); + setController( xForm, NULL ); } } catch( const Exception& ) @@ -207,7 +226,7 @@ void FmXPageViewWinRec::dispose() { try { - Reference< XFormController > xController( *i, UNO_SET_THROW ); + Reference< XFormController > xController( *i, UNO_QUERY_THROW ); // detaching the events Reference< XChild > xControllerModel( xController->getModel(), UNO_QUERY ); @@ -276,6 +295,21 @@ Any SAL_CALL FmXPageViewWinRec::getByIndex(sal_Int32 nIndex) throw( IndexOutOfBo } //------------------------------------------------------------------------ +void SAL_CALL FmXPageViewWinRec::makeVisible( const Reference< XControl >& _Control ) throw (RuntimeException) +{ + ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); + + Reference< XWindow > xWindow( _Control, UNO_QUERY ); + if ( xWindow.is() && m_pViewImpl->getView() && m_pWindow ) + { + awt::Rectangle aRect = xWindow->getPosSize(); + ::Rectangle aNewRect( aRect.X, aRect.Y, aRect.X + aRect.Width, aRect.Y + aRect.Height ); + aNewRect = m_pWindow->PixelToLogic( aNewRect ); + m_pViewImpl->getView()->MakeVisible( aNewRect, *m_pWindow ); + } +} + +//------------------------------------------------------------------------ Reference< XFormController > getControllerSearchChilds( const Reference< XIndexAccess > & xIndex, const Reference< XTabControllerModel > & xModel) { if (xIndex.is() && xIndex->getCount()) @@ -319,9 +353,8 @@ Reference< XFormController > FmXPageViewWinRec::getController( const Reference< } //------------------------------------------------------------------------ -void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FmXFormController* _pParent ) +void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, const Reference< XFormController >& _rxParentController ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXPageViewWinRec::setController" ); DBG_ASSERT( xForm.is(), "FmXPageViewWinRec::setController: there should be a form!" ); Reference< XIndexAccess > xFormCps(xForm, UNO_QUERY); if (!xFormCps.is()) @@ -330,58 +363,52 @@ void FmXPageViewWinRec::setController(const Reference< XForm > & xForm, FmXForm Reference< XTabControllerModel > xTabOrder(xForm, UNO_QUERY); // create a form controller - FmXFormController* pController = new FmXFormController( m_aContext.getLegacyServiceFactory(), m_pViewImpl->getView(), m_pWindow ); - Reference< XFormController > xController( pController ); + Reference< XFormController > xController( m_aContext.createComponent( FM_FORM_CONTROLLER ), UNO_QUERY ); + if ( !xController.is() ) + { + ShowServiceNotAvailableError( m_pWindow, FM_FORM_CONTROLLER, sal_True ); + return; + } Reference< XInteractionHandler > xHandler; - if ( _pParent ) - xHandler = _pParent->getInteractionHandler(); + if ( _rxParentController.is() ) + xHandler = _rxParentController->getInteractionHandler(); else { // TODO: should we create a default handler? Not really necessary, since the // FormController itself has a default fallback } if ( xHandler.is() ) - { - Reference< XInitialization > xInitController( xController, UNO_QUERY ); - DBG_ASSERT( xInitController.is(), "FmXPageViewWinRec::setController: can't initialize the controller!" ); - if ( xInitController.is() ) - { - Sequence< Any > aInitArgs( 1 ); - aInitArgs[ 0 ] <<= NamedValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "InteractionHandler" ) ), makeAny( xHandler ) ); - xInitController->initialize( aInitArgs ); - } - } + xController->setInteractionHandler( xHandler ); - pController->setModel(xTabOrder); - pController->setContainer( m_xControlContainer ); - pController->activateTabOrder(); - pController->addActivateListener(m_pViewImpl); + xController->setContext( this ); - if ( _pParent ) - _pParent->addChild(pController); + xController->setModel( xTabOrder ); + xController->setContainer( m_xControlContainer ); + xController->activateTabOrder(); + xController->addActivateListener( m_pViewImpl ); + + if ( _rxParentController.is() ) + _rxParentController->addChildController( xController ); else { - // Reference< XFormController > xController(pController); m_aControllerList.push_back(xController); - pController->setParent(*this); + xController->setParent( *this ); // attaching the events - Reference< XEventAttacherManager > xEventManager(xForm->getParent(), UNO_QUERY); + Reference< XEventAttacherManager > xEventManager( xForm->getParent(), UNO_QUERY ); Reference< XInterface > xIfc(xController, UNO_QUERY); xEventManager->attach(m_aControllerList.size() - 1, xIfc, makeAny(xController) ); } - - // jetzt die Subforms durchgehen sal_uInt32 nLength = xFormCps->getCount(); Reference< XForm > xSubForm; for (sal_uInt32 i = 0; i < nLength; i++) { if ( xFormCps->getByIndex(i) >>= xSubForm ) - setController(xSubForm, pController); + setController( xSubForm, xController ); } } @@ -406,18 +433,12 @@ void FmXPageViewWinRec::updateTabOrder( const Reference< XForm >& _rxForm ) // if it's a sub form, then we must ensure there exist TabControllers // for all its ancestors, too Reference< XForm > xParentForm( _rxForm->getParent(), UNO_QUERY ); - FmXFormController* pFormController = NULL; // there is a parent form -> look for the respective controller + Reference< XFormController > xParentController; if ( xParentForm.is() ) - xTabCtrl = Reference< XTabController >( getController( xParentForm ), UNO_QUERY ); + xParentController.set( getController( xParentForm ), UNO_QUERY ); - if ( xTabCtrl.is() ) - { - Reference< XUnoTunnel > xTunnel( xTabCtrl, UNO_QUERY_THROW ); - pFormController = reinterpret_cast< FmXFormController* >( xTunnel->getSomething( FmXFormController::getUnoTunnelImplementationId() ) ); - } - - setController( _rxForm, pFormController ); + setController( _rxForm, xParentController ); } } catch( const Exception& ) @@ -1068,20 +1089,14 @@ IMPL_LINK( FmXFormView, OnStartControlWizard, void*, /**/ ) if ( pWizardAsciiName ) { // build the argument list - Sequence< Any > aWizardArgs(1); - // the object affected - aWizardArgs[0] = makeAny( PropertyValue( - ::rtl::OUString::createFromAscii("ObjectModel"), - 0, - makeAny( m_xLastCreatedControlModel ), - PropertyState_DIRECT_VALUE - ) ); + ::comphelper::NamedValueCollection aWizardArgs; + aWizardArgs.put( "ObjectModel", m_xLastCreatedControlModel ); // create the wizard object Reference< XExecutableDialog > xWizard; try { - m_aContext.createComponentWithArguments( pWizardAsciiName, aWizardArgs, xWizard ); + m_aContext.createComponentWithArguments( pWizardAsciiName, aWizardArgs.getWrappedPropertyValues(), xWizard ); } catch( const Exception& ) { @@ -1187,9 +1202,10 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript m_aContext.getLegacyServiceFactory() ) ); } - catch(const SQLContext& e) { aError.Reason <<= e; } - catch(const SQLWarning& e) { aError.Reason <<= e; } - catch(const SQLException& e) { aError.Reason <<= e; } + catch ( const SQLException& ) + { + aError.Reason = ::cppu::getCaughtException(); + } catch( const Exception& ) { /* will be asserted below */ } if (aError.Reason.hasValue()) { @@ -1217,14 +1233,11 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript if (xFields.is() && xFields->hasByName(sFieldName)) xFields->getByName(sFieldName) >>= xField; - - Reference< XNumberFormatsSupplier > xSupplier = aDBATools.getNumberFormats(xConnection, sal_False); - if (!xSupplier.is() || !xField.is()) + if ( !xField.is() ) return NULL; - Reference< XNumberFormats > xNumberFormats(xSupplier->getNumberFormats()); - if (!xNumberFormats.is()) - return NULL; + Reference< XNumberFormatsSupplier > xSupplier( aDBATools.getNumberFormats( xConnection, sal_False ), UNO_SET_THROW ); + Reference< XNumberFormats > xNumberFormats( xSupplier->getNumberFormats(), UNO_SET_THROW ); ::rtl::OUString sLabelPostfix; @@ -1275,10 +1288,12 @@ SdrObject* FmXFormView::implCreateFieldControl( const ::svx::ODataAccessDescript else switch (nDataType) { + case DataType::BLOB: case DataType::LONGVARBINARY: nOBJID = OBJ_FM_IMAGECONTROL; break; case DataType::LONGVARCHAR: + case DataType::CLOB: nOBJID = OBJ_FM_EDIT; break; case DataType::BINARY: @@ -1610,7 +1625,9 @@ bool FmXFormView::createControlLabelPair( const ::comphelper::ComponentContext& aControlSize = aDefSize; break; case DataType::LONGVARCHAR: + case DataType::CLOB: case DataType::LONGVARBINARY: + case DataType::BLOB: aControlSize = aDefImageSize; break; } @@ -1643,7 +1660,7 @@ bool FmXFormView::createControlLabelPair( const ::comphelper::ComponentContext& } } - if ( nDataType == DataType::LONGVARCHAR && xControlPropInfo->hasPropertyByName( FM_PROP_MULTILINE ) ) + if ( (nDataType == DataType::LONGVARCHAR || nDataType == DataType::CLOB) && xControlPropInfo->hasPropertyByName( FM_PROP_MULTILINE ) ) { xControlSet->setPropertyValue( FM_PROP_MULTILINE, makeAny( sal_Bool( sal_True ) ) ); } diff --git a/svx/source/form/formcontrolfactory.cxx b/svx/source/form/formcontrolfactory.cxx index afc7e8ace77f..0a0f17f8d1c6 100644 --- a/svx/source/form/formcontrolfactory.cxx +++ b/svx/source/form/formcontrolfactory.cxx @@ -432,7 +432,8 @@ namespace svxform case FormComponentType::COMBOBOX: { sal_Bool bDropDown = !_rControlBoundRect.IsEmpty() && ( _rControlBoundRect.GetWidth() >= 3 * _rControlBoundRect.GetHeight() ); - _rxControlModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) ); + if ( xPSI->hasPropertyByName( FM_PROP_DROPDOWN ) ) + _rxControlModel->setPropertyValue( FM_PROP_DROPDOWN, makeAny( (sal_Bool)bDropDown ) ); _rxControlModel->setPropertyValue( FM_PROP_LINECOUNT, makeAny( sal_Int16( 20 ) ) ); } break; diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/formcontroller.cxx index af2a103c5d03..d77422dccd9a 100644 --- a/svx/source/form/fmctrler.cxx +++ b/svx/source/form/formcontroller.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmctrler.cxx,v $ - * $Revision: 1.71 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -31,24 +28,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "confirmdelete.hxx" #include "fmcontrolbordermanager.hxx" #include "fmcontrollayout.hxx" -#include "fmctrler.hxx" -#include "fmdispatch.hxx" +#include "formcontroller.hxx" +#include "formfeaturedispatcher.hxx" #include "fmdocumentclassification.hxx" +#include "formcontrolling.hxx" #include "fmprop.hrc" +#include "svx/dialmgr.hxx" #include "fmresids.hrc" #include "fmservs.hxx" -#include "fmshimp.hxx" #include "svx/fmtools.hxx" #include "fmurl.hxx" -#include "svx/dialmgr.hxx" -#include "svx/fmshell.hxx" -#include "svx/fmview.hxx" -#include "svx/sdrpagewindow.hxx" -#include "svx/svdpagv.hxx" -#include "trace.hxx" /** === begin UNO includes === **/ #include <com/sun/star/awt/FocusChangeReason.hpp> @@ -72,6 +63,13 @@ #include <com/sun/star/sdb/XInteractionSupplyParameters.hpp> #include <com/sun/star/sdbc/ColumnValue.hpp> #include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/form/runtime/FormOperations.hpp> +#include <com/sun/star/form/runtime/FormFeature.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/util/XNumberFormatter.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/sdb/XColumn.hpp> /** === end UNO includes === **/ #include <comphelper/enumhelper.hxx> @@ -84,9 +82,6 @@ #include <comphelper/uno3.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> -#include <sfx2/bindings.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/viewsh.hxx> #include <toolkit/controls/unocontrol.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <tools/debug.hxx> @@ -94,32 +89,126 @@ #include <tools/shl.hxx> #include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> +#include <vos/mutex.hxx> #include <rtl/logfile.hxx> #include <algorithm> #include <functional> using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::sdb; -using namespace ::com::sun::star::sdbc; -using namespace ::com::sun::star::sdbcx; -using namespace ::com::sun::star::task; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::util; -using namespace ::com::sun::star::form; -using namespace ::com::sun::star::form::validation; -using namespace ::com::sun::star::form::runtime; -using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::script; -using namespace ::com::sun::star::container; using namespace ::comphelper; using namespace ::connectivity; -using namespace ::svxform; using namespace ::connectivity::simple; +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + FormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ) +{ + return *( new ::svxform::FormController( _rxORB ) ); +} + +namespace svxform +{ + + /** === begin UNO using === **/ + using ::com::sun::star::sdb::XColumn; + using ::com::sun::star::awt::XControl; + using ::com::sun::star::awt::XTabController; + using ::com::sun::star::awt::XToolkit; + using ::com::sun::star::awt::XWindowPeer; + using ::com::sun::star::form::XGrid; + using ::com::sun::star::beans::XPropertySet; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::container::XIndexAccess; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Reference; + using ::com::sun::star::beans::XPropertySetInfo; + using ::com::sun::star::beans::PropertyValue; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::lang::IndexOutOfBoundsException; + using ::com::sun::star::sdb::XInteractionSupplyParameters; + using ::com::sun::star::awt::XTextComponent; + using ::com::sun::star::awt::XTextListener; + using ::com::sun::star::uno::Any; + using ::com::sun::star::frame::XDispatch; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::uno::XAggregation; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::IllegalArgumentException; + using ::com::sun::star::sdbc::XConnection; + using ::com::sun::star::sdbc::XRowSet; + using ::com::sun::star::sdbc::XDatabaseMetaData; + using ::com::sun::star::util::XNumberFormatsSupplier; + using ::com::sun::star::util::XNumberFormatter; + using ::com::sun::star::sdbcx::XColumnsSupplier; + using ::com::sun::star::container::XNameAccess; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::beans::Property; + using ::com::sun::star::container::XEnumeration; + using ::com::sun::star::form::XFormComponent; + using ::com::sun::star::form::runtime::XFormOperations; + using ::com::sun::star::form::runtime::FilterEvent; + using ::com::sun::star::form::runtime::XFilterControllerListener; + using ::com::sun::star::awt::XControlContainer; + using ::com::sun::star::container::XIdentifierReplace; + using ::com::sun::star::lang::WrappedTargetException; + using ::com::sun::star::form::XFormControllerListener; + using ::com::sun::star::awt::XWindow; + using ::com::sun::star::sdbc::XResultSet; + using ::com::sun::star::awt::XControlModel; + using ::com::sun::star::awt::XTabControllerModel; + using ::com::sun::star::beans::PropertyChangeEvent; + using ::com::sun::star::form::validation::XValidatableFormComponent; + using ::com::sun::star::form::XLoadable; + using ::com::sun::star::script::XEventAttacherManager; + using ::com::sun::star::form::XBoundControl; + using ::com::sun::star::beans::XPropertyChangeListener; + using ::com::sun::star::awt::TextEvent; + using ::com::sun::star::form::XBoundComponent; + using ::com::sun::star::awt::XCheckBox; + using ::com::sun::star::awt::XComboBox; + using ::com::sun::star::awt::XListBox; + using ::com::sun::star::awt::ItemEvent; + using ::com::sun::star::util::XModifyListener; + using ::com::sun::star::form::XReset; + using ::com::sun::star::frame::XDispatchProviderInterception; + using ::com::sun::star::form::XGridControl; + using ::com::sun::star::awt::XVclWindowPeer; + using ::com::sun::star::form::validation::XValidator; + using ::com::sun::star::awt::FocusEvent; + using ::com::sun::star::sdb::SQLContext; + using ::com::sun::star::container::XChild; + using ::com::sun::star::form::TabulatorCycle_RECORDS; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::lang::DisposedException; + using ::com::sun::star::lang::Locale; + using ::com::sun::star::beans::NamedValue; + using ::com::sun::star::lang::NoSupportException; + using ::com::sun::star::sdb::RowChangeEvent; + using ::com::sun::star::frame::XStatusListener; + using ::com::sun::star::frame::XDispatchProviderInterceptor; + using ::com::sun::star::sdb::SQLErrorEvent; + using ::com::sun::star::form::DatabaseParameterEvent; + using ::com::sun::star::sdb::ParametersRequest; + using ::com::sun::star::task::XInteractionRequest; + using ::com::sun::star::util::URL; + using ::com::sun::star::frame::FeatureStateEvent; + using ::com::sun::star::form::runtime::XFormControllerContext; + using ::com::sun::star::task::XInteractionHandler; + using ::com::sun::star::form::runtime::FormOperations; + using ::com::sun::star::container::XContainer; + using ::com::sun::star::sdbc::SQLWarning; + /** === end UNO using === **/ + namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue; + namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; + namespace FocusChangeReason = ::com::sun::star::awt::FocusChangeReason; + namespace RowChangeAction = ::com::sun::star::sdb::RowChangeAction; + namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; + //============================================================================== // ColumnInfo //============================================================================== @@ -184,7 +273,6 @@ ColumnInfoCache::ColumnInfoCache( const Reference< XColumnsSupplier >& _rxColSup :m_aColumns() ,m_bControlsInitialized( false ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "ColumnInfoCache::ColumnInfoCache" ); try { m_aColumns.clear(); @@ -242,7 +330,6 @@ namespace //------------------------------------------------------------------------------ void ColumnInfoCache::deinitializeControls() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "ColumnInfoCache::deinitializeControls" ); for ( ColumnInfos::iterator col = m_aColumns.begin(); col != m_aColumns.end(); ++col @@ -255,7 +342,6 @@ void ColumnInfoCache::deinitializeControls() //------------------------------------------------------------------------------ void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > >& _rControls ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "ColumnInfoCache::initializeControls" ); try { // for every of our known columns, find the controls which are bound to this column @@ -338,7 +424,6 @@ void ColumnInfoCache::initializeControls( const Sequence< Reference< XControl > //------------------------------------------------------------------------------ const ColumnInfo& ColumnInfoCache::getColumnInfo( size_t _pos ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "ColumnInfoCache::getColumnInfo" ); if ( _pos >= m_aColumns.size() ) throw IndexOutOfBoundsException(); @@ -424,7 +509,7 @@ void FmXAutoControl::ImplSetPeerProperty( const ::rtl::OUString& rPropName, cons } //------------------------------------------------------------------------------ -IMPL_LINK( FmXFormController, OnActivateTabOrder, void*, /*EMPTYTAG*/ ) +IMPL_LINK( FormController, OnActivateTabOrder, void*, /*EMPTYTAG*/ ) { activateTabOrder(); return 1; @@ -441,10 +526,10 @@ struct UpdateAllListeners : public ::std::unary_function< Reference< XDispatch > } }; //.............................................................................. -IMPL_LINK( FmXFormController, OnInvalidateFeatures, void*, /*_pNotInterestedInThisParam*/ ) +IMPL_LINK( FormController, OnInvalidateFeatures, void*, /*_pNotInterestedInThisParam*/ ) { ::osl::MutexGuard aGuard( m_aMutex ); - for ( ::std::set< sal_Int32 >::const_iterator aLoop = m_aInvalidFeatures.begin(); + for ( ::std::set< sal_Int16 >::const_iterator aLoop = m_aInvalidFeatures.begin(); aLoop != m_aInvalidFeatures.end(); ++aLoop ) @@ -462,48 +547,28 @@ IMPL_LINK( FmXFormController, OnInvalidateFeatures, void*, /*_pNotInterestedInTh /*************************************************************************/ +DBG_NAME( FormController ) //------------------------------------------------------------------ -Reference< XInterface > SAL_CALL - FmXFormController_NewInstance_Impl(const Reference< XMultiServiceFactory > & _rxORB) -{ - return *(new FmXFormController(_rxORB)); -} - -//------------------------------------------------------------------ -namespace fmctrlr -{ - const ::rtl::OUString& getDataModeIdentifier() - { - static ::rtl::OUString s_sDataModeIdentifier = DATA_MODE; - return s_sDataModeIdentifier; - } -} -using namespace fmctrlr; - -DBG_NAME( FmXFormController ) -//------------------------------------------------------------------ -FmXFormController::FmXFormController(const Reference< XMultiServiceFactory > & _rxORB, - FmFormView* _pView, Window* _pWindow ) - :FmXFormController_BASE( m_aMutex ) - ,OPropertySetHelper( FmXFormController_BASE::rBHelper ) - ,OSQLParserClient(_rxORB) - ,m_xORB(_rxORB) +FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB ) + :FormController_BASE( m_aMutex ) + ,OPropertySetHelper( FormController_BASE::rBHelper ) + ,OSQLParserClient( _rxORB ) + ,m_aContext( _rxORB ) ,m_aActivateListeners(m_aMutex) ,m_aModifyListeners(m_aMutex) ,m_aErrorListeners(m_aMutex) ,m_aDeleteListeners(m_aMutex) ,m_aRowSetApproveListeners(m_aMutex) ,m_aParameterListeners(m_aMutex) - ,m_pView(_pView) - ,m_pWindow(_pWindow) + ,m_aFilterListeners(m_aMutex) ,m_pControlBorderManager( new ::svxform::ControlBorderManager ) - ,m_aControllerFeatures( _rxORB, this ) - ,m_aMode(getDataModeIdentifier()) - ,m_aLoadEvent( LINK( this, FmXFormController, OnLoad ) ) - ,m_aToggleEvent( LINK( this, FmXFormController, OnToggleAutoFields ) ) - ,m_aActivationEvent( LINK( this, FmXFormController, OnActivated ) ) - ,m_aDeactivationEvent( LINK( this, FmXFormController, OnDeactivated ) ) - ,m_nCurrentFilterPosition(0) + ,m_xFormOperations() + ,m_aMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) ) + ,m_aLoadEvent( LINK( this, FormController, OnLoad ) ) + ,m_aToggleEvent( LINK( this, FormController, OnToggleAutoFields ) ) + ,m_aActivationEvent( LINK( this, FormController, OnActivated ) ) + ,m_aDeactivationEvent( LINK( this, FormController, OnDeactivated ) ) + ,m_nCurrentFilterPosition(-1) ,m_bCurrentRecordModified(sal_False) ,m_bCurrentRecordNew(sal_False) ,m_bLocked(sal_False) @@ -519,17 +584,16 @@ FmXFormController::FmXFormController(const Reference< XMultiServiceFactory > & _ ,m_bDetachEvents(sal_True) ,m_bAttemptedHandlerCreation( false ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::FmXFormController" ); - DBG_CTOR( FmXFormController, NULL ); + DBG_CTOR( FormController, NULL ); ::comphelper::increment(m_refCount); { { m_xAggregate = Reference< XAggregation >( - m_xORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.awt.TabController" ) ), + m_aContext.createComponent( "com.sun.star.awt.TabController" ), UNO_QUERY ); - DBG_ASSERT( m_xAggregate.is(), "FmXFormController::FmXFormController : could not create my aggregate !" ); + DBG_ASSERT( m_xAggregate.is(), "FormController::FormController : could not create my aggregate !" ); m_xTabController = Reference< XTabController >( m_xAggregate, UNO_QUERY ); } @@ -539,14 +603,14 @@ FmXFormController::FmXFormController(const Reference< XMultiServiceFactory > & _ ::comphelper::decrement(m_refCount); m_aTabActivationTimer.SetTimeout( 500 ); - m_aTabActivationTimer.SetTimeoutHdl( LINK( this, FmXFormController, OnActivateTabOrder ) ); + m_aTabActivationTimer.SetTimeoutHdl( LINK( this, FormController, OnActivateTabOrder ) ); m_aFeatureInvalidationTimer.SetTimeout( 200 ); - m_aFeatureInvalidationTimer.SetTimeoutHdl( LINK( this, FmXFormController, OnInvalidateFeatures ) ); + m_aFeatureInvalidationTimer.SetTimeoutHdl( LINK( this, FormController, OnInvalidateFeatures ) ); } //------------------------------------------------------------------ -FmXFormController::~FmXFormController() +FormController::~FormController() { { ::osl::MutexGuard aGuard( m_aMutex ); @@ -565,6 +629,10 @@ FmXFormController::~FmXFormController() disposeAllFeaturesAndDispatchers(); + if ( m_xFormOperations.is() ) + m_xFormOperations->dispose(); + m_xFormOperations.clear(); + // Freigeben der Aggregation if ( m_xAggregate.is() ) { @@ -574,28 +642,25 @@ FmXFormController::~FmXFormController() DELETEZ( m_pControlBorderManager ); - DBG_DTOR( FmXFormController, NULL ); + DBG_DTOR( FormController, NULL ); } // ----------------------------------------------------------------------------- -void SAL_CALL FmXFormController::acquire() throw () +void SAL_CALL FormController::acquire() throw () { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::acquire" ); - FmXFormController_BASE::acquire(); + FormController_BASE::acquire(); } // ----------------------------------------------------------------------------- -void SAL_CALL FmXFormController::release() throw () +void SAL_CALL FormController::release() throw () { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::release" ); - FmXFormController_BASE::release(); + FormController_BASE::release(); } //------------------------------------------------------------------ -Any SAL_CALL FmXFormController::queryInterface( const Type& _rType ) throw(RuntimeException) +Any SAL_CALL FormController::queryInterface( const Type& _rType ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::queryInterface" ); - Any aRet = FmXFormController_BASE::queryInterface( _rType ); + Any aRet = FormController_BASE::queryInterface( _rType ); if ( !aRet.hasValue() ) aRet = OPropertySetHelper::queryInterface( _rType ); if ( !aRet.hasValue() ) @@ -604,9 +669,8 @@ Any SAL_CALL FmXFormController::queryInterface( const Type& _rType ) throw(Runti } //------------------------------------------------------------------------------ -Sequence< sal_Int8 > SAL_CALL FmXFormController::getImplementationId() throw( RuntimeException ) +Sequence< sal_Int8 > SAL_CALL FormController::getImplementationId() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getImplementationId" ); static ::cppu::OImplementationId* pId = NULL; if ( !pId ) { @@ -621,56 +685,18 @@ Sequence< sal_Int8 > SAL_CALL FmXFormController::getImplementationId() throw( Ru } //------------------------------------------------------------------------------ -Sequence< Type > SAL_CALL FmXFormController::getTypes( ) throw(RuntimeException) +Sequence< Type > SAL_CALL FormController::getTypes( ) throw(RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getTypes" ); return comphelper::concatSequences( - FmXFormController_BASE::getTypes(), + FormController_BASE::getTypes(), ::cppu::OPropertySetHelper::getTypes() ); } -// ----------------------------------------------------------------------------- -// XUnoTunnel -Sequence< sal_Int8 > FmXFormController::getUnoTunnelImplementationId() -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getUnoTunnelImplementationId" ); - static ::cppu::OImplementationId * pId = NULL; - if ( !pId ) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if ( !pId ) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} -//------------------------------------------------------------------------------ -FmXFormController* FmXFormController::getImplementation( const Reference< XInterface >& _rxComponent ) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getImplementation" ); - Reference< XUnoTunnel > xTunnel( _rxComponent, UNO_QUERY ); - if ( xTunnel.is() ) - return reinterpret_cast< FmXFormController* >( xTunnel->getSomething( getUnoTunnelImplementationId() ) ); - return NULL; -} -//------------------------------------------------------------------------------ -sal_Int64 SAL_CALL FmXFormController::getSomething(Sequence<sal_Int8> const& rId)throw( RuntimeException ) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getSomething" ); - if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - return reinterpret_cast< sal_Int64 >( this ); - - return sal_Int64(); -} - // XServiceInfo //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::supportsService(const ::rtl::OUString& ServiceName) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::supportsService" ); Sequence< ::rtl::OUString> aSNL(getSupportedServiceNames()); const ::rtl::OUString * pArray = aSNL.getConstArray(); for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) @@ -680,16 +706,14 @@ sal_Bool SAL_CALL FmXFormController::supportsService(const ::rtl::OUString& Serv } //------------------------------------------------------------------------------ -::rtl::OUString SAL_CALL FmXFormController::getImplementationName() throw( RuntimeException ) +::rtl::OUString SAL_CALL FormController::getImplementationName() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getImplementationName" ); - return ::rtl::OUString::createFromAscii("com.sun.star.form.FmXFormController"); + return ::rtl::OUString::createFromAscii( "org.openoffice.comp.svx.FormController" ); } //------------------------------------------------------------------------------ -Sequence< ::rtl::OUString> SAL_CALL FmXFormController::getSupportedServiceNames(void) throw( RuntimeException ) +Sequence< ::rtl::OUString> SAL_CALL FormController::getSupportedServiceNames(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getSupportedServiceNames" ); // service names which are supported only, but cannot be used to created an // instance at a service factory Sequence< ::rtl::OUString > aNonCreatableServiceNames( 1 ); @@ -701,94 +725,107 @@ Sequence< ::rtl::OUString> SAL_CALL FmXFormController::getSupportedServiceNames( } //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::approveReset(const EventObject& /*rEvent*/) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::approveReset(const EventObject& /*rEvent*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::approveReset" ); return sal_True; } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::resetted(const EventObject& rEvent) throw( RuntimeException ) +void SAL_CALL FormController::resetted(const EventObject& rEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::resetted" ); ::osl::MutexGuard aGuard(m_aMutex); if (getCurrentControl().is() && (getCurrentControl()->getModel() == rEvent.Source)) m_bModified = sal_False; } //------------------------------------------------------------------------------ -Sequence< ::rtl::OUString> FmXFormController::getSupportedServiceNames_Static(void) +Sequence< ::rtl::OUString> FormController::getSupportedServiceNames_Static(void) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getSupportedServiceNames_Static" ); static Sequence< ::rtl::OUString> aServices; if (!aServices.getLength()) { aServices.realloc(2); - aServices.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.FormController"); + aServices.getArray()[0] = FM_FORM_CONTROLLER; aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.control.TabController"); } return aServices; } -//------------------------------------------------------------------------------ -void FmXFormController::setCurrentFilterPosition( sal_Int32 nPos ) +// ----------------------------------------------------------------------------- +namespace { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setCurrentFilterPosition" ); - DBG_ASSERT(nPos < (sal_Int32)m_aFilters.size(), "Invalid Position"); - - if (nPos != m_nCurrentFilterPosition) + struct ResetComponentText : public ::std::unary_function< Reference< XTextComponent >, void > { - m_nCurrentFilterPosition = nPos; + void operator()( const Reference< XTextComponent >& _rxText ) + { + _rxText->setText( ::rtl::OUString() ); + } + }; - // reset the text for all controls - for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); iter++) - (*iter).first->setText(rtl::OUString()); + struct RemoveComponentTextListener : public ::std::unary_function< Reference< XTextComponent >, void > + { + RemoveComponentTextListener( const Reference< XTextListener >& _rxListener ) + :m_xListener( _rxListener ) + { + } - if ( nPos != -1 ) + void operator()( const Reference< XTextComponent >& _rxText ) { - impl_setTextOnAllFilter_throw(); + _rxText->removeTextListener( m_xListener ); } - } + + private: + Reference< XTextListener > m_xListener; + }; } + // ----------------------------------------------------------------------------- -void FmXFormController::impl_setTextOnAllFilter_throw() +void FormController::impl_setTextOnAllFilter_throw() { + // reset the text for all controls + ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), ResetComponentText() ); + + if ( m_aFilterRows.empty() ) + // nothing to do anymore + return; + + if ( m_nCurrentFilterPosition < 0 ) + return; + // set the text for all filters - OSL_ENSURE( ( m_aFilters.size() > (size_t)m_nCurrentFilterPosition ) && ( m_nCurrentFilterPosition >= 0 ), - "FmXFormController::setCurrentFilterPosition: m_nCurrentFilterPosition too big" ); + OSL_ENSURE( m_aFilterRows.size() > (size_t)m_nCurrentFilterPosition, + "FormController::impl_setTextOnAllFilter_throw: m_nCurrentFilterPosition too big" ); - if ( ( m_nCurrentFilterPosition >= 0 ) && ( (size_t)m_nCurrentFilterPosition < m_aFilters.size() ) ) + if ( (size_t)m_nCurrentFilterPosition < m_aFilterRows.size() ) { - FmFilterRow& rRow = m_aFilters[m_nCurrentFilterPosition]; - for (FmFilterRow::const_iterator iter2 = rRow.begin(); - iter2 != rRow.end(); iter2++) + FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ]; + for ( FmFilterRow::const_iterator iter2 = rRow.begin(); + iter2 != rRow.end(); + ++iter2 + ) { - (*iter2).first->setText((*iter2).second); + iter2->first->setText( iter2->second ); } - } // if ( ( m_nCurrentFilterPosition >= 0 ) && ( (size_t)m_nCurrentFilterPosition < m_aFilters.size() ) ) + } } // OPropertySetHelper //------------------------------------------------------------------------------ -sal_Bool FmXFormController::convertFastPropertyValue( Any & /*rConvertedValue*/, Any & /*rOldValue*/, +sal_Bool FormController::convertFastPropertyValue( Any & /*rConvertedValue*/, Any & /*rOldValue*/, sal_Int32 /*nHandle*/, const Any& /*rValue*/ ) throw( IllegalArgumentException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::convertFastPropertyValue" ); return sal_False; } //------------------------------------------------------------------------------ -void FmXFormController::setFastPropertyValue_NoBroadcast( sal_Int32 /*nHandle*/, const Any& /*rValue*/ ) +void FormController::setFastPropertyValue_NoBroadcast( sal_Int32 /*nHandle*/, const Any& /*rValue*/ ) throw( Exception ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setFastPropertyValue_NoBroadcast" ); } //------------------------------------------------------------------------------ -void FmXFormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const +void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getFastPropertyValue" ); switch (nHandle) { case FM_ATTR_FILTER: @@ -799,9 +836,8 @@ void FmXFormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) c if (xConnection.is()) { Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData()); - Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats(xConnection, sal_True)); - Reference< XNumberFormatter> xFormatter(m_xORB - ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); + Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats( xConnection, sal_True ) ); + Reference< XNumberFormatter> xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY_THROW ); xFormatter->attachNumberFormatsSupplier(xFormatSupplier); Reference< XColumnsSupplier> xSupplyCols(m_xModelAsIndex, UNO_QUERY); @@ -809,40 +845,48 @@ void FmXFormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) c ::rtl::OUString aQuote( xMetaData->getIdentifierQuoteString() ); - // now add the filter rows - for ( FmFilterRows::const_iterator row = m_aFilters.begin(); row != m_aFilters.end(); ++row ) + // now add the filter rows + try { - const FmFilterRow& rRow = *row; + for ( FmFilterRows::const_iterator row = m_aFilterRows.begin(); row != m_aFilterRows.end(); ++row ) + { + const FmFilterRow& rRow = *row; - if ( rRow.empty() ) - continue; + if ( rRow.empty() ) + continue; - if ( aFilter.getLength() ) - aFilter.appendAscii( " OR " ); + if ( aFilter.getLength() ) + aFilter.appendAscii( " OR " ); - aFilter.appendAscii( "( " ); - for ( FmFilterRow::const_iterator condition = rRow.begin(); condition != rRow.end(); ++condition ) - { - // get the field of the controls map - Reference< XTextComponent > xText = condition->first; - Reference< XPropertySet > xField = m_aFilterControls.find( xText )->second; - DBG_ASSERT( xField.is(), "FmXFormController::getFastPropertyValue: no field found!" ); - if ( condition != rRow.begin() ) - aFilter.appendAscii( " AND " ); - - ::rtl::OUString sFilterValue( condition->second ); - - ::rtl::OUString sErrorMsg, sCriteria; - ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( sErrorMsg, sFilterValue, xFormatter, xField ); - OSL_ENSURE( xParseNode.is(), "FmXFormController::getFastPropertyValue: could not parse the field value predicate!" ); - if ( xParseNode.is() ) + aFilter.appendAscii( "( " ); + for ( FmFilterRow::const_iterator condition = rRow.begin(); condition != rRow.end(); ++condition ) { - // don't use a parse context here, we need it unlocalized - xParseNode->parseNodeToStr( sCriteria, xConnection, NULL ); - aFilter.append( sCriteria ); + // get the field of the controls map + Reference< XControl > xControl( condition->first, UNO_QUERY_THROW ); + Reference< XPropertySet > xModelProps( xControl->getModel(), UNO_QUERY_THROW ); + Reference< XPropertySet > xField( xModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ), UNO_QUERY_THROW ); + if ( condition != rRow.begin() ) + aFilter.appendAscii( " AND " ); + + ::rtl::OUString sFilterValue( condition->second ); + + ::rtl::OUString sErrorMsg, sCriteria; + ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree( sErrorMsg, sFilterValue, xFormatter, xField ); + OSL_ENSURE( xParseNode.is(), "FormController::getFastPropertyValue: could not parse the field value predicate!" ); + if ( xParseNode.is() ) + { + // don't use a parse context here, we need it unlocalized + xParseNode->parseNodeToStr( sCriteria, xConnection, NULL ); + aFilter.append( sCriteria ); + } } + aFilter.appendAscii( " )" ); } - aFilter.appendAscii( " )" ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + aFilter.setLength(0); } } rValue <<= aFilter.makeStringAndClear(); @@ -850,15 +894,14 @@ void FmXFormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) c break; case FM_ATTR_FORM_OPERATIONS: - rValue <<= m_aControllerFeatures->getFormOperations(); + rValue <<= m_xFormOperations; break; } } //------------------------------------------------------------------------------ -Reference< XPropertySetInfo > FmXFormController::getPropertySetInfo() throw( RuntimeException ) +Reference< XPropertySetInfo > FormController::getPropertySetInfo() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getPropertySetInfo" ); static Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); return xInfo; } @@ -872,12 +915,11 @@ pDesc[nPos++] = Property(FM_PROP_##varname, FM_ATTR_##varname, ::getCppuType((co DECL_PROP_CORE(varname, type) PropertyAttribute::attrib1) //------------------------------------------------------------------------------ -void FmXFormController::fillProperties( +void FormController::fillProperties( Sequence< Property >& /* [out] */ _rProps, Sequence< Property >& /* [out] */ /*_rAggregateProps*/ ) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::fillProperties" ); _rProps.realloc(2); sal_Int32 nPos = 0; Property* pDesc = _rProps.getArray(); @@ -886,90 +928,229 @@ void FmXFormController::fillProperties( } //------------------------------------------------------------------------------ -::cppu::IPropertyArrayHelper& FmXFormController::getInfoHelper() +::cppu::IPropertyArrayHelper& FormController::getInfoHelper() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getInfoHelper" ); return *getArrayHelper(); } +// XFilterController +//------------------------------------------------------------------------------ +void SAL_CALL FormController::addFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException ) +{ + m_aFilterListeners.addInterface( _Listener ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeFilterControllerListener( const Reference< XFilterControllerListener >& _Listener ) throw( RuntimeException ) +{ + m_aFilterListeners.removeInterface( _Listener ); +} + +//------------------------------------------------------------------------------ +::sal_Int32 SAL_CALL FormController::getFilterComponents() throw( ::com::sun::star::uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_aFilterComponents.size(); +} + +//------------------------------------------------------------------------------ +::sal_Int32 SAL_CALL FormController::getDisjunctiveTerms() throw( ::com::sun::star::uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_aFilterRows.size(); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw( RuntimeException, IndexOutOfBoundsException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) || ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + Reference< XTextComponent > xText( m_aFilterComponents[ _Component ] ); + xText->setText( _PredicateExpression ); + + FmFilterRow& rFilterRow = m_aFilterRows[ _Term ]; + if ( _PredicateExpression.getLength() ) + rFilterRow[ xText ] = _PredicateExpression; + else + rFilterRow.erase( xText ); +} + +//------------------------------------------------------------------------------ +Reference< XControl > FormController::getFilterComponent( ::sal_Int32 _Component ) throw( RuntimeException, IndexOutOfBoundsException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _Component < 0 ) || ( _Component >= getFilterComponents() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + return Reference< XControl >( m_aFilterComponents[ _Component ], UNO_QUERY ); +} + +//------------------------------------------------------------------------------ +Sequence< Sequence< ::rtl::OUString > > FormController::getPredicateExpressions() throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + Sequence< Sequence< ::rtl::OUString > > aExpressions( m_aFilterRows.size() ); + sal_Int32 termIndex = 0; + for ( FmFilterRows::const_iterator row = m_aFilterRows.begin(); + row != m_aFilterRows.end(); + ++row, ++termIndex + ) + { + const FmFilterRow& rRow( *row ); + + Sequence< ::rtl::OUString > aConjunction( m_aFilterComponents.size() ); + sal_Int32 componentIndex = 0; + for ( FilterComponents::const_iterator comp = m_aFilterComponents.begin(); + comp != m_aFilterComponents.end(); + ++comp, ++componentIndex + ) + { + FmFilterRow::const_iterator predicate = rRow.find( *comp ); + if ( predicate != rRow.end() ) + aConjunction[ componentIndex ] = predicate->second; + } + + aExpressions[ termIndex ] = aConjunction; + } + + return aExpressions; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (IndexOutOfBoundsException, RuntimeException) +{ + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _Term < 0 ) || ( _Term >= getDisjunctiveTerms() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + // if the to-be-deleted row is our current row, we need to shift + if ( _Term == m_nCurrentFilterPosition ) + { + if ( m_nCurrentFilterPosition < sal_Int32( m_aFilterRows.size() - 1 ) ) + ++m_nCurrentFilterPosition; + else + --m_nCurrentFilterPosition; + } + + FmFilterRows::iterator pos = m_aFilterRows.begin() + _Term; + m_aFilterRows.erase( pos ); + + // adjust m_nCurrentFilterPosition if the removed row preceeded it + if ( _Term < m_nCurrentFilterPosition ) + --m_nCurrentFilterPosition; + + OSL_POSTCOND( ( m_nCurrentFilterPosition < 0 ) == ( m_aFilterRows.empty() ), + "FormController::removeDisjunctiveTerm: inconsistency!" ); + + // update the texts in the filter controls + impl_setTextOnAllFilter_throw(); + + FilterEvent aEvent; + aEvent.Source = *this; + aEvent.DisjunctiveTerm = _Term; + aGuard.clear(); + // <-- SYNCHRONIZED + + m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermRemoved, aEvent ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::appendEmptyDisjunctiveTerm() throw (RuntimeException) +{ + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + impl_appendEmptyFilterRow( aGuard ); + // <-- SYNCHRONIZED +} + +//------------------------------------------------------------------------------ +::sal_Int32 SAL_CALL FormController::getActiveTerm() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_nCurrentFilterPosition; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (IndexOutOfBoundsException, RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( ( _ActiveTerm < 0 ) || ( _ActiveTerm >= getDisjunctiveTerms() ) ) + throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); + + if ( _ActiveTerm == getActiveTerm() ) + return; + + m_nCurrentFilterPosition = _ActiveTerm; + impl_setTextOnAllFilter_throw(); +} + // XElementAccess //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::hasElements(void) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::hasElements(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::hasElements" ); -::osl::MutexGuard aGuard( m_aMutex ); + ::osl::MutexGuard aGuard( m_aMutex ); return !m_aChilds.empty(); } //------------------------------------------------------------------------------ -Type SAL_CALL FmXFormController::getElementType(void) throw( RuntimeException ) +Type SAL_CALL FormController::getElementType(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getElementType" ); return ::getCppuType((const Reference< XFormController>*)0); } // XEnumerationAccess //------------------------------------------------------------------------------ -Reference< XEnumeration > SAL_CALL FmXFormController::createEnumeration(void) throw( RuntimeException ) +Reference< XEnumeration > SAL_CALL FormController::createEnumeration(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::createEnumeration" ); ::osl::MutexGuard aGuard( m_aMutex ); return new ::comphelper::OEnumerationByIndex(this); } // XIndexAccess //------------------------------------------------------------------------------ -sal_Int32 SAL_CALL FmXFormController::getCount(void) throw( RuntimeException ) +sal_Int32 SAL_CALL FormController::getCount(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getCount" ); ::osl::MutexGuard aGuard( m_aMutex ); return m_aChilds.size(); } //------------------------------------------------------------------------------ -Any SAL_CALL FmXFormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) +Any SAL_CALL FormController::getByIndex(sal_Int32 Index) throw( IndexOutOfBoundsException, WrappedTargetException, RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getByIndex" ); ::osl::MutexGuard aGuard( m_aMutex ); if (Index < 0 || Index >= (sal_Int32)m_aChilds.size()) throw IndexOutOfBoundsException(); - return makeAny(m_aChilds[Index]); - // , ::getCppuType((const XFormController*)0)); -} - -//----------------------------------------------------------------------------- -void FmXFormController::addChild(FmXFormController* pChild) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addChild" ); - Reference< XFormController > xController(pChild); - m_aChilds.push_back(xController); - pChild->setParent(static_cast< XFormController* >(this)); - - Reference< XFormComponent > xForm(pChild->getModel(), UNO_QUERY); - - // search the position of the model within the form - sal_uInt32 nPos = m_xModelAsIndex->getCount(); - Reference< XFormComponent > xTemp; - for( ; nPos; ) - { - m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; - if ((XFormComponent*)xForm.get() == (XFormComponent*)xTemp.get()) - { - Reference< XInterface > xIfc(xController, UNO_QUERY); - m_xModelAsManager->attach( nPos, xIfc, makeAny( xController) ); - break; - } - } + return makeAny( m_aChilds[ Index ] ); } // EventListener //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::disposing(const EventObject& e) throw( RuntimeException ) +void SAL_CALL FormController::disposing(const EventObject& e) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::disposing" ); // Ist der Container disposed worden ::osl::MutexGuard aGuard( m_aMutex ); Reference< XControlContainer > xContainer(e.Source, UNO_QUERY); @@ -991,9 +1172,8 @@ void SAL_CALL FmXFormController::disposing(const EventObject& e) throw( RuntimeE // OComponentHelper //----------------------------------------------------------------------------- -void FmXFormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) +void FormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::disposeAllFeaturesAndDispatchers" ); for ( DispatcherContainer::iterator aDispatcher = m_aFeatureDispatchers.begin(); aDispatcher != m_aFeatureDispatchers.end(); ++aDispatcher @@ -1005,18 +1185,16 @@ void FmXFormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::disposeAllFeaturesAndDispatchers: caught an exception while disposing a dispatcher!" ); + DBG_UNHANDLED_EXCEPTION(); } } m_aFeatureDispatchers.clear(); - m_aControllerFeatures.dispose(); } //----------------------------------------------------------------------------- -void FmXFormController::disposing(void) +void FormController::disposing(void) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::disposing" ); - EventObject aEvt(static_cast< XFormController* >(this)); + EventObject aEvt( *this ); // if we're still active, simulate a "deactivated" event if ( m_xActiveControl.is() ) @@ -1029,13 +1207,14 @@ void FmXFormController::disposing(void) m_aDeleteListeners.disposeAndClear(aEvt); m_aRowSetApproveListeners.disposeAndClear(aEvt); m_aParameterListeners.disposeAndClear(aEvt); + m_aFilterListeners.disposeAndClear(aEvt); removeBoundFieldListener(); stopFiltering(); m_pControlBorderManager->restoreAll(); - m_aFilters.clear(); + m_aFilterRows.clear(); ::osl::MutexGuard aGuard( m_aMutex ); m_xActiveControl = NULL; @@ -1067,6 +1246,10 @@ void FmXFormController::disposing(void) disposeAllFeaturesAndDispatchers(); + if ( m_xFormOperations.is() ) + m_xFormOperations->dispose(); + m_xFormOperations.clear(); + if (m_bDBConnection) unload(); @@ -1076,7 +1259,6 @@ void FmXFormController::disposing(void) ::comphelper::disposeComponent( m_xComposer ); - m_xORB = NULL; m_bDBConnection = sal_False; } @@ -1096,10 +1278,9 @@ namespace } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException ) +void SAL_CALL FormController::propertyChange(const PropertyChangeEvent& evt) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::propertyChange" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); if ( evt.PropertyName == FM_PROP_BOUNDFIELD ) { Reference<XPropertySet> xOldBound; @@ -1164,14 +1345,13 @@ void SAL_CALL FmXFormController::propertyChange(const PropertyChangeEvent& evt) } //------------------------------------------------------------------------------ -bool FmXFormController::replaceControl( const Reference< XControl >& _rxExistentControl, const Reference< XControl >& _rxNewControl ) +bool FormController::replaceControl( const Reference< XControl >& _rxExistentControl, const Reference< XControl >& _rxNewControl ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::replaceControl" ); bool bSuccess = false; try { Reference< XIdentifierReplace > xContainer( getContainer(), UNO_QUERY ); - DBG_ASSERT( xContainer.is(), "FmXFormController::replaceControl: yes, it's not required by the service description, but XItentifierReplaces would be nice!" ); + DBG_ASSERT( xContainer.is(), "FormController::replaceControl: yes, it's not required by the service description, but XItentifierReplaces would be nice!" ); if ( xContainer.is() ) { // look up the ID of _rxExistentControl @@ -1184,7 +1364,7 @@ bool FmXFormController::replaceControl( const Reference< XControl >& _rxExistent if ( xCheck == _rxExistentControl ) break; } - DBG_ASSERT( pIdentifiers != pIdentifiersEnd, "FmXFormController::replaceControl: did not find the control in the container!" ); + DBG_ASSERT( pIdentifiers != pIdentifiersEnd, "FormController::replaceControl: did not find the control in the container!" ); if ( pIdentifiers != pIdentifiersEnd ) { bool bReplacedWasActive = ( m_xActiveControl.get() == _rxExistentControl.get() ); @@ -1217,7 +1397,7 @@ bool FmXFormController::replaceControl( const Reference< XControl >& _rxExistent } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::replaceControl: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } Reference< XControl > xDisposeIt( bSuccess ? _rxExistentControl : _rxNewControl ); @@ -1226,10 +1406,9 @@ bool FmXFormController::replaceControl( const Reference< XControl >& _rxExistent } //------------------------------------------------------------------------------ -void FmXFormController::toggleAutoFields(sal_Bool bAutoFields) +void FormController::toggleAutoFields(sal_Bool bAutoFields) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::toggleAutoFields" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); Sequence< Reference< XControl > > aControlsCopy( m_aControls ); @@ -1289,7 +1468,7 @@ void FmXFormController::toggleAutoFields(sal_Bool bAutoFields) { ::rtl::OUString sServiceName; OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName ); - Reference< XControl > xNewControl( m_xORB->createInstance( sServiceName ), UNO_QUERY ); + Reference< XControl > xNewControl( m_aContext.createComponent( sServiceName ), UNO_QUERY ); replaceControl( xControl, xNewControl ); } } @@ -1300,9 +1479,9 @@ void FmXFormController::toggleAutoFields(sal_Bool bAutoFields) } //------------------------------------------------------------------------------ -IMPL_LINK(FmXFormController, OnToggleAutoFields, void*, EMPTYARG) +IMPL_LINK(FormController, OnToggleAutoFields, void*, EMPTYARG) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); toggleAutoFields(m_bCurrentRecordNew); return 1L; @@ -1310,35 +1489,52 @@ IMPL_LINK(FmXFormController, OnToggleAutoFields, void*, EMPTYARG) // XTextListener //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::textChanged(const TextEvent& e) throw( RuntimeException ) +void SAL_CALL FormController::textChanged(const TextEvent& e) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::textChanged" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); if (m_bFiltering) { Reference< XTextComponent > xText(e.Source,UNO_QUERY); ::rtl::OUString aText = xText->getText(); - // Suchen der aktuellen Row - OSL_ENSURE( ( m_aFilters.size() > (size_t)m_nCurrentFilterPosition ) && ( m_nCurrentFilterPosition >= 0 ), - "FmXFormController::textChanged: m_nCurrentFilterPosition too big" ); + if ( m_aFilterRows.empty() ) + appendEmptyDisjunctiveTerm(); - if ( ( m_nCurrentFilterPosition >= 0 ) && ( (size_t)m_nCurrentFilterPosition < m_aFilters.size() ) ) + // Suchen der aktuellen Row + if ( ( (size_t)m_nCurrentFilterPosition >= m_aFilterRows.size() ) || ( m_nCurrentFilterPosition < 0 ) ) { - FmFilterRow& rRow = m_aFilters[m_nCurrentFilterPosition]; + OSL_ENSURE( false, "FormController::textChanged: m_nCurrentFilterPosition is wrong!" ); + return; + } - // do we have a new filter - if (aText.getLength()) - rRow[xText] = aText; - else - { - // do we have the control in the row - FmFilterRow::iterator iter = rRow.find(xText); - // erase the entry out of the row - if (iter != rRow.end()) - rRow.erase(iter); - } + FmFilterRow& rRow = m_aFilterRows[ m_nCurrentFilterPosition ]; + + // do we have a new filter + if (aText.getLength()) + rRow[xText] = aText; + else + { + // do we have the control in the row + FmFilterRow::iterator iter = rRow.find(xText); + // erase the entry out of the row + if (iter != rRow.end()) + rRow.erase(iter); } + + // multiplex the event to our FilterControllerListeners + FilterEvent aEvent; + aEvent.Source = *this; + aEvent.FilterComponent = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xText ) - m_aFilterComponents.begin(); + aEvent.DisjunctiveTerm = getActiveTerm(); + aEvent.PredicateExpression = aText; + + aGuard.clear(); + // <-- SYNCHRONIZED + + // notify the changed filter expression + m_aFilterListeners.notifyEach( &XFilterControllerListener::predicateExpressionChanged, aEvent ); } else impl_onModify(); @@ -1346,36 +1542,34 @@ void SAL_CALL FmXFormController::textChanged(const TextEvent& e) throw( RuntimeE // XItemListener //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::itemStateChanged(const ItemEvent& /*rEvent*/) throw( RuntimeException ) +void SAL_CALL FormController::itemStateChanged(const ItemEvent& /*rEvent*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::itemStateChanged" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); impl_onModify(); } // XModificationBroadcaster //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) +void SAL_CALL FormController::addModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addModifyListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); m_aModifyListeners.addInterface( l ); } //------------------------------------------------------------------------------ -void FmXFormController::removeModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) +void FormController::removeModifyListener(const Reference< XModifyListener > & l) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeModifyListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); m_aModifyListeners.removeInterface( l ); } // XModificationListener //------------------------------------------------------------------------------ -void FmXFormController::modified( const EventObject& _rEvent ) throw( RuntimeException ) +void FormController::modified( const EventObject& _rEvent ) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::modified" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); try { @@ -1400,10 +1594,16 @@ void FmXFormController::modified( const EventObject& _rEvent ) throw( RuntimeExc } //------------------------------------------------------------------------------ -void FmXFormController::impl_onModify() +void FormController::impl_checkDisposed_throw() const +{ + if ( impl_isDisposed_nofail() ) + throw DisposedException( ::rtl::OUString(), *const_cast< FormController* >( this ) ); +} + +//------------------------------------------------------------------------------ +void FormController::impl_onModify() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::onModify" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); { ::osl::MutexGuard aGuard( m_aMutex ); @@ -1416,10 +1616,36 @@ void FmXFormController::impl_onModify() } //------------------------------------------------------------------------------ -sal_Bool FmXFormController::determineLockState() const +void FormController::impl_addFilterRow( const FmFilterRow& _row ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::determineLockState" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + m_aFilterRows.push_back( _row ); + + if ( m_aFilterRows.size() == 1 ) + { // that's the first row ever + OSL_ENSURE( m_nCurrentFilterPosition == -1, "FormController::impl_addFilterRow: inconsistency!" ); + m_nCurrentFilterPosition = 0; + } +} + +//------------------------------------------------------------------------------ +void FormController::impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ) +{ + // SYNCHRONIZED --> + impl_addFilterRow( FmFilterRow() ); + + // notify the listeners + FilterEvent aEvent; + aEvent.Source = *this; + aEvent.DisjunctiveTerm = (sal_Int32)m_aFilterRows.size() - 1; + _rClearBeforeNotify.clear(); + // <-- SYNCHRONIZED + m_aFilterListeners.notifyEach( &XFilterControllerListener::disjunctiveTermAdded, aEvent ); +} + +//------------------------------------------------------------------------------ +sal_Bool FormController::determineLockState() const +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); // a.) in filter mode we are always locked // b.) if we have no valid model or our model (a result set) is not alive -> we're locked // c.) if we are inserting everything is OK and we are not locked @@ -1434,17 +1660,15 @@ sal_Bool FmXFormController::determineLockState() const // FocusListener //------------------------------------------------------------------------------ -void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException ) +void FormController::focusGained(const FocusEvent& e) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::focusGained" ); - TRACE_RANGE( "FmXFormController::focusGained" ); - - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - ::osl::MutexGuard aGuard( m_aMutex ); - Reference< XControl > xControl(e.Source, UNO_QUERY); + // SYNCHRONIZED --> + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); m_pControlBorderManager->focusGained( e.Source ); + Reference< XControl > xControl(e.Source, UNO_QUERY); if (m_bDBConnection) { // do we need to keep the locking of the commit @@ -1473,7 +1697,7 @@ void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException #if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL Reference< XBoundControl > xLockingTest(m_xCurrentControl, UNO_QUERY); sal_Bool bControlIsLocked = xLockingTest.is() && xLockingTest->getLock(); - OSL_ENSURE(!bControlIsLocked, "FmXFormController::Gained: I'm modified and the current control is locked ? How this ?"); + OSL_ENSURE(!bControlIsLocked, "FormController::Gained: I'm modified and the current control is locked ? How this ?"); // normalerweise sollte ein gelocktes Control nicht modified sein, also muss wohl mein bModified aus einem anderen Kontext // gesetzt worden sein, was ich nicht verstehen wuerde ... #endif @@ -1505,22 +1729,33 @@ void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException if (!m_bFiltering && m_bCycle && (e.FocusFlags & FocusChangeReason::AROUND) && m_xCurrentControl.is()) { - if ( e.FocusFlags & FocusChangeReason::FORWARD ) + SQLErrorEvent aErrorEvent; + OSL_ENSURE( m_xFormOperations.is(), "FormController::focusGained: hmm?" ); + // should have been created in setModel + try { - if ( m_aControllerFeatures->isEnabled( SID_FM_RECORD_NEXT ) ) - m_aControllerFeatures->moveRight(); + if ( e.FocusFlags & FocusChangeReason::FORWARD ) + { + if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToNext ) ) + m_xFormOperations->execute( FormFeature::MoveToNext ); + } + else // backward + { + if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToPrevious ) ) + m_xFormOperations->execute( FormFeature::MoveToPrevious ); + } } - else // backward + catch ( const Exception& ) { - if ( m_aControllerFeatures->isEnabled( SID_FM_RECORD_PREV ) ) - m_aControllerFeatures->moveLeft(); + // don't handle this any further. That's an ... admissible error. + DBG_UNHANDLED_EXCEPTION(); } } } // Immer noch ein und dasselbe Control - if ( (m_xActiveControl.get() == xControl.get()) - && (xControl.get() == m_xCurrentControl.get()) + if ( ( m_xActiveControl == xControl ) + && ( xControl == m_xCurrentControl ) ) { DBG_ASSERT(m_xCurrentControl.is(), "Kein CurrentControl selektiert"); @@ -1545,25 +1780,24 @@ void FmXFormController::focusGained(const FocusEvent& e) throw( RuntimeException } // invalidate all features which depend on the currently focused control - if ( m_bDBConnection && !m_bFiltering && m_pView ) + if ( m_bDBConnection && !m_bFiltering ) implInvalidateCurrentControlDependentFeatures(); - if (m_xCurrentControl.is()) - { - // Control erhaelt Focus, dann eventuell in den sichtbaren Bereich - Reference< XWindow > xWindow(xControl, UNO_QUERY); - if (xWindow.is() && m_pView && m_pWindow) - { - ::com::sun::star::awt::Rectangle aRect = xWindow->getPosSize(); - ::Rectangle aNewRect(aRect.X,aRect.Y,aRect.X+aRect.Width,aRect.Y+aRect.Height); - aNewRect = m_pWindow->PixelToLogic(aNewRect); - m_pView->MakeVisible( aNewRect, *const_cast< Window* >( m_pWindow ) ); - } - } + if ( !m_xCurrentControl.is() ) + return; + + // Control erhaelt Focus, dann eventuell in den sichtbaren Bereich + Reference< XFormControllerContext > xContext( m_xContext ); + Reference< XControl > xCurrentControl( m_xCurrentControl ); + aGuard.clear(); + // <-- SYNCHRONIZED + + if ( xContext.is() ) + xContext->makeVisible( xCurrentControl ); } //------------------------------------------------------------------------------ -IMPL_LINK( FmXFormController, OnActivated, void*, /**/ ) +IMPL_LINK( FormController, OnActivated, void*, /**/ ) { EventObject aEvent; aEvent.Source = *this; @@ -1573,7 +1807,7 @@ IMPL_LINK( FmXFormController, OnActivated, void*, /**/ ) } //------------------------------------------------------------------------------ -IMPL_LINK( FmXFormController, OnDeactivated, void*, /**/ ) +IMPL_LINK( FormController, OnDeactivated, void*, /**/ ) { EventObject aEvent; aEvent.Source = *this; @@ -1583,10 +1817,9 @@ IMPL_LINK( FmXFormController, OnDeactivated, void*, /**/ ) } //------------------------------------------------------------------------------ -void FmXFormController::focusLost(const FocusEvent& e) throw( RuntimeException ) +void FormController::focusLost(const FocusEvent& e) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::focusLost" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_pControlBorderManager->focusLost( e.Source ); @@ -1601,53 +1834,48 @@ void FmXFormController::focusLost(const FocusEvent& e) throw( RuntimeException ) } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::mousePressed( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) +void SAL_CALL FormController::mousePressed( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::mousePressed" ); // not interested in } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::mouseReleased( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) +void SAL_CALL FormController::mouseReleased( const awt::MouseEvent& /*_rEvent*/ ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::mouseReleased" ); // not interested in } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::mouseEntered( const awt::MouseEvent& _rEvent ) throw (RuntimeException) +void SAL_CALL FormController::mouseEntered( const awt::MouseEvent& _rEvent ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::mouseEntered" ); m_pControlBorderManager->mouseEntered( _rEvent.Source ); } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::mouseExited( const awt::MouseEvent& _rEvent ) throw (RuntimeException) +void SAL_CALL FormController::mouseExited( const awt::MouseEvent& _rEvent ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::mouseExited" ); m_pControlBorderManager->mouseExited( _rEvent.Source ); } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::componentValidityChanged( const EventObject& _rSource ) throw (RuntimeException) +void SAL_CALL FormController::componentValidityChanged( const EventObject& _rSource ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::componentValidityChanged" ); Reference< XControl > xControl( findControl( m_aControls, Reference< XControlModel >( _rSource.Source, UNO_QUERY ), sal_False, sal_False ) ); Reference< XValidatableFormComponent > xValidatable( _rSource.Source, UNO_QUERY ); - OSL_ENSURE( xControl.is() && xValidatable.is(), "FmXFormController::componentValidityChanged: huh?" ); + OSL_ENSURE( xControl.is() && xValidatable.is(), "FormController::componentValidityChanged: huh?" ); if ( xControl.is() && xValidatable.is() ) m_pControlBorderManager->validityChanged( xControl, xValidatable ); } //-------------------------------------------------------------------- -void FmXFormController::setModel(const Reference< XTabControllerModel > & Model) throw( RuntimeException ) +void FormController::setModel(const Reference< XTabControllerModel > & Model) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setModel" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::setModel : invalid aggregate !"); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::setModel : invalid aggregate !"); try { @@ -1672,10 +1900,15 @@ void FmXFormController::setModel(const Reference< XTabControllerModel > & Model) Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(m_xModelAsIndex, UNO_QUERY); if (xParamBroadcaster.is()) xParamBroadcaster->removeParameterListener(this); + } disposeAllFeaturesAndDispatchers(); + if ( m_xFormOperations.is() ) + m_xFormOperations->dispose(); + m_xFormOperations.clear(); + // set the new model wait for the load event if (m_xTabController.is()) m_xTabController->setModel(Model); @@ -1691,7 +1924,9 @@ void FmXFormController::setModel(const Reference< XTabControllerModel > & Model) if (m_xModelAsIndex.is()) { - m_aControllerFeatures.assign( this ); + // re-create m_xFormOperations + m_xFormOperations.set( FormOperations::createWithFormController( m_aContext.getUNOContext(), this ), UNO_SET_THROW ); + m_xFormOperations->setFeatureInvalidation( this ); // adding load and ui interaction listeners Reference< XLoadable > xForm(Model, UNO_QUERY); @@ -1743,27 +1978,27 @@ void FmXFormController::setModel(const Reference< XTabControllerModel > & Model) } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::setModel: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } //------------------------------------------------------------------------------ -Reference< XTabControllerModel > FmXFormController::getModel() throw( RuntimeException ) +Reference< XTabControllerModel > FormController::getModel() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getModel" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::getModel : invalid aggregate !"); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::getModel : invalid aggregate !"); if (!m_xTabController.is()) return Reference< XTabControllerModel > (); return m_xTabController->getModel(); } //------------------------------------------------------------------------------ -void FmXFormController::addToEventAttacher(const Reference< XControl > & xControl) +void FormController::addToEventAttacher(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addToEventAttacher" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - OSL_ENSURE( xControl.is(), "FmXFormController::addToEventAttacher: invalid control - how did you reach this?" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + OSL_ENSURE( xControl.is(), "FormController::addToEventAttacher: invalid control - how did you reach this?" ); if ( !xControl.is() ) return; /* throw IllegalArgumentException(); */ @@ -1788,11 +2023,10 @@ void FmXFormController::addToEventAttacher(const Reference< XControl > & xContro } //------------------------------------------------------------------------------ -void FmXFormController::removeFromEventAttacher(const Reference< XControl > & xControl) +void FormController::removeFromEventAttacher(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeFromEventAttacher" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - OSL_ENSURE( xControl.is(), "FmXFormController::removeFromEventAttacher: invalid control - how did you reach this?" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + OSL_ENSURE( xControl.is(), "FormController::removeFromEventAttacher: invalid control - how did you reach this?" ); if ( !xControl.is() ) return; /* throw IllegalArgumentException(); */ @@ -1817,14 +2051,13 @@ void FmXFormController::removeFromEventAttacher(const Reference< XControl > & xC } //------------------------------------------------------------------------------ -void FmXFormController::setContainer(const Reference< XControlContainer > & xContainer) throw( RuntimeException ) +void FormController::setContainer(const Reference< XControlContainer > & xContainer) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setContainer" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); Reference< XTabControllerModel > xTabModel(getModel()); DBG_ASSERT(xTabModel.is() || !xContainer.is(), "No Model defined"); // if we have a new container we need a model - DBG_ASSERT(m_xTabController.is(), "FmXFormController::setContainer : invalid aggregate !"); + DBG_ASSERT(m_xTabController.is(), "FormController::setContainer : invalid aggregate !"); ::osl::MutexGuard aGuard( m_aMutex ); Reference< XContainer > xCurrentContainer; @@ -1838,11 +2071,8 @@ void FmXFormController::setContainer(const Reference< XControlContainer > & xCon m_aTabActivationTimer.Stop(); // clear the filter map - for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); ++iter) - (*iter).first->removeTextListener(this); - - m_aFilterControls.clear(); + ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) ); + m_aFilterComponents.clear(); // einsammeln der Controls const Reference< XControl >* pControls = m_aControls.getConstArray(); @@ -1906,23 +2136,23 @@ void FmXFormController::setContainer(const Reference< XControlContainer > & xCon } //------------------------------------------------------------------------------ -Reference< XControlContainer > FmXFormController::getContainer() throw( RuntimeException ) +Reference< XControlContainer > FormController::getContainer() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getContainer" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::getContainer : invalid aggregate !"); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::getContainer : invalid aggregate !"); if (!m_xTabController.is()) return Reference< XControlContainer > (); return m_xTabController->getContainer(); } //------------------------------------------------------------------------------ -Sequence< Reference< XControl > > FmXFormController::getControls(void) throw( RuntimeException ) +Sequence< Reference< XControl > > FormController::getControls(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getControls" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + if (!m_bControlsSorted) { Reference< XTabControllerModel > xModel = getModel(); @@ -1958,32 +2188,31 @@ Sequence< Reference< XControl > > FmXFormController::getControls(void) throw( Ru } //------------------------------------------------------------------------------ -void FmXFormController::autoTabOrder() throw( RuntimeException ) +void FormController::autoTabOrder() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::autoTabOrder" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::autoTabOrder : invalid aggregate !"); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::autoTabOrder : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->autoTabOrder(); } //------------------------------------------------------------------------------ -void FmXFormController::activateTabOrder() throw( RuntimeException ) +void FormController::activateTabOrder() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::activateTabOrder" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::activateTabOrder : invalid aggregate !"); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::activateTabOrder : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->activateTabOrder(); } //------------------------------------------------------------------------------ -void FmXFormController::setControlLock(const Reference< XControl > & xControl) +void FormController::setControlLock(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setControlLock" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); sal_Bool bLocked = isLocked(); // es wird gelockt @@ -2022,8 +2251,9 @@ void FmXFormController::setControlLock(const Reference< XControl > & xControl) else xBound->setLock(bLocked); } - catch(...) + catch( const Exception& ) { + DBG_UNHANDLED_EXCEPTION(); } } @@ -2034,10 +2264,9 @@ void FmXFormController::setControlLock(const Reference< XControl > & xControl) } //------------------------------------------------------------------------------ -void FmXFormController::setLocks() +void FormController::setLocks() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setLocks" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); // alle Controls, die mit einer Datenquelle verbunden sind locken/unlocken const Reference< XControl >* pControls = m_aControls.getConstArray(); const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); @@ -2076,10 +2305,9 @@ namespace } //------------------------------------------------------------------------------ -void FmXFormController::startControlModifyListening(const Reference< XControl > & xControl) +void FormController::startControlModifyListening(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::startControlModifyListening" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); bool bModifyListening = lcl_shouldListenForModifications( xControl, this ); @@ -2126,10 +2354,9 @@ void FmXFormController::startControlModifyListening(const Reference< XControl > } //------------------------------------------------------------------------------ -void FmXFormController::stopControlModifyListening(const Reference< XControl > & xControl) +void FormController::stopControlModifyListening(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::stopControlModifyListening" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); bool bModifyListening = lcl_shouldListenForModifications( xControl, NULL ); @@ -2175,10 +2402,9 @@ void FmXFormController::stopControlModifyListening(const Reference< XControl > & } //------------------------------------------------------------------------------ -void FmXFormController::startListening() +void FormController::startListening() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::startListening" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_bModified = sal_False; // jetzt anmelden bei gebundenen feldern @@ -2189,10 +2415,9 @@ void FmXFormController::startListening() } //------------------------------------------------------------------------------ -void FmXFormController::stopListening() +void FormController::stopListening() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::stopListening" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_bModified = sal_False; // jetzt anmelden bei gebundenen feldern @@ -2204,10 +2429,9 @@ void FmXFormController::stopListening() //------------------------------------------------------------------------------ -Reference< XControl > FmXFormController::findControl(Sequence< Reference< XControl > >& _rControls, const Reference< XControlModel > & xCtrlModel ,sal_Bool _bRemove,sal_Bool _bOverWrite) const +Reference< XControl > FormController::findControl(Sequence< Reference< XControl > >& _rControls, const Reference< XControlModel > & xCtrlModel ,sal_Bool _bRemove,sal_Bool _bOverWrite) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::findControl" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); DBG_ASSERT( xCtrlModel.is(), "findControl - welches ?!" ); Reference< XControl >* pControls = _rControls.getArray(); @@ -2232,9 +2456,8 @@ Reference< XControl > FmXFormController::findControl(Sequence< Reference< XCont } //------------------------------------------------------------------------------ -void FmXFormController::implControlInserted( const Reference< XControl>& _rxControl, bool _bAddToEventAttacher ) +void FormController::implControlInserted( const Reference< XControl>& _rxControl, bool _bAddToEventAttacher ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::implControlInserted" ); Reference< XWindow > xWindow( _rxControl, UNO_QUERY ); if ( xWindow.is() ) { @@ -2272,9 +2495,8 @@ void FmXFormController::implControlInserted( const Reference< XControl>& _rxCont } //------------------------------------------------------------------------------ -void FmXFormController::implControlRemoved( const Reference< XControl>& _rxControl, bool _bRemoveFromEventAttacher ) +void FormController::implControlRemoved( const Reference< XControl>& _rxControl, bool _bRemoveFromEventAttacher ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::implControlRemoved" ); Reference< XWindow > xWindow( _rxControl, UNO_QUERY ); if ( xWindow.is() ) { @@ -2304,9 +2526,8 @@ void FmXFormController::implControlRemoved( const Reference< XControl>& _rxContr } //------------------------------------------------------------------------------ -void FmXFormController::implSetCurrentControl( const Reference< XControl >& _rxControl ) +void FormController::implSetCurrentControl( const Reference< XControl >& _rxControl ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::implSetCurrentControl" ); if ( m_xCurrentControl.get() == _rxControl.get() ) return; @@ -2322,10 +2543,9 @@ void FmXFormController::implSetCurrentControl( const Reference< XControl >& _rxC } //------------------------------------------------------------------------------ -void FmXFormController::insertControl(const Reference< XControl > & xControl) +void FormController::insertControl(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::insertControl" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_bControlsSorted = sal_False; m_aControls.realloc(m_aControls.getLength() + 1); m_aControls.getArray()[m_aControls.getLength() - 1] = xControl; @@ -2343,10 +2563,9 @@ void FmXFormController::insertControl(const Reference< XControl > & xControl) } //------------------------------------------------------------------------------ -void FmXFormController::removeControl(const Reference< XControl > & xControl) +void FormController::removeControl(const Reference< XControl > & xControl) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeControl" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); const Reference< XControl >* pControls = m_aControls.getConstArray(); const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); while ( pControls != pControlsEnd ) @@ -2358,13 +2577,9 @@ void FmXFormController::removeControl(const Reference< XControl > & xControl) } } - if (m_aFilterControls.size()) - { - Reference< XTextComponent > xText(xControl, UNO_QUERY); - FmFilterControls::iterator iter = m_aFilterControls.find(xText); - if (iter != m_aFilterControls.end()) - m_aFilterControls.erase(iter); - } + FilterComponents::iterator componentPos = ::std::find( m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl ); + if ( componentPos != m_aFilterComponents.end() ) + m_aFilterComponents.erase( componentPos ); implControlRemoved( xControl, m_bDetachEvents ); @@ -2374,12 +2589,11 @@ void FmXFormController::removeControl(const Reference< XControl > & xControl) // XLoadListener //------------------------------------------------------------------------------ -void FmXFormController::loaded(const EventObject& rEvent) throw( RuntimeException ) +void FormController::loaded(const EventObject& rEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::loaded" ); - OSL_ENSURE( rEvent.Source == m_xModelAsIndex, "FmXFormController::loaded: where did this come from?" ); + OSL_ENSURE( rEvent.Source == m_xModelAsIndex, "FormController::loaded: where did this come from?" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); Reference< XRowSet > xForm(rEvent.Source, UNO_QUERY); // do we have a connected data source @@ -2431,9 +2645,8 @@ void FmXFormController::loaded(const EventObject& rEvent) throw( RuntimeExceptio } //------------------------------------------------------------------------------ -void FmXFormController::updateAllDispatchers() const +void FormController::updateAllDispatchers() const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::updateAllDispatchers" ); ::std::for_each( m_aFeatureDispatchers.begin(), m_aFeatureDispatchers.end(), @@ -2445,9 +2658,9 @@ void FmXFormController::updateAllDispatchers() const } //------------------------------------------------------------------------------ -IMPL_LINK(FmXFormController, OnLoad, void*, EMPTYARG) +IMPL_LINK(FormController, OnLoad, void*, EMPTYARG) { - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); m_bLocked = determineLockState(); setLocks(); @@ -2463,19 +2676,20 @@ IMPL_LINK(FmXFormController, OnLoad, void*, EMPTYARG) } //------------------------------------------------------------------------------ -void FmXFormController::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException ) +void FormController::unloaded(const EventObject& /*rEvent*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::unloaded" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + updateAllDispatchers(); } //------------------------------------------------------------------------------ -void FmXFormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException ) +void FormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::reloading" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + // do the same like in unloading // just one exception toggle the auto values m_aToggleEvent.CancelPendingCall(); @@ -2483,27 +2697,28 @@ void FmXFormController::reloading(const EventObject& /*aEvent*/) throw( RuntimeE } //------------------------------------------------------------------------------ -void FmXFormController::reloaded(const EventObject& aEvent) throw( RuntimeException ) +void FormController::reloaded(const EventObject& aEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::reloaded" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + loaded(aEvent); } //------------------------------------------------------------------------------ -void FmXFormController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException ) +void FormController::unloading(const EventObject& /*aEvent*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::unloading" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + unload(); } //------------------------------------------------------------------------------ -void FmXFormController::unload() throw( RuntimeException ) +void FormController::unload() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::unload" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); m_aLoadEvent.CancelPendingCall(); @@ -2529,9 +2744,8 @@ void FmXFormController::unload() throw( RuntimeException ) } // ----------------------------------------------------------------------------- -void FmXFormController::removeBoundFieldListener() +void FormController::removeBoundFieldListener() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeBoundFieldListener" ); const Reference< XControl >* pControls = m_aControls.getConstArray(); const Reference< XControl >* pControlsEnd = pControls + m_aControls.getLength(); while ( pControls != pControlsEnd ) @@ -2543,9 +2757,8 @@ void FmXFormController::removeBoundFieldListener() } //------------------------------------------------------------------------------ -void FmXFormController::startFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) +void FormController::startFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::startFormListening" ); try { if ( m_bCanInsert || m_bCanUpdate ) // form can be modified @@ -2573,14 +2786,13 @@ void FmXFormController::startFormListening( const Reference< XPropertySet >& _rx } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::startFormListening: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } //------------------------------------------------------------------------------ -void FmXFormController::stopFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) +void FormController::stopFormListening( const Reference< XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::stopFormListening" ); try { if ( m_bCanInsert || m_bCanUpdate ) @@ -2606,20 +2818,20 @@ void FmXFormController::stopFormListening( const Reference< XPropertySet >& _rxF } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::stopFormListening: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } } // com::sun::star::sdbc::XRowSetListener //------------------------------------------------------------------------------ -void FmXFormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeException ) +void FormController::cursorMoved(const EventObject& /*event*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::cursorMoved" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + // toggle the locking ? if (m_bLocked != determineLockState()) { - ::osl::MutexGuard aGuard( m_aMutex ); m_bLocked = !m_bLocked; setLocks(); if (isListeningForChanges()) @@ -2633,31 +2845,28 @@ void FmXFormController::cursorMoved(const EventObject& /*event*/) throw( Runtime } //------------------------------------------------------------------------------ -void FmXFormController::rowChanged(const EventObject& /*event*/) throw( RuntimeException ) +void FormController::rowChanged(const EventObject& /*event*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::rowChanged" ); // not interested in ... } //------------------------------------------------------------------------------ -void FmXFormController::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException ) +void FormController::rowSetChanged(const EventObject& /*event*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::rowSetChanged" ); // not interested in ... } // XContainerListener //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::elementInserted(const ContainerEvent& evt) throw( RuntimeException ) +void SAL_CALL FormController::elementInserted(const ContainerEvent& evt) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::elementInserted" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - Reference< XControl > xControl; - evt.Element >>= xControl; - if (!xControl.is()) + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + Reference< XControl > xControl( evt.Element, UNO_QUERY ); + if ( !xControl.is() ) return; - ::osl::MutexGuard aGuard( m_aMutex ); Reference< XFormComponent > xModel(xControl->getModel(), UNO_QUERY); if (xModel.is() && m_xModelAsIndex == xModel->getParent()) { @@ -2686,8 +2895,8 @@ void SAL_CALL FmXFormController::elementInserted(const ContainerEvent& evt) thro if (xText.is() && xField.is() && ::comphelper::hasProperty(FM_PROP_SEARCHABLE, xField) && ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_SEARCHABLE))) { - m_aFilterControls[xText] = xField; - xText->addTextListener(this); + m_aFilterComponents.push_back( xText ); + xText->addTextListener( this ); } } } @@ -2695,9 +2904,8 @@ void SAL_CALL FmXFormController::elementInserted(const ContainerEvent& evt) thro } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::elementReplaced(const ContainerEvent& evt) throw( RuntimeException ) +void SAL_CALL FormController::elementReplaced(const ContainerEvent& evt) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::elementReplaced" ); // simulate an elementRemoved ContainerEvent aRemoveEvent( evt ); aRemoveEvent.Element = evt.ReplacedElement; @@ -2711,11 +2919,10 @@ void SAL_CALL FmXFormController::elementReplaced(const ContainerEvent& evt) thro } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::elementRemoved(const ContainerEvent& evt) throw( RuntimeException ) +void SAL_CALL FormController::elementRemoved(const ContainerEvent& evt) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::elementRemoved" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); Reference< XControl > xControl; evt.Element >>= xControl; @@ -2731,18 +2938,17 @@ void SAL_CALL FmXFormController::elementRemoved(const ContainerEvent& evt) throw // are we in filtermode and a XModeSelector has inserted an element else if (m_bFiltering && Reference< XModeSelector > (evt.Source, UNO_QUERY).is()) { - Reference< XTextComponent > xText(xControl, UNO_QUERY); - FmFilterControls::iterator iter = m_aFilterControls.find(xText); - if (iter != m_aFilterControls.end()) - m_aFilterControls.erase(iter); + FilterComponents::iterator componentPos = ::std::find( + m_aFilterComponents.begin(), m_aFilterComponents.end(), xControl ); + if ( componentPos != m_aFilterComponents.end() ) + m_aFilterComponents.erase( componentPos ); } } //------------------------------------------------------------------------------ -Reference< XControl > FmXFormController::isInList(const Reference< XWindowPeer > & xPeer) const +Reference< XControl > FormController::isInList(const Reference< XWindowPeer > & xPeer) const { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::isInList" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); const Reference< XControl >* pControls = m_aControls.getConstArray(); sal_uInt32 nCtrls = m_aControls.getLength(); @@ -2759,58 +2965,134 @@ Reference< XControl > FmXFormController::isInList(const Reference< XWindowPeer } //------------------------------------------------------------------------------ -void FmXFormController::activateFirst() throw( RuntimeException ) +void FormController::activateFirst() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::activateFirst" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::activateFirst : invalid aggregate !"); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::activateFirst : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->activateFirst(); } //------------------------------------------------------------------------------ -void FmXFormController::activateLast() throw( RuntimeException ) +void FormController::activateLast() throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::activateLast" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); ::osl::MutexGuard aGuard( m_aMutex ); - DBG_ASSERT(m_xTabController.is(), "FmXFormController::activateLast : invalid aggregate !"); + impl_checkDisposed_throw(); + + DBG_ASSERT(m_xTabController.is(), "FormController::activateLast : invalid aggregate !"); if (m_xTabController.is()) m_xTabController->activateLast(); } // XFormController //------------------------------------------------------------------------------ -Reference< XControl> SAL_CALL FmXFormController::getCurrentControl(void) throw( RuntimeException ) +Reference< XFormOperations > SAL_CALL FormController::getFormOperations() throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getCurrentControl" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + return m_xFormOperations; +} + +//------------------------------------------------------------------------------ +Reference< XControl> SAL_CALL FormController::getCurrentControl(void) throw( RuntimeException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); return m_xCurrentControl; } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) +void SAL_CALL FormController::addActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addActivateListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + impl_checkDisposed_throw(); m_aActivateListeners.addInterface(l); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) +void SAL_CALL FormController::removeActivateListener(const Reference< XFormControllerListener > & l) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeActivateListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + impl_checkDisposed_throw(); m_aActivateListeners.removeInterface(l); } //------------------------------------------------------------------------------ -void FmXFormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos) +void SAL_CALL FormController::addChildController( const Reference< XFormController >& _ChildController ) throw( RuntimeException, IllegalArgumentException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + + if ( !_ChildController.is() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + // TODO: (localized) error message + + // the parent of our (to-be-)child must be our own model + Reference< XFormComponent > xFormOfChild( _ChildController->getModel(), UNO_QUERY ); + if ( !xFormOfChild.is() ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + // TODO: (localized) error message + + if ( xFormOfChild->getParent() != m_xModelAsIndex ) + throw IllegalArgumentException( ::rtl::OUString(), *this, 1 ); + // TODO: (localized) error message + + m_aChilds.push_back( _ChildController ); + _ChildController->setParent( *this ); + + // search the position of the model within the form + sal_uInt32 nPos = m_xModelAsIndex->getCount(); + Reference< XFormComponent > xTemp; + for( ; nPos; ) + { + m_xModelAsIndex->getByIndex(--nPos) >>= xTemp; + if ( xFormOfChild == xTemp ) + { + Reference< XInterface > xIfc( _ChildController, UNO_QUERY ); + m_xModelAsManager->attach( nPos, xIfc, makeAny( _ChildController) ); + break; + } + } +} + +//------------------------------------------------------------------------------ +Reference< XFormControllerContext > SAL_CALL FormController::getContext() throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + return m_xContext; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setContext( const Reference< XFormControllerContext >& _context ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_xContext = _context; +} + +//------------------------------------------------------------------------------ +Reference< XInteractionHandler > SAL_CALL FormController::getInteractionHandler() throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setFilter" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + return m_xInteractionHandler; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setInteractionHandler( const Reference< XInteractionHandler >& _interactionHandler ) throw (RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_xInteractionHandler = _interactionHandler; +} + +//------------------------------------------------------------------------------ +void FormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos) +{ + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); // create the composer Reference< XRowSet > xForm(m_xModelAsIndex, UNO_QUERY); Reference< XConnection > xConnection(OStaticDataAccessTools().getRowSetConnection(xForm)); @@ -2865,11 +3147,10 @@ void FmXFormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos) // need to parse criteria localized OStaticDataAccessTools aStaticTools; Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats(xConnection, sal_True)); - Reference< XNumberFormatter> xFormatter(m_xORB - ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); + Reference< XNumberFormatter> xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY ); xFormatter->attachNumberFormatsSupplier(xFormatSupplier); Locale aAppLocale = Application::GetSettings().GetUILocale(); - LocaleDataWrapper aLocaleWrapper(m_xORB,aAppLocale); + LocaleDataWrapper aLocaleWrapper( m_aContext.getLegacyServiceFactory(), aAppLocale ); // retrieving the filter const Sequence < PropertyValue >* pRow = aFilterRows.getConstArray(); @@ -2967,26 +3248,24 @@ void FmXFormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos) if (aRow.empty()) continue; - m_aFilters.push_back(aRow); + impl_addFilterRow( aRow ); } } // now set the filter controls - for (::std::vector<FmFieldInfo>::iterator iter = rFieldInfos.begin(); - iter != rFieldInfos.end(); iter++) + for ( ::std::vector<FmFieldInfo>::iterator field = rFieldInfos.begin(); + field != rFieldInfos.end(); + ++field + ) { - m_aFilterControls[(*iter).xText] = (*iter).xField; + m_aFilterComponents.push_back( field->xText ); } - - // add an empty row - m_aFilters.push_back(FmFilterRow()); } //------------------------------------------------------------------------------ -void FmXFormController::startFiltering() +void FormController::startFiltering() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::startFiltering" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); OStaticDataAccessTools aStaticTools; Reference< XConnection > xConnection( aStaticTools.getRowSetConnection( Reference< XRowSet >( m_xModelAsIndex, UNO_QUERY ) ) ); @@ -3013,8 +3292,7 @@ void FmXFormController::startFiltering() // the control we have to activate after replacement Reference< XDatabaseMetaData > xMetaData(xConnection->getMetaData()); Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, sal_True); - Reference< XNumberFormatter > xFormatter(m_xORB - ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); + Reference< XNumberFormatter > xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY ); xFormatter->attachNumberFormatsSupplier(xFormatSupplier); // structure for storing the field info @@ -3032,7 +3310,7 @@ void FmXFormController::startFiltering() Reference< XModeSelector > xSelector(xControl, UNO_QUERY); if (xSelector.is()) { - xSelector->setMode(FILTER_MODE); + xSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) ); // listening for new controls of the selector Reference< XContainer > xContainer(xSelector, UNO_QUERY); @@ -3092,13 +3370,10 @@ void FmXFormController::startFiltering() aCreationArgs[ 1 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "NumberFormatter" ), makeAny( xFormatter ) ); aCreationArgs[ 2 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "ControlModel" ), makeAny( xModel ) ); Reference< XControl > xFilterControl( - m_xORB->createInstanceWithArguments( - ::rtl::OUString::createFromAscii( "com.sun.star.form.control.FilterControl" ), - aCreationArgs - ), + m_aContext.createComponentWithArguments( "com.sun.star.form.control.FilterControl", aCreationArgs ), UNO_QUERY ); - DBG_ASSERT( xFilterControl.is(), "FmXFormController::startFiltering: could not create a filter control!" ); + DBG_ASSERT( xFilterControl.is(), "FormController::startFiltering: could not create a filter control!" ); if ( replaceControl( xControl, xFilterControl ) ) { @@ -3132,10 +3407,9 @@ void FmXFormController::startFiltering() } //------------------------------------------------------------------------------ -void FmXFormController::stopFiltering() +void FormController::stopFiltering() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::stopFiltering" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); if ( !m_bFiltering ) // #104693# OJ { // nothing to do return; @@ -3150,17 +3424,10 @@ void FmXFormController::stopFiltering() Sequence< Reference< XControl > > aControlsCopy( m_aControls ); const Reference< XControl > * pControls = aControlsCopy.getConstArray(); sal_Int32 nControlCount = aControlsCopy.getLength(); - // SdrPageView* pCurPageView = m_pView->GetSdrPageView(); - - // sal_uInt16 nPos = pCurPageView ? pCurPageView->GetWinList().Find((OutputDevice*)m_pView->GetActualOutDev()) : SDRPAGEVIEWWIN_NOTFOUND; - // const SdrPageWindow* pWindow = pCurPageView ? pCurPageView->FindPageWindow(*((OutputDevice*)m_pView->GetActualOutDev())) : 0L; // clear the filter control map - for (FmFilterControls::const_iterator iter = m_aFilterControls.begin(); - iter != m_aFilterControls.end(); iter++) - (*iter).first->removeTextListener(this); - - m_aFilterControls.clear(); + ::std::for_each( m_aFilterComponents.begin(), m_aFilterComponents.end(), RemoveComponentTextListener( this ) ); + m_aFilterComponents.clear(); for ( sal_Int32 i = nControlCount; i > 0; ) { @@ -3173,7 +3440,7 @@ void FmXFormController::stopFiltering() Reference< XModeSelector > xSelector(xControl, UNO_QUERY); if (xSelector.is()) { - xSelector->setMode(DATA_MODE); + xSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) ); // listening for new controls of the selector Reference< XContainer > xContainer(xSelector, UNO_QUERY); @@ -3197,7 +3464,7 @@ void FmXFormController::stopFiltering() { ::rtl::OUString sServiceName; OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName ); - Reference< XControl > xNewControl( m_xORB->createInstance( sServiceName ), UNO_QUERY ); + Reference< XControl > xNewControl( m_aContext.createComponent( sServiceName ), UNO_QUERY ); replaceControl( xControl, xNewControl ); } } @@ -3210,8 +3477,8 @@ void FmXFormController::stopFiltering() m_bDetachEvents = sal_True; - m_aFilters.clear(); - m_nCurrentFilterPosition = 0; + m_aFilterRows.clear(); + m_nCurrentFilterPosition = -1; // release the locks if possible // lock all controls which are not used for filtering @@ -3225,12 +3492,11 @@ void FmXFormController::stopFiltering() // XModeSelector //------------------------------------------------------------------------------ -void FmXFormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException ) +void FormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportException, RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::setMode" ); ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); if (!supportsMode(Mode)) throw NoSupportException(); @@ -3239,7 +3505,7 @@ void FmXFormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportExc m_aMode = Mode; - if (Mode == FILTER_MODE) + if ( Mode.equalsAscii( "FilterMode" ) ) startFiltering(); else stopFiltering(); @@ -3254,35 +3520,37 @@ void FmXFormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportExc } //------------------------------------------------------------------------------ -::rtl::OUString SAL_CALL FmXFormController::getMode(void) throw( RuntimeException ) +::rtl::OUString SAL_CALL FormController::getMode(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getMode" ); -::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + return m_aMode; } //------------------------------------------------------------------------------ -Sequence< ::rtl::OUString > SAL_CALL FmXFormController::getSupportedModes(void) throw( RuntimeException ) +Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedModes(void) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getSupportedModes" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + static Sequence< ::rtl::OUString > aModes; if (!aModes.getLength()) { aModes.realloc(2); ::rtl::OUString* pModes = aModes.getArray(); - pModes[0] = DATA_MODE; - pModes[1] = FILTER_MODE; + pModes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ); + pModes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ); } return aModes; } //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::supportsMode(const ::rtl::OUString& Mode) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::supportsMode" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + Sequence< ::rtl::OUString > aModes(getSupportedModes()); const ::rtl::OUString* pModes = aModes.getConstArray(); for (sal_Int32 i = aModes.getLength(); i > 0; ) @@ -3294,37 +3562,32 @@ sal_Bool SAL_CALL FmXFormController::supportsMode(const ::rtl::OUString& Mode) t } //------------------------------------------------------------------------------ -Window* FmXFormController::getDialogParentWindow() +Window* FormController::getDialogParentWindow() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::getDialogParentWindow" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); - Window* pParent = m_pWindow; - if ( !pParent ) + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); + Window* pParentWindow = NULL; + try { - try - { - Reference< XControl > xContainerControl( getContainer(), UNO_QUERY_THROW ); - Reference< XWindowPeer > xContainerPeer( xContainerControl->getPeer(), UNO_QUERY_THROW ); - pParent = VCLUnoHelper::GetWindow( xContainerPeer ); - } - catch( const Exception& ) - { - OSL_ENSURE( sal_False, "FmXFormController::getDialogParentWindow: caught an exception!" ); - } + Reference< XControl > xContainerControl( getContainer(), UNO_QUERY_THROW ); + Reference< XWindowPeer > xContainerPeer( xContainerControl->getPeer(), UNO_QUERY_THROW ); + pParentWindow = VCLUnoHelper::GetWindow( xContainerPeer ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } - return pParent; + return pParentWindow; } //------------------------------------------------------------------------------ -bool FmXFormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, Reference< XControlModel >& /* [out] */ _rxFirstInvalidModel ) SAL_THROW(()) +bool FormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, Reference< XControlModel >& /* [out] */ _rxFirstInvalidModel ) SAL_THROW(()) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::checkFormComponentValidity" ); try { Reference< XEnumerationAccess > xControlEnumAcc( getModel(), UNO_QUERY ); Reference< XEnumeration > xControlEnumeration; if ( xControlEnumAcc.is() ) xControlEnumeration = xControlEnumAcc->createEnumeration(); - OSL_ENSURE( xControlEnumeration.is(), "FmXFormController::checkFormComponentValidity: cannot enumerate the controls!" ); + OSL_ENSURE( xControlEnumeration.is(), "FormController::checkFormComponentValidity: cannot enumerate the controls!" ); if ( !xControlEnumeration.is() ) // assume all valid return true; @@ -3340,7 +3603,7 @@ bool FmXFormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ continue; Reference< XValidator > xValidator( xValidatable->getValidator() ); - OSL_ENSURE( xValidator.is(), "FmXFormController::checkFormComponentValidity: invalid, but no validator?" ); + OSL_ENSURE( xValidator.is(), "FormController::checkFormComponentValidity: invalid, but no validator?" ); if ( !xValidator.is() ) // this violates the interface definition of css.form.validation.XValidatableFormComponent ... continue; @@ -3352,15 +3615,14 @@ bool FmXFormController::checkFormComponentValidity( ::rtl::OUString& /* [out] */ } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::checkFormComponentValidity: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } return true; } //------------------------------------------------------------------------------ -Reference< XControl > FmXFormController::locateControl( const Reference< XControlModel >& _rxModel ) SAL_THROW(()) +Reference< XControl > FormController::locateControl( const Reference< XControlModel >& _rxModel ) SAL_THROW(()) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::locateControl" ); try { Sequence< Reference< XControl > > aControls( getControls() ); @@ -3369,18 +3631,18 @@ Reference< XControl > FmXFormController::locateControl( const Reference< XContro for ( ; pControls != pControlsEnd; ++pControls ) { - OSL_ENSURE( pControls->is(), "FmXFormController::locateControl: NULL-control?" ); + OSL_ENSURE( pControls->is(), "FormController::locateControl: NULL-control?" ); if ( pControls->is() ) { if ( ( *pControls)->getModel() == _rxModel ) return *pControls; } } - OSL_ENSURE( sal_False, "FmXFormController::locateControl: did not find a control for this model!" ); + OSL_ENSURE( sal_False, "FormController::locateControl: did not find a control for this model!" ); } catch( const Exception& ) { - OSL_ENSURE( sal_False, "FmXFormController::locateControl: caught an exception!" ); + DBG_UNHANDLED_EXCEPTION(); } return NULL; } @@ -3448,12 +3710,11 @@ namespace // XRowSetApproveListener //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::approveRowChange(const RowChangeEvent& _rEvent) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::approveRowChange(const RowChangeEvent& _rEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::approveRowChange" ); ::osl::ClearableMutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); sal_Bool bValid = sal_True; if (aIter.hasMoreElements()) @@ -3486,7 +3747,7 @@ sal_Bool SAL_CALL FmXFormController::approveRowChange(const RowChangeEvent& _rEv if ( !lcl_shouldValidateRequiredFields_nothrow( _rEvent.Source ) ) return sal_True; - OSL_ENSURE( m_pColumnInfoCache.get(), "FmXFormController::approveRowChange: no column infos!" ); + OSL_ENSURE( m_pColumnInfoCache.get(), "FormController::approveRowChange: no column infos!" ); if ( !m_pColumnInfoCache.get() ) return sal_True; @@ -3537,11 +3798,11 @@ sal_Bool SAL_CALL FmXFormController::approveRowChange(const RowChangeEvent& _rEv } //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::approveCursorMove(const EventObject& event) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::approveCursorMove(const EventObject& event) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::approveCursorMove" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + impl_checkDisposed_throw(); + ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); if (aIter.hasMoreElements()) { @@ -3554,11 +3815,11 @@ sal_Bool SAL_CALL FmXFormController::approveCursorMove(const EventObject& event) } //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::approveRowSetChange(const EventObject& event) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::approveRowSetChange(const EventObject& event) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::approveRowSetChange" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + impl_checkDisposed_throw(); + ::cppu::OInterfaceIteratorHelper aIter(m_aRowSetApproveListeners); if (aIter.hasMoreElements()) { @@ -3572,30 +3833,29 @@ sal_Bool SAL_CALL FmXFormController::approveRowSetChange(const EventObject& even // XRowSetApproveBroadcaster //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) +void SAL_CALL FormController::addRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addRowSetApproveListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + impl_checkDisposed_throw(); + m_aRowSetApproveListeners.addInterface(_rxListener); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) +void SAL_CALL FormController::removeRowSetApproveListener(const Reference< XRowSetApproveListener > & _rxListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeRowSetApproveListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + impl_checkDisposed_throw(); + m_aRowSetApproveListeners.removeInterface(_rxListener); } // XErrorListener //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::errorOccured(const SQLErrorEvent& aEvent) throw( RuntimeException ) +void SAL_CALL FormController::errorOccured(const SQLErrorEvent& aEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::errorOccured" ); ::osl::ClearableMutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + impl_checkDisposed_throw(); ::cppu::OInterfaceIteratorHelper aIter(m_aErrorListeners); if (aIter.hasMoreElements()) @@ -3613,61 +3873,62 @@ void SAL_CALL FmXFormController::errorOccured(const SQLErrorEvent& aEvent) throw // XErrorBroadcaster //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::addSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addSQLErrorListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + impl_checkDisposed_throw(); + m_aErrorListeners.addInterface(aListener); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::removeSQLErrorListener(const Reference< XSQLErrorListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeSQLErrorListener" ); ::osl::MutexGuard aGuard( m_aMutex ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + impl_checkDisposed_throw(); + m_aErrorListeners.removeInterface(aListener); } // XDatabaseParameterBroadcaster2 //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::addDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addDatabaseParameterListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aParameterListeners.addInterface(aListener); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::removeDatabaseParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeDatabaseParameterListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aParameterListeners.removeInterface(aListener); } // XDatabaseParameterBroadcaster //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::addParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addParameterListener" ); - FmXFormController::addDatabaseParameterListener( aListener ); + FormController::addDatabaseParameterListener( aListener ); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::removeParameterListener(const Reference< XDatabaseParameterListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeParameterListener" ); - FmXFormController::removeDatabaseParameterListener( aListener ); + FormController::removeDatabaseParameterListener( aListener ); } // XDatabaseParameterListener //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::approveParameter(const DatabaseParameterEvent& aEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::approveParameter" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::vos::OGuard aSolarGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); ::cppu::OInterfaceIteratorHelper aIter(m_aParameterListeners); if (aIter.hasMoreElements()) @@ -3698,10 +3959,7 @@ sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEve pParamRequest->addContinuation(pAbort); // handle the request - { - ::vos::OGuard aGuard(Application::GetSolarMutex()); - m_xInteractionHandler->handle(xParamRequest); - } + m_xInteractionHandler->handle(xParamRequest); if (!pParamValues->wasSelected()) // canceled @@ -3711,7 +3969,7 @@ sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEve Sequence< PropertyValue > aFinalValues = pParamValues->getValues(); if (aFinalValues.getLength() != aRequest.Parameters->getCount()) { - DBG_ERROR("FmXFormController::approveParameter: the InteractionHandler returned nonsense!"); + DBG_ERROR("FormController::approveParameter: the InteractionHandler returned nonsense!"); return sal_False; } const PropertyValue* pFinalValues = aFinalValues.getConstArray(); @@ -3724,19 +3982,19 @@ sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEve #ifdef DBG_UTIL ::rtl::OUString sName; xParam->getPropertyValue(FM_PROP_NAME) >>= sName; - DBG_ASSERT(sName.equals(pFinalValues->Name), "FmXFormController::approveParameter: suspicious value names!"); + DBG_ASSERT(sName.equals(pFinalValues->Name), "FormController::approveParameter: suspicious value names!"); #endif try { xParam->setPropertyValue(FM_PROP_VALUE, pFinalValues->Value); } catch(Exception&) { - DBG_ERROR("FmXFormController::approveParameter: setting one of the properties failed!"); + DBG_ERROR("FormController::approveParameter: setting one of the properties failed!"); } } } } catch(Exception&) { - DBG_ERROR("FmXFormController::approveParameter: caught an Exception (tried to let the InteractionHandler handle it)!"); + DBG_UNHANDLED_EXCEPTION(); } } return sal_True; @@ -3744,27 +4002,29 @@ sal_Bool SAL_CALL FmXFormController::approveParameter(const DatabaseParameterEve // XConfirmDeleteBroadcaster //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::addConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addConfirmDeleteListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aDeleteListeners.addInterface(aListener); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) +void SAL_CALL FormController::removeConfirmDeleteListener(const Reference< XConfirmDeleteListener > & aListener) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeConfirmDeleteListener" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); + m_aDeleteListeners.removeInterface(aListener); } // XConfirmDeleteListener //------------------------------------------------------------------------------ -sal_Bool SAL_CALL FmXFormController::confirmDelete(const RowChangeEvent& aEvent) throw( RuntimeException ) +sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::confirmDelete" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + ::osl::MutexGuard aGuard( m_aMutex ); + impl_checkDisposed_throw(); ::cppu::OInterfaceIteratorHelper aIter(m_aDeleteListeners); if (aIter.hasMoreElements()) @@ -3773,32 +4033,62 @@ sal_Bool SAL_CALL FmXFormController::confirmDelete(const RowChangeEvent& aEvent) aEvt.Source = *this; return ((XConfirmDeleteListener*)aIter.next())->confirmDelete(aEvt); } + // default handling: instantiate an interaction handler and let it handle the request + + String sTitle; + sal_Int32 nLength = aEvent.Rows; + if ( nLength > 1 ) + { + sTitle = SVX_RES( RID_STR_DELETECONFIRM_RECORDS ); + sTitle.SearchAndReplace( '#', String::CreateFromInt32( nLength ) ); + } else + sTitle = SVX_RES( RID_STR_DELETECONFIRM_RECORD ); + + try { - // default handling - UniString aTitle; - sal_Int32 nLength = aEvent.Rows; - if (nLength > 1) - { - aTitle = SVX_RES(RID_STR_DELETECONFIRM_RECORDS); - aTitle.SearchAndReplace('#', String::CreateFromInt32(nLength)); - } - else - aTitle = SVX_RES(RID_STR_DELETECONFIRM_RECORD); + if ( !ensureInteractionHandler() ) + return sal_False; + + // two continuations allowed: Yes and No + OInteractionApprove* pApprove = new OInteractionApprove; + OInteractionDisapprove* pDisapprove = new OInteractionDisapprove; - ConfirmDeleteDialog aDlg(getDialogParentWindow(), aTitle); - return RET_YES == aDlg.Execute(); + // the request + SQLWarning aWarning; + aWarning.Message = sTitle; + SQLWarning aDetails; + aDetails.Message = String( SVX_RES( RID_STR_DELETECONFIRM ) ); + aWarning.NextException <<= aDetails; + + OInteractionRequest* pRequest = new OInteractionRequest( makeAny( aWarning ) ); + Reference< XInteractionRequest > xRequest( pRequest ); + + // some knittings + pRequest->addContinuation( pApprove ); + pRequest->addContinuation( pDisapprove ); + + // handle the request + m_xInteractionHandler->handle( xRequest ); + + if ( pApprove->wasSelected() ) + return sal_True; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } + + return sal_False; } //------------------------------------------------------------------------------ -void FmXFormController::invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ) +void SAL_CALL FormController::invalidateFeatures( const Sequence< ::sal_Int16 >& _Features ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::invalidateFeatures" ); ::osl::MutexGuard aGuard( m_aMutex ); // for now, just copy the ids of the features, because .... - ::std::copy( _rFeatures.begin(), _rFeatures.end(), - ::std::insert_iterator< ::std::set< sal_Int32 > >( m_aInvalidFeatures, m_aInvalidFeatures.begin() ) + ::std::copy( _Features.getConstArray(), _Features.getConstArray() + _Features.getLength(), + ::std::insert_iterator< ::std::set< sal_Int16 > >( m_aInvalidFeatures, m_aInvalidFeatures.begin() ) ); // ... we will do the real invalidation asynchronously @@ -3807,13 +4097,30 @@ void FmXFormController::invalidateFeatures( const ::std::vector< sal_Int32 >& _r } //------------------------------------------------------------------------------ +void SAL_CALL FormController::invalidateAllFeatures( ) throw (RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + Sequence< sal_Int16 > aInterceptedFeatures( m_aFeatureDispatchers.size() ); + ::std::transform( + m_aFeatureDispatchers.begin(), + m_aFeatureDispatchers.end(), + aInterceptedFeatures.getArray(), + ::std::select1st< DispatcherContainer::value_type >() + ); + + aGuard.clear(); + if ( aInterceptedFeatures.getLength() ) + invalidateFeatures( aInterceptedFeatures ); +} + +//------------------------------------------------------------------------------ Reference< XDispatch > -FmXFormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL, +FormController::interceptedQueryDispatch( const URL& aURL, const ::rtl::OUString& /*aTargetFrameName*/, sal_Int32 /*nSearchFlags*/) throw( RuntimeException ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::interceptedQueryDispatch" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); Reference< XDispatch > xReturn; // dispatches handled by ourself if ( ( aURL.Complete == FMURL_CONFIRM_DELETION ) @@ -3824,22 +4131,23 @@ FmXFormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL xReturn = static_cast< XDispatch* >( this ); // dispatches of FormSlot-URLs we have to translate - if ( !xReturn.is() && m_aControllerFeatures.isAssigned() ) + if ( !xReturn.is() && m_xFormOperations.is() ) { // find the slot id which corresponds to the URL - sal_Int32 nFeatureId = ::svx::FeatureSlotTranslation::getControllerFeatureSlotIdForURL( aURL.Main ); - if ( nFeatureId > 0 ) + sal_Int32 nFeatureSlotId = ::svx::FeatureSlotTranslation::getControllerFeatureSlotIdForURL( aURL.Main ); + sal_Int16 nFormFeature = ( nFeatureSlotId != -1 ) ? ::svx::FeatureSlotTranslation::getFormFeatureForSlotId( nFeatureSlotId ) : -1; + if ( nFormFeature > 0 ) { // get the dispatcher for this feature, create if necessary - DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( nFeatureId ); + DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( nFormFeature ); if ( aDispatcherPos == m_aFeatureDispatchers.end() ) { aDispatcherPos = m_aFeatureDispatchers.insert( - DispatcherContainer::value_type( nFeatureId, new ::svx::OSingleFeatureDispatcher( aURL, nFeatureId, *m_aControllerFeatures, m_aMutex ) ) + DispatcherContainer::value_type( nFormFeature, new ::svx::OSingleFeatureDispatcher( aURL, nFormFeature, m_xFormOperations, m_aMutex ) ) ).first; } - OSL_ENSURE( aDispatcherPos->second.is(), "FmXFormController::interceptedQueryDispatch: should have a dispatcher by now!" ); + OSL_ENSURE( aDispatcherPos->second.is(), "FormController::interceptedQueryDispatch: should have a dispatcher by now!" ); return aDispatcherPos->second; } } @@ -3849,12 +4157,11 @@ FmXFormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArgs ) throw (RuntimeException) +void SAL_CALL FormController::dispatch( const URL& _rURL, const Sequence< PropertyValue >& _rArgs ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::dispatch" ); if ( _rArgs.getLength() != 1 ) { - DBG_ERROR( "FmXFormController::dispatch: no arguments -> no dispatch!" ); + DBG_ERROR( "FormController::dispatch: no arguments -> no dispatch!" ); return; } @@ -3869,18 +4176,17 @@ void SAL_CALL FmXFormController::dispatch( const URL& _rURL, const Sequence< Pro if ( _rURL.Complete == FMURL_CONFIRM_DELETION ) { - DBG_ERROR( "FmXFormController::dispatch: How do you expect me to return something via this call?" ); + DBG_ERROR( "FormController::dispatch: How do you expect me to return something via this call?" ); // confirmDelete has a return value - dispatch hasn't return; } - DBG_ERROR( "FmXFormController::dispatch: unknown URL!" ); + DBG_ERROR( "FormController::dispatch: unknown URL!" ); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::addStatusListener( const Reference< XStatusListener >& _rxListener, const URL& _rURL ) throw (RuntimeException) +void SAL_CALL FormController::addStatusListener( const Reference< XStatusListener >& _rxListener, const URL& _rURL ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::addStatusListener" ); if (_rURL.Complete == FMURL_CONFIRM_DELETION) { if (_rxListener.is()) @@ -3893,23 +4199,33 @@ void SAL_CALL FmXFormController::addStatusListener( const Reference< XStatusList } } else - OSL_ENSURE(sal_False, "FmXFormController::addStatusListener: invalid (unsupported) URL!"); + OSL_ENSURE(sal_False, "FormController::addStatusListener: invalid (unsupported) URL!"); +} + +//------------------------------------------------------------------------------ +Reference< XInterface > SAL_CALL FormController::getParent() throw( RuntimeException ) +{ + return m_xParent; +} + +//------------------------------------------------------------------------------ +void SAL_CALL FormController::setParent( const Reference< XInterface >& Parent) throw( NoSupportException, RuntimeException ) +{ + m_xParent = Parent; } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::removeStatusListener( const Reference< XStatusListener >& /*_rxListener*/, const URL& _rURL ) throw (RuntimeException) +void SAL_CALL FormController::removeStatusListener( const Reference< XStatusListener >& /*_rxListener*/, const URL& _rURL ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::removeStatusListener" ); (void)_rURL; - OSL_ENSURE(_rURL.Complete == FMURL_CONFIRM_DELETION, "FmXFormController::removeStatusListener: invalid (unsupported) URL!"); + OSL_ENSURE(_rURL.Complete == FMURL_CONFIRM_DELETION, "FormController::removeStatusListener: invalid (unsupported) URL!"); // we never really added the listener, so we don't need to remove it } //------------------------------------------------------------------------------ -Reference< XDispatchProviderInterceptor > FmXFormController::createInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) +Reference< XDispatchProviderInterceptor > FormController::createInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::createInterceptor" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); #ifdef DBG_UTIL // check if we already have a interceptor for the given object for ( ConstInterceptorsIterator aIter = m_aControlDispatchInterceptors.begin(); @@ -3918,49 +4234,43 @@ Reference< XDispatchProviderInterceptor > FmXFormController::createInterceptor( ) { if ((*aIter)->getIntercepted() == _xInterception) - DBG_ERROR("FmXFormController::createInterceptor : we already do intercept this objects dispatches !"); + DBG_ERROR("FormController::createInterceptor : we already do intercept this objects dispatches !"); } #endif - ::rtl::OUString sInterceptorScheme(RTL_CONSTASCII_USTRINGPARAM("*")); - FmXDispatchInterceptorImpl* pInterceptor = new FmXDispatchInterceptorImpl(_xInterception, this, 0, Sequence< ::rtl::OUString >(&sInterceptorScheme, 1)); + DispatchInterceptionMultiplexer* pInterceptor = new DispatchInterceptionMultiplexer( _xInterception, this ); pInterceptor->acquire(); - m_aControlDispatchInterceptors.insert(m_aControlDispatchInterceptors.end(), pInterceptor); + m_aControlDispatchInterceptors.insert( m_aControlDispatchInterceptors.end(), pInterceptor ); - return (XDispatchProviderInterceptor*)pInterceptor; + return pInterceptor; } //------------------------------------------------------------------------------ -bool FmXFormController::ensureInteractionHandler() +bool FormController::ensureInteractionHandler() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::ensureInteractionHandler" ); if ( m_xInteractionHandler.is() ) return true; if ( m_bAttemptedHandlerCreation ) return false; m_bAttemptedHandlerCreation = true; - if ( !m_xORB.is() ) - return false; - m_xInteractionHandler.set( m_xORB->createInstance( SRV_SDB_INTERACTION_HANDLER ), UNO_QUERY ); - OSL_ENSURE( m_xInteractionHandler.is(), "FmXFormController::ensureInteractionHandler: could not create an interaction handler!" ); + m_xInteractionHandler.set( m_aContext.createComponent( (::rtl::OUString)SRV_SDB_INTERACTION_HANDLER ), UNO_QUERY ); + OSL_ENSURE( m_xInteractionHandler.is(), "FormController::ensureInteractionHandler: could not create an interaction handler!" ); return m_xInteractionHandler.is(); } //------------------------------------------------------------------------------ -void SAL_CALL FmXFormController::handle( const Reference< XInteractionRequest >& _rRequest ) throw (RuntimeException) +void SAL_CALL FormController::handle( const Reference< XInteractionRequest >& _rRequest ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::handle" ); if ( !ensureInteractionHandler() ) return; m_xInteractionHandler->handle( _rRequest ); } //------------------------------------------------------------------------------ -void FmXFormController::deleteInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) +void FormController::deleteInterceptor(const Reference< XDispatchProviderInterception > & _xInterception) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::deleteInterceptor" ); - OSL_ENSURE( !impl_isDisposed_nofail(), "FmXFormController: already disposed!" ); + OSL_ENSURE( !impl_isDisposed_nofail(), "FormController: already disposed!" ); // search the interceptor responsible for the given object InterceptorsIterator aIter; for ( aIter = m_aControlDispatchInterceptors.begin(); @@ -3977,7 +4287,7 @@ void FmXFormController::deleteInterceptor(const Reference< XDispatchProviderInte } // log off the interception from it's interception object - FmXDispatchInterceptorImpl* pInterceptorImpl = *aIter; + DispatchInterceptionMultiplexer* pInterceptorImpl = *aIter; pInterceptorImpl->dispose(); pInterceptorImpl->release(); @@ -3986,35 +4296,22 @@ void FmXFormController::deleteInterceptor(const Reference< XDispatchProviderInte } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException) +void FormController::implInvalidateCurrentControlDependentFeatures() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::initialize" ); - DBG_ASSERT( !m_xInteractionHandler.is(), "FmXFormController::initialize: already initialized!" ); - // currently, we only initialize our interaction handler here, so it's sufficient to assert this + Sequence< sal_Int16 > aCurrentControlDependentFeatures(4); - ::comphelper::NamedValueCollection aArgs( aArguments ); - m_xInteractionHandler = aArgs.getOrDefault( "InteractionHandler", m_xInteractionHandler ); -} - -//-------------------------------------------------------------------- -void FmXFormController::implInvalidateCurrentControlDependentFeatures() -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::implInvalidateCurrentControlDependentFeatures" ); - ::std::vector< sal_Int32 > aCurrentControlDependentFeatures; - - aCurrentControlDependentFeatures.push_back( SID_FM_SORTUP ); - aCurrentControlDependentFeatures.push_back( SID_FM_SORTDOWN ); - aCurrentControlDependentFeatures.push_back( SID_FM_AUTOFILTER ); - aCurrentControlDependentFeatures.push_back( SID_FM_REFRESH_FORM_CONTROL ); + aCurrentControlDependentFeatures[0] = FormFeature::SortAscending; + aCurrentControlDependentFeatures[1] = FormFeature::SortDescending; + aCurrentControlDependentFeatures[2] = FormFeature::AutoFilter; + aCurrentControlDependentFeatures[3] = FormFeature::RefreshCurrentControl; - if ( m_pView && m_pView->GetFormShell() && m_pView->GetFormShell()->GetImpl() ) - m_pView->GetFormShell()->GetImpl()->invalidateFeatures( aCurrentControlDependentFeatures ); invalidateFeatures( aCurrentControlDependentFeatures ); } //-------------------------------------------------------------------- -void SAL_CALL FmXFormController::columnChanged( const EventObject& /*_event*/ ) throw (RuntimeException) +void SAL_CALL FormController::columnChanged( const EventObject& /*_event*/ ) throw (RuntimeException) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "FmXFormController::columnChanged" ); implInvalidateCurrentControlDependentFeatures(); } + +} // namespace svxform diff --git a/svx/source/form/formcontrolling.cxx b/svx/source/form/formcontrolling.cxx index 454bdef5d8bf..de6208ef7527 100644 --- a/svx/source/form/formcontrolling.cxx +++ b/svx/source/form/formcontrolling.cxx @@ -33,7 +33,7 @@ #include "formcontrolling.hxx" #include "fmurl.hxx" -#include <svx/svxids.hrc> +#include "svx/svxids.hrc" #include "fmprop.hrc" #include "svx/fmtools.hxx" @@ -60,7 +60,7 @@ namespace svx /** === begin UNO using === **/ using ::com::sun::star::uno::Reference; using ::com::sun::star::lang::XMultiServiceFactory; - using ::com::sun::star::form::XFormController; + using ::com::sun::star::form::runtime::XFormController; using ::com::sun::star::form::XForm; using ::com::sun::star::form::runtime::FormOperations; using ::com::sun::star::uno::Exception; diff --git a/svx/source/form/formdispatchinterceptor.cxx b/svx/source/form/formdispatchinterceptor.cxx new file mode 100644 index 000000000000..2950b1605b0f --- /dev/null +++ b/svx/source/form/formdispatchinterceptor.cxx @@ -0,0 +1,213 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "formdispatchinterceptor.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <tools/debug.hxx> + +//........................................................................ +namespace svxform +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XDispatchProviderInterception; + using ::com::sun::star::frame::XDispatchProviderInterceptor; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::util::URL; + using ::com::sun::star::frame::XDispatch; + using ::com::sun::star::frame::DispatchDescriptor; + using ::com::sun::star::frame::XDispatchProvider; + using ::com::sun::star::lang::EventObject; + /** === end UNO using === **/ + + //======================================================================== + //= DispatchInterceptionMultiplexer + //======================================================================== + + DBG_NAME(DispatchInterceptionMultiplexer) + //------------------------------------------------------------------------ + DispatchInterceptionMultiplexer::DispatchInterceptionMultiplexer( + const Reference< XDispatchProviderInterception >& _rxToIntercept, DispatchInterceptor* _pMaster ) + :DispatchInterceptionMultiplexer_BASE(_pMaster && _pMaster->getInterceptorMutex() ? *_pMaster->getInterceptorMutex() : m_aFallback) + ,m_aFallback() + ,m_pMutex( _pMaster && _pMaster->getInterceptorMutex() ? _pMaster->getInterceptorMutex() : &m_aFallback ) + ,m_xIntercepted(_rxToIntercept) + ,m_bListening(sal_False) + ,m_pMaster(_pMaster) + { + DBG_CTOR(DispatchInterceptionMultiplexer,NULL); + + ::osl::MutexGuard aGuard( *m_pMutex ); + ::comphelper::increment(m_refCount); + if (_rxToIntercept.is()) + { + _rxToIntercept->registerDispatchProviderInterceptor((XDispatchProviderInterceptor*)this); + // this should make us the top-level dispatch-provider for the component, via a call to our + // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill + Reference< XComponent> xInterceptedComponent(_rxToIntercept, UNO_QUERY); + if (xInterceptedComponent.is()) + { + xInterceptedComponent->addEventListener(this); + m_bListening = sal_True; + } + } + ::comphelper::decrement(m_refCount); + } + + //------------------------------------------------------------------------ + DispatchInterceptionMultiplexer::~DispatchInterceptionMultiplexer() + { + if (!rBHelper.bDisposed) + dispose(); + + DBG_DTOR(DispatchInterceptionMultiplexer,NULL); + } + + //------------------------------------------------------------------------------ + Reference< XDispatch > SAL_CALL DispatchInterceptionMultiplexer::queryDispatch( const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + Reference< XDispatch> xResult; + // ask our 'real' interceptor + if (m_pMaster) + xResult = m_pMaster->interceptedQueryDispatch( aURL, aTargetFrameName, nSearchFlags); + + // ask our slave provider + if (!xResult.is() && m_xSlaveDispatcher.is()) + xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags); + + return xResult; + } + + //------------------------------------------------------------------------------ + Sequence< Reference< XDispatch > > SAL_CALL + DispatchInterceptionMultiplexer::queryDispatches( const Sequence< DispatchDescriptor >& aDescripts ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + Sequence< Reference< XDispatch> > aReturn(aDescripts.getLength()); + Reference< XDispatch>* pReturn = aReturn.getArray(); + const DispatchDescriptor* pDescripts = aDescripts.getConstArray(); + for (sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts) + { + *pReturn = queryDispatch(pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags); + } + return aReturn; + } + + //------------------------------------------------------------------------------ + Reference< XDispatchProvider > SAL_CALL DispatchInterceptionMultiplexer::getSlaveDispatchProvider( ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + return m_xSlaveDispatcher; + } + + //------------------------------------------------------------------------------ + void SAL_CALL DispatchInterceptionMultiplexer::setSlaveDispatchProvider(const Reference< XDispatchProvider>& xNewDispatchProvider) throw( RuntimeException ) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + m_xSlaveDispatcher = xNewDispatchProvider; + } + + //------------------------------------------------------------------------------ + Reference< XDispatchProvider> SAL_CALL DispatchInterceptionMultiplexer::getMasterDispatchProvider(void) throw( RuntimeException ) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + return m_xMasterDispatcher; + } + + //------------------------------------------------------------------------------ + void SAL_CALL DispatchInterceptionMultiplexer::setMasterDispatchProvider(const Reference< XDispatchProvider>& xNewSupplier) throw( RuntimeException ) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + m_xMasterDispatcher = xNewSupplier; + } + + //------------------------------------------------------------------------------ + void SAL_CALL DispatchInterceptionMultiplexer::disposing(const EventObject& Source) throw( RuntimeException ) + { + if (m_bListening) + { + Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); + if (Source.Source == xIntercepted) + ImplDetach(); + } + } + + //------------------------------------------------------------------------------ + void DispatchInterceptionMultiplexer::ImplDetach() + { + ::osl::MutexGuard aGuard( *m_pMutex ); + OSL_ENSURE(m_bListening, "DispatchInterceptionMultiplexer::ImplDetach: invalid call!"); + + // deregister ourself from the interception component + Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); + if (xIntercepted.is()) + xIntercepted->releaseDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this)); + + // m_xIntercepted = Reference< XDispatchProviderInterception >(); + // Don't reset m_xIntercepted: It may be needed by our owner to check for which object we were + // responsible. As we hold the object with a weak reference only, this should be no problem. + // 88936 - 23.07.2001 - frank.schoenheit@sun.com + m_pMaster = NULL; + m_pMutex = &m_aFallback; + m_bListening = sal_False; + } + + //------------------------------------------------------------------------------ + void DispatchInterceptionMultiplexer::disposing() + { + // remove ourself as event listener from the interception component + if (m_bListening) + { + Reference< XComponent> xInterceptedComponent(m_xIntercepted.get(), UNO_QUERY); + if (xInterceptedComponent.is()) + xInterceptedComponent->removeEventListener(static_cast<XEventListener*>(this)); + + // detach from the interception component + ImplDetach(); + } + } + +//........................................................................ +} // namespace svxform +//........................................................................ diff --git a/svx/source/form/fmdispatch.cxx b/svx/source/form/formfeaturedispatcher.cxx index 154063409bef..82ca17812562 100644 --- a/svx/source/form/fmdispatch.cxx +++ b/svx/source/form/formfeaturedispatcher.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmdispatch.cxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -30,8 +27,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "fmdispatch.hxx" -#include "formcontrolling.hxx" + +#include "formfeaturedispatcher.hxx" + +#include <comphelper/namedvaluecollection.hxx> +#include <tools/diagnose_ex.h> //........................................................................ namespace svx @@ -49,13 +49,13 @@ namespace svx //= OSingleFeatureDispatcher //==================================================================== //-------------------------------------------------------------------- - OSingleFeatureDispatcher::OSingleFeatureDispatcher( const URL& _rFeatureURL, sal_Int32 _nFeatureId, - const FormControllerHelper& _rController, ::osl::Mutex& _rMutex ) + OSingleFeatureDispatcher::OSingleFeatureDispatcher( const URL& _rFeatureURL, const sal_Int16 _nFormFeature, + const Reference< XFormOperations >& _rxFormOperations, ::osl::Mutex& _rMutex ) :m_rMutex( _rMutex ) ,m_aStatusListeners( _rMutex ) - ,m_rController( _rController ) + ,m_xFormOperations( _rxFormOperations ) ,m_aFeatureURL( _rFeatureURL ) - ,m_nFeatureId( _nFeatureId ) + ,m_nFormFeature( _nFormFeature ) ,m_bLastKnownEnabled( sal_False ) ,m_bDisposed( sal_False ) { @@ -82,10 +82,9 @@ namespace svx //-------------------------------------------------------------------- void OSingleFeatureDispatcher::getUnoState( FeatureStateEvent& /* [out] */ _rState ) const { - FeatureState aState; _rState.Source = *const_cast< OSingleFeatureDispatcher* >( this ); - m_rController.getState( m_nFeatureId, aState ); + FeatureState aState( m_xFormOperations->getState( m_nFormFeature ) ); _rState.FeatureURL = m_aFeatureURL; _rState.IsEnabled = aState.Enabled; @@ -161,21 +160,34 @@ namespace svx OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::dispatch: not responsible for this URL!" ); (void)_rURL; - if ( m_rController.isEnabled( m_nFeatureId ) ) - { - // release our mutex before executing the slot? - sal_Int32 nFeatureId( m_nFeatureId ); - aGuard.clear(); + if ( !m_xFormOperations->isEnabled( m_nFormFeature ) ) + return; + // release our mutex before executing the command + sal_Int16 nFormFeature( m_nFormFeature ); + Reference< XFormOperations > xFormOperations( m_xFormOperations ); + aGuard.clear(); + + try + { if ( !_rArguments.getLength() ) { - m_rController.execute( nFeatureId ); + xFormOperations->execute( nFormFeature ); } else { // at the moment we only support one parameter - m_rController.execute( nFeatureId, _rArguments[0].Name, _rArguments[0].Value ); + ::comphelper::NamedValueCollection aArgs( _rArguments ); + xFormOperations->executeWithArguments( nFormFeature, aArgs.getNamedValues() ); } } + catch( const RuntimeException& ) + { + throw; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //-------------------------------------------------------------------- diff --git a/svx/source/form/legacyformcontroller.cxx b/svx/source/form/legacyformcontroller.cxx new file mode 100644 index 000000000000..47805a8d6ee1 --- /dev/null +++ b/svx/source/form/legacyformcontroller.cxx @@ -0,0 +1,225 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ +
+// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "fmservs.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/form/XFormController.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/implbase2.hxx> + +//........................................................................ +namespace svxform +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::awt::XControl; + using ::com::sun::star::awt::XTabControllerModel; + using ::com::sun::star::awt::XControlContainer; + using ::com::sun::star::lang::XServiceInfo; + /** === end UNO using === **/ + + using namespace ::com::sun::star; + + //==================================================================== + //= LegacyFormController + //==================================================================== + typedef ::cppu::WeakImplHelper2 < form::XFormController + , XServiceInfo + > LegacyFormController_Base; + /** is an implementation of the legacy form controller service, namely css.form.FormController, supporting the + css.form.XFormController interface. + + This legacy API is superseded by css.form.runtime.(X)FormController, and though we migrated all OOo-internal + usage of this old API, their might be clients external to OOo still using it (though this is rather unlikely). + */ + class LegacyFormController : public LegacyFormController_Base + { + public: + static Reference< XInterface > Create( const Reference< XMultiServiceFactory >& _rxFactory ) + { + return *( new LegacyFormController( _rxFactory ) ); + } + + protected: + LegacyFormController( const Reference< XMultiServiceFactory >& _rxFactory ) + :m_xDelegator( _rxFactory->createInstance( FM_FORM_CONTROLLER ), UNO_QUERY_THROW ) + { + } + + // form::XFormController + virtual Reference< XControl > SAL_CALL getCurrentControl( ) throw (RuntimeException); + virtual void SAL_CALL addActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException); + virtual void SAL_CALL removeActivateListener( const Reference< form::XFormControllerListener >& l ) throw (RuntimeException); + + // awt::XTabController + virtual void SAL_CALL setModel( const Reference< XTabControllerModel >& Model ) throw (RuntimeException); + virtual Reference< XTabControllerModel > SAL_CALL getModel( ) throw (RuntimeException); + virtual void SAL_CALL setContainer( const Reference< XControlContainer >& Container ) throw (RuntimeException); + virtual Reference< XControlContainer > SAL_CALL getContainer( ) throw (RuntimeException); + virtual Sequence< Reference< XControl > > SAL_CALL getControls( ) throw (RuntimeException); + virtual void SAL_CALL autoTabOrder( ) throw (RuntimeException); + virtual void SAL_CALL activateTabOrder( ) throw (RuntimeException); + virtual void SAL_CALL activateFirst( ) throw (RuntimeException); + virtual void SAL_CALL activateLast( ) throw (RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); + virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + + private: + const Reference< form::runtime::XFormController > m_xDelegator; + }; + + //-------------------------------------------------------------------- + Reference< XControl > SAL_CALL LegacyFormController::getCurrentControl( ) throw (RuntimeException) + { + return m_xDelegator->getCurrentControl(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::addActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException) + { + m_xDelegator->addActivateListener( _listener ); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::removeActivateListener( const Reference< form::XFormControllerListener >& _listener ) throw (RuntimeException) + { + m_xDelegator->removeActivateListener( _listener ); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::setModel( const Reference< XTabControllerModel >& _model ) throw (RuntimeException) + { + m_xDelegator->setModel( _model ); + } + + //-------------------------------------------------------------------- + Reference< XTabControllerModel > SAL_CALL LegacyFormController::getModel( ) throw (RuntimeException) + { + return m_xDelegator->getModel(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::setContainer( const Reference< XControlContainer >& _container ) throw (RuntimeException) + { + m_xDelegator->setContainer( _container ); + } + + //-------------------------------------------------------------------- + Reference< XControlContainer > SAL_CALL LegacyFormController::getContainer( ) throw (RuntimeException) + { + return m_xDelegator->getContainer(); + } + + //-------------------------------------------------------------------- + Sequence< Reference< XControl > > SAL_CALL LegacyFormController::getControls( ) throw (RuntimeException) + { + return m_xDelegator->getControls(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::autoTabOrder( ) throw (RuntimeException) + { + m_xDelegator->autoTabOrder(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::activateTabOrder( ) throw (RuntimeException) + { + m_xDelegator->activateTabOrder(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::activateFirst( ) throw (RuntimeException) + { + m_xDelegator->activateFirst(); + } + + //-------------------------------------------------------------------- + void SAL_CALL LegacyFormController::activateLast( ) throw (RuntimeException) + { + m_xDelegator->activateLast(); + } + + //-------------------------------------------------------------------- + ::rtl::OUString SAL_CALL LegacyFormController::getImplementationName( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.svx.LegacyFormController" ) ); + } + + //-------------------------------------------------------------------- + ::sal_Bool SAL_CALL LegacyFormController::supportsService( const ::rtl::OUString& _serviceName ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aServices( getSupportedServiceNames() ); + const ::rtl::OUString* pServices = aServices.getConstArray(); + for ( sal_Int32 i = 0; i < aServices.getLength(); ++i, ++pServices ) + if( pServices->equals( _serviceName ) ) + return sal_True; + return sal_False; + } + + //-------------------------------------------------------------------- + Sequence< ::rtl::OUString > SAL_CALL LegacyFormController::getSupportedServiceNames( ) throw (RuntimeException) + { + Sequence< ::rtl::OUString > aServices(2); + aServices.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ); + aServices.getArray()[1] = ::rtl::OUString::createFromAscii("com.sun.star.awt.control.TabController"); + return aServices; + } + +//........................................................................ +} // namespace svxform +//........................................................................ + +//------------------------------------------------------------------ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + LegacyFormController_NewInstance_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ) +{ + return ::svxform::LegacyFormController::Create( _rxORB ); +} + diff --git a/svx/source/form/makefile.mk b/svx/source/form/makefile.mk index e5d8e15903fe..1ea5a3f71e5a 100644 --- a/svx/source/form/makefile.mk +++ b/svx/source/form/makefile.mk @@ -63,7 +63,6 @@ LIB1OBJFILES= \ $(SLO)$/fmtextcontrolshell.obj \ $(SLO)$/ParseContext.obj \ $(SLO)$/typeconversionclient.obj \ - $(SLO)$/confirmdelete.obj \ $(SLO)$/dbtoolsclient.obj \ $(SLO)$/sqlparserclient.obj \ $(SLO)$/dataaccessdescriptor.obj \ @@ -73,7 +72,7 @@ LIB1OBJFILES= \ $(SLO)$/navigatortree.obj \ $(SLO)$/navigatortreemodel.obj \ $(SLO)$/fmexpl.obj \ - $(SLO)$/fmctrler.obj \ + $(SLO)$/formcontroller.obj \ $(SLO)$/fmpgeimp.obj \ $(SLO)$/fmvwimp.obj \ $(SLO)$/fmdpage.obj \ @@ -89,14 +88,16 @@ LIB1OBJFILES= \ $(SLO)$/fmview.obj \ $(SLO)$/sdbdatacolumn.obj \ $(SLO)$/formcontrolling.obj \ - $(SLO)$/fmdispatch.obj \ + $(SLO)$/formfeaturedispatcher.obj \ + $(SLO)$/formdispatchinterceptor.obj \ $(SLO)$/datanavi.obj \ $(SLO)$/xfm_addcondition.obj \ $(SLO)$/datalistener.obj \ $(SLO)$/fmscriptingenv.obj \ $(SLO)$/stringlistresource.obj \ $(SLO)$/delayedevent.obj \ - $(SLO)$/formcontrolfactory.obj + $(SLO)$/formcontrolfactory.obj \ + $(SLO)$/legacyformcontroller.obj LIB2TARGET= $(SLB)$/$(TARGET).lib LIB2OBJFILES= \ diff --git a/svx/source/gengal/gengal.sh b/svx/source/gengal/gengal.sh index 0e9613da4df8..d6a9e3cbec94 100644 --- a/svx/source/gengal/gengal.sh +++ b/svx/source/gengal/gengal.sh @@ -80,11 +80,6 @@ case $sd_platform in export SHLIB_PATH ;; - IRIX*) - LD_LIBRARYN32_PATH=${sd_prog}${LD_LIBRARYN32_PATH+:${LD_LIBRARYN32_PATH}} - export LD_LIBRARYN32_PATH - ;; - *) LD_LIBRARY_PATH=${sd_prog}${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}} export LD_LIBRARY_PATH diff --git a/svx/source/inc/confirmdelete.hxx b/svx/source/inc/confirmdelete.hxx deleted file mode 100644 index a06e297a8748..000000000000 --- a/svx/source/inc/confirmdelete.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: confirmdelete.hxx,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef SVX_FORM_CONFIRMDELETE_HXX -#define SVX_FORM_CONFIRMDELETE_HXX - -#include <vcl/btndlg.hxx> -#include <vcl/fixed.hxx> - -//........................................................................ -namespace svxform -{ -//........................................................................ - - //==================================================================== - //= class ConfirmDeleteDialog - //==================================================================== - class ConfirmDeleteDialog : public ButtonDialog - { - FixedImage m_aInfoImage; - FixedText m_aTitle; - FixedText m_aMessage; - - public: - ConfirmDeleteDialog(Window* pParent, const String& _rTitle); - ~ConfirmDeleteDialog(); - }; - -//........................................................................ -} // namespace svxform -//........................................................................ - -#endif // SVX_FORM_CONFIRMDELETE_HXX - - diff --git a/svx/source/inc/delayedevent.hxx b/svx/source/inc/delayedevent.hxx index 151b998f2f8c..bd8194a00c82 100644 --- a/svx/source/inc/delayedevent.hxx +++ b/svx/source/inc/delayedevent.hxx @@ -5,10 +5,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * -* $RCSfile: delayedevent.hxx,v $ -* -* $Revision: 1.1.2.1 $ -* * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/filtnav.hxx b/svx/source/inc/filtnav.hxx index ce382a1986bc..ce845b7cdea0 100644 --- a/svx/source/inc/filtnav.hxx +++ b/svx/source/inc/filtnav.hxx @@ -30,10 +30,12 @@ #ifndef _SVX_FILTNAV_HXX #define _SVX_FILTNAV_HXX -#include <com/sun/star/awt/XTextComponent.hpp> #include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/form/runtime/XFilterController.hpp> #include <svl/lstner.hxx> #include <svl/brdcst.hxx> + #include <vcl/window.hxx> #include <sfx2/childwin.hxx> #include <svl/poolitem.hxx> @@ -93,8 +95,7 @@ public: class FmParentData : public FmFilterData { protected: - ::std::vector<FmFilterData*> m_aChilds; - + ::std::vector< FmFilterData* > m_aChildren; public: TYPEINFO(); @@ -103,28 +104,34 @@ public: {} virtual ~FmParentData(); - ::std::vector<FmFilterData*>& GetChilds() {return m_aChilds;} + ::std::vector< FmFilterData* >& GetChildren() { return m_aChildren; } }; //======================================================================== // Item representing the forms and subforms class FmFormItem : public FmParentData { - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > m_xController; - sal_Int32 m_nCurrent; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterController > m_xFilterController; public: TYPEINFO(); - FmFormItem(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory):FmParentData(_rxFactory,NULL, ::rtl::OUString()){} - FmFormItem(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmParentData* _pParent, - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & _xController, - const ::rtl::OUString& _rText):FmParentData(_rxFactory,_pParent, _rText) - ,m_xController(_xController) - ,m_nCurrent(0){} - - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & GetController(){return m_xController;} - void SetCurrentPosition(sal_Int32 nCurrent){m_nCurrent = nCurrent;} - sal_Int32 GetCurrentPosition() const {return m_nCurrent;} + + FmFormItem( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmParentData* _pParent, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & _xController, + const ::rtl::OUString& _rText) + :FmParentData( _rxFactory, _pParent, _rText ) + ,m_xController( _xController ) + ,m_xFilterController( _xController, ::com::sun::star::uno::UNO_QUERY_THROW ) + { + } + + inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& + GetController() { return m_xController; } + + inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterController >& + GetFilterController() { return m_xFilterController; } + virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const; }; @@ -136,26 +143,28 @@ public: FmFilterItems(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory):FmParentData(_rxFactory,NULL, ::rtl::OUString()){} FmFilterItems(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory,FmFormItem* pParent, const ::rtl::OUString& rText ):FmParentData(_rxFactory,pParent, rText){} - FmFilterItem* Find(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > & xText) const; + FmFilterItem* Find( const ::sal_Int32 _nFilterComponentIndex ) const; virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const; }; //======================================================================== class FmFilterItem : public FmFilterData { - ::rtl::OUString m_aFieldName; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > m_xText; + ::rtl::OUString m_aFieldName; + const sal_Int32 m_nComponentIndex; public: TYPEINFO(); - FmFilterItem(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory, - FmFilterItems* pParent, - const ::rtl::OUString& aFieldName, - const ::rtl::OUString& aCondition, - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > & xText); + FmFilterItem( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory, + FmFilterItems* pParent, + const ::rtl::OUString& aFieldName, + const ::rtl::OUString& aCondition, + const sal_Int32 _nComponentIndex + ); const ::rtl::OUString& GetFieldName() const {return m_aFieldName;} - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > & GetTextComponent() const {return m_xText;} + sal_Int32 GetComponentIndex() const { return m_nComponentIndex; } virtual Image GetImage( BmpColorMode _eMode = BMP_COLOR_NORMAL ) const; }; @@ -167,9 +176,9 @@ class FmFilterModel : public FmParentData { friend class FmFilterAdapter; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xControllers; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > m_xController; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xControllers; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xController; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; FmFilterAdapter* m_pAdapter; FmFilterItems* m_pCurrentItems; @@ -178,7 +187,7 @@ public: FmFilterModel(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory); virtual ~FmFilterModel(); - void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & xCurrent); + void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent); void Clear(); sal_Bool ValidateText(FmFilterItem* pItem, UniString& rText, UniString& rErrorMsg) const; void Append(FmFilterItems* pItems, FmFilterItem* pFilterItem); @@ -190,17 +199,17 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getORB() const { return m_xORB; } const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & GetControllers() const {return m_xControllers;} - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & GetCurrentController() const {return m_xController;} - void SetCurrentController(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & xController); + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & GetCurrentController() const {return m_xController;} + void SetCurrentController(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController); void Remove(FmFilterData* pFilterItem); - void AppendFilterItems(FmFormItem* pItem); - void CheckIntegrity(FmParentData* pItem); + void AppendFilterItems( FmFormItem& _rItem ); + void EnsureEmptyFilterRows( FmParentData& _rItem ); protected: void Insert(const ::std::vector<FmFilterData*>::iterator& rPos, FmFilterData* pFilterItem); - void Remove(const ::std::vector<FmFilterData*>::iterator& rPos, FmFilterData* pFilterItem); - FmFormItem* Find(const ::std::vector<FmFilterData*>& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & xController) const; + void Remove( const ::std::vector<FmFilterData*>::iterator& rPos ); + FmFormItem* Find(const ::std::vector<FmFilterData*>& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xController) const; FmFormItem* Find(const ::std::vector<FmFilterData*>& rItems, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm) const; void Update(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, FmParentData* pParent); }; @@ -267,7 +276,10 @@ public: FmFilterNavigator( Window* pParent ); virtual ~FmFilterNavigator(); - void UpdateContent(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > & xCurrent); + void UpdateContent( + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > & xControllers, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > & xCurrent + ); const FmFilterModel* GetFilterModel() const {return m_pModel;} protected: diff --git a/svx/source/inc/fmPropBrw.hxx b/svx/source/inc/fmPropBrw.hxx index 70072a0fe7de..cb35b2534043 100644 --- a/svx/source/inc/fmPropBrw.hxx +++ b/svx/source/inc/fmPropBrw.hxx @@ -37,6 +37,7 @@ #include <com/sun/star/inspection/XObjectInspectorModel.hpp> #include <com/sun/star/uno/XComponentContext.hpp> /** === end UNO includes === **/ + #include <sfx2/basedlgs.hxx> #include <sfx2/ctrlitem.hxx> #include <sfx2/childwin.hxx> diff --git a/svx/source/inc/fmcontrolbordermanager.hxx b/svx/source/inc/fmcontrolbordermanager.hxx index c08907026585..a9e605873940 100644 --- a/svx/source/inc/fmcontrolbordermanager.hxx +++ b/svx/source/inc/fmcontrolbordermanager.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrolbordermanager.hxx,v $ - * $Revision: 1.6 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -132,7 +129,7 @@ namespace svxform //==================================================================== /** manages the dynamic border color for form controls - Used by the <type>FmXFormController</type>, this class manages the dynamic changes in the + Used by the <type>FormController</type>, this class manages the dynamic changes in the border color of form controls. For this a set of events have to be forwarded to the manager instance, which then will switch the border color depending on the mouse and focus status of the controls. diff --git a/svx/source/inc/fmcontrollayout.hxx b/svx/source/inc/fmcontrollayout.hxx index c5abe43f3228..4522cf352382 100644 --- a/svx/source/inc/fmcontrollayout.hxx +++ b/svx/source/inc/fmcontrollayout.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrollayout.hxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/fmctrler.hxx b/svx/source/inc/fmctrler.hxx deleted file mode 100644 index 060f1fdb04db..000000000000 --- a/svx/source/inc/fmctrler.hxx +++ /dev/null @@ -1,617 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: fmctrler.hxx,v $ - * $Revision: 1.24 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SVX_FMCTRLER_HXX -#define _SVX_FMCTRLER_HXX - -#include "svx/fmtools.hxx" -#include "formcontrolling.hxx" -#include "sqlparserclient.hxx" -#include "delayedevent.hxx" - -/** === begin UNO includes === **/ -#include <com/sun/star/awt/XControl.hpp> -#include <com/sun/star/awt/XControlContainer.hpp> -#include <com/sun/star/awt/XControlModel.hpp> -#include <com/sun/star/awt/XFocusListener.hpp> -#include <com/sun/star/awt/XItemListener.hpp> -#include <com/sun/star/awt/XMouseListener.hpp> -#include <com/sun/star/awt/XTabController.hpp> -#include <com/sun/star/awt/XTabControllerModel.hpp> -#include <com/sun/star/awt/XTextComponent.hpp> -#include <com/sun/star/awt/XTextListener.hpp> -#include <com/sun/star/beans/PropertyChangeEvent.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/XPropertyChangeListener.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/XPropertySetInfo.hpp> -#include <com/sun/star/container/ContainerEvent.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/container/XContainer.hpp> -#include <com/sun/star/container/XContainerListener.hpp> -#include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/container/XIndexContainer.hpp> -#include <com/sun/star/form/DatabaseDeleteEvent.hpp> -#include <com/sun/star/form/DatabaseParameterEvent.hpp> -#include <com/sun/star/form/ErrorEvent.hpp> -#include <com/sun/star/form/validation/XFormComponentValidityListener.hpp> -#include <com/sun/star/form/XConfirmDeleteBroadcaster.hpp> -#include <com/sun/star/form/XConfirmDeleteListener.hpp> -#include <com/sun/star/form/XDatabaseParameterBroadcaster2.hpp> -#include <com/sun/star/form/XDatabaseParameterListener.hpp> -#include <com/sun/star/form/XFormController.hpp> -#include <com/sun/star/form/XFormControllerListener.hpp> -#include <com/sun/star/form/XGridControlListener.hpp> -#include <com/sun/star/form/XLoadListener.hpp> -#include <com/sun/star/form/XResetListener.hpp> -#include <com/sun/star/frame/DispatchDescriptor.hpp> -#include <com/sun/star/frame/XDispatch.hpp> -#include <com/sun/star/frame/XDispatchProvider.hpp> -#include <com/sun/star/frame/XDispatchProviderInterception.hpp> -#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <com/sun/star/script/XEventAttacherManager.hpp> -#include <com/sun/star/sdb/XRowSetApproveBroadcaster.hpp> -#include <com/sun/star/sdb/XRowSetApproveListener.hpp> -#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> -#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp> -#include <com/sun/star/sdb/XSQLErrorListener.hpp> -#include <com/sun/star/sdbc/XRowSetListener.hpp> -#include <com/sun/star/task/XInteractionHandler.hpp> -#include <com/sun/star/util/XModeSelector.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> -#include <com/sun/star/util/XModifyListener.hpp> -/** === end UNO includes === **/ - -#include <comphelper/broadcasthelper.hxx> -#include <comphelper/proparrhlp.hxx> -#include <comphelper/stl_types.hxx> -#include <connectivity/sqlparse.hxx> -#include <cppuhelper/propshlp.hxx> -#include <tools/debug.hxx> -#include <vcl/timer.hxx> - -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_31) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_31 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 31 -#include <comphelper/implbase_var.hxx> -#endif - -struct FmXTextComponentLess : public ::std::binary_function< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent> , sal_Bool> -{ - sal_Bool operator() (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& x, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& y) const - { - return reinterpret_cast<sal_Int64>(x.get()) < reinterpret_cast<sal_Int64>(y.get()); - } -}; - -typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, FmXTextComponentLess> FmFilterControls; -typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::rtl::OUString, FmXTextComponentLess> FmFilterRow; -typedef ::std::vector< FmFilterRow > FmFilterRows; -typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > > FmFormControllers; - -struct FmFieldInfo; -class FmFormView; -class Window; - -namespace svxform -{ - class ControlBorderManager; -} - -typedef ::comphelper::WeakComponentImplHelper31 < ::com::sun::star::form::XFormController - , ::com::sun::star::container::XChild - , ::com::sun::star::container::XIndexAccess - , ::com::sun::star::container::XEnumerationAccess - , ::com::sun::star::awt::XFocusListener - , ::com::sun::star::form::XLoadListener - , ::com::sun::star::beans::XPropertyChangeListener - , ::com::sun::star::awt::XTextListener - , ::com::sun::star::awt::XItemListener - , ::com::sun::star::container::XContainerListener - , ::com::sun::star::util::XModifyListener - , ::com::sun::star::util::XModifyBroadcaster - , ::com::sun::star::util::XModeSelector - , ::com::sun::star::form::XConfirmDeleteListener - , ::com::sun::star::form::XConfirmDeleteBroadcaster - , ::com::sun::star::sdb::XSQLErrorListener - , ::com::sun::star::sdb::XSQLErrorBroadcaster - , ::com::sun::star::sdbc::XRowSetListener - , ::com::sun::star::sdb::XRowSetApproveListener - , ::com::sun::star::sdb::XRowSetApproveBroadcaster - , ::com::sun::star::form::XDatabaseParameterListener - , ::com::sun::star::form::XDatabaseParameterBroadcaster - , ::com::sun::star::lang::XServiceInfo - , ::com::sun::star::form::XResetListener - , ::com::sun::star::lang::XUnoTunnel - , ::com::sun::star::frame::XDispatch - , ::com::sun::star::awt::XMouseListener - , ::com::sun::star::form::validation::XFormComponentValidityListener - , ::com::sun::star::task::XInteractionHandler - , ::com::sun::star::lang::XInitialization - , ::com::sun::star::form::XGridControlListener - > FmXFormController_BASE; - -//================================================================== -// FmXFormController -//================================================================== -class ColumnInfoCache; -class SAL_DLLPRIVATE FmXFormController :public ::comphelper::OBaseMutex - ,public FmXFormController_BASE - ,public ::cppu::OPropertySetHelper - ,public FmDispatchInterceptor - ,public ::comphelper::OAggregationArrayUsageHelper< FmXFormController > - ,public ::svxform::OSQLParserClient - ,public ::svx::IControllerFeatureInvalidation -{ - typedef ::std::map < sal_Int32, - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > - > DispatcherContainer; - - friend class FmXPageViewWinRec; - - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController> m_xTabController; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> m_xActiveControl, m_xCurrentControl; - ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xModelAsIndex; - ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacherManager> m_xModelAsManager; - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; - // Composer used for checking filter conditions - ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer; - ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInteractionHandler; - - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > m_aControls; - ::cppu::OInterfaceContainerHelper - m_aActivateListeners, - m_aModifyListeners, - m_aErrorListeners, - m_aDeleteListeners, - m_aRowSetApproveListeners, - m_aParameterListeners; - - FmFormControllers m_aChilds; - FmFilterControls m_aFilterControls; - FmFilterRows m_aFilters; - - Timer m_aTabActivationTimer; - Timer m_aFeatureInvalidationTimer; - - FmFormView* m_pView; - Window* m_pWindow; - ::svxform::ControlBorderManager* - m_pControlBorderManager; - - ::svx::ControllerFeatures m_aControllerFeatures; - DispatcherContainer m_aFeatureDispatchers; - ::std::set< sal_Int32 > m_aInvalidFeatures; // for asynchronous feature invalidation - - ::rtl::OUString m_aMode; - - ::svxform::DelayedEvent m_aLoadEvent; - ::svxform::DelayedEvent m_aToggleEvent; - ::svxform::DelayedEvent m_aActivationEvent; - ::svxform::DelayedEvent m_aDeactivationEvent; - - ::std::auto_ptr< ColumnInfoCache > - m_pColumnInfoCache; - - sal_Int32 m_nCurrentFilterPosition; // current level for filtering (or-criteria) - - sal_Bool m_bCurrentRecordModified : 1; - sal_Bool m_bCurrentRecordNew : 1; - sal_Bool m_bLocked : 1; - sal_Bool m_bDBConnection : 1; // Focuslistener nur fuer Datenbankformulare - sal_Bool m_bCycle : 1; - sal_Bool m_bCanInsert : 1; - sal_Bool m_bCanUpdate : 1; - sal_Bool m_bCommitLock : 1; // lock the committing of controls see focusGained - sal_Bool m_bModified : 1; // ist der Inhalt eines Controls modifiziert ? - sal_Bool m_bControlsSorted : 1; - sal_Bool m_bFiltering : 1; - sal_Bool m_bAttachEvents : 1; - sal_Bool m_bDetachEvents : 1; - sal_Bool m_bAttemptedHandlerCreation : 1; - - // as we want to intercept dispatches of _all_ controls we're responsible for, and an object implementing - // the ::com::sun::star::frame::XDispatchProviderInterceptor interface can intercept only _one_ objects dispatches, we need a helper class - DECLARE_STL_VECTOR(FmXDispatchInterceptorImpl*, Interceptors); - Interceptors m_aControlDispatchInterceptors; - -public: - inline const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& - getInteractionHandler() const - { - const_cast< FmXFormController* >( this )->ensureInteractionHandler(); - return m_xInteractionHandler; - } - -public: - FmXFormController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB, - FmFormView* _pView = NULL, Window* _pWindow = NULL ); - ~FmXFormController(); - -// XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL acquire() throw (); - virtual void SAL_CALL release() throw (); - -// XTypeProvider - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - -// XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId(); - SVX_DLLPUBLIC static FmXFormController* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent ); - -// XDispatch - virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); - -// ::com::sun::star::container::XChild - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL getParent(void) throw( ::com::sun::star::uno::RuntimeException ) {return m_xParent;} - virtual void SAL_CALL setParent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Parent) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ) - {m_xParent = Parent;} - -// ::com::sun::star::lang::XEventListener - virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ); - -// OComponentHelper - virtual void SAL_CALL disposing(); - -// OPropertySetHelper - virtual sal_Bool SAL_CALL convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, - sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) - throw( ::com::sun::star::lang::IllegalArgumentException ); - - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw( ::com::sun::star::uno::Exception ); - virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException ); - virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - - using OPropertySetHelper::getFastPropertyValue; - -// XElementAccess - virtual ::com::sun::star::uno::Type SAL_CALL getElementType(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL hasElements(void) throw( ::com::sun::star::uno::RuntimeException ); - -// ::com::sun::star::container::XEnumerationAccess - virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration> SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); - -// ::com::sun::star::container::XContainerListener - virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - -// XLoadListener - virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - -// XModeSelector - virtual void SAL_CALL setMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ); - virtual ::rtl::OUString SAL_CALL getMode(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedModes(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL supportsMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::uno::RuntimeException ); - -// ::com::sun::star::container::XIndexAccess - virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 Index) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - -// XModifyBroadcaster - virtual void SAL_CALL addModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); - -// XFocusListener - virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); - -// XMouseListener - virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); - -// XFormComponentValidityListener - virtual void SAL_CALL componentValidityChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); - -// XInteractionHandler - virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException); - -// XInitialization - 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); - -// XGridControlListener - virtual void SAL_CALL columnChanged( const ::com::sun::star::lang::EventObject& _event ) throw (::com::sun::star::uno::RuntimeException); - -// ::com::sun::star::beans::XPropertyChangeListener -> aenderung der stati - virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException ); - -// XTextListener -> modify setzen - virtual void SAL_CALL textChanged(const ::com::sun::star::awt::TextEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - -// XItemListener -> modify setzen - virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - -// XModifyListener -> modify setzen - virtual void SAL_CALL modified(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - -// XFormController - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); - -// XTabController - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > SAL_CALL getControls(void) throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel>& Model) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel> SAL_CALL getModel() throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL setContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer>& Container) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer> SAL_CALL getContainer() throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL autoTabOrder() throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL activateTabOrder() throw( ::com::sun::star::uno::RuntimeException ); - - virtual void SAL_CALL activateFirst() throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL activateLast() throw( ::com::sun::star::uno::RuntimeException ); - -// com::sun::star::sdbc::XRowSetListener - virtual void SAL_CALL cursorMoved(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL rowChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL rowSetChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - -// XRowSetApproveListener - virtual sal_Bool SAL_CALL approveCursorMove(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL approveRowChange(const ::com::sun::star::sdb::RowChangeEvent& event) throw( ::com::sun::star::uno::RuntimeException ); - virtual sal_Bool SAL_CALL approveRowSetChange(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); - -// XRowSetApproveBroadcaster - virtual void SAL_CALL addRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); - -// XSQLErrorBroadcaster - virtual void SAL_CALL errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - -// XSQLErrorListener - virtual void SAL_CALL addSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); - -// XDatabaseParameterBroadcaster2 - virtual void SAL_CALL addDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - -// XDatabaseParameterBroadcaster - virtual void SAL_CALL addParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - -// XDatabaseParameterListener - virtual sal_Bool SAL_CALL approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - -// XConfirmDeleteBroadcaster - virtual void SAL_CALL addConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL removeConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); - -// XConfirmDeleteListener - virtual sal_Bool SAL_CALL confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); - -// XServiceInfo - virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw(::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw(::com::sun::star::uno::RuntimeException); - -// XResetListener - virtual sal_Bool SAL_CALL approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - virtual void SAL_CALL resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - -// method for registration - static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void); - - // comphelper::OPropertyArrayUsageHelper - virtual void fillProperties( - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps - ) const; - -// access to the controls for filtering - const FmFilterControls& getFilterControls() const {return m_aFilterControls;} - -// access to the current filter rows - const FmFilterRows& getFilterRows() const {return m_aFilters;} - FmFilterRows& getFilterRows() {return m_aFilters;} - - // just decr. the positions no notifications for the view - void decrementCurrentFilterPosition() - { - DBG_ASSERT(m_nCurrentFilterPosition, "Invalid Position"); - --m_nCurrentFilterPosition; - } - - SVX_DLLPUBLIC void setCurrentFilterPosition(sal_Int32 nPos); - sal_Int32 getCurrentFilterPosition() const {return m_nCurrentFilterPosition;} - -protected: - // FmDispatchInterceptor - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> - interceptedQueryDispatch(sal_uInt16 _nId,const ::com::sun::star::util::URL& aURL, - const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) - throw( ::com::sun::star::uno::RuntimeException ); - - // IControllerFeatureInvalidation - virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ); - - virtual ::osl::Mutex* getInterceptorMutex() { return &m_aMutex; } - - /// update all our dispatchers - void updateAllDispatchers() const; - - /** disposes all dispatchers in m_aFeatureDispatchers, empties m_aFeatureDispatchers, - and disposes m_aControllerFeatures - */ - void disposeAllFeaturesAndDispatchers() SAL_THROW(()); - - void startFiltering(); - void stopFiltering(); - void setFilter(::std::vector<FmFieldInfo>&); - void startListening(); - void stopListening(); - - /** ensures that we have an interaction handler, if possible - - If an interaction handler was provided at creation time (<member>initialize</member>), this - one will be used. Else, an attempt is made to create an <type scope="com::sun::star::sdb">InteractionHandler</type> - is made. - - @return <TRUE/> - if and only if <member>m_xInteractionHandler</member> is valid when the method returns - */ - bool ensureInteractionHandler(); - - /** replaces one of our controls with another one - - Upon successful replacing, the old control will be disposed. Also, internal members pointing - to the current or active control will be adjusted. Yet more, if the replaced control was - the active control, the new control will be made active. - - @param _rxExistentControl - The control to replace. Must be one of the controls in our ControlContainer. - @param _rxNewControl - The control which should replace the existent control. - @return - <TRUE/> if and only if the control was successfully replaced - */ - bool replaceControl( - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxExistentControl, - const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxNewControl - ); - - // we're listening at all bound controls for modifications - void startControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void stopControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - - void setLocks(); - void setControlLock(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void addToEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void removeFromEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void toggleAutoFields(sal_Bool bAutoFields); - void unload() throw( ::com::sun::star::uno::RuntimeException ); - void removeBoundFieldListener(); - - void startFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); - void stopFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); - - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> findControl( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> >& rCtrls, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& rxCtrlModel, sal_Bool _bRemove, sal_Bool _bOverWrite ) const; - - void insertControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - void removeControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); - - /// called when a new control is to be handled by the controller - void implControlInserted( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bAddToEventAttacher ); - /// called when a control is not to be handled by the controller anymore - void implControlRemoved( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bRemoveFromEventAttacher ); - - /** sets m_xCurrentControl, plus does administrative tasks depending on it - */ - void implSetCurrentControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); - - /** invalidates the FormFeatures which depend on the current control - */ - void implInvalidateCurrentControlDependentFeatures(); - - bool impl_isDisposed_nofail() const { return FmXFormController_BASE::rBHelper.bDisposed; } - - void impl_onModify(); - - sal_Bool isLocked() const {return m_bLocked;} - sal_Bool determineLockState() const; - - Window* getDialogParentWindow(); - // returns m_pWindow or - if m_pWindow is NULL - the window of the currently set container - - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor> createInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); - // create a new interceptor, register it on the given object - void deleteInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); - // if createInterceptor was called for the given object the according interceptor will be removed - // from the objects interceptor chain and released - - /** checks all form controls belonging to our form for validity - - If a form control supports the XValidatableFormComponent interface, this is used to determine - the validity of the control. If the interface is not supported, the control is supposed to be - valid. - - @param _rFirstInvalidityExplanation - if the method returns <FALSE/> (i.e. if there is an invalid control), this string contains - the explanation for the invalidity, as obtained from the validator. - - @param _rxFirstInvalidModel - if the method returns <FALSE/> (i.e. if there is an invalid control), this contains - the control model - - @return - <TRUE/> if and only if all controls belonging to our form are valid - */ - bool checkFormComponentValidity( - ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& /* [out] */ _rxFirstInvalidModel - ) SAL_THROW(()); - - /** locates the control which belongs to a given model - */ - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > - locateControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ) SAL_THROW(()); - - // set the text for all filters - void impl_setTextOnAllFilter_throw(); - - // in filter mode we do not listen for changes - sal_Bool isListeningForChanges() const {return m_bDBConnection && !m_bFiltering && !isLocked();} - void addChild(FmXFormController* pChild); - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> isInList(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& xPeer) const; - - DECL_LINK( OnActivateTabOrder, void* ); - DECL_LINK( OnInvalidateFeatures, void* ); - DECL_LINK( OnLoad, void* ); - DECL_LINK( OnToggleAutoFields, void* ); - DECL_LINK( OnActivated, void* ); - DECL_LINK( OnDeactivated, void* ); -}; - - -#endif // _SVX_FMCTRLER_HXX - diff --git a/svx/source/inc/fmexpl.hxx b/svx/source/inc/fmexpl.hxx index 6f2ced3c98ca..8d01b6c01907 100644 --- a/svx/source/inc/fmexpl.hxx +++ b/svx/source/inc/fmexpl.hxx @@ -39,12 +39,17 @@ #include <sfx2/dockwin.hxx> #include <sfx2/ctrlitem.hxx> #include <vcl/image.hxx> + +/** === begin UNO includes === **/ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/form/XForm.hpp> #include <com/sun/star/form/XFormComponent.hpp> #include <com/sun/star/beans/PropertyChangeEvent.hpp> #include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/beans/XPropertyChangeListener.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +/** === end UNO includes === **/ #include <svtools/svtreebx.hxx> @@ -57,7 +62,6 @@ #include <svx/fmview.hxx> #include "fmexch.hxx" -#include "svx/fmtools.hxx" class SdrObjListIter; class FmFormShell; diff --git a/svx/source/inc/fmservs.hxx b/svx/source/inc/fmservs.hxx index 201a5a351224..62d9654858a3 100644 --- a/svx/source/inc/fmservs.hxx +++ b/svx/source/inc/fmservs.hxx @@ -57,7 +57,7 @@ #define FM_COMPONENT_IMAGECONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.component.ImageControl" ) ) #define FM_CONTROL_GRID rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.control.Grid" ) ) #define FM_CONTROL_GRIDCONTROL rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "stardiv.one.form.control.GridControl" ) ) -#define FM_FORM_CONTROLLER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ) +#define FM_FORM_CONTROLLER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.runtime.FormController" ) ) #define SRV_SDB_CONNECTION rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.Connection" ) ) #define SRV_SDB_INTERACTION_HANDLER rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.InteractionHandler" ) ) #define FM_SUN_COMPONENT_FORM rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.component.Form" ) ) diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx index 89c384dd2648..35a00ccf7427 100644 --- a/svx/source/inc/fmshimp.hxx +++ b/svx/source/inc/fmshimp.hxx @@ -40,7 +40,7 @@ #include <com/sun/star/awt/XControlContainer.hpp> #include <com/sun/star/util/XModifyListener.hpp> #include <com/sun/star/form/XForm.hpp> -#include <com/sun/star/form/XFormController.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> #include <com/sun/star/form/XFormComponent.hpp> #include <com/sun/star/form/NavigationBarMode.hpp> #include <com/sun/star/frame/XFrame.hpp> @@ -243,9 +243,9 @@ class SAL_DLLPRIVATE FmXFormShell :public FmXFormShell_BASE // aktuelle Form, Controller // nur im alive mode verfuegbar - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController> m_xActiveController; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController> m_xNavigationController; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> m_xActiveForm; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xActiveController; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xNavigationController; + ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > m_xActiveForm; // Aktueller container einer Page // nur im designmode verfuegbar @@ -266,11 +266,9 @@ class SAL_DLLPRIVATE FmXFormShell :public FmXFormShell_BASE // the frame we live in ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame> m_xAttachedFrame; // Administration of external form views (see the SID_FM_VIEW_AS_GRID-slot) - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController> m_xExternalViewController; // the controller for the external form view - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController> m_xExtViewTriggerController; // the nav controller at the time the external display was triggered - ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> m_xExternalDisplayedForm; // the form which the external view is based on - - FmXDispatchInterceptorImpl* m_pExternalViewInterceptor; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xExternalViewController; // the controller for the external form view + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xExtViewTriggerController; // the nav controller at the time the external display was triggered + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xExternalDisplayedForm; // the form which the external view is based on mutable ::svxform::DocumentType m_eDocumentType; /// the type of document we're living in @@ -399,11 +397,11 @@ protected: public: // methode fuer nicht designmode (alive mode) - void setActiveController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& _xController, sal_Bool _bNoSaveOldContent = sal_False ); - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& getActiveController() const {return m_xActiveController;} - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& getActiveInternalController() const { return m_xActiveController == m_xExternalViewController ? m_xExtViewTriggerController : m_xActiveController; } + void setActiveController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& _xController, sal_Bool _bNoSaveOldContent = sal_False ); + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getActiveController() const {return m_xActiveController;} + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getActiveInternalController() const { return m_xActiveController == m_xExternalViewController ? m_xExtViewTriggerController : m_xActiveController; } const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& getActiveForm() const {return m_xActiveForm;} - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& getNavController() const {return m_xNavigationController;} + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& getNavController() const {return m_xNavigationController;} inline const ::svx::ControllerFeatures& getActiveControllerFeatures() const { return m_aActiveControllerFeatures; } @@ -569,13 +567,13 @@ private: public: enum CURSOR_ACTION { CA_MOVE_TO_LAST, CA_MOVE_ABSOLUTE }; - void DoAsyncCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& _xController, CURSOR_ACTION _eWhat); + void DoAsyncCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& _xController, CURSOR_ACTION _eWhat); void DoAsyncCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xForm, CURSOR_ACTION _eWhat); sal_Bool HasAnyPendingCursorAction() const; void CancelAnyPendingCursorAction(); - sal_Bool HasPendingCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController>& _xController) const; + sal_Bool HasPendingCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& _xController) const; sal_Bool HasPendingCursorAction(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet>& _xForm) const; /** execute the given form slot diff --git a/svx/source/inc/fmsrcimp.hxx b/svx/source/inc/fmsrcimp.hxx index 0d6acf4f2909..0ede7660d2e4 100644 --- a/svx/source/inc/fmsrcimp.hxx +++ b/svx/source/inc/fmsrcimp.hxx @@ -32,18 +32,27 @@ #define _FMSRCIMP_HXX #include <svx/fmtools.hxx> -#include <vos/thread.hxx> -#include <osl/mutex.hxx> -#include <com/sun/star/awt/XTextComponent.hpp> +#include "svx/svxdllapi.h" + +/** === begin UNO includes === **/ #include <com/sun/star/awt/XCheckBox.hpp> #include <com/sun/star/awt/XListBox.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/util/XNumberFormatter.hpp> +/** === end UNO includes === **/ + #include <comphelper/stl_types.hxx> #include <cppuhelper/implbase1.hxx> +#include <osl/mutex.hxx> #include <unotools/charclass.hxx> #include <unotools/collatorwrapper.hxx> -#include "svx/svxdllapi.h" +#include <vos/thread.hxx> + +#ifndef _SVSTDARR_ULONGS +#define _SVSTDARR_ULONGS +#include <svl/svstdarr.hxx> +#endif // =================================================================================================== // Hilfsstrukturen diff --git a/svx/source/inc/fmtextcontrolshell.hxx b/svx/source/inc/fmtextcontrolshell.hxx index 17ba06d5513b..a67520f89ed8 100644 --- a/svx/source/inc/fmtextcontrolshell.hxx +++ b/svx/source/inc/fmtextcontrolshell.hxx @@ -36,7 +36,7 @@ #include <com/sun/star/frame/XStatusListener.hpp> #include <com/sun/star/awt/XFocusListener.hpp> #include <com/sun/star/awt/XMouseListener.hpp> -#include <com/sun/star/form/XFormController.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> #include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/util/XURLTransformer.hpp> /** === end UNO includes === **/ @@ -92,10 +92,10 @@ namespace svx ,public IContextRequestObserver { private: - ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > m_xActiveControl; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > m_xActiveTextComponent; - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > m_xActiveController; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > m_xActiveControl; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > m_xActiveTextComponent; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xActiveController; #ifndef DONT_REMEMBER_LAST_CONTROL // without this define, m_xActiveControl remembers the *last* active control, even // if it, in the meantime, already lost the focus @@ -144,10 +144,10 @@ namespace svx /** to be called when a form in our document has been activated */ - void formActivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController ); + void formActivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController ); /** to be called when a form in our document has been deactivated */ - void formDeactivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController ); + void formDeactivated( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController ); /** notifies the instance that the design mode has changed */ @@ -205,7 +205,7 @@ namespace svx @precond we don't have an active controller currently */ - void startControllerListening( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController ); + void startControllerListening( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController ); /** stops listening at the active controller @precond we have an active controller currently diff --git a/svx/source/inc/fmvwimp.hxx b/svx/source/inc/fmvwimp.hxx index 12965c07ad3b..c51c935883ed 100644 --- a/svx/source/inc/fmvwimp.hxx +++ b/svx/source/inc/fmvwimp.hxx @@ -37,7 +37,8 @@ #include <com/sun/star/form/XForm.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XEnumeration.hpp> -#include <com/sun/star/form/XFormController.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/form/runtime/XFormControllerContext.hpp> #include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/container/ContainerEvent.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -49,7 +50,7 @@ #include <comphelper/stl_types.hxx> #include <tools/link.hxx> #include <tools/string.hxx> -#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase3.hxx> #include <comphelper/uno3.hxx> #include <comphelper/componentcontext.hxx> @@ -73,7 +74,6 @@ FORWARD_DECLARE_INTERFACE(awt,XWindow) FORWARD_DECLARE_INTERFACE(beans,XPropertySet) FORWARD_DECLARE_INTERFACE(util,XNumberFormats) -class FmXFormController; class FmXFormView; namespace svx { @@ -84,41 +84,49 @@ namespace svx { //================================================================== // FmXPageViewWinRec //================================================================== -class FmXPageViewWinRec : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XIndexAccess> +typedef ::cppu::WeakImplHelper2 < ::com::sun::star::container::XIndexAccess + , ::com::sun::star::form::runtime::XFormControllerContext + > FmXPageViewWinRec_Base; + +class FmXPageViewWinRec : public FmXPageViewWinRec_Base { friend class FmXFormView; - ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > > m_aControllerList; - ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xControlContainer; - ::comphelper::ComponentContext m_aContext; + ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > m_aControllerList; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > m_xControlContainer; + ::comphelper::ComponentContext m_aContext; FmXFormView* m_pViewImpl; Window* m_pWindow; +protected: + ~FmXPageViewWinRec(); + public: FmXPageViewWinRec( const ::comphelper::ComponentContext& _rContext, const SdrPageWindow&, FmXFormView* pView); //const SdrPageViewWinRec*, FmXFormView* pView); - ~FmXPageViewWinRec(); - -// UNO Anbindung -// ::com::sun::star::container::XElementAccess + // XElementAccess virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); -// ::com::sun::star::container::XEnumerationAccess + // XEnumerationAccess virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException); -// ::com::sun::star::container::XIndexAccess + // XIndexAccess virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 _Index) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > >& GetList() {return m_aControllerList;} + // XFormControllerContext + virtual void SAL_CALL makeVisible( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _Control ) throw (::com::sun::star::uno::RuntimeException); + + const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > >& GetList() {return m_aControllerList;} protected: - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > getController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm ) const; - void setController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm, - FmXFormController* pParent = NULL); + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > getController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm ) const; + void setController( + const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& xForm, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxParentController ); ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer > getControlContainer() const { return m_xControlContainer; } void updateTabOrder( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm ); void dispose(); @@ -213,7 +221,7 @@ public: FmWinRecList::const_iterator findWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxCC ) const; const FmWinRecList& getWindowList() const {return m_aWinList;} - ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController > + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > getFormController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& _rxForm, const OutputDevice& _rDevice ) const; // activation handling diff --git a/svx/source/inc/formcontroller.hxx b/svx/source/inc/formcontroller.hxx new file mode 100644 index 000000000000..4c4ba187187d --- /dev/null +++ b/svx/source/inc/formcontroller.hxx @@ -0,0 +1,592 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SVX_FMCTRLER_HXX +#define _SVX_FMCTRLER_HXX + +#include "delayedevent.hxx" +#include "formdispatchinterceptor.hxx" +#include "sqlparserclient.hxx" + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/XControl.hpp> +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> +#include <com/sun/star/awt/XItemListener.hpp> +#include <com/sun/star/awt/XMouseListener.hpp> +#include <com/sun/star/awt/XTabController.hpp> +#include <com/sun/star/awt/XTextComponent.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/form/DatabaseDeleteEvent.hpp> +#include <com/sun/star/form/DatabaseParameterEvent.hpp> +#include <com/sun/star/form/ErrorEvent.hpp> +#include <com/sun/star/form/validation/XFormComponentValidityListener.hpp> +#include <com/sun/star/form/XConfirmDeleteBroadcaster.hpp> +#include <com/sun/star/form/XConfirmDeleteListener.hpp> +#include <com/sun/star/form/XDatabaseParameterBroadcaster2.hpp> +#include <com/sun/star/form/XDatabaseParameterListener.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> +#include <com/sun/star/form/runtime/XFilterController.hpp> +#include <com/sun/star/form/XFormControllerListener.hpp> +#include <com/sun/star/form/XGridControlListener.hpp> +#include <com/sun/star/form/XLoadListener.hpp> +#include <com/sun/star/form/XResetListener.hpp> +#include <com/sun/star/frame/DispatchDescriptor.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XDispatchProviderInterception.hpp> +#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/script/XEventAttacherManager.hpp> +#include <com/sun/star/sdb/XRowSetApproveBroadcaster.hpp> +#include <com/sun/star/sdb/XRowSetApproveListener.hpp> +#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp> +#include <com/sun/star/sdb/XSQLErrorBroadcaster.hpp> +#include <com/sun/star/sdb/XSQLErrorListener.hpp> +#include <com/sun/star/sdbc/XRowSetListener.hpp> +#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/util/XModeSelector.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +/** === end UNO includes === **/ + +#include <comphelper/broadcasthelper.hxx> +#include <comphelper/componentcontext.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/stl_types.hxx> +#include <connectivity/sqlparse.hxx> +#include <cppuhelper/propshlp.hxx> +#include <tools/debug.hxx> +#include <vcl/timer.hxx> + +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 22 +#include <comphelper/implbase_var.hxx> +#endif + +struct FmXTextComponentLess : public ::std::binary_function< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent> , sal_Bool> +{ + sal_Bool operator() (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& x, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >& y) const + { + return reinterpret_cast<sal_Int64>(x.get()) < reinterpret_cast<sal_Int64>(y.get()); + } +}; + +typedef ::std::map< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent >, ::rtl::OUString, FmXTextComponentLess> FmFilterRow; +typedef ::std::vector< FmFilterRow > FmFilterRows; +typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > > FmFormControllers; + +class FmFormView; +class Window; + +namespace svxform +{ + typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTextComponent > > FilterComponents; + class ControlBorderManager; + struct FmFieldInfo; + + typedef ::comphelper::WeakComponentImplHelper22 < ::com::sun::star::form::runtime::XFormController + , ::com::sun::star::form::runtime::XFilterController + , ::com::sun::star::awt::XFocusListener + , ::com::sun::star::form::XLoadListener + , ::com::sun::star::beans::XPropertyChangeListener + , ::com::sun::star::awt::XTextListener + , ::com::sun::star::awt::XItemListener + , ::com::sun::star::container::XContainerListener + , ::com::sun::star::util::XModifyListener + , ::com::sun::star::form::XConfirmDeleteListener + , ::com::sun::star::sdb::XSQLErrorListener + , ::com::sun::star::sdbc::XRowSetListener + , ::com::sun::star::sdb::XRowSetApproveListener + , ::com::sun::star::form::XDatabaseParameterListener + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::form::XResetListener + , ::com::sun::star::frame::XDispatch + , ::com::sun::star::awt::XMouseListener + , ::com::sun::star::form::validation::XFormComponentValidityListener + , ::com::sun::star::task::XInteractionHandler + , ::com::sun::star::form::XGridControlListener + , ::com::sun::star::form::runtime::XFeatureInvalidation + > FormController_BASE; + + //================================================================== + // FormController + //================================================================== + class ColumnInfoCache; + class SAL_DLLPRIVATE FormController :public ::comphelper::OBaseMutex + ,public FormController_BASE + ,public ::cppu::OPropertySetHelper + ,public DispatchInterceptor + ,public ::comphelper::OAggregationArrayUsageHelper< FormController > + ,public ::svxform::OSQLParserClient + { + typedef ::std::map < sal_Int16, + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > + > DispatcherContainer; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation> m_xAggregate; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabController> m_xTabController; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> m_xActiveControl, m_xCurrentControl; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xModelAsIndex; + ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacherManager> m_xModelAsManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent; + ::comphelper::ComponentContext m_aContext; + // Composer used for checking filter conditions + ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer; + ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInteractionHandler; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > m_xContext; + + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > m_aControls; + ::cppu::OInterfaceContainerHelper + m_aActivateListeners, + m_aModifyListeners, + m_aErrorListeners, + m_aDeleteListeners, + m_aRowSetApproveListeners, + m_aParameterListeners, + m_aFilterListeners; + + FmFormControllers m_aChilds; + FilterComponents m_aFilterComponents; + FmFilterRows m_aFilterRows; + + Timer m_aTabActivationTimer; + Timer m_aFeatureInvalidationTimer; + + ::svxform::ControlBorderManager* + m_pControlBorderManager; + + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > + m_xFormOperations; + DispatcherContainer m_aFeatureDispatchers; + ::std::set< sal_Int16 > m_aInvalidFeatures; // for asynchronous feature invalidation + + ::rtl::OUString m_aMode; + + ::svxform::DelayedEvent m_aLoadEvent; + ::svxform::DelayedEvent m_aToggleEvent; + ::svxform::DelayedEvent m_aActivationEvent; + ::svxform::DelayedEvent m_aDeactivationEvent; + + ::std::auto_ptr< ColumnInfoCache > + m_pColumnInfoCache; + + sal_Int32 m_nCurrentFilterPosition; // current level for filtering (or-criteria) + + sal_Bool m_bCurrentRecordModified : 1; + sal_Bool m_bCurrentRecordNew : 1; + sal_Bool m_bLocked : 1; + sal_Bool m_bDBConnection : 1; // Focuslistener nur fuer Datenbankformulare + sal_Bool m_bCycle : 1; + sal_Bool m_bCanInsert : 1; + sal_Bool m_bCanUpdate : 1; + sal_Bool m_bCommitLock : 1; // lock the committing of controls see focusGained + sal_Bool m_bModified : 1; // ist der Inhalt eines Controls modifiziert ? + sal_Bool m_bControlsSorted : 1; + sal_Bool m_bFiltering : 1; + sal_Bool m_bAttachEvents : 1; + sal_Bool m_bDetachEvents : 1; + sal_Bool m_bAttemptedHandlerCreation : 1; + + // as we want to intercept dispatches of _all_ controls we're responsible for, and an object implementing + // the ::com::sun::star::frame::XDispatchProviderInterceptor interface can intercept only _one_ objects dispatches, we need a helper class + DECLARE_STL_VECTOR(DispatchInterceptionMultiplexer*, Interceptors); + Interceptors m_aControlDispatchInterceptors; + + public: + FormController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & _rxORB ); + + protected: + ~FormController(); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL acquire() throw (); + virtual void SAL_CALL release() throw (); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); + + // XDispatch + virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& _rURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& _rxListener, const ::com::sun::star::util::URL& _rURL ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::container::XChild + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL getParent(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setParent(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& Parent) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + // OPropertySetHelper + virtual sal_Bool SAL_CALL convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) + throw( ::com::sun::star::lang::IllegalArgumentException ); + + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw( ::com::sun::star::uno::Exception ); + virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + + using OPropertySetHelper::getFastPropertyValue; + + // XFilterController + virtual ::sal_Int32 SAL_CALL getFilterComponents() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getDisjunctiveTerms() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addFilterControllerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterControllerListener >& _Listener ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeFilterControllerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFilterControllerListener >& _Listener ) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL setPredicateExpression( ::sal_Int32 _Component, ::sal_Int32 _Term, const ::rtl::OUString& _PredicateExpression ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > SAL_CALL getFilterComponent( ::sal_Int32 _Component ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL getPredicateExpressions() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeDisjunctiveTerm( ::sal_Int32 _Term ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL appendEmptyDisjunctiveTerm() throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getActiveTerm() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setActiveTerm( ::sal_Int32 _ActiveTerm ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL hasElements(void) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::container::XEnumerationAccess + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration> SAL_CALL createEnumeration(void) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::container::XContainerListener + virtual void SAL_CALL elementInserted(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL elementReplaced(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL elementRemoved(const ::com::sun::star::container::ContainerEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XLoadListener + virtual void SAL_CALL loaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL unloaded(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL unloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL reloading(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL reloaded(const ::com::sun::star::lang::EventObject& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XModeSelector + virtual void SAL_CALL setMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException ); + virtual ::rtl::OUString SAL_CALL getMode(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedModes(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsMode(const ::rtl::OUString& Mode) throw( ::com::sun::star::uno::RuntimeException ); + + // ::com::sun::star::container::XIndexAccess + virtual sal_Int32 SAL_CALL getCount(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Any SAL_CALL getByIndex(sal_Int32 Index) throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); + + // XModifyBroadcaster + virtual void SAL_CALL addModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeModifyListener(const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + + // XFocusListener + virtual void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw( ::com::sun::star::uno::RuntimeException ); + + // XMouseListener + virtual void SAL_CALL mousePressed( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseReleased( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseEntered( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL mouseExited( const ::com::sun::star::awt::MouseEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException); + + // XFormComponentValidityListener + virtual void SAL_CALL componentValidityChanged( const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException); + + // XInteractionHandler + virtual void SAL_CALL handle( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& Request ) throw (::com::sun::star::uno::RuntimeException); + + // XGridControlListener + virtual void SAL_CALL columnChanged( const ::com::sun::star::lang::EventObject& _event ) throw (::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::beans::XPropertyChangeListener -> aenderung der stati + virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt) throw( ::com::sun::star::uno::RuntimeException ); + + // XTextListener -> modify setzen + virtual void SAL_CALL textChanged(const ::com::sun::star::awt::TextEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XItemListener -> modify setzen + virtual void SAL_CALL itemStateChanged(const ::com::sun::star::awt::ItemEvent& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XModifyListener -> modify setzen + virtual void SAL_CALL modified(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XFormController + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > SAL_CALL getFormOperations() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> SAL_CALL getCurrentControl(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeActivateListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormControllerListener>& l) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL addChildController( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _ChildController ) throw( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext > SAL_CALL getContext() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormControllerContext >& _context ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL getInteractionHandler() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setInteractionHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _interactionHandler ) throw (::com::sun::star::uno::RuntimeException); + + // XTabController + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> > SAL_CALL getControls(void) throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setModel(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel>& Model) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel> SAL_CALL getModel() throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL setContainer(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer>& Container) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer> SAL_CALL getContainer() throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL autoTabOrder() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL activateTabOrder() throw( ::com::sun::star::uno::RuntimeException ); + + virtual void SAL_CALL activateFirst() throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL activateLast() throw( ::com::sun::star::uno::RuntimeException ); + + // com::sun::star::sdbc::XRowSetListener + virtual void SAL_CALL cursorMoved(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL rowChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL rowSetChanged(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + + // XRowSetApproveListener + virtual sal_Bool SAL_CALL approveCursorMove(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL approveRowChange(const ::com::sun::star::sdb::RowChangeEvent& event) throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL approveRowSetChange(const ::com::sun::star::lang::EventObject& event) throw( ::com::sun::star::uno::RuntimeException ); + + // XRowSetApproveBroadcaster + virtual void SAL_CALL addRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeRowSetApproveListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XRowSetApproveListener>& listener) throw( ::com::sun::star::uno::RuntimeException ); + + // XSQLErrorBroadcaster + virtual void SAL_CALL errorOccured(const ::com::sun::star::sdb::SQLErrorEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XSQLErrorListener + virtual void SAL_CALL addSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeSQLErrorListener(const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSQLErrorListener>& _rListener) throw( ::com::sun::star::uno::RuntimeException ); + + // XDatabaseParameterBroadcaster2 + virtual void SAL_CALL addDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeDatabaseParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + + // XDatabaseParameterBroadcaster + virtual void SAL_CALL addParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeParameterListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XDatabaseParameterListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + + // XDatabaseParameterListener + virtual sal_Bool SAL_CALL approveParameter(const ::com::sun::star::form::DatabaseParameterEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XConfirmDeleteBroadcaster + virtual void SAL_CALL addConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL removeConfirmDeleteListener(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XConfirmDeleteListener>& aListener) throw( ::com::sun::star::uno::RuntimeException ); + + // XConfirmDeleteListener + virtual sal_Bool SAL_CALL confirmDelete(const ::com::sun::star::sdb::RowChangeEvent& aEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XServiceInfo + virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& ServiceName) throw(::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw(::com::sun::star::uno::RuntimeException); + + // XResetListener + virtual sal_Bool SAL_CALL approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); + + // XFeatureInvalidation + virtual void SAL_CALL invalidateFeatures( const ::com::sun::star::uno::Sequence< ::sal_Int16 >& Features ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL invalidateAllFeatures( ) throw (::com::sun::star::uno::RuntimeException); + +// method for registration + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void); + + // comphelper::OPropertyArrayUsageHelper + virtual void fillProperties( + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rProps, + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& /* [out] */ _rAggregateProps + ) const; + + protected: + // DispatchInterceptor + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> + interceptedQueryDispatch( + const ::com::sun::star::util::URL& aURL, + const ::rtl::OUString& aTargetFrameName, + sal_Int32 nSearchFlags + ) throw( ::com::sun::star::uno::RuntimeException ); + + virtual ::osl::Mutex* getInterceptorMutex() { return &m_aMutex; } + + /// update all our dispatchers + void updateAllDispatchers() const; + + /** disposes all dispatchers in m_aFeatureDispatchers, and empties m_aFeatureDispatchers + */ + void disposeAllFeaturesAndDispatchers() SAL_THROW(()); + + void startFiltering(); + void stopFiltering(); + void setFilter(::std::vector<FmFieldInfo>&); + void startListening(); + void stopListening(); + + /** ensures that we have an interaction handler, if possible + + If an interaction handler was provided at creation time (<member>initialize</member>), this + one will be used. Else, an attempt is made to create an <type scope="com::sun::star::sdb">InteractionHandler</type> + is made. + + @return <TRUE/> + if and only if <member>m_xInteractionHandler</member> is valid when the method returns + */ + bool ensureInteractionHandler(); + + /** replaces one of our controls with another one + + Upon successful replacing, the old control will be disposed. Also, internal members pointing + to the current or active control will be adjusted. Yet more, if the replaced control was + the active control, the new control will be made active. + + @param _rxExistentControl + The control to replace. Must be one of the controls in our ControlContainer. + @param _rxNewControl + The control which should replace the existent control. + @return + <TRUE/> if and only if the control was successfully replaced + */ + bool replaceControl( + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxExistentControl, + const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxNewControl + ); + + // we're listening at all bound controls for modifications + void startControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void stopControlModifyListening(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + + void setLocks(); + void setControlLock(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void addToEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void removeFromEventAttacher(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void toggleAutoFields(sal_Bool bAutoFields); + void unload() throw( ::com::sun::star::uno::RuntimeException ); + void removeBoundFieldListener(); + + void startFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); + void stopFormListening( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm, sal_Bool _bPropertiesOnly ); + + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> findControl( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> >& rCtrls, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel>& rxCtrlModel, sal_Bool _bRemove, sal_Bool _bOverWrite ) const; + + void insertControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + void removeControl(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl); + + /// called when a new control is to be handled by the controller + void implControlInserted( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bAddToEventAttacher ); + /// called when a control is not to be handled by the controller anymore + void implControlRemoved( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rxControl, bool _bRemoveFromEventAttacher ); + + /** sets m_xCurrentControl, plus does administrative tasks depending on it + */ + void implSetCurrentControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >& _rxControl ); + + /** invalidates the FormFeatures which depend on the current control + */ + void implInvalidateCurrentControlDependentFeatures(); + + bool impl_isDisposed_nofail() const { return FormController_BASE::rBHelper.bDisposed; } + void impl_checkDisposed_throw() const; + + void impl_onModify(); + + /** adds the given filter row to m_aFilterRows, setting m_nCurrentFilterPosition to 0 if the newly added + row is the first one. + + @precond + our mutex is locked + */ + void impl_addFilterRow( const FmFilterRow& _row ); + + /** adds an empty filter row to m_aFilterRows, and notifies our listeners + */ + void impl_appendEmptyFilterRow( ::osl::ClearableMutexGuard& _rClearBeforeNotify ); + + sal_Bool isLocked() const {return m_bLocked;} + sal_Bool determineLockState() const; + + Window* getDialogParentWindow(); + // returns the window which should be used as parent window for dialogs + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterceptor> createInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); + // create a new interceptor, register it on the given object + void deleteInterceptor(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _xInterception); + // if createInterceptor was called for the given object the according interceptor will be removed + // from the objects interceptor chain and released + + /** checks all form controls belonging to our form for validity + + If a form control supports the XValidatableFormComponent interface, this is used to determine + the validity of the control. If the interface is not supported, the control is supposed to be + valid. + + @param _rFirstInvalidityExplanation + if the method returns <FALSE/> (i.e. if there is an invalid control), this string contains + the explanation for the invalidity, as obtained from the validator. + + @param _rxFirstInvalidModel + if the method returns <FALSE/> (i.e. if there is an invalid control), this contains + the control model + + @return + <TRUE/> if and only if all controls belonging to our form are valid + */ + bool checkFormComponentValidity( + ::rtl::OUString& /* [out] */ _rFirstInvalidityExplanation, + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& /* [out] */ _rxFirstInvalidModel + ) SAL_THROW(()); + + /** locates the control which belongs to a given model + */ + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > + locateControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& _rxModel ) SAL_THROW(()); + + // set the text for all filters + void impl_setTextOnAllFilter_throw(); + + // in filter mode we do not listen for changes + sal_Bool isListeningForChanges() const {return m_bDBConnection && !m_bFiltering && !isLocked();} + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl> isInList(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer>& xPeer) const; + + DECL_LINK( OnActivateTabOrder, void* ); + DECL_LINK( OnInvalidateFeatures, void* ); + DECL_LINK( OnLoad, void* ); + DECL_LINK( OnToggleAutoFields, void* ); + DECL_LINK( OnActivated, void* ); + DECL_LINK( OnDeactivated, void* ); + }; + +} // namespace svxform + +#endif // _SVX_FMCTRLER_HXX + diff --git a/svx/source/inc/formcontrolling.hxx b/svx/source/inc/formcontrolling.hxx index d082bd889804..f818ced85189 100644 --- a/svx/source/inc/formcontrolling.hxx +++ b/svx/source/inc/formcontrolling.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: formcontrolling.hxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -31,7 +28,7 @@ #ifndef SVX_FORMCONTROLLING_HXX #define SVX_FORMCONTROLLING_HXX -#include <com/sun/star/form/XFormController.hpp> +#include <com/sun/star/form/runtime/XFormController.hpp> #include <com/sun/star/form/XForm.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/form/runtime/FeatureState.hpp> @@ -117,7 +114,7 @@ namespace svx IControllerFeatureInvalidation* _pInvalidationCallback ); - /** constructs the instance from a <type scope="com::sun::star::form">XFormController<type> instance + /** constructs the instance from a <type scope="com::sun::star::form::runtime">XFormController<type> instance @param _rxORB a multi service factory for creating various needed components @@ -131,7 +128,7 @@ namespace svx */ ControllerFeatures( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB, - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback ); @@ -163,7 +160,7 @@ namespace svx /** assign to a controller */ void assign( - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController ); /** assign to a controller @@ -206,7 +203,7 @@ namespace svx ::com::sun::star::uno::Any m_aOperationError; public: - /** constructs the helper from a <type scope="com::sun::star::form">XFormController<type> instance + /** constructs the helper from a <type scope="com::sun::star::form::runtime">XFormController<type> instance @param _rContext the context the component lives in @@ -218,7 +215,7 @@ namespace svx */ FormControllerHelper( const ::comphelper::ComponentContext& _rContext, - const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormController >& _rxController, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController >& _rxController, IControllerFeatureInvalidation* _pInvalidationCallback ); diff --git a/svx/source/inc/formdispatchinterceptor.hxx b/svx/source/inc/formdispatchinterceptor.hxx new file mode 100644 index 000000000000..5bcfc1726ad0 --- /dev/null +++ b/svx/source/inc/formdispatchinterceptor.hxx @@ -0,0 +1,118 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +#ifndef SVX_FORMDISPATCHINTERCEPTOR_HXX +#define SVX_FORMDISPATCHINTERCEPTOR_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> +#include <com/sun/star/frame/XDispatchProviderInterception.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/compbase2.hxx> +#include <comphelper/uno3.hxx> + +//........................................................................ +namespace svxform +{ +//........................................................................ + + //==================================================================== + //= DispatchInterceptor + //==================================================================== + class DispatchInterceptor + { + public: + DispatchInterceptor() { } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> interceptedQueryDispatch( + const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException ) = 0; + + virtual ::osl::Mutex* getInterceptorMutex() = 0; + }; + + //==================================================================== + //= + //==================================================================== + typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::frame::XDispatchProviderInterceptor + , ::com::sun::star::lang::XEventListener + > DispatchInterceptionMultiplexer_BASE; + + class DispatchInterceptionMultiplexer : public DispatchInterceptionMultiplexer_BASE + { + ::osl::Mutex m_aFallback; + ::osl::Mutex* m_pMutex; + + // the component which's dispatches we're intercepting + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProviderInterception > + m_xIntercepted; + sal_Bool m_bListening; + + // the real interceptor + DispatchInterceptor* m_pMaster; + + // chaining + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xSlaveDispatcher; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xMasterDispatcher; + + virtual ~DispatchInterceptionMultiplexer(); + + public: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception> getIntercepted() const { return m_xIntercepted; } + + public: + DispatchInterceptionMultiplexer( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _rToIntercept, + DispatchInterceptor* _pMaster + ); + + // UNO + DECLARE_UNO3_DEFAULTS(DispatchInterceptionMultiplexer, DispatchInterceptionMultiplexer_BASE); + + // ::com::sun::star::frame::XDispatchProvider + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::frame::XDispatchProviderInterceptor + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewDispatchProvider ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSupplier ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + protected: + void ImplDetach(); + }; + +//........................................................................ +} // namespace svxform +//........................................................................ + +#endif // SVX_FORMDISPATCHINTERCEPTOR_HXX diff --git a/svx/source/inc/fmdispatch.hxx b/svx/source/inc/formfeaturedispatcher.hxx index 90480afc4609..32316d52b922 100644 --- a/svx/source/inc/fmdispatch.hxx +++ b/svx/source/inc/formfeaturedispatcher.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmdispatch.hxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -31,19 +28,20 @@ #ifndef SVX_FMDISPATCH_HXX #define SVX_FMDISPATCH_HXX -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/interfacecontainer.hxx> +/** === begin UNO includes === **/ #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/form/runtime/XFormOperations.hpp> +/** === end UNO includes === **/ +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/interfacecontainer.hxx> //........................................................................ namespace svx { //........................................................................ - class FormControllerHelper; - //==================================================================== //= OSingleFeatureDispatcher //==================================================================== @@ -55,10 +53,11 @@ namespace svx private: ::osl::Mutex& m_rMutex; ::cppu::OInterfaceContainerHelper m_aStatusListeners; - const FormControllerHelper& m_rController; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > + m_xFormOperations; const ::com::sun::star::util::URL m_aFeatureURL; ::com::sun::star::uno::Any m_aLastKnownState; - const sal_Int32 m_nFeatureId; + const sal_Int16 m_nFormFeature; sal_Bool m_bLastKnownEnabled; sal_Bool m_bDisposed; @@ -80,9 +79,9 @@ namespace svx */ OSingleFeatureDispatcher( const ::com::sun::star::util::URL& _rFeatureURL, - sal_Int32 _nFeatureId, - const FormControllerHelper& _rController, - ::osl::Mutex& _rMutex + const sal_Int16 _nFormFeature, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations >& _rxFormOperations, + ::osl::Mutex& _rMutex ); /** disposes the dispatcher instance diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx index 504aaff7acf3..b3792b76422c 100644 --- a/svx/source/inc/gridcell.hxx +++ b/svx/source/inc/gridcell.hxx @@ -35,7 +35,6 @@ #include "sqlparserclient.hxx" #include "typeconversionclient.hxx" -#include "svx/fmtools.hxx" /** === begin UNO includes === **/ #include <com/sun/star/sdb/XColumn.hpp> @@ -51,6 +50,7 @@ #include <com/sun/star/beans/XFastPropertySet.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/form/XChangeBroadcaster.hpp> +#include <com/sun/star/awt/XWindow.hpp> /** === end UNO includes === **/ #include <comphelper/propmultiplex.hxx> diff --git a/svx/source/inc/tabwin.hxx b/svx/source/inc/tabwin.hxx index 8feda5ef6b68..02f58a507511 100644 --- a/svx/source/inc/tabwin.hxx +++ b/svx/source/inc/tabwin.hxx @@ -37,9 +37,6 @@ #include <sfx2/ctrlitem.hxx> #include <com/sun/star/form/XForm.hpp> -//#ifndef _SVX_FMTOOLS_HXX -//#include "svx/fmtools.hxx" -//#endif #include <comphelper/propmultiplex.hxx> #include <svtools/transfer.hxx> #include "svx/dbtoolsclient.hxx" diff --git a/svx/source/sdr/contact/viewcontactofgraphic.cxx b/svx/source/sdr/contact/viewcontactofgraphic.cxx index 86bbdf78c47c..a80a8f16d852 100644 --- a/svx/source/sdr/contact/viewcontactofgraphic.cxx +++ b/svx/source/sdr/contact/viewcontactofgraphic.cxx @@ -52,18 +52,16 @@ #include "svdstr.hrc" #include <svdglob.hxx> #include <vcl/svapp.hxx> - #include <basegfx/polygon/b2dpolygontools.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> #include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <drawinglayer/primitive2d/textlayoutdevice.hxx> #include <drawinglayer/primitive2d/maskprimitive2d.hxx> - #include <svx/sdr/primitive2d/sdrtextprimitive2d.hxx> #include <editeng/eeitem.hxx> #include <editeng/colritem.hxx> -//#include <svx/xtable.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -148,11 +146,9 @@ namespace sdr { // create the EmptyPresObj fallback visualisation. The fallback graphic // is already provided in rGraphicObject in this case, use it - aSmallerMatrix.scale(aPrefSize.getWidth(), aPrefSize.getHeight()); - aSmallerMatrix.translate(fOffsetX, fOffsetY); - aSmallerMatrix.shearX(fShearX); - aSmallerMatrix.rotate(fRotate); - aSmallerMatrix.translate(aTranslate.getX(), aTranslate.getY()); + aSmallerMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aPrefSize.getWidth(), aPrefSize.getHeight(), fOffsetX, fOffsetY); + aSmallerMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate) + * aSmallerMatrix; const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false); const drawinglayer::attribute::SdrLineFillShadowTextAttribute aEmptyAttributes(0, 0, 0, 0, 0, 0); @@ -241,12 +237,8 @@ namespace sdr && basegfx::fTools::lessOrEqual(fWidth, aScale.getX()) && basegfx::fTools::lessOrEqual(fHeight, aScale.getY())) { - basegfx::B2DHomMatrix aBitmapMatrix; - - aBitmapMatrix.scale(fWidth, fHeight); - aBitmapMatrix.shearX(fShearX); - aBitmapMatrix.rotate(fRotate); - aBitmapMatrix.translate(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DHomMatrix aBitmapMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + fWidth, fHeight, fShearX, fRotate, aTranslate.getX(), aTranslate.getY())); drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, drawinglayer::primitive2d::Primitive2DReference( @@ -293,12 +285,8 @@ namespace sdr if(pSdrText && pOPO) { // directly use the remaining space as TextRangeTransform - basegfx::B2DHomMatrix aTextRangeTransform; - - aTextRangeTransform.scale(aScale.getX(), aScale.getY()); - aTextRangeTransform.shearX(fShearX); - aTextRangeTransform.rotate(fRotate); - aTextRangeTransform.translate(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DHomMatrix aTextRangeTransform(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aScale, fShearX, fRotate, aTranslate)); // directly create temp SdrBlockTextPrimitive2D drawinglayer::primitive2d::SdrBlockTextPrimitive2D aBlockTextPrimitive( @@ -380,7 +368,6 @@ namespace sdr // which will use the primitive data we just create in the near future const Rectangle& rRectangle = GetGrafObject().GetGeoRect(); const ::basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom()); - basegfx::B2DHomMatrix aObjectMatrix; // look for mirroring const GeoStat& rGeoStat(GetGrafObject().GetGeoStat()); @@ -411,10 +398,10 @@ namespace sdr // fill object matrix const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0); const double fRotate(nDrehWink ? (36000 - nDrehWink) * F_PI18000 : 0.0); - aObjectMatrix.scale(aObjectRange.getWidth(), aObjectRange.getHeight()); - aObjectMatrix.shearX(fShearX); - aObjectMatrix.rotate(fRotate); - aObjectMatrix.translate(aObjectRange.getMinX(), aObjectRange.getMinY()); + const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aObjectRange.getWidth(), aObjectRange.getHeight(), + fShearX, fRotate, + aObjectRange.getMinX(), aObjectRange.getMinY())); // get the current, unchenged graphic obect from SdrGrafObj const GraphicObject& rGraphicObject = GetGrafObject().GetGraphicObject(false); diff --git a/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx b/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx index c5c682222fde..337681e4d391 100644 --- a/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrcaptionobj.cxx @@ -37,6 +37,7 @@ #include <svx/sdr/primitive2d/sdrattributecreator.hxx> #include <svx/sdr/attribute/sdrallattribute.hxx> #include <svx/sdr/primitive2d/sdrcaptionprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// // includes for special text box shadow (SC) @@ -83,30 +84,13 @@ namespace sdr const Rectangle& rRectangle = rCaptionObj.GetGeoRect(); const ::basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom()); const GeoStat& rGeoStat(rCaptionObj.GetGeoStat()); - ::basegfx::B2DHomMatrix aObjectMatrix; // fill object matrix - if(!::basegfx::fTools::equalZero(aObjectRange.getWidth())) - { - aObjectMatrix.set(0, 0, aObjectRange.getWidth()); - } - - if(!::basegfx::fTools::equalZero(aObjectRange.getHeight())) - { - aObjectMatrix.set(1, 1, aObjectRange.getHeight()); - } - - if(rGeoStat.nShearWink) - { - aObjectMatrix.shearX(tan((36000 - rGeoStat.nShearWink) * F_PI18000)); - } - - if(rGeoStat.nDrehWink) - { - aObjectMatrix.rotate((36000 - rGeoStat.nDrehWink) * F_PI18000); - } - - aObjectMatrix.translate(aObjectRange.getMinX(), aObjectRange.getMinY()); + basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aObjectRange.getWidth(), aObjectRange.getHeight(), + rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0, + rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0, + aObjectRange.getMinX(), aObjectRange.getMinY())); // calculate corner radius double fCornerRadiusX; @@ -164,7 +148,7 @@ namespace sdr const sal_uInt32 nYDist(((SdrShadowYDistItem&)(rItemSet.Get(SDRATTR_SHADOWYDIST))).GetValue()); aObjectMatrix.translate(nXDist, nYDist); - // create unit outline polygon as geometry (see SdrCaptionPrimitive2D::createLocalDecomposition) + // create unit outline polygon as geometry (see SdrCaptionPrimitive2D::create2DDecomposition) basegfx::B2DPolygon aUnitOutline(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0), fCornerRadiusX, fCornerRadiusY)); // create the specialized shadow primitive diff --git a/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx b/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx index c57c153e9e40..047685dc14f2 100644 --- a/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrcircobj.cxx @@ -39,6 +39,7 @@ #include <svx/sdr/primitive2d/sdrellipseprimitive2d.hxx> #include <svl/itemset.hxx> #include <svx/sxciaitm.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -73,30 +74,13 @@ namespace sdr const Rectangle& rRectangle = GetCircObj().GetGeoRect(); const ::basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom()); const GeoStat& rGeoStat(GetCircObj().GetGeoStat()); - ::basegfx::B2DHomMatrix aObjectMatrix; // fill object matrix - if(!::basegfx::fTools::equalZero(aObjectRange.getWidth())) - { - aObjectMatrix.set(0, 0, aObjectRange.getWidth()); - } - - if(!::basegfx::fTools::equalZero(aObjectRange.getHeight())) - { - aObjectMatrix.set(1, 1, aObjectRange.getHeight()); - } - - if(rGeoStat.nShearWink) - { - aObjectMatrix.shearX(tan((36000 - rGeoStat.nShearWink) * F_PI18000)); - } - - if(rGeoStat.nDrehWink) - { - aObjectMatrix.rotate((36000 - rGeoStat.nDrehWink) * F_PI18000); - } - - aObjectMatrix.translate(aObjectRange.getMinX(), aObjectRange.getMinY()); + const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aObjectRange.getWidth(), aObjectRange.getHeight(), + rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0, + rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0, + aObjectRange.getMinX(), aObjectRange.getMinY())); // create primitive data const sal_uInt16 nIdentifier(GetCircObj().GetObjIdentifier()); diff --git a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx index 9d19e752396c..352b9198e97b 100644 --- a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx @@ -39,6 +39,7 @@ #include <svx/sdr/primitive2d/sdrcustomshapeprimitive2d.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <svx/obj3d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -223,13 +224,14 @@ namespace sdr } // create primitive - const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::SdrCustomShapePrimitive2D( - *pAttribute, - xGroup, - aTextBoxMatrix, - bWordWrap, - false, // #SJ# New parameter to force to clipped BlockText for SC - b3DShape)); + const drawinglayer::primitive2d::Primitive2DReference xReference( + new drawinglayer::primitive2d::SdrCustomShapePrimitive2D( + *pAttribute, + xGroup, + aTextBoxMatrix, + bWordWrap, + b3DShape, + false)); // #SJ# New parameter to force to clipped BlockText for SC xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1); } diff --git a/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx b/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx index a054e881b7c3..7672577138d0 100644 --- a/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrole2obj.cxx @@ -46,6 +46,7 @@ #include <svx/sdr/primitive2d/sdrattributecreator.hxx> #include <vcl/svapp.hxx> #include <svx/sdr/primitive2d/sdrolecontentprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -88,12 +89,9 @@ namespace sdr const GeoStat& rGeoStat(GetOle2Obj().GetGeoStat()); const double fShearX(rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0); const double fRotate(rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0); - basegfx::B2DHomMatrix aObjectMatrix; - - aObjectMatrix.scale(aObjectRange.getWidth(), aObjectRange.getHeight()); - aObjectMatrix.shearX(fShearX); - aObjectMatrix.rotate(fRotate); - aObjectMatrix.translate(aObjectRange.getMinX(), aObjectRange.getMinY()); + const basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aObjectRange.getWidth(), aObjectRange.getHeight(), fShearX, fRotate, + aObjectRange.getMinX(), aObjectRange.getMinY())); // Prepare attribute settings, will be used soon anyways const SfxItemSet& rItemSet = GetOle2Obj().GetMergedItemSet(); diff --git a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx index 0f818ff40f7a..3c8449bae7f6 100644 --- a/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrpathobj.cxx @@ -38,6 +38,7 @@ #include <svx/sdr/attribute/sdrallattribute.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <svx/sdr/primitive2d/sdrpathprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -98,9 +99,11 @@ namespace sdr aUnitPolyPolygon.setB2DPolygon(0, aNewPolygon); // #i102548# fill objectMatrix with rotation and offset (no shear for lines) - aObjectMatrix.scale(aLine.getLength(), 1.0); - aObjectMatrix.rotate(atan2(aLine.getY(), aLine.getX())); - aObjectMatrix.translate(aStart.getX(), aStart.getY()); + aObjectMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aLine.getLength(), 1.0, + 0.0, + atan2(aLine.getY(), aLine.getX()), + aStart.getX(), aStart.getY()); } else { @@ -110,22 +113,14 @@ namespace sdr const GeoStat& rGeoStat(GetPathObj().GetGeoStat()); const double fWidth(aObjectRange.getWidth()); const double fHeight(aObjectRange.getHeight()); - - aObjectMatrix.scale( - basegfx::fTools::equalZero(fWidth) ? 1.0 : fWidth, - basegfx::fTools::equalZero(fHeight) ? 1.0 : fHeight); - - if(rGeoStat.nShearWink) - { - aObjectMatrix.shearX(tan((36000 - rGeoStat.nShearWink) * F_PI18000)); - } - - if(rGeoStat.nDrehWink) - { - aObjectMatrix.rotate((36000 - rGeoStat.nDrehWink) * F_PI18000); - } - - aObjectMatrix.translate(aObjectRange.getMinX(), aObjectRange.getMinY()); + const double fScaleX(basegfx::fTools::equalZero(fWidth) ? 1.0 : fWidth); + const double fScaleY(basegfx::fTools::equalZero(fHeight) ? 1.0 : fHeight); + + aObjectMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + fScaleX, fScaleY, + rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0, + rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0, + aObjectRange.getMinX(), aObjectRange.getMinY()); // ceate unit polygon from object's absolute path basegfx::B2DHomMatrix aInverse(aObjectMatrix); diff --git a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx index 0eab2c882ce5..94b26b5d020e 100644 --- a/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx +++ b/svx/source/sdr/contact/viewcontactofsdrrectobj.cxx @@ -39,6 +39,7 @@ #include <svx/sdr/primitive2d/sdrrectangleprimitive2d.hxx> #include <svl/itemset.hxx> #include <svx/sdr/primitive2d/sdrprimitivetools.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <svx/svdmodel.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -74,30 +75,13 @@ namespace sdr const Rectangle& rRectangle = GetRectObj().GetGeoRect(); const ::basegfx::B2DRange aObjectRange(rRectangle.Left(), rRectangle.Top(), rRectangle.Right(), rRectangle.Bottom()); const GeoStat& rGeoStat(GetRectObj().GetGeoStat()); - ::basegfx::B2DHomMatrix aObjectMatrix; // fill object matrix - if(!::basegfx::fTools::equalZero(aObjectRange.getWidth())) - { - aObjectMatrix.set(0, 0, aObjectRange.getWidth()); - } - - if(!::basegfx::fTools::equalZero(aObjectRange.getHeight())) - { - aObjectMatrix.set(1, 1, aObjectRange.getHeight()); - } - - if(rGeoStat.nShearWink) - { - aObjectMatrix.shearX(tan((36000 - rGeoStat.nShearWink) * F_PI18000)); - } - - if(rGeoStat.nDrehWink) - { - aObjectMatrix.rotate((36000 - rGeoStat.nDrehWink) * F_PI18000); - } - - aObjectMatrix.translate(aObjectRange.getMinX(), aObjectRange.getMinY()); + basegfx::B2DHomMatrix aObjectMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aObjectRange.getWidth(), aObjectRange.getHeight(), + rGeoStat.nShearWink ? tan((36000 - rGeoStat.nShearWink) * F_PI18000) : 0.0, + rGeoStat.nDrehWink ? (36000 - rGeoStat.nDrehWink) * F_PI18000 : 0.0, + aObjectRange.getMinX(), aObjectRange.getMinY())); // calculate corner radius sal_uInt32 nCornerRadius(((SdrEckenradiusItem&)(rItemSet.Get(SDRATTR_ECKENRADIUS))).GetValue()); diff --git a/svx/source/sdr/contact/viewobjectcontact.cxx b/svx/source/sdr/contact/viewobjectcontact.cxx index af222889a253..f265af141ef1 100644 --- a/svx/source/sdr/contact/viewobjectcontact.cxx +++ b/svx/source/sdr/contact/viewobjectcontact.cxx @@ -112,7 +112,7 @@ namespace void AnimatedExtractingProcessor2D::processBasePrimitive2D(const drawinglayer::primitive2d::BasePrimitive2D& rCandidate) { // known implementation, access directly - switch(rCandidate.getPrimitiveID()) + switch(rCandidate.getPrimitive2DID()) { // add and accept animated primitives directly, no need to decompose case PRIMITIVE2D_ID_ANIMATEDSWITCHPRIMITIVE2D : diff --git a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx index 34fddf088c98..bd208b5cf54f 100644 --- a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx @@ -44,6 +44,7 @@ #include <svx/svdpage.hxx> #include <unoapi.hxx> #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> +#include <drawinglayer/primitive2d/hittestprimitive2d.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -153,7 +154,7 @@ namespace sdr // would be possible, but would require the internal transformation // which maps between the page visualisation object and the page // content, including the aspect ratios (for details see in - // PagePreviewPrimitive2D::createLocalDecomposition) + // PagePreviewPrimitive2D::create2DDecomposition) basegfx::B2DRange(), GetXDrawPageForSdrPage(const_cast< SdrPage* >(pStartPage)), @@ -234,6 +235,9 @@ namespace sdr aPageObjectTransform.set(1, 2, aPageObjectBound.getMinY()); } + // #i102637# add gray frame also when printing and page exists (handout pages) + const bool bCreateGrayFrame(!GetObjectContact().isOutputToPrinter() || pPage); + // get displayed page's content. This is the uscaled page content if(mpExtractor && pPage) { @@ -289,10 +293,28 @@ namespace sdr xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xPagePreview, 1); } } + else if(bCreateGrayFrame) + { + // #i105146# no content, but frame display. To make hitting the page preview objects + // on the handout page more simple, add a HitTest fill primitive + const basegfx::B2DRange aUnitRange(0.0, 0.0, 1.0, 1.0); + basegfx::B2DPolygon aOutline(basegfx::tools::createPolygonFromRect(aUnitRange)); + aOutline.transform(aPageObjectTransform); + + const drawinglayer::primitive2d::Primitive2DReference xHitFill( + new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( + basegfx::B2DPolyPolygon(aOutline), + basegfx::BColor(0.0, 0.0, 0.0))); + + const drawinglayer::primitive2d::Primitive2DReference xHit( + new drawinglayer::primitive2d::HitTestPrimitive2D( + drawinglayer::primitive2d::Primitive2DSequence(&xHitFill, 1))); + + xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xHit, 1); + } // add a gray outline frame, except not when printing - // #i102637# add frame also when printing and page exists (handout pages) - if(!GetObjectContact().isOutputToPrinter() || pPage) + if(bCreateGrayFrame) { const Color aFrameColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES).nColor); basegfx::B2DPolygon aOwnOutline(basegfx::tools::createPolygonFromRect(basegfx::B2DRange(0.0, 0.0, 1.0, 1.0))); diff --git a/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx b/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx index b785b2285873..244fea07285f 100644..100755 --- a/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofsdrobj.cxx @@ -40,6 +40,8 @@ #include <svx/svdoole2.hxx> #include <svx/svdview.hxx> +#include "fmobj.hxx" + ////////////////////////////////////////////////////////////////////////////// namespace sdr @@ -91,8 +93,9 @@ namespace sdr const bool bHideOle(rSdrView.getHideOle()); const bool bHideChart(rSdrView.getHideChart()); const bool bHideDraw(rSdrView.getHideDraw()); + const bool bHideFormControl(rSdrView.getHideFormControl()); - if(bHideOle || bHideChart || bHideDraw) + if(bHideOle || bHideChart || bHideDraw || bHideFormControl) { if(OBJ_OLE2 == rObject.GetObjIdentifier()) { @@ -123,8 +126,13 @@ namespace sdr } else { + const bool bIsFormControl = dynamic_cast< const FmFormObj * >( &rObject ) != 0; + if(bIsFormControl && bHideFormControl) + { + return false; + } // any other draw object - if(bHideDraw) + if(!bIsFormControl && bHideDraw) { return false; } diff --git a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx index ec876ec036ac..5f7bf41386e0 100644 --- a/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx @@ -303,8 +303,8 @@ namespace sdr { namespace contact { // no check whether we're valid, this is the responsibility of the caller // Argh. Why does XView have a setZoom only, but not a getZoom? - Window* pWindow = VCLUnoHelper::GetWindow( m_xControlWindow ); - OSL_ENSURE( pWindow, "ControlHolder::setZoom: no implementation access!" ); + Window* pWindow = VCLUnoHelper::GetWindow( m_xControl->getPeer() ); + OSL_ENSURE( pWindow, "ControlHolder::getZoom: no implementation access!" ); ::basegfx::B2DVector aZoom( 1, 1 ); if ( pWindow ) @@ -351,6 +351,12 @@ namespace sdr { namespace contact { if ( !_rControl.is() ) return; + #if OSL_DEBUG_LEVEL > 0 + ::basegfx::B2DTuple aViewScale, aViewTranslate; + double nViewRotate(0), nViewShearX(0); + _rViewTransformation.decompose( aViewScale, aViewTranslate, nViewRotate, nViewShearX ); + #endif + // transform the logic bound rect, using the view transformation, to pixel coordinates ::basegfx::B2DPoint aTopLeft( _rLogicBoundingRect.Left(), _rLogicBoundingRect.Top() ); aTopLeft *= _rViewTransformation; @@ -615,7 +621,7 @@ namespace sdr { namespace contact { Failure of this method will be reported via an assertion in a non-product version. */ - bool ensureControl(); + bool ensureControl( const basegfx::B2DHomMatrix* _pInitialViewTransformationOrNULL ); /** returns our XControl, if it already has been created @@ -652,20 +658,14 @@ namespace sdr { namespace contact { */ bool isControlVisible() const { return impl_isControlVisible_nofail(); } - /** determines whether the instance belongs to a given OutputDevice - @precond - The instance knows the device it belongs to, or can determine it. - If this is not the case, you will notice an assertion, and the method will - return false. - */ - bool belongsToDevice( const OutputDevice* _pDevice ) const; - /// creates an XControl for the given device and SdrUnoObj static bool createControlForDevice( IPageViewAccess& _rPageView, const OutputDevice& _rDevice, const SdrUnoObj& _rUnoObject, + const basegfx::B2DHomMatrix& _rInitialViewTransformation, + const basegfx::B2DHomMatrix& _rInitialZoomNormalization, ControlHolder& _out_rControl ); @@ -840,7 +840,11 @@ namespace sdr { namespace contact { /** ensures that we have a control for the given PageView/OutputDevice */ - bool impl_ensureControl_nothrow( IPageViewAccess& _rPageView, const OutputDevice& _rDevice ); + bool impl_ensureControl_nothrow( + IPageViewAccess& _rPageView, + const OutputDevice& _rDevice, + const basegfx::B2DHomMatrix& _rInitialViewTransformation + ); /** retrieves the device which a PageView belongs to, starting from its ObjectContactOfPageView @@ -880,14 +884,19 @@ namespace sdr { namespace contact { //==================================================================== //= LazyControlCreationPrimitive2D //==================================================================== - class LazyControlCreationPrimitive2D : public ::drawinglayer::primitive2d::BasePrimitive2D + class LazyControlCreationPrimitive2D : public ::drawinglayer::primitive2d::BufferedDecompositionPrimitive2D { private: - typedef ::drawinglayer::primitive2d::BasePrimitive2D BasePrimitive2D; + typedef ::drawinglayer::primitive2d::BufferedDecompositionPrimitive2D BufferedDecompositionPrimitive2D; protected: virtual ::drawinglayer::primitive2d::Primitive2DSequence - createLocalDecomposition( + get2DDecomposition( + const ::drawinglayer::geometry::ViewInformation2D& rViewInformation + ) const; + + virtual ::drawinglayer::primitive2d::Primitive2DSequence + create2DDecomposition( const ::drawinglayer::geometry::ViewInformation2D& rViewInformation ) const; @@ -1021,8 +1030,8 @@ namespace sdr { namespace contact { //-------------------------------------------------------------------- void ViewObjectContactOfUnoControl_Impl::positionAndZoomControl( const basegfx::B2DHomMatrix& _rViewTransformation ) const { - OSL_PRECOND( ( m_pOutputDeviceForWindow != NULL ) && m_aControl.is(), "ViewObjectContactOfUnoControl_Impl::positionAndZoomControl: no output device or no control!" ); - if ( ( m_pOutputDeviceForWindow == NULL ) || !m_aControl.is() ) + OSL_PRECOND( m_aControl.is(), "ViewObjectContactOfUnoControl_Impl::positionAndZoomControl: no output device or no control!" ); + if ( !m_aControl.is() ) return; try @@ -1042,7 +1051,7 @@ namespace sdr { namespace contact { } //-------------------------------------------------------------------- - bool ViewObjectContactOfUnoControl_Impl::ensureControl() + bool ViewObjectContactOfUnoControl_Impl::ensureControl( const basegfx::B2DHomMatrix* _pInitialViewTransformationOrNULL ) { OSL_PRECOND( !impl_isDisposed_nofail(), "ViewObjectContactOfUnoControl_Impl::ensureControl: already disposed()" ); if ( impl_isDisposed_nofail() ) @@ -1052,16 +1061,20 @@ namespace sdr { namespace contact { if ( pPageViewContact ) { SdrPageViewAccess aPVAccess( pPageViewContact->GetPageWindow().GetPageView() ); + const OutputDevice& rDevice( impl_getPageViewOutputDevice_nothrow( *pPageViewContact ) ); return impl_ensureControl_nothrow( aPVAccess, - impl_getPageViewOutputDevice_nothrow( *pPageViewContact ) + rDevice, + _pInitialViewTransformationOrNULL ? *_pInitialViewTransformationOrNULL : rDevice.GetViewTransformation() ); } DummyPageViewAccess aNoPageView; + const OutputDevice& rDevice( impl_getOutputDevice_throw() ); return impl_ensureControl_nothrow( aNoPageView, - impl_getOutputDevice_throw() + rDevice, + _pInitialViewTransformationOrNULL ? *_pInitialViewTransformationOrNULL : rDevice.GetViewTransformation() ); } @@ -1104,7 +1117,8 @@ namespace sdr { namespace contact { } //-------------------------------------------------------------------- - bool ViewObjectContactOfUnoControl_Impl::impl_ensureControl_nothrow( IPageViewAccess& _rPageView, const OutputDevice& _rDevice ) + bool ViewObjectContactOfUnoControl_Impl::impl_ensureControl_nothrow( IPageViewAccess& _rPageView, const OutputDevice& _rDevice, + const basegfx::B2DHomMatrix& _rInitialViewTransformation ) { if ( m_bCreatingControl ) { @@ -1148,7 +1162,7 @@ namespace sdr { namespace contact { return false; ControlHolder aControl; - if ( !createControlForDevice( _rPageView, _rDevice, *pUnoObject, aControl ) ) + if ( !createControlForDevice( _rPageView, _rDevice, *pUnoObject, _rInitialViewTransformation, m_aZoomLevelNormalization, aControl ) ) return false; m_pOutputDeviceForWindow = &_rDevice; @@ -1183,7 +1197,8 @@ namespace sdr { namespace contact { //-------------------------------------------------------------------- bool ViewObjectContactOfUnoControl_Impl::createControlForDevice( IPageViewAccess& _rPageView, - const OutputDevice& _rDevice, const SdrUnoObj& _rUnoObject, ControlHolder& _out_rControl ) + const OutputDevice& _rDevice, const SdrUnoObj& _rUnoObject, const basegfx::B2DHomMatrix& _rInitialViewTransformation, + const basegfx::B2DHomMatrix& _rInitialZoomNormalization, ControlHolder& _out_rControl ) { _out_rControl.clear(); @@ -1207,8 +1222,8 @@ namespace sdr { namespace contact { UnoControlContactHelper::adjustControlGeometry_throw( _out_rControl, _rUnoObject.GetLogicRect(), - _rDevice.GetViewTransformation(), - _rDevice.GetInverseViewTransformation() + _rInitialViewTransformation, + _rInitialZoomNormalization ); // #107049# set design mode before peer is created, @@ -1527,31 +1542,33 @@ namespace sdr { namespace contact { VOCGuard aGuard( *this ); DBG_ASSERT( Event.Source == m_xContainer, "ViewObjectContactOfUnoControl_Impl::elementReplaced: where did this come from?" ); - if ( m_aControl == Event.ReplacedElement ) - { - Reference< XControl > xNewControl( Event.Element, UNO_QUERY ); - DBG_ASSERT( xNewControl.is(), "ViewObjectContactOfUnoControl_Impl::elementReplaced: invalid new control!" ); - if ( !xNewControl.is() ) - return; + if ( ! ( m_aControl == Event.ReplacedElement ) ) + return; - ENSURE_OR_THROW( m_pOutputDeviceForWindow, "calling this without /me having an output device should be impossible." ); + Reference< XControl > xNewControl( Event.Element, UNO_QUERY ); + DBG_ASSERT( xNewControl.is(), "ViewObjectContactOfUnoControl_Impl::elementReplaced: invalid new control!" ); + if ( !xNewControl.is() ) + return; - DBG_ASSERT( xNewControl->getModel() == m_aControl.getModel(), "ViewObjectContactOfUnoControl_Impl::elementReplaced: another model at the new control?" ); - // another model should - in the drawing layer - also imply another SdrUnoObj, which - // should also result in new ViewContact, and thus in new ViewObjectContacts + ENSURE_OR_THROW( m_pOutputDeviceForWindow, "calling this without /me having an output device should be impossible." ); - impl_switchControlListening_nothrow( false ); + DBG_ASSERT( xNewControl->getModel() == m_aControl.getModel(), "ViewObjectContactOfUnoControl_Impl::elementReplaced: another model at the new control?" ); + // another model should - in the drawing layer - also imply another SdrUnoObj, which + // should also result in new ViewContact, and thus in new ViewObjectContacts - ControlHolder aNewControl( xNewControl ); - aNewControl.setZoom( m_aControl.getZoom() ); - aNewControl.setPosSize( m_aControl.getPosSize() ); - aNewControl.setDesignMode( impl_isControlDesignMode_nothrow() ); + impl_switchControlListening_nothrow( false ); - m_aControl = xNewControl; - m_bControlIsVisible = m_aControl.isVisible(); + ControlHolder aNewControl( xNewControl ); + aNewControl.setZoom( m_aControl.getZoom() ); + aNewControl.setPosSize( m_aControl.getPosSize() ); + aNewControl.setDesignMode( impl_isControlDesignMode_nothrow() ); - impl_switchControlListening_nothrow( true ); - } + m_aControl = xNewControl; + m_bControlIsVisible = m_aControl.isVisible(); + + impl_switchControlListening_nothrow( true ); + + m_pAntiImpl->onControlChangedOrModified( ViewObjectContactOfUnoControl::ImplAccess() ); } //-------------------------------------------------------------------- @@ -1583,7 +1600,7 @@ namespace sdr { namespace contact { //-------------------------------------------------------------------- bool LazyControlCreationPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if ( !BasePrimitive2D::operator==( rPrimitive ) ) + if ( !BufferedDecompositionPrimitive2D::operator==( rPrimitive ) ) return false; const LazyControlCreationPrimitive2D* pRHS = dynamic_cast< const LazyControlCreationPrimitive2D* >( &rPrimitive ); @@ -1629,7 +1646,20 @@ namespace sdr { namespace contact { } //-------------------------------------------------------------------- - ::drawinglayer::primitive2d::Primitive2DSequence LazyControlCreationPrimitive2D::createLocalDecomposition( const ::drawinglayer::geometry::ViewInformation2D& _rViewInformation ) const + ::drawinglayer::primitive2d::Primitive2DSequence LazyControlCreationPrimitive2D::get2DDecomposition( const ::drawinglayer::geometry::ViewInformation2D& _rViewInformation ) const + { + #if OSL_DEBUG_LEVEL > 1 + ::basegfx::B2DVector aScale, aTranslate; + double fRotate, fShearX; + _rViewInformation.getObjectToViewTransformation().decompose( aScale, aTranslate, fRotate, fShearX ); + #endif + if ( m_pVOCImpl->hasControl() ) + impl_positionAndZoomControl( _rViewInformation ); + return BufferedDecompositionPrimitive2D::get2DDecomposition( _rViewInformation ); + } + + //-------------------------------------------------------------------- + ::drawinglayer::primitive2d::Primitive2DSequence LazyControlCreationPrimitive2D::create2DDecomposition( const ::drawinglayer::geometry::ViewInformation2D& _rViewInformation ) const { #if OSL_DEBUG_LEVEL > 1 ::basegfx::B2DVector aScale, aTranslate; @@ -1638,7 +1668,7 @@ namespace sdr { namespace contact { #endif // force control here to make it a VCL ChildWindow. Will be fetched // and used below by getExistentControl() - m_pVOCImpl->ensureControl(); + m_pVOCImpl->ensureControl( &_rViewInformation.getObjectToViewTransformation() ); impl_positionAndZoomControl( _rViewInformation ); // get needed data @@ -1697,7 +1727,7 @@ namespace sdr { namespace contact { Reference< XControl > ViewObjectContactOfUnoControl::getControl() { VOCGuard aGuard( *m_pImpl ); - m_pImpl->ensureControl(); + m_pImpl->ensureControl( NULL ); return m_pImpl->getExistentControl().getControl(); } @@ -1708,7 +1738,8 @@ namespace sdr { namespace contact { ControlHolder aControl; InvisibleControlViewAccess aSimulatePageView( _inout_ControlContainer ); - OSL_VERIFY( ViewObjectContactOfUnoControl_Impl::createControlForDevice( aSimulatePageView, _rWindow, _rUnoObject, aControl ) ); + OSL_VERIFY( ViewObjectContactOfUnoControl_Impl::createControlForDevice( aSimulatePageView, _rWindow, _rUnoObject, + _rWindow.GetViewTransformation(), _rWindow.GetInverseViewTransformation(), aControl ) ); return aControl.getControl(); } @@ -1801,14 +1832,7 @@ namespace sdr { namespace contact { //-------------------------------------------------------------------- void ViewObjectContactOfUnoControl::propertyChange() { - // graphical invalidate at all views - ActionChanged(); - - // #i93318# flush Primitive2DSequence to force recreation with updated XControlModel - // since e.g. background color has changed and existing decompositions are possibly no - // longer valid. Unfortunately this is not detected from ControlPrimitive2D::operator== - // since it only has a uno reference to the XControlModel - flushPrimitive2DSequence(); + impl_onControlChangedOrModified(); } //-------------------------------------------------------------------- @@ -1836,6 +1860,19 @@ namespace sdr { namespace contact { } } + //-------------------------------------------------------------------- + void ViewObjectContactOfUnoControl::impl_onControlChangedOrModified() + { + // graphical invalidate at all views + ActionChanged(); + + // #i93318# flush Primitive2DSequence to force recreation with updated XControlModel + // since e.g. background color has changed and existing decompositions are possibly no + // longer valid. Unfortunately this is not detected from ControlPrimitive2D::operator== + // since it only has a uno reference to the XControlModel + flushPrimitive2DSequence(); + } + //==================================================================== //= UnoControlPrintOrPreviewContact //==================================================================== diff --git a/svx/source/sdr/overlay/overlayselection.cxx b/svx/source/sdr/overlay/overlayselection.cxx index 2411ca3c31b4..b788de195903 100644 --- a/svx/source/sdr/overlay/overlayselection.cxx +++ b/svx/source/sdr/overlay/overlayselection.cxx @@ -113,9 +113,16 @@ namespace sdr if(nCount) { // create range primitives - const basegfx::BColor aRGBColor(getBaseColor().getBColor()); + const bool bInvert(OVERLAY_INVERT == maLastOverlayType); + basegfx::BColor aRGBColor(getBaseColor().getBColor()); aRetval.realloc(nCount); + if(bInvert) + { + // force color to white for invert to get a full invert + aRGBColor = basegfx::BColor(1.0, 1.0, 1.0); + } + for(sal_uInt32 a(0);a < nCount; a++) { const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(maRanges[a])); @@ -125,7 +132,7 @@ namespace sdr aRGBColor)); } - if(OVERLAY_INVERT == maLastOverlayType) + if(bInvert) { // embed all in invert primitive const drawinglayer::primitive2d::Primitive2DReference aInvert( diff --git a/svx/source/sdr/overlay/overlaytools.cxx b/svx/source/sdr/overlay/overlaytools.cxx index 664c487c7e43..22b273a2a0e4 100644 --- a/svx/source/sdr/overlay/overlaytools.cxx +++ b/svx/source/sdr/overlay/overlaytools.cxx @@ -40,6 +40,7 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -59,7 +60,7 @@ namespace drawinglayer mnCenterY(nCenterY) {} - Primitive2DSequence OverlayBitmapExPrimitive::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence OverlayBitmapExPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { Primitive2DSequence aRetval; const Size aBitmapSize(getBitmapEx().GetSizePixel()); @@ -129,7 +130,7 @@ namespace drawinglayer mfDiscreteDashLength(fDiscreteDashLength) {} - Primitive2DSequence OverlayCrosshairPrimitive::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence OverlayCrosshairPrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { // use the prepared Viewport information accessible using getViewport() Primitive2DSequence aRetval; @@ -208,7 +209,7 @@ namespace drawinglayer mfRotation(fRotation) {} - Primitive2DSequence OverlayHatchRectanglePrimitive::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence OverlayHatchRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { Primitive2DSequence aRetval; @@ -230,11 +231,8 @@ namespace drawinglayer if(!basegfx::fTools::equalZero(getRotation())) { - basegfx::B2DHomMatrix aTransform; - - aTransform.translate(-getObjectRange().getMinX(), -getObjectRange().getMinY()); - aTransform.rotate(getRotation()); - aTransform.translate(getObjectRange().getMinX(), getObjectRange().getMinY()); + const basegfx::B2DHomMatrix aTransform(basegfx::tools::createRotateAroundPoint( + getObjectRange().getMinX(), getObjectRange().getMinY(), getRotation())); aHatchPolyPolygon.transform(aTransform); } @@ -301,7 +299,7 @@ namespace drawinglayer mfDiscreteDashLength(fDiscreteDashLength) {} - Primitive2DSequence OverlayHelplineStripedPrimitive::createLocalDecomposition(const geometry::ViewInformation2D& rViewInformation) const + Primitive2DSequence OverlayHelplineStripedPrimitive::create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const { // use the prepared Viewport information accessible using getViewport() Primitive2DSequence aRetval; @@ -417,7 +415,7 @@ namespace drawinglayer mfDiscreteDashLength(fDiscreteDashLength) {} - Primitive2DSequence OverlayRollingRectanglePrimitive::createLocalDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DSequence OverlayRollingRectanglePrimitive::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { // use the prepared Viewport information accessible using getViewport() Primitive2DSequence aRetval; diff --git a/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx index 73d5689350c2..e4967f767299 100644 --- a/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrcaptionprimitive2d.cxx @@ -47,7 +47,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrCaptionPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrCaptionPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence aRetval; Primitive2DSequence aHitTestContent; @@ -142,7 +142,7 @@ namespace drawinglayer const basegfx::B2DPolygon& rTail, double fCornerRadiusX, double fCornerRadiusY) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), maSdrLFSTAttribute(rSdrLFSTAttribute), maTail(rTail), @@ -160,7 +160,7 @@ namespace drawinglayer bool SdrCaptionPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrCaptionPrimitive2D& rCompare = (SdrCaptionPrimitive2D&)rPrimitive; diff --git a/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx index a04021ae21ad..0c39f7a6480f 100644 --- a/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrconnectorprimitive2d.cxx @@ -47,7 +47,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrConnectorPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrConnectorPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence aRetval; @@ -87,7 +87,7 @@ namespace drawinglayer SdrConnectorPrimitive2D::SdrConnectorPrimitive2D( const attribute::SdrLineShadowTextAttribute& rSdrLSTAttribute, const ::basegfx::B2DPolygon& rUnitPolygon) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maSdrLSTAttribute(rSdrLSTAttribute), maUnitPolygon(rUnitPolygon) { @@ -95,7 +95,7 @@ namespace drawinglayer bool SdrConnectorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrConnectorPrimitive2D& rCompare = (SdrConnectorPrimitive2D&)rPrimitive; diff --git a/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx index af3e6aacb410..5b686bb5abae 100644 --- a/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrcustomshapeprimitive2d.cxx @@ -47,7 +47,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrCustomShapePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrCustomShapePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence aRetval(getSubPrimitives()); @@ -92,21 +92,21 @@ namespace drawinglayer const Primitive2DSequence& rSubPrimitives, const basegfx::B2DHomMatrix& rTextBox, bool bWordWrap, - bool bForceTextClipToTextRange, - bool b3DShape) - : BasePrimitive2D(), + bool b3DShape, + bool bForceTextClipToTextRange) + : BufferedDecompositionPrimitive2D(), maSdrSTAttribute(rSdrSTAttribute), maSubPrimitives(rSubPrimitives), maTextBox(rTextBox), mbWordWrap(bWordWrap), - mbForceTextClipToTextRange(bForceTextClipToTextRange), - mb3DShape(b3DShape) + mb3DShape(b3DShape), + mbForceTextClipToTextRange(bForceTextClipToTextRange) { } bool SdrCustomShapePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrCustomShapePrimitive2D& rCompare = (SdrCustomShapePrimitive2D&)rPrimitive; @@ -114,8 +114,8 @@ namespace drawinglayer && getSubPrimitives() == rCompare.getSubPrimitives() && getTextBox() == rCompare.getTextBox() && getWordWrap() == rCompare.getWordWrap() - && isForceTextClipToTextRange() == rCompare.isForceTextClipToTextRange() - && get3DShape() == rCompare.get3DShape()); + && get3DShape() == rCompare.get3DShape() + && isForceTextClipToTextRange() == rCompare.isForceTextClipToTextRange()); } return false; diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx index cd426edfdd05..8474b72be2e4 100644 --- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx +++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx @@ -75,11 +75,11 @@ namespace drawinglayer // prepare fully scaled polygon basegfx::B2DPolyPolygon aScaledPolyPolygon(rUnitPolyPolygon); aScaledPolyPolygon.transform(rObjectTransform); - BasePrimitive2D* pNewFillPrimitive = 0L; + BasePrimitive2D* pNewFillPrimitive = 0; if(rFill.isGradient()) { - pNewFillPrimitive = new PolyPolygonGradientPrimitive2D(aScaledPolyPolygon, rFill.getColor(), *rFill.getGradient()); + pNewFillPrimitive = new PolyPolygonGradientPrimitive2D(aScaledPolyPolygon, *rFill.getGradient()); } else if(rFill.isHatch()) { @@ -88,7 +88,7 @@ namespace drawinglayer else if(rFill.isBitmap()) { const basegfx::B2DRange aRange(basegfx::tools::getRange(aScaledPolyPolygon)); - pNewFillPrimitive = new PolyPolygonBitmapPrimitive2D(aScaledPolyPolygon, rFill.getColor(), rFill.getBitmap()->getFillBitmapAttribute(aRange)); + pNewFillPrimitive = new PolyPolygonBitmapPrimitive2D(aScaledPolyPolygon, rFill.getBitmap()->getFillBitmapAttribute(aRange)); } else { @@ -192,19 +192,17 @@ namespace drawinglayer // scale outline to object's size to allow growing with value relative to that size // and also to keep aspect ratio - basegfx::B2DHomMatrix aScaleTransform; - aScaleTransform.set(0, 0, fabs(aScale.getX())); - aScaleTransform.set(1, 1, fabs(aScale.getY())); basegfx::B2DPolyPolygon aScaledUnitPolyPolygon(rUnitPolyPolygon); - aScaledUnitPolyPolygon.transform(aScaleTransform); + aScaledUnitPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix( + fabs(aScale.getX()), fabs(aScale.getY()))); // grow the polygon. To shrink, use negative value (half width) aScaledUnitPolyPolygon = basegfx::tools::growInNormalDirection(aScaledUnitPolyPolygon, -(pStroke->getWidth() * 0.5)); // scale back to unit polygon - aScaleTransform.set(0, 0, 0.0 != aScale.getX() ? 1.0 / aScale.getX() : 1.0); - aScaleTransform.set(1, 1, 0.0 != aScale.getY() ? 1.0 / aScale.getY() : 1.0); - aScaledUnitPolyPolygon.transform(aScaleTransform); + aScaledUnitPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix( + 0.0 != aScale.getX() ? 1.0 / aScale.getX() : 1.0, + 0.0 != aScale.getY() ? 1.0 / aScale.getY() : 1.0)); // create with unit polygon pNew = new SdrContourTextPrimitive2D( @@ -265,17 +263,16 @@ namespace drawinglayer aTextAnchorRange.expand(aBottomRight); // now create a transformation from this basic range (aTextAnchorRange) - aAnchorTransform.identity(); - aAnchorTransform.scale(aTextAnchorRange.getWidth(), aTextAnchorRange.getHeight()); - aAnchorTransform.translate(aTextAnchorRange.getMinX(), aTextAnchorRange.getMinY()); + aAnchorTransform = basegfx::tools::createScaleTranslateB2DHomMatrix( + aTextAnchorRange.getWidth(), aTextAnchorRange.getHeight(), + aTextAnchorRange.getMinX(), aTextAnchorRange.getMinY()); // apply mirroring aAnchorTransform.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0); // apply object's other transforms - aAnchorTransform.shearX(fShearX); - aAnchorTransform.rotate(fRotate); - aAnchorTransform.translate(aTranslate.getX(), aTranslate.getY()); + aAnchorTransform = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate) + * aAnchorTransform; if(rText.isFitToSize()) { @@ -342,10 +339,8 @@ namespace drawinglayer aAnchorTransform.decompose(aScale, aTranslate, fRotate, fShearX); // build transform from scaled only to full AnchorTransform and inverse - basegfx::B2DHomMatrix aSRT; - aSRT.shearX(fShearX); - aSRT.rotate(fRotate); - aSRT.translate(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DHomMatrix aSRT(basegfx::tools::createShearXRotateTranslateB2DHomMatrix( + fShearX, fRotate, aTranslate)); basegfx::B2DHomMatrix aISRT(aSRT); aISRT.invert(); diff --git a/svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx index 4f7e2c768669..1327d2a422fa 100644 --- a/svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrellipseprimitive2d.cxx @@ -39,6 +39,7 @@ #include <drawinglayer/primitive2d/hittestprimitive2d.hxx> #include <basegfx/color/bcolor.hxx> #include <drawinglayer/attribute/sdrattribute.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -50,7 +51,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrEllipsePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrEllipsePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence aRetval; @@ -61,11 +62,7 @@ namespace drawinglayer ::basegfx::B2DPolygon aUnitOutline(::basegfx::tools::createPolygonFromUnitCircle(1)); // scale and move UnitEllipse to UnitObject (-1,-1 1,1) -> (0,0 1,1) - ::basegfx::B2DHomMatrix aUnitCorrectionMatrix; - aUnitCorrectionMatrix.set(0, 0, 0.5); - aUnitCorrectionMatrix.set(1, 1, 0.5); - aUnitCorrectionMatrix.set(0, 2, 0.5); - aUnitCorrectionMatrix.set(1, 2, 0.5); + const basegfx::B2DHomMatrix aUnitCorrectionMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix(0.5, 0.5, 0.5, 0.5)); // apply to the geometry aUnitOutline.transform(aUnitCorrectionMatrix); @@ -109,7 +106,7 @@ namespace drawinglayer SdrEllipsePrimitive2D::SdrEllipsePrimitive2D( const ::basegfx::B2DHomMatrix& rTransform, const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), maSdrLFSTAttribute(rSdrLFSTAttribute) { @@ -117,7 +114,7 @@ namespace drawinglayer bool SdrEllipsePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrEllipsePrimitive2D& rCompare = (SdrEllipsePrimitive2D&)rPrimitive; @@ -140,13 +137,12 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrEllipseSegmentPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrEllipseSegmentPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence aRetval; // create unit outline polygon ::basegfx::B2DPolygon aUnitOutline(::basegfx::tools::createPolygonFromUnitEllipseSegment(mfStartAngle, mfEndAngle)); - ::basegfx::B2DHomMatrix aUnitCorrectionMatrix; if(mbCloseSegment) { @@ -161,7 +157,7 @@ namespace drawinglayer } // move and scale UnitEllipse to UnitObject (-1,-1 1,1) -> (0,0 1,1) - aUnitCorrectionMatrix.translate(1.0, 1.0); + basegfx::B2DHomMatrix aUnitCorrectionMatrix(basegfx::tools::createTranslateB2DHomMatrix(1.0, 1.0)); aUnitCorrectionMatrix.scale(0.5, 0.5); // apply to the geometry diff --git a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx index 63d050a775af..befff1b0c539 100644 --- a/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrgrafprimitive2d.cxx @@ -44,7 +44,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrGrafPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrGrafPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence aRetval; @@ -121,7 +121,7 @@ namespace drawinglayer const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute, const GraphicObject& rGraphicObject, const GraphicAttr& rGraphicAttr) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), maSdrLFSTAttribute(rSdrLFSTAttribute), maGraphicObject(rGraphicObject), @@ -133,7 +133,7 @@ namespace drawinglayer bool SdrGrafPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrGrafPrimitive2D& rCompare = (SdrGrafPrimitive2D&)rPrimitive; diff --git a/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx index cb2452e8ba1f..e22e9eb61c5b 100644 --- a/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrmeasureprimitive2d.cxx @@ -40,6 +40,7 @@ #include <drawinglayer/primitive2d/groupprimitive2d.hxx> #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> #include <drawinglayer/primitive2d/hittestprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -85,7 +86,7 @@ namespace drawinglayer return createPolygonLinePrimitive(aPolygon, rObjectMatrix, rLineAttribute, &aLineStartEnd); } - Primitive2DSequence SdrMeasurePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const + Primitive2DSequence SdrMeasurePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const { Primitive2DSequence aRetval; SdrBlockTextPrimitive2D* pBlockText = 0L; @@ -97,10 +98,8 @@ namespace drawinglayer const double fAngle(atan2(aLine.getY(), aLine.getX())); bool bAutoUpsideDown(false); const attribute::SdrTextAttribute* pTextAttribute = getSdrLSTAttribute().getText(); - - basegfx::B2DHomMatrix aObjectMatrix; - aObjectMatrix.rotate(fAngle); - aObjectMatrix.translate(getStart().getX(), getStart().getY()); + const basegfx::B2DHomMatrix aObjectMatrix( + basegfx::tools::createShearXRotateTranslateB2DHomMatrix(0.0, fAngle, getStart())); if(pTextAttribute) { @@ -430,7 +429,7 @@ namespace drawinglayer // apply to existing text primitive SdrTextPrimitive2D* pNewBlockText = pBlockText->createTransformedClone(aChange); - OSL_ENSURE(pNewBlockText, "SdrMeasurePrimitive2D::createLocalDecomposition: Could not create transformed clone of text primitive (!)"); + OSL_ENSURE(pNewBlockText, "SdrMeasurePrimitive2D::create2DDecomposition: Could not create transformed clone of text primitive (!)"); delete pBlockText; // add to local primitives @@ -460,7 +459,7 @@ namespace drawinglayer bool bBelow, bool bTextRotation, bool bTextAutoAngle) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maSdrLSTAttribute(rSdrLSTAttribute), maStart(rStart), maEnd(rEnd), @@ -479,7 +478,7 @@ namespace drawinglayer bool SdrMeasurePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrMeasurePrimitive2D& rCompare = (SdrMeasurePrimitive2D&)rPrimitive; diff --git a/svx/source/sdr/primitive2d/sdrole2primitive2d.cxx b/svx/source/sdr/primitive2d/sdrole2primitive2d.cxx index 7c44311d3c5a..bf2df22fb2e6 100644 --- a/svx/source/sdr/primitive2d/sdrole2primitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrole2primitive2d.cxx @@ -46,9 +46,37 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrOle2Primitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + SdrOle2Primitive2D::SdrOle2Primitive2D( + const Primitive2DSequence& rOLEContent, + const basegfx::B2DHomMatrix& rTransform, + const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute) + : BasePrimitive2D(), + maOLEContent(rOLEContent), + maTransform(rTransform), + maSdrLFSTAttribute(rSdrLFSTAttribute) + { + } + + bool SdrOle2Primitive2D::operator==(const BasePrimitive2D& rPrimitive) const + { + if(BasePrimitive2D::operator==(rPrimitive)) + { + const SdrOle2Primitive2D& rCompare = (SdrOle2Primitive2D&)rPrimitive; + + if(getOLEContent() == rCompare.getOLEContent() + && getTransform() == rCompare.getTransform() + && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()) + { + return true; + } + } + + return false; + } + + Primitive2DSequence SdrOle2Primitive2D::get2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { - // to take care of getSdrLFSTAttribute() later, the same as in SdrGrafPrimitive2D::createLocalDecomposition + // to take care of getSdrLFSTAttribute() later, the same as in SdrGrafPrimitive2D::create2DDecomposition // should happen. For the moment we only need the OLE itself // Added complete primitive preparation using getSdrLFSTAttribute() now. To not do stuff which is not needed now, it // may be supressed by using a static bool. The paint version only supported text. @@ -104,7 +132,7 @@ namespace drawinglayer } // add graphic content - appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, getChildren()); + appendPrimitive2DSequenceToPrimitive2DSequence(aRetval, getOLEContent()); // add text, no need to supress to stay compatible since text was // always supported by the old paints, too @@ -122,32 +150,6 @@ namespace drawinglayer return aRetval; } - SdrOle2Primitive2D::SdrOle2Primitive2D( - const Primitive2DSequence& rChildren, - const ::basegfx::B2DHomMatrix& rTransform, - const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute) - : GroupPrimitive2D(rChildren), - maTransform(rTransform), - maSdrLFSTAttribute(rSdrLFSTAttribute) - { - } - - bool SdrOle2Primitive2D::operator==(const BasePrimitive2D& rPrimitive) const - { - if(GroupPrimitive2D::operator==(rPrimitive)) - { - const SdrOle2Primitive2D& rCompare = (SdrOle2Primitive2D&)rPrimitive; - - if(getTransform() == rCompare.getTransform() - && getSdrLFSTAttribute() == rCompare.getSdrLFSTAttribute()) - { - return true; - } - } - - return false; - } - // provide unique ID ImplPrimitrive2DIDBlock(SdrOle2Primitive2D, PRIMITIVE2D_ID_SDROLE2PRIMITIVE2D) diff --git a/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx index e682c0e04b55..d46ab7b4b14d 100644 --- a/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrolecontentprimitive2d.cxx @@ -39,6 +39,7 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -46,7 +47,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrOleContentPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrOleContentPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence aRetval; const SdrOle2Obj* pSource = (mpSdrOle2Obj.is() ? static_cast< SdrOle2Obj* >(mpSdrOle2Obj.get()) : 0); @@ -105,13 +106,10 @@ namespace drawinglayer if(basegfx::fTools::moreOrEqual(fOffsetX, 0.0) && basegfx::fTools::moreOrEqual(fOffsetY, 0.0)) { // if content fits into frame, create it - basegfx::B2DHomMatrix aInnerObjectMatrix; - - aInnerObjectMatrix.scale(aPrefSize.getWidth(), aPrefSize.getHeight()); - aInnerObjectMatrix.translate(fOffsetX, fOffsetY); - aInnerObjectMatrix.shearX(fShearX); - aInnerObjectMatrix.rotate(fRotate); - aInnerObjectMatrix.translate(aTranslate.getX(), aTranslate.getY()); + basegfx::B2DHomMatrix aInnerObjectMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix( + aPrefSize.getWidth(), aPrefSize.getHeight(), fOffsetX, fOffsetY)); + aInnerObjectMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix(fShearX, fRotate, aTranslate) + * aInnerObjectMatrix; const drawinglayer::primitive2d::Primitive2DReference aGraphicPrimitive( new drawinglayer::primitive2d::GraphicPrimitive2D( @@ -159,7 +157,7 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rObjectTransform, sal_uInt32 nGraphicVersion, bool bHighContrast) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), mpSdrOle2Obj(const_cast< SdrOle2Obj* >(&rSdrOle2Obj)), maObjectTransform(rObjectTransform), mnGraphicVersion(nGraphicVersion), @@ -169,7 +167,7 @@ namespace drawinglayer bool SdrOleContentPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrOleContentPrimitive2D& rCompare = (SdrOleContentPrimitive2D&)rPrimitive; const bool bBothNot(!mpSdrOle2Obj.is() && !rCompare.mpSdrOle2Obj.is()); diff --git a/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx index 96da706fb66a..39f3efc617f5 100644 --- a/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrpathprimitive2d.cxx @@ -47,7 +47,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrPathPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrPathPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence aRetval; @@ -105,7 +105,7 @@ namespace drawinglayer const basegfx::B2DHomMatrix& rTransform, const attribute::SdrLineFillShadowTextAttribute& rSdrLFSTAttribute, const basegfx::B2DPolyPolygon& rUnitPolyPolygon) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), maSdrLFSTAttribute(rSdrLFSTAttribute), maUnitPolyPolygon(rUnitPolyPolygon) @@ -114,7 +114,7 @@ namespace drawinglayer bool SdrPathPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrPathPrimitive2D& rCompare = (SdrPathPrimitive2D&)rPrimitive; diff --git a/svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx index 097cd5edd445..93ed597cb0a3 100644 --- a/svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrrectangleprimitive2d.cxx @@ -47,7 +47,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrRectanglePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrRectanglePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence aRetval; Primitive2DSequence aHitTestContent; @@ -128,7 +128,7 @@ namespace drawinglayer double fCornerRadiusX, double fCornerRadiusY, bool bForceFillForHitTest) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), maSdrLFSTAttribute(rSdrLFSTAttribute), mfCornerRadiusX(fCornerRadiusX), @@ -139,7 +139,7 @@ namespace drawinglayer bool SdrRectanglePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrRectanglePrimitive2D& rCompare = (SdrRectanglePrimitive2D&)rPrimitive; diff --git a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx index 2702d2c13b4c..2ff3fc9f1e6c 100644 --- a/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx +++ b/svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx @@ -109,7 +109,7 @@ namespace drawinglayer SdrTextPrimitive2D::SdrTextPrimitive2D( const SdrText* pSdrText, const OutlinerParaObject& rOutlinerParaObject) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), mrSdrText(const_cast< SdrText* >(pSdrText)), maOutlinerParaObject(rOutlinerParaObject), mxLastVisualizingPage(), @@ -132,7 +132,7 @@ namespace drawinglayer bool SdrTextPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrTextPrimitive2D& rCompare = (SdrTextPrimitive2D&)rPrimitive; @@ -157,7 +157,7 @@ namespace drawinglayer sal_Int16 nCurrentlyValidPageNumber(0); sal_Int16 nCurrentlyValidPageCount(0); - if(getLocalDecomposition().hasElements()) + if(getBuffered2DDecomposition().hasElements()) { bool bDoDelete(false); @@ -211,11 +211,11 @@ namespace drawinglayer if(bDoDelete) { - const_cast< SdrTextPrimitive2D* >(this)->setLocalDecomposition(Primitive2DSequence()); + const_cast< SdrTextPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); } } - if(!getLocalDecomposition().hasElements()) + if(!getBuffered2DDecomposition().hasElements()) { if(!bCurrentlyVisualizingPageIsSet && mbContainsPageField) { @@ -245,7 +245,7 @@ namespace drawinglayer } // call parent - return BasePrimitive2D::get2DDecomposition(rViewInformation); + return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); } } // end of namespace primitive2d } // end of namespace drawinglayer @@ -256,7 +256,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrContourTextPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const + Primitive2DSequence SdrContourTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const { Primitive2DSequence aRetval; getSdrText()->GetObject().impDecomposeContourTextPrimitive(aRetval, *this, aViewInformation); @@ -309,7 +309,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrPathTextPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const + Primitive2DSequence SdrPathTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const { Primitive2DSequence aRetval; getSdrText()->GetObject().impDecomposePathTextPrimitive(aRetval, *this, aViewInformation); @@ -365,7 +365,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrBlockTextPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const + Primitive2DSequence SdrBlockTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const { Primitive2DSequence aRetval; getSdrText()->GetObject().impDecomposeBlockTextPrimitive(aRetval, *this, aViewInformation); @@ -442,7 +442,7 @@ namespace drawinglayer { namespace primitive2d { - Primitive2DSequence SdrStretchTextPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const + Primitive2DSequence SdrStretchTextPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const { Primitive2DSequence aRetval; getSdrText()->GetObject().impDecomposeStretchTextPrimitive(aRetval, *this, aViewInformation); diff --git a/svx/source/src/app.src b/svx/source/src/app.src index 695424878729..c96511663073 100644 --- a/svx/source/src/app.src +++ b/svx/source/src/app.src @@ -47,26 +47,9 @@ ErrorBox RID_ERRBOX_MODULENOTINSTALLED SID_HLINKBAR_SEARCH; \ SID_HLINKBAR_TARGET; \ SID_HYPERLINK_DIALOG; \ - SID_FM_RECORD_ABSOLUTE; \ - SID_FM_RECORD_FIRST; \ - SID_FM_RECORD_PREV; \ - SID_FM_RECORD_NEXT; \ - SID_FM_RECORD_LAST; \ - SID_FM_RECORD_SAVE; \ - SID_FM_RECORD_UNDO; \ - SID_FM_RECORD_NEW; \ - SID_FM_RECORD_DELETE; \ - SID_FM_REFRESH; \ - SID_FM_SORTUP; \ - SID_FM_SORTDOWN; \ - SID_FM_ORDERCRIT; \ - SID_FM_AUTOFILTER; \ - SID_FM_FILTERCRIT; \ - SID_FM_FORM_FILTERED; \ - SID_FM_REMOVE_FILTER_SORT; \ };\ IdCount = {\ - 21;\ + 4;\ }; ImageList RID_DEFAULTIMAGELIST_SC diff --git a/svx/source/svdraw/gradtrns.cxx b/svx/source/svdraw/gradtrns.cxx index 0e62aa9ed75f..5f607cd20bb6 100644 --- a/svx/source/svdraw/gradtrns.cxx +++ b/svx/source/svdraw/gradtrns.cxx @@ -35,6 +35,7 @@ #include <svx/svdobj.hxx> #include <basegfx/range/b2drange.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <vcl/salbtype.hxx> // FRound ////////////////////////////////////////////////////////////////////////////// @@ -81,11 +82,7 @@ void GradTransformer::GradToVec(GradTransGradient& rG, GradTransVector& rV, cons if(rG.aGradient.GetAngle()) { const double fAngle = (double)rG.aGradient.GetAngle() * (F_PI180 / 10.0); - basegfx::B2DHomMatrix aTransformation; - - aTransformation.translate(-aCenter.getX(), -aCenter.getY()); - aTransformation.rotate(-fAngle); - aTransformation.translate(aCenter.getX(), aCenter.getY()); + const basegfx::B2DHomMatrix aTransformation(basegfx::tools::createRotateAroundPoint(aCenter, -fAngle)); aStartPos *= aTransformation; aEndPos *= aTransformation; @@ -108,11 +105,7 @@ void GradTransformer::GradToVec(GradTransGradient& rG, GradTransVector& rV, cons if(rG.aGradient.GetAngle()) { const double fAngle = (double)rG.aGradient.GetAngle() * (F_PI180 / 10.0); - basegfx::B2DHomMatrix aTransformation; - - aTransformation.translate(-aCenter.getX(), -aCenter.getY()); - aTransformation.rotate(-fAngle); - aTransformation.translate(aCenter.getX(), aCenter.getY()); + const basegfx::B2DHomMatrix aTransformation(basegfx::tools::createRotateAroundPoint(aCenter, -fAngle)); aStartPos *= aTransformation; aEndPos *= aTransformation; @@ -136,11 +129,7 @@ void GradTransformer::GradToVec(GradTransGradient& rG, GradTransVector& rV, cons if(rG.aGradient.GetAngle()) { const double fAngle = (double)rG.aGradient.GetAngle() * (F_PI180 / 10.0); - basegfx::B2DHomMatrix aTransformation; - - aTransformation.translate(-aEndPos.getX(), -aEndPos.getY()); - aTransformation.rotate(-fAngle); - aTransformation.translate(aEndPos.getX(), aEndPos.getY()); + const basegfx::B2DHomMatrix aTransformation(basegfx::tools::createRotateAroundPoint(aEndPos, -fAngle)); aStartPos *= aTransformation; aEndPos *= aTransformation; @@ -175,11 +164,7 @@ void GradTransformer::GradToVec(GradTransGradient& rG, GradTransVector& rV, cons if(rG.aGradient.GetAngle()) { const double fAngle = (double)rG.aGradient.GetAngle() * (F_PI180 / 10.0); - basegfx::B2DHomMatrix aTransformation; - - aTransformation.translate(-aEndPos.getX(), -aEndPos.getY()); - aTransformation.rotate(-fAngle); - aTransformation.translate(aEndPos.getX(), aEndPos.getY()); + const basegfx::B2DHomMatrix aTransformation(basegfx::tools::createRotateAroundPoint(aEndPos, -fAngle)); aStartPos *= aTransformation; aEndPos *= aTransformation; diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx index a8d588e73fe5..826e87520ce3 100644 --- a/svx/source/svdraw/svddrgmt.cxx +++ b/svx/source/svdraw/svddrgmt.cxx @@ -84,6 +84,7 @@ #include <svx/svdovirt.hxx> #include <svx/svdouno.hxx> #include <svx/sdr/primitive2d/sdrprimitivetools.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -608,9 +609,8 @@ void SdrDragMethod::applyCurrentTransformationToSdrObject(SdrObject& rTarget) const double fScaleY(fabs(aScale.getY()) / (basegfx::fTools::equalZero(aPolyRange.getHeight()) ? 1.0 : aPolyRange.getHeight())); // prepare transform matrix for polygon - basegfx::B2DHomMatrix aPolyTransform; - - aPolyTransform.translate(-aPolyRange.getMinX(), -aPolyRange.getMinY()); + basegfx::B2DHomMatrix aPolyTransform(basegfx::tools::createTranslateB2DHomMatrix( + -aPolyRange.getMinX(), -aPolyRange.getMinY())); aPolyTransform.scale(fScaleX, fScaleY); // normally the poly should be moved back, but the translation is in the object @@ -1449,11 +1449,7 @@ bool SdrDragMove::BeginSdrDrag() basegfx::B2DHomMatrix SdrDragMove::getCurrentTransformation() { - basegfx::B2DHomMatrix aRetval; - - aRetval.translate(DragStat().GetDX(), DragStat().GetDY()); - - return aRetval; + return basegfx::tools::createTranslateB2DHomMatrix(DragStat().GetDX(), DragStat().GetDY()); } void SdrDragMove::ImpCheckSnap(const Point& rPt) @@ -1778,9 +1774,8 @@ bool SdrDragResize::BeginSdrDrag() basegfx::B2DHomMatrix SdrDragResize::getCurrentTransformation() { - basegfx::B2DHomMatrix aRetval; - - aRetval.translate(-DragStat().Ref1().X(), -DragStat().Ref1().Y()); + basegfx::B2DHomMatrix aRetval(basegfx::tools::createTranslateB2DHomMatrix( + -DragStat().Ref1().X(), -DragStat().Ref1().Y())); aRetval.scale(aXFact, aYFact); aRetval.translate(DragStat().Ref1().X(), DragStat().Ref1().Y()); @@ -2064,13 +2059,9 @@ bool SdrDragRotate::BeginSdrDrag() basegfx::B2DHomMatrix SdrDragRotate::getCurrentTransformation() { - basegfx::B2DHomMatrix aRetval; - - aRetval.translate(-DragStat().GetRef1().X(), -DragStat().GetRef1().Y()); - aRetval.rotate(-atan2(nSin, nCos)); - aRetval.translate(DragStat().GetRef1().X(), DragStat().GetRef1().Y()); - - return aRetval; + return basegfx::tools::createRotateAroundPoint( + DragStat().GetRef1().X(), DragStat().GetRef1().Y(), + -atan2(nSin, nCos)); } void SdrDragRotate::MoveSdrDrag(const Point& rPnt_) @@ -2220,9 +2211,8 @@ bool SdrDragShear::BeginSdrDrag() basegfx::B2DHomMatrix SdrDragShear::getCurrentTransformation() { - basegfx::B2DHomMatrix aRetval; - - aRetval.translate(-DragStat().GetRef1().X(), -DragStat().GetRef1().Y()); + basegfx::B2DHomMatrix aRetval(basegfx::tools::createTranslateB2DHomMatrix( + -DragStat().GetRef1().X(), -DragStat().GetRef1().Y())); if (bResize) { @@ -2520,7 +2510,7 @@ basegfx::B2DHomMatrix SdrDragMirror::getCurrentTransformation() const double fDeltaY(DragStat().GetRef2().Y() - DragStat().GetRef1().Y()); const double fRotation(atan2(fDeltaY, fDeltaX)); - aRetval.translate(-DragStat().GetRef1().X(), -DragStat().GetRef1().Y()); + aRetval = basegfx::tools::createTranslateB2DHomMatrix(-DragStat().GetRef1().X(), -DragStat().GetRef1().Y()); aRetval.rotate(-fRotation); aRetval.scale(1.0, -1.0); aRetval.rotate(fRotation); diff --git a/svx/source/svdraw/svdfmtf.cxx b/svx/source/svdraw/svdfmtf.cxx index 6d28c4837421..508667b5c628 100644 --- a/svx/source/svdraw/svdfmtf.cxx +++ b/svx/source/svdraw/svdfmtf.cxx @@ -46,7 +46,6 @@ #include <svx/xlnclit.hxx> #include <svx/xlnwtit.hxx> #include <svx/xflclit.hxx> - #include <svx/xgrad.hxx> #include <svx/xflgrit.hxx> #include <editeng/fontitem.hxx> @@ -55,9 +54,7 @@ #include <editeng/cntritem.hxx> #include <editeng/colritem.hxx> #include <vcl/metric.hxx> - #include <editeng/charscaleitem.hxx> - #include <svx/xflhtit.hxx> #include <svx/svdattr.hxx> #include <svx/svdmodel.hxx> @@ -73,9 +70,10 @@ #include <svl/itemset.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <vcl/salbtype.hxx> // FRound - -// #i73407# #include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <svx/xlinjoit.hxx> +#include <svx/xlndsit.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -84,6 +82,8 @@ ImpSdrGDIMetaFileImport::ImpSdrGDIMetaFileImport(SdrModel& rModel): pLineAttr(NULL),pFillAttr(NULL),pTextAttr(NULL), pPage(NULL),pModel(NULL),nLayer(0), nLineWidth(0), + maLineJoin(basegfx::B2DLINEJOIN_NONE), + maDash(XDASH_RECT, 0, 0, 0, 0, 0), bFntDirty(TRUE), bLastObjWasPolyWithoutLine(FALSE),bNoLine(FALSE),bNoFill(FALSE),bLastObjWasLine(FALSE) { @@ -277,6 +277,9 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, FASTBOOL bForceText { if ( nLineWidth ) pLineAttr->Put( XLineWidthItem( nLineWidth ) ); + else + pLineAttr->Put( XLineWidthItem( 0 ) ); + aOldLineColor = aVD.GetLineColor(); if( aVD.IsLineColor() ) { @@ -285,6 +288,34 @@ void ImpSdrGDIMetaFileImport::SetAttributes(SdrObject* pObj, FASTBOOL bForceText } else pLineAttr->Put(XLineStyleItem(XLINE_NONE)); + + switch(maLineJoin) + { + default : // basegfx::B2DLINEJOIN_NONE + pLineAttr->Put(XLineJointItem(XLINEJOINT_NONE)); + break; + case basegfx::B2DLINEJOIN_MIDDLE: + pLineAttr->Put(XLineJointItem(XLINEJOINT_MIDDLE)); + break; + case basegfx::B2DLINEJOIN_BEVEL: + pLineAttr->Put(XLineJointItem(XLINEJOINT_BEVEL)); + break; + case basegfx::B2DLINEJOIN_MITER: + pLineAttr->Put(XLineJointItem(XLINEJOINT_MITER)); + break; + case basegfx::B2DLINEJOIN_ROUND: + pLineAttr->Put(XLineJointItem(XLINEJOINT_ROUND)); + break; + } + + if(((maDash.GetDots() && maDash.GetDotLen()) || (maDash.GetDashes() && maDash.GetDashLen())) && maDash.GetDistance()) + { + pLineAttr->Put(XLineDashItem(String(), maDash)); + } + else + { + pLineAttr->Put(XLineDashItem(String(), XDash(XDASH_RECT))); + } } else bNoLine = TRUE; @@ -385,12 +416,10 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct) if(!aStart.equal(aEnd)) { basegfx::B2DPolygon aLine; - basegfx::B2DHomMatrix aTransform; + const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y())); aLine.append(aStart); aLine.append(aEnd); - aTransform.scale(fScaleX, fScaleY); - aTransform.translate(aOfs.X(), aOfs.Y()); aLine.transform(aTransform); const LineInfo& rLineInfo = rAct.GetLineInfo(); @@ -402,12 +431,19 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaLineAction& rAct) bCreateLineObject = false; } - nLineWidth = nNewLineWidth; - if(bCreateLineObject) { SdrPathObj* pPath = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aLine)); + nLineWidth = nNewLineWidth; + maLineJoin = rLineInfo.GetLineJoin(); + maDash = XDash(XDASH_RECT, + rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), + rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), + rLineInfo.GetDistance()); SetAttributes(pPath); + nLineWidth = 0; + maLineJoin = basegfx::B2DLINEJOIN_NONE; + maDash = XDash(); InsertObj(pPath, false); } } @@ -581,10 +617,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct ) if(aSource.count()) { - basegfx::B2DHomMatrix aTransform; - - aTransform.scale(fScaleX, fScaleY); - aTransform.translate(aOfs.X(), aOfs.Y()); + const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y())); aSource.transform(aTransform); } @@ -601,12 +634,21 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolyLineAction& rAct ) bCreateLineObject = false; } - nLineWidth = nNewLineWidth; - if(bCreateLineObject) { - SdrPathObj* pPath = new SdrPathObj(OBJ_PLIN, basegfx::B2DPolyPolygon(aSource)); + SdrPathObj* pPath = new SdrPathObj( + aSource.isClosed() ? OBJ_POLY : OBJ_PLIN, + basegfx::B2DPolyPolygon(aSource)); + nLineWidth = nNewLineWidth; + maLineJoin = rLineInfo.GetLineJoin(); + maDash = XDash(XDASH_RECT, + rLineInfo.GetDotCount(), rLineInfo.GetDotLen(), + rLineInfo.GetDashCount(), rLineInfo.GetDashLen(), + rLineInfo.GetDistance()); SetAttributes(pPath); + nLineWidth = 0; + maLineJoin = basegfx::B2DLINEJOIN_NONE; + maDash = XDash(); InsertObj(pPath, false); } } @@ -618,10 +660,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaPolygonAction& rAct ) if(aSource.count()) { - basegfx::B2DHomMatrix aTransform; - - aTransform.scale(fScaleX, fScaleY); - aTransform.translate(aOfs.X(), aOfs.Y()); + const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y())); aSource.transform(aTransform); if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(basegfx::B2DPolyPolygon(aSource))) @@ -643,10 +682,7 @@ void ImpSdrGDIMetaFileImport::DoAction(MetaPolyPolygonAction& rAct) if(aSource.count()) { - basegfx::B2DHomMatrix aTransform; - - aTransform.scale(fScaleX, fScaleY); - aTransform.translate(aOfs.X(), aOfs.Y()); + const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y())); aSource.transform(aTransform); if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) @@ -791,9 +827,7 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaHatchAction& rAct ) if(aSource.count()) { - basegfx::B2DHomMatrix aTransform; - aTransform.scale(fScaleX, fScaleY); - aTransform.translate(aOfs.X(), aOfs.Y()); + const basegfx::B2DHomMatrix aTransform(basegfx::tools::createScaleTranslateB2DHomMatrix(fScaleX, fScaleY, aOfs.X(), aOfs.Y())); aSource.transform(aTransform); if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) @@ -886,12 +920,6 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM if(aSource.count()) { - basegfx::B2DHomMatrix aTransform; - - aTransform.scale(fScaleX, fScaleY); - aTransform.translate(aOfs.X(), aOfs.Y()); - aSource.transform(aTransform); - if(!bLastObjWasPolyWithoutLine || !CheckLastPolyLineAndFillMerge(aSource)) { const Gradient& rGrad = pAct->GetGradient(); @@ -912,7 +940,20 @@ void ImpSdrGDIMetaFileImport::DoAction( MetaCommentAction& rAct, GDIMetaFile* pM aXGradient.SetEndIntens(rGrad.GetEndIntensity()); aXGradient.SetSteps(rGrad.GetSteps()); - SetAttributes(pPath); + if(aVD.IsLineColor()) + { + // switch line off; when there was one there will be a + // META_POLYLINE_ACTION following creating another object + const Color aLineColor(aVD.GetLineColor()); + aVD.SetLineColor(); + SetAttributes(pPath); + aVD.SetLineColor(aLineColor); + } + else + { + SetAttributes(pPath); + } + aGradAttr.Put(XFillStyleItem(XFILL_GRADIENT)); aGradAttr.Put(XFillGradientItem(&pModel->GetItemPool(), aXGradient)); pPath->SetMergedItemSet(aGradAttr); diff --git a/svx/source/svdraw/svdfmtf.hxx b/svx/source/svdraw/svdfmtf.hxx index b4d583e6c506..84f2b30b6a15 100644 --- a/svx/source/svdraw/svdfmtf.hxx +++ b/svx/source/svdraw/svdfmtf.hxx @@ -86,6 +86,8 @@ protected: SdrLayerID nLayer; Color aOldLineColor; sal_Int32 nLineWidth; + basegfx::B2DLineJoin maLineJoin; + XDash maDash; sal_Bool bMov; sal_Bool bSize; diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 392a9993a80b..551f483280d3 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -94,6 +94,7 @@ #include <svx/svdview.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> // #104018# replace macros above with type-safe methods inline double ImplTwipsToMM(double fVal) { return (fVal * (127.0 / 72.0)); } @@ -3444,31 +3445,11 @@ sal_Bool SdrObjCustomShape::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, ba } // build matrix - rMatrix.identity(); - - if(!basegfx::fTools::equal(aScale.getX(), 1.0) || !basegfx::fTools::equal(aScale.getY(), 1.0)) - { - rMatrix.scale(aScale.getX(), aScale.getY()); - } - - if(!basegfx::fTools::equalZero(fShearX)) - { - rMatrix.shearX(tan(fShearX)); - } - - if(!basegfx::fTools::equalZero(fRotate)) - { - // #i78696# - // fRotate is from the old GeoStat struct and thus mathematically wrong orientated. For - // the linear combination of matrices it needed to be fixed in the API, so it needs to - // be mirrored here - rMatrix.rotate(-fRotate); - } - - if(!aTranslate.equalZero()) - { - rMatrix.translate(aTranslate.getX(), aTranslate.getY()); - } + rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aScale, + basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX), + basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate, + aTranslate); return sal_False; } diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index d5f92a1d18f1..7464e510f89b 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -68,9 +68,6 @@ #include <svx/svdattrx.hxx> // NotPersistItems #include <svx/svdoashp.hxx> #include <svx/svdomedia.hxx> - -//////////////////////////////////////////////////////////////////////////////////////////////////// - #include <svx/xlnwtit.hxx> #include <svx/xlnstwit.hxx> #include <svx/xlnedwit.hxx> @@ -107,8 +104,6 @@ #include <vcl/graphictools.hxx> #include <svtools/colorcfg.hxx> #include <svx/sdr/properties/emptyproperties.hxx> - -// #110094# #include <svx/sdr/contact/viewcontactofsdrobj.hxx> #include <svx/sdr/contact/viewcontactofgraphic.hxx> #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx> @@ -120,7 +115,6 @@ #include <basegfx/range/b2drange.hxx> #include <svx/unoshape.hxx> #include <vcl/virdev.hxx> - #include <basegfx/polygon/b2dpolypolygoncutter.hxx> #include <drawinglayer/processor2d/contourextractor2d.hxx> #include <drawinglayer/processor2d/linegeometryextractor2d.hxx> @@ -128,10 +122,8 @@ #include "svx/svdotable.hxx" #include "svx/shapepropertynotifier.hxx" #include <svx/sdrhittesthelper.hxx> - -// --> OD 2009-07-10 #i73249# #include <svx/svdundo.hxx> -// <-- +#include <basegfx/matrix/b2dhommatrixtools.hxx> using namespace ::com::sun::star; @@ -3056,17 +3048,7 @@ sal_Bool SdrObject::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx::B } // build matrix - rMatrix.identity(); - - if(1.0 != aScale.getX() || 1.0 != aScale.getY()) - { - rMatrix.scale(aScale.getX(), aScale.getY()); - } - - if(0.0 != aTranslate.getX() || 0.0 != aTranslate.getY()) - { - rMatrix.translate(aTranslate.getX(), aTranslate.getY()); - } + rMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aScale, aTranslate); return sal_False; } diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index 33b3710979ba..d60162030497 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -61,6 +61,7 @@ #include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -225,24 +226,17 @@ basegfx::B2DPolygon SdrCircObj::ImpCalcXPolyCirc(const SdrObjKind eCicrleKind, c if(OBJ_CIRC == eCicrleKind) { - // create full circle. Do not use createPolygonFromEllipse, but the single - // calls to appendUnitCircleQuadrant() to get the start point to the bottom of the - // circle to keep compatible to old geometry creation - basegfx::tools::appendUnitCircleQuadrant(aCircPolygon, 1); - basegfx::tools::appendUnitCircleQuadrant(aCircPolygon, 2); - basegfx::tools::appendUnitCircleQuadrant(aCircPolygon, 3); - basegfx::tools::appendUnitCircleQuadrant(aCircPolygon, 0); - aCircPolygon.setClosed(true); - - // remove double points between segments created by segmented creation - aCircPolygon.removeDoublePoints(); - - // needs own scaling and translation from unit circle to target size - basegfx::B2DHomMatrix aMatrix; - const basegfx::B2DPoint aCenter(aRange.getCenter()); + // create full circle. Do not use createPolygonFromEllipse; it's necessary + // to get the start point to the bottom of the circle to keep compatible to + // old geometry creation + aCircPolygon = basegfx::tools::createPolygonFromUnitCircle(1); - aMatrix.scale(aRange.getWidth() / 2.0, aRange.getHeight() / 2.0); - aMatrix.translate(aCenter.getX(), aCenter.getY()); + // needs own scaling and translation from unit circle to target size (same as + // would be in createPolygonFromEllipse) + const basegfx::B2DPoint aCenter(aRange.getCenter()); + const basegfx::B2DHomMatrix aMatrix(basegfx::tools::createScaleTranslateB2DHomMatrix( + aRange.getWidth() / 2.0, aRange.getHeight() / 2.0, + aCenter.getX(), aCenter.getY())); aCircPolygon.transform(aMatrix); } else @@ -252,7 +246,9 @@ basegfx::B2DPolygon SdrCircObj::ImpCalcXPolyCirc(const SdrObjKind eCicrleKind, c const double fEnd(((36000 - nStart) % 36000) * F_PI18000); // create circle segment. This is not closed by default - aCircPolygon = basegfx::tools::createPolygonFromEllipseSegment(aRange.getCenter(), aRange.getWidth() / 2.0, aRange.getHeight() / 2.0, fStart, fEnd); + aCircPolygon = basegfx::tools::createPolygonFromEllipseSegment( + aRange.getCenter(), aRange.getWidth() / 2.0, aRange.getHeight() / 2.0, + fStart, fEnd); // check closing states const bool bCloseSegment(OBJ_CARC != eCicrleKind); @@ -277,26 +273,16 @@ basegfx::B2DPolygon SdrCircObj::ImpCalcXPolyCirc(const SdrObjKind eCicrleKind, c // #i76950# if(aGeo.nShearWink || aGeo.nDrehWink) { - const basegfx::B2DPoint aTopLeft(aRange.getMinimum()); - basegfx::B2DHomMatrix aMatrix; - // translate top left to (0,0) - aMatrix.translate(-aTopLeft.getX(), -aTopLeft.getY()); - - // shear (if needed) - if(aGeo.nShearWink) - { - aMatrix.shearX(tan((36000 - aGeo.nShearWink) * F_PI18000)); - } - - // rotate (if needed) - if(aGeo.nDrehWink) - { - aMatrix.rotate((36000 - aGeo.nDrehWink) * F_PI18000); - } - - // back to top left - aMatrix.translate(aTopLeft.getX(), aTopLeft.getY()); + const basegfx::B2DPoint aTopLeft(aRange.getMinimum()); + basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix( + -aTopLeft.getX(), -aTopLeft.getY())); + + // shear, rotate and back to top left (if needed) + aMatrix = basegfx::tools::createShearXRotateTranslateB2DHomMatrix( + aGeo.nShearWink ? tan((36000 - aGeo.nShearWink) * F_PI18000) : 0.0, + aGeo.nDrehWink ? (36000 - aGeo.nDrehWink) * F_PI18000 : 0.0, + aTopLeft) * aMatrix; // apply transformation aCircPolygon.transform(aMatrix); diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 4d7b51a073e5..0c25958ee31b 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -133,14 +133,8 @@ void SdrGraphicLink::DataChanged( const String& rMimeType, Graphic aGraphic; if( sfx2::LinkManager::GetGraphicFromAny( rMimeType, rValue, aGraphic )) { - GraphicType eOldGraphicType = pGrafObj->GetGraphicType(); // kein Hereinswappen - const sal_Bool bIsChanged = pModel->IsChanged(); - - pGrafObj->SetGraphic( aGraphic ); - if( GRAPHIC_NONE != eOldGraphicType ) - pGrafObj->SetChanged(); - else - pModel->SetChanged( bIsChanged ); + pGrafObj->NbcSetGraphic( aGraphic ); + pGrafObj->ActionChanged(); } else if( SotExchange::GetFormatIdFromMimeType( rMimeType ) != sfx2::LinkManager::RegisterStatusInfoId() ) { @@ -302,11 +296,16 @@ const GraphicObject& SdrGrafObj::GetGraphicObject(bool bForceSwapIn) const // ----------------------------------------------------------------------------- -void SdrGrafObj::SetGraphic( const Graphic& rGrf ) +void SdrGrafObj::NbcSetGraphic( const Graphic& rGrf ) { pGraphic->SetGraphic( rGrf ); pGraphic->SetUserData(); mbIsPreview = sal_False; +} + +void SdrGrafObj::SetGraphic( const Graphic& rGrf ) +{ + NbcSetGraphic(rGrf); SetChanged(); BroadcastObjectChange(); } @@ -681,7 +680,7 @@ void SdrGrafObj::operator=( const SdrObject& rObj ) const SdrGrafObj& rGraf = (SdrGrafObj&) rObj; - pGraphic->SetGraphic( rGraf.GetGraphic() ); + pGraphic->SetGraphic( rGraf.GetGraphic(), &rGraf.GetGraphicObject() ); aCropRect = rGraf.aCropRect; aFileName = rGraf.aFileName; aFilterName = rGraf.aFilterName; diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index 28b85ac2d309..39b49ca1b25c 100644 --- a/svx/source/svdraw/svdomeas.cxx +++ b/svx/source/svdraw/svdomeas.cxx @@ -71,6 +71,7 @@ #include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1426,17 +1427,7 @@ sal_Bool SdrMeasureObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegf } // build return value matrix - rMatrix.identity(); - - if(!basegfx::fTools::equal(aScale.getX(), 1.0) || !basegfx::fTools::equal(aScale.getY(), 1.0)) - { - rMatrix.scale(aScale.getX(), aScale.getY()); - } - - if(!aTranslate.equalZero()) - { - rMatrix.translate(aTranslate.getX(), aTranslate.getY()); - } + rMatrix = basegfx::tools::createScaleTranslateB2DHomMatrix(aScale, aTranslate); return sal_True; } diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index f44efe3c5dfa..dfad9824a8fd 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -56,7 +56,6 @@ #include <svx/xlnclit.hxx> #include <svx/xflclit.hxx> #include <svx/svdogrp.hxx> - #include <svx/polypolygoneditor.hxx> #include <svx/xlntrit.hxx> #include <vcl/salbtype.hxx> // FRound @@ -77,10 +76,9 @@ inline double ImplMMToTwips(double fVal) { return (fVal * (72.0 / 127.0)); } #include <basegfx/range/b2drange.hxx> #include <basegfx/curve/b2dcubicbezier.hxx> #include <basegfx/polygon/b2dpolygontools.hxx> - -// #i89784# #include <svx/sdr/attribute/sdrtextattribute.hxx> #include <svx/sdr/primitive2d/sdrattributecreator.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> using namespace sdr; @@ -2359,9 +2357,7 @@ Pointer SdrPathObj::GetCreatePointer() const void SdrPathObj::NbcMove(const Size& rSiz) { - basegfx::B2DHomMatrix aTrans; - aTrans.translate(rSiz.Width(), rSiz.Height()); - maPathPolygon.transform(aTrans); + maPathPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(rSiz.Width(), rSiz.Height())); // #i19871# first modify locally, then call parent (to get correct SnapRect with GluePoints) SdrTextObj::NbcMove(rSiz); @@ -2369,10 +2365,9 @@ void SdrPathObj::NbcMove(const Size& rSiz) void SdrPathObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) { - basegfx::B2DHomMatrix aTrans; - aTrans.translate(-rRef.X(), -rRef.Y()); - aTrans.scale(double(xFact), double(yFact)); - aTrans.translate(rRef.X(), rRef.Y()); + basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-rRef.X(), -rRef.Y())); + aTrans = basegfx::tools::createScaleTranslateB2DHomMatrix( + double(xFact), double(yFact), rRef.X(), rRef.Y()) * aTrans; maPathPolygon.transform(aTrans); // #i19871# first modify locally, then call parent (to get correct SnapRect with GluePoints) @@ -2381,10 +2376,8 @@ void SdrPathObj::NbcResize(const Point& rRef, const Fraction& xFact, const Fract void SdrPathObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs) { - basegfx::B2DHomMatrix aTrans; - aTrans.translate(-rRef.X(), -rRef.Y()); - aTrans.rotate(-nWink * nPi180); // Thank JOE, the angles are defined mirrored to the mathematical meanings - aTrans.translate(rRef.X(), rRef.Y()); + // Thank JOE, the angles are defined mirrored to the mathematical meanings + const basegfx::B2DHomMatrix aTrans(basegfx::tools::createRotateAroundPoint(rRef.X(), rRef.Y(), -nWink * nPi180)); maPathPolygon.transform(aTrans); // #i19871# first modify locally, then call parent (to get correct SnapRect with GluePoints) @@ -2393,8 +2386,7 @@ void SdrPathObj::NbcRotate(const Point& rRef, long nWink, double sn, double cs) void SdrPathObj::NbcShear(const Point& rRefPnt, long nAngle, double fTan, FASTBOOL bVShear) { - basegfx::B2DHomMatrix aTrans; - aTrans.translate(-rRefPnt.X(), -rRefPnt.Y()); + basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-rRefPnt.X(), -rRefPnt.Y())); if(bVShear) { @@ -2415,11 +2407,10 @@ void SdrPathObj::NbcShear(const Point& rRefPnt, long nAngle, double fTan, FASTBO void SdrPathObj::NbcMirror(const Point& rRefPnt1, const Point& rRefPnt2) { - basegfx::B2DHomMatrix aTrans; const double fDiffX(rRefPnt2.X() - rRefPnt1.X()); const double fDiffY(rRefPnt2.Y() - rRefPnt1.Y()); const double fRot(atan2(fDiffY, fDiffX)); - aTrans.translate(-rRefPnt1.X(), -rRefPnt1.Y()); + basegfx::B2DHomMatrix aTrans(basegfx::tools::createTranslateB2DHomMatrix(-rRefPnt1.X(), -rRefPnt1.Y())); aTrans.rotate(-fRot); aTrans.scale(1.0, -1.0); aTrans.rotate(fRot); @@ -3003,31 +2994,11 @@ sal_Bool SdrPathObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx:: } // build return value matrix - rMatrix.identity(); - - if(!basegfx::fTools::equal(aScale.getX(), 1.0) || !basegfx::fTools::equal(aScale.getY(), 1.0)) - { - rMatrix.scale(aScale.getX(), aScale.getY()); - } - - if(!basegfx::fTools::equalZero(fShearX)) - { - rMatrix.shearX(tan(fShearX)); - } - - if(!basegfx::fTools::equalZero(fRotate)) - { - // #i78696# - // fRotate is from the old GeoStat and thus mathematically wrong orientated. For - // the linear combination of matrices it needed to be fixed in the API, so it needs to - // be mirrored here - rMatrix.rotate(-fRotate); - } - - if(!aTranslate.equalZero()) - { - rMatrix.translate(aTranslate.getX(), aTranslate.getY()); - } + rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aScale, + basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX), + basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate, + aTranslate); return sal_True; } diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 6382ceebceac..72522c3d8793 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -63,17 +63,14 @@ #include <editeng/editeng.hxx> #include <svl/itemiter.hxx> #include <svx/sdr/properties/textproperties.hxx> - -// #110496# #include <vcl/metaact.hxx> - -// #111111# #include <svx/sdr/contact/viewcontactoftextobj.hxx> #include <basegfx/tuple/b2dtuple.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/polygon/b2dpolygon.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <vcl/virdev.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -737,9 +734,9 @@ void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, Rectangle& rAncho { basegfx::B2DPolyPolygon aXorPolyPolygon(TakeXorPoly()); basegfx::B2DPolyPolygon* pContourPolyPolygon = 0L; - basegfx::B2DHomMatrix aMatrix; + basegfx::B2DHomMatrix aMatrix(basegfx::tools::createTranslateB2DHomMatrix( + -rAnchorRect.Left(), -rAnchorRect.Top())); - aMatrix.translate(-rAnchorRect.Left(), -rAnchorRect.Top()); if(aGeo.nDrehWink) { // Unrotate! @@ -1735,31 +1732,11 @@ sal_Bool SdrTextObj::TRGetBaseGeometry(basegfx::B2DHomMatrix& rMatrix, basegfx:: } // build matrix - rMatrix.identity(); - - if(!basegfx::fTools::equal(aScale.getX(), 1.0) || !basegfx::fTools::equal(aScale.getY(), 1.0)) - { - rMatrix.scale(aScale.getX(), aScale.getY()); - } - - if(!basegfx::fTools::equalZero(fShearX)) - { - rMatrix.shearX(tan(fShearX)); - } - - if(!basegfx::fTools::equalZero(fRotate)) - { - // #i78696# - // fRotate is from the old GeoStat and thus mathematically wrong orientated. For - // the linear combination of matrices it needed to be fixed in the API, so it needs to - // be mirrored here - rMatrix.rotate(-fRotate); - } - - if(!aTranslate.equalZero()) - { - rMatrix.translate(aTranslate.getX(), aTranslate.getY()); - } + rMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + aScale, + basegfx::fTools::equalZero(fShearX) ? 0.0 : tan(fShearX), + basegfx::fTools::equalZero(fRotate) ? 0.0 : -fRotate, + aTranslate); return sal_False; } @@ -1772,7 +1749,8 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b // break up matrix basegfx::B2DTuple aScale; basegfx::B2DTuple aTranslate; - double fRotate, fShearX; + double fRotate(0.0); + double fShearX(0.0); rMatrix.decompose(aScale, aTranslate, fRotate, fShearX); // #i75086# Old DrawingLayer (GeoStat and geometry) does not support holding negative scalings diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 62182d8e66db..8f93463672c3 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -60,6 +60,7 @@ #include <unoapi.hxx> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <editeng/outlobj.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> ////////////////////////////////////////////////////////////////////////////// // helpers @@ -79,32 +80,6 @@ namespace return aRetval; } - static drawinglayer::primitive2d::FontUnderline mapTextLineStyle(FontUnderline eLineStyle) - { - switch(eLineStyle) - { - case UNDERLINE_SINGLE: return drawinglayer::primitive2d::FONT_UNDERLINE_SINGLE; - case UNDERLINE_DOUBLE: return drawinglayer::primitive2d::FONT_UNDERLINE_DOUBLE; - case UNDERLINE_DOTTED: return drawinglayer::primitive2d::FONT_UNDERLINE_DOTTED; - case UNDERLINE_DASH: return drawinglayer::primitive2d::FONT_UNDERLINE_DASH; - case UNDERLINE_LONGDASH: return drawinglayer::primitive2d::FONT_UNDERLINE_LONGDASH; - case UNDERLINE_DASHDOT: return drawinglayer::primitive2d::FONT_UNDERLINE_DASHDOT; - case UNDERLINE_DASHDOTDOT: return drawinglayer::primitive2d::FONT_UNDERLINE_DASHDOTDOT; - case UNDERLINE_SMALLWAVE: return drawinglayer::primitive2d::FONT_UNDERLINE_SMALLWAVE; - case UNDERLINE_WAVE: return drawinglayer::primitive2d::FONT_UNDERLINE_WAVE; - case UNDERLINE_DOUBLEWAVE: return drawinglayer::primitive2d::FONT_UNDERLINE_DOUBLEWAVE; - case UNDERLINE_BOLD: return drawinglayer::primitive2d::FONT_UNDERLINE_BOLD; - case UNDERLINE_BOLDDOTTED: return drawinglayer::primitive2d::FONT_UNDERLINE_BOLDDOTTED; - case UNDERLINE_BOLDDASH: return drawinglayer::primitive2d::FONT_UNDERLINE_BOLDDASH; - case UNDERLINE_BOLDLONGDASH: return drawinglayer::primitive2d::FONT_UNDERLINE_BOLDLONGDASH; - case UNDERLINE_BOLDDASHDOT: return drawinglayer::primitive2d::FONT_UNDERLINE_BOLDDASHDOT; - case UNDERLINE_BOLDDASHDOTDOT: return drawinglayer::primitive2d::FONT_UNDERLINE_BOLDDASHDOTDOT; - case UNDERLINE_BOLDWAVE: return drawinglayer::primitive2d::FONT_UNDERLINE_BOLDWAVE; - // FontUnderline_FORCE_EQUAL_SIZE, UNDERLINE_DONTKNOW, UNDERLINE_NONE - default: return drawinglayer::primitive2d::FONT_UNDERLINE_NONE; - } - } - class impTextBreakupHandler { private: @@ -216,8 +191,8 @@ namespace if(rInfo.mrText.Len() && rInfo.mnTextLen) { basegfx::B2DVector aFontScaling; - drawinglayer::primitive2d::FontAttributes aFontAttributes( - drawinglayer::primitive2d::getFontAttributesFromVclFont( + drawinglayer::attribute::FontAttribute aFontAttribute( + drawinglayer::primitive2d::getFontAttributeFromVclFont( aFontScaling, rInfo.mrFont, rInfo.IsRTL(), @@ -295,6 +270,11 @@ namespace const Color aFontColor(rInfo.mrFont.GetColor()); const basegfx::BColor aBFontColor(aFontColor.getBColor()); + // prepare wordLineMode (for underline and strikeout) + // NOT for bullet texts. It is set (this may be an error by itself), but needs to be suppressed to hinder e.g. '1)' + // to be splitted which would not look like the original + const bool bWordLineMode(rInfo.mrFont.IsWordLineMode() && !rInfo.mbEndOfBullet); + // prepare new primitive drawinglayer::primitive2d::BasePrimitive2D* pNewPrimitive = 0; const bool bDecoratedIsNeeded( @@ -303,7 +283,8 @@ namespace || STRIKEOUT_NONE != rInfo.mrFont.GetStrikeout() || EMPHASISMARK_NONE != (rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_STYLE) || RELIEF_NONE != rInfo.mrFont.GetRelief() - || rInfo.mrFont.IsShadow()); + || rInfo.mrFont.IsShadow() + || bWordLineMode); if(bDecoratedIsNeeded) { @@ -315,51 +296,40 @@ namespace const basegfx::BColor aBOverlineColor((0xffffffff == aOverlineColor.GetColor()) ? aBFontColor : aOverlineColor.getBColor()); // prepare overline and underline data - const drawinglayer::primitive2d::FontUnderline eFontOverline(mapTextLineStyle(rInfo.mrFont.GetOverline())); - const drawinglayer::primitive2d::FontUnderline eFontUnderline(mapTextLineStyle(rInfo.mrFont.GetUnderline())); + const drawinglayer::primitive2d::TextLine eFontOverline( + drawinglayer::primitive2d::mapFontUnderlineToTextLine(rInfo.mrFont.GetOverline())); + const drawinglayer::primitive2d::TextLine eFontUnderline( + drawinglayer::primitive2d::mapFontUnderlineToTextLine(rInfo.mrFont.GetUnderline())); // check UndelineAbove - const bool bUnderlineAbove(drawinglayer::primitive2d::FONT_UNDERLINE_NONE != eFontUnderline && impIsUnderlineAbove(rInfo.mrFont)); + const bool bUnderlineAbove( + drawinglayer::primitive2d::TEXT_LINE_NONE != eFontUnderline && impIsUnderlineAbove(rInfo.mrFont)); // prepare strikeout data - drawinglayer::primitive2d::FontStrikeout eFontStrikeout(drawinglayer::primitive2d::FONT_STRIKEOUT_NONE); - - switch(rInfo.mrFont.GetStrikeout()) - { - case STRIKEOUT_SINGLE: eFontStrikeout = drawinglayer::primitive2d::FONT_STRIKEOUT_SINGLE; break; - case STRIKEOUT_DOUBLE: eFontStrikeout = drawinglayer::primitive2d::FONT_STRIKEOUT_DOUBLE; break; - case STRIKEOUT_BOLD: eFontStrikeout = drawinglayer::primitive2d::FONT_STRIKEOUT_BOLD; break; - case STRIKEOUT_SLASH: eFontStrikeout = drawinglayer::primitive2d::FONT_STRIKEOUT_SLASH; break; - case STRIKEOUT_X: eFontStrikeout = drawinglayer::primitive2d::FONT_STRIKEOUT_X; break; - default : break; // FontStrikeout_FORCE_EQUAL_SIZE, STRIKEOUT_NONE, STRIKEOUT_DONTKNOW - } - - // prepare wordLineMode (for underline and strikeout) - // NOT for bullet texts. It is set (this may be an error by itself), but needs to be suppressed to hinder e.g. '1)' - // to be splitted which would not look like the original - const bool bWordLineMode(rInfo.mrFont.IsWordLineMode() && !rInfo.mbEndOfBullet); + const drawinglayer::primitive2d::TextStrikeout eTextStrikeout( + drawinglayer::primitive2d::mapFontStrikeoutToTextStrikeout(rInfo.mrFont.GetStrikeout())); // prepare emphasis mark data - drawinglayer::primitive2d::FontEmphasisMark eFontEmphasisMark(drawinglayer::primitive2d::FONT_EMPHASISMARK_NONE); + drawinglayer::primitive2d::TextEmphasisMark eTextEmphasisMark(drawinglayer::primitive2d::TEXT_EMPHASISMARK_NONE); switch(rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_STYLE) { - case EMPHASISMARK_DOT : eFontEmphasisMark = drawinglayer::primitive2d::FONT_EMPHASISMARK_DOT; break; - case EMPHASISMARK_CIRCLE : eFontEmphasisMark = drawinglayer::primitive2d::FONT_EMPHASISMARK_CIRCLE; break; - case EMPHASISMARK_DISC : eFontEmphasisMark = drawinglayer::primitive2d::FONT_EMPHASISMARK_DISC; break; - case EMPHASISMARK_ACCENT : eFontEmphasisMark = drawinglayer::primitive2d::FONT_EMPHASISMARK_ACCENT; break; + case EMPHASISMARK_DOT : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_DOT; break; + case EMPHASISMARK_CIRCLE : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_CIRCLE; break; + case EMPHASISMARK_DISC : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_DISC; break; + case EMPHASISMARK_ACCENT : eTextEmphasisMark = drawinglayer::primitive2d::TEXT_EMPHASISMARK_ACCENT; break; } const bool bEmphasisMarkAbove(rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_POS_ABOVE); const bool bEmphasisMarkBelow(rInfo.mrFont.GetEmphasisMark() & EMPHASISMARK_POS_BELOW); // prepare font relief data - drawinglayer::primitive2d::FontRelief eFontRelief(drawinglayer::primitive2d::FONT_RELIEF_NONE); + drawinglayer::primitive2d::TextRelief eTextRelief(drawinglayer::primitive2d::TEXT_RELIEF_NONE); switch(rInfo.mrFont.GetRelief()) { - case RELIEF_EMBOSSED : eFontRelief = drawinglayer::primitive2d::FONT_RELIEF_EMBOSSED; break; - case RELIEF_ENGRAVED : eFontRelief = drawinglayer::primitive2d::FONT_RELIEF_ENGRAVED; break; + case RELIEF_EMBOSSED : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_EMBOSSED; break; + case RELIEF_ENGRAVED : eTextRelief = drawinglayer::primitive2d::TEXT_RELIEF_ENGRAVED; break; default : break; // RELIEF_NONE, FontRelief_FORCE_EQUAL_SIZE } @@ -375,7 +345,7 @@ namespace rInfo.mnTextStart, rInfo.mnTextLen, aDXArray, - aFontAttributes, + aFontAttribute, rInfo.mpLocale ? *rInfo.mpLocale : ::com::sun::star::lang::Locale(), aBFontColor, @@ -385,12 +355,12 @@ namespace eFontOverline, eFontUnderline, bUnderlineAbove, - eFontStrikeout, + eTextStrikeout, bWordLineMode, - eFontEmphasisMark, + eTextEmphasisMark, bEmphasisMarkAbove, bEmphasisMarkBelow, - eFontRelief, + eTextRelief, bShadow); } else @@ -402,7 +372,7 @@ namespace rInfo.mnTextStart, rInfo.mnTextLen, aDXArray, - aFontAttributes, + aFontAttribute, rInfo.mpLocale ? *rInfo.mpLocale : ::com::sun::star::lang::Locale(), aBFontColor); } @@ -723,9 +693,7 @@ void SdrTextObj::impDecomposeContourTextPrimitive( // prepare contour polygon, force to non-mirrored for layouting basegfx::B2DPolyPolygon aPolyPolygon(rSdrContourTextPrimitive.getUnitPolyPolygon()); - basegfx::B2DHomMatrix aTransform; - aTransform.scale(fabs(aScale.getX()), fabs(aScale.getY())); - aPolyPolygon.transform(aTransform); + aPolyPolygon.transform(basegfx::tools::createScaleB2DHomMatrix(fabs(aScale.getX()), fabs(aScale.getY()))); // prepare outliner SdrOutliner& rOutliner = ImpGetDrawOutliner(); @@ -740,19 +708,17 @@ void SdrTextObj::impDecomposeContourTextPrimitive( // prepare matrices to apply to newly created primitives basegfx::B2DHomMatrix aNewTransformA; - basegfx::B2DHomMatrix aNewTransformB; // mirroring. We are now in the polygon sizes. When mirroring in X and Y, // move the null point which was top left to bottom right. const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0)); const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0)); - aNewTransformB.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0); // in-between the translations of the single primitives will take place. Afterwards, // the object's transformations need to be applied - aNewTransformB.shearX(fShearX); - aNewTransformB.rotate(fRotate); - aNewTransformB.translate(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DHomMatrix aNewTransformB(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0, + fShearX, fRotate, aTranslate.getX(), aTranslate.getY())); // now break up text primitives. impTextBreakupHandler aConverter(rOutliner); @@ -938,27 +904,23 @@ void SdrTextObj::impDecomposeBlockTextPrimitive( // prepare matrices to apply to newly created primitives. aNewTransformA // will get coordinates in aOutlinerScale size and positive in X, Y. - basegfx::B2DHomMatrix aNewTransformA; - basegfx::B2DHomMatrix aNewTransformB; - - // translate relative to given primitive to get same rotation and shear + // Translate relative to given primitive to get same rotation and shear // as the master shape we are working on. For vertical, use the top-right // corner const double fStartInX(bVerticalWritintg ? aAdjustTranslate.getX() + aOutlinerScale.getX() : aAdjustTranslate.getX()); const basegfx::B2DTuple aAdjOffset(fStartInX, aAdjustTranslate.getY()); - aNewTransformA.translate(aAdjOffset.getX(), aAdjOffset.getY()); + basegfx::B2DHomMatrix aNewTransformA(basegfx::tools::createTranslateB2DHomMatrix(aAdjOffset.getX(), aAdjOffset.getY())); // mirroring. We are now in aAnchorTextRange sizes. When mirroring in X and Y, // move the null point which was top left to bottom right. const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0)); const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0)); - aNewTransformB.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0); // in-between the translations of the single primitives will take place. Afterwards, // the object's transformations need to be applied - aNewTransformB.shearX(fShearX); - aNewTransformB.rotate(fRotate); - aNewTransformB.translate(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DHomMatrix aNewTransformB(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0, + fShearX, fRotate, aTranslate.getX(), aTranslate.getY())); // #SJ# create ClipRange (if needed)
basegfx::B2DRange aClipRange;
@@ -1018,7 +980,6 @@ void SdrTextObj::impDecomposeStretchTextPrimitive( // prepare matrices to apply to newly created primitives basegfx::B2DHomMatrix aNewTransformA; - basegfx::B2DHomMatrix aNewTransformB; // #i101957# Check for vertical text. If used, aNewTransformA // needs to translate the text initially around object width to orient @@ -1040,13 +1001,12 @@ void SdrTextObj::impDecomposeStretchTextPrimitive( // move the null point which was top left to bottom right. const bool bMirrorX(basegfx::fTools::less(aScale.getX(), 0.0)); const bool bMirrorY(basegfx::fTools::less(aScale.getY(), 0.0)); - aNewTransformB.scale(bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0); // in-between the translations of the single primitives will take place. Afterwards, // the object's transformations need to be applied - aNewTransformB.shearX(fShearX); - aNewTransformB.rotate(fRotate); - aNewTransformB.translate(aTranslate.getX(), aTranslate.getY()); + const basegfx::B2DHomMatrix aNewTransformB(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix( + bMirrorX ? -1.0 : 1.0, bMirrorY ? -1.0 : 1.0, + fShearX, fRotate, aTranslate.getX(), aTranslate.getY())); // now break up text primitives. impTextBreakupHandler aConverter(rOutliner); diff --git a/svx/source/svdraw/svdotextpathdecomposition.cxx b/svx/source/svdraw/svdotextpathdecomposition.cxx index 82ee5caa4de8..0e6abad89757 100644 --- a/svx/source/svdraw/svdotextpathdecomposition.cxx +++ b/svx/source/svdraw/svdotextpathdecomposition.cxx @@ -366,8 +366,8 @@ namespace { const impPathTextPortion* pCandidate = rTextPortions[a]; basegfx::B2DVector aFontScaling; - const drawinglayer::primitive2d::FontAttributes aCandidateFontAttributes( - drawinglayer::primitive2d::getFontAttributesFromVclFont( + const drawinglayer::attribute::FontAttribute aCandidateFontAttribute( + drawinglayer::primitive2d::getFontAttributeFromVclFont( aFontScaling, pCandidate->getFont(), pCandidate->isRTL(), @@ -520,7 +520,7 @@ namespace nPortionIndex, nNextGlyphLen, aNewDXArray, - aCandidateFontAttributes, + aCandidateFontAttribute, pCandidate->getLocale(), aRGBShadowColor); @@ -545,7 +545,7 @@ namespace nPortionIndex, nNextGlyphLen, aNewDXArray, - aCandidateFontAttributes, + aCandidateFontAttribute, pCandidate->getLocale(), aRGBColor); diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx index 18840cde18e0..523eb6b4b2c3 100644 --- a/svx/source/svdraw/svdovirt.cxx +++ b/svx/source/svdraw/svdovirt.cxx @@ -40,6 +40,7 @@ #include <basegfx/matrix/b2dhommatrix.hxx> #include <svx/svdograf.hxx> #include <svx/svddrgv.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -216,9 +217,7 @@ basegfx::B2DPolyPolygon SdrVirtObj::TakeXorPoly() const if(aAnchor.X() || aAnchor.Y()) { - basegfx::B2DHomMatrix aMatrix; - aMatrix.translate(aAnchor.X(), aAnchor.Y()); - aPolyPolygon.transform(aMatrix); + aPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(aAnchor.X(), aAnchor.Y())); } return aPolyPolygon; diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index 55e0347e6522..a8cbfbb24c3d 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -1831,6 +1831,12 @@ GDIMetaFile SdrPage::GetMetaFile(const SetOfByte& /*rVisibleLayers*/, FASTBOOL / return GDIMetaFile(); } +bool SdrPage::isHandoutMasterPage() const +{ + return mbMaster && GetModel() && GetModel()->GetMasterPageCount() + && GetModel()->GetMasterPage(0) == this; +} + ////////////////////////////////////////////////////////////////////////////// // sdr::Comment interface diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx index bfdc2911de7a..37fcf9e5ffdc 100644..100755 --- a/svx/source/svdraw/svdpntv.cxx +++ b/svx/source/svdraw/svdpntv.cxx @@ -275,7 +275,8 @@ SdrPaintView::SdrPaintView(SdrModel* pModel1, OutputDevice* pOut) mbPagePaintingAllowed(true), mbHideOle(false), mbHideChart(false), - mbHideDraw(false) + mbHideDraw(false), + mbHideFormControl(false) { DBG_CTOR(SdrPaintView,NULL); pMod=pModel1; diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index e6d7da88d0d6..32f42e376df5 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -2575,7 +2575,7 @@ basegfx::B2DPolyPolygon SdrTableObj::getSpecialDragPoly(const SdrDragStat& rDrag basegfx::B2DPolyPolygon aRetval; const SdrHdl* pHdl = rDrag.GetHdl(); - if(HDL_USER == pHdl->GetKind()) + if( pHdl && (HDL_USER == pHdl->GetKind()) ) { const TableEdgeHdl* pEdgeHdl = dynamic_cast< const TableEdgeHdl* >( pHdl ); diff --git a/svx/source/table/viewcontactoftableobj.cxx b/svx/source/table/viewcontactoftableobj.cxx index 01ee9ae919db..b7393994b0ea 100644 --- a/svx/source/table/viewcontactoftableobj.cxx +++ b/svx/source/table/viewcontactoftableobj.cxx @@ -64,7 +64,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrCellPrimitive2D : public BasePrimitive2D + class SdrCellPrimitive2D : public BufferedDecompositionPrimitive2D { private: basegfx::B2DHomMatrix maTransform; @@ -72,13 +72,13 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrCellPrimitive2D( const basegfx::B2DHomMatrix& rTransform, const attribute::SdrFillTextAttribute& rSdrFTAttribute) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), maSdrFTAttribute(rSdrFTAttribute) { @@ -95,7 +95,7 @@ namespace drawinglayer DeclPrimitrive2DIDBlock() }; - Primitive2DSequence SdrCellPrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrCellPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence aRetval; @@ -132,7 +132,7 @@ namespace drawinglayer bool SdrCellPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrCellPrimitive2D& rCompare = (SdrCellPrimitive2D&)rPrimitive; @@ -155,7 +155,7 @@ namespace drawinglayer { namespace primitive2d { - class SdrBorderlinePrimitive2D : public BasePrimitive2D + class SdrBorderlinePrimitive2D : public BufferedDecompositionPrimitive2D { private: basegfx::B2DHomMatrix maTransform; @@ -173,7 +173,7 @@ namespace drawinglayer protected: // local decomposition. - virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const; + virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; public: SdrBorderlinePrimitive2D( @@ -187,7 +187,7 @@ namespace drawinglayer bool bRightIsOutside, bool bTopIsOutside, bool bInTwips) - : BasePrimitive2D(), + : BufferedDecompositionPrimitive2D(), maTransform(rTransform), maLeftLine(rLeftLine), maBottomLine(rBottomLine), @@ -282,7 +282,7 @@ namespace drawinglayer return (double)nValue; } - Primitive2DSequence SdrBorderlinePrimitive2D::createLocalDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const + Primitive2DSequence SdrBorderlinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*aViewInformation*/) const { Primitive2DSequence xRetval(4); sal_uInt32 nInsert(0); @@ -462,7 +462,7 @@ namespace drawinglayer bool SdrBorderlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const { - if(BasePrimitive2D::operator==(rPrimitive)) + if(BufferedDecompositionPrimitive2D::operator==(rPrimitive)) { const SdrBorderlinePrimitive2D& rCompare = (SdrBorderlinePrimitive2D&)rPrimitive; diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index d5257e82a35f..5be15a1c6a68 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -1820,7 +1820,9 @@ bool SvxGraphicObject::getPropertyValueImpl( const ::rtl::OUString& rName, const SvMemoryStream aDestStrm( 65535, 65535 ); ConvertGDIMetaFileToWMF( rGraphic.GetGDIMetaFile(), aDestStrm, NULL, sal_False ); - uno::Sequence<sal_Int8> aSeq((sal_Int8*)aDestStrm.GetData(), aDestStrm.GetSize()); + const uno::Sequence<sal_Int8> aSeq( + static_cast< const sal_Int8* >(aDestStrm.GetData()), + aDestStrm.GetEndOfData()); rValue <<= aSeq; } break; diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx index 1ed781f8b097..64baf56eee63 100644 --- a/svx/source/unodraw/unoshap4.cxx +++ b/svx/source/unodraw/unoshap4.cxx @@ -315,7 +315,9 @@ bool SvxOle2Shape::getPropertyValueImpl( const ::rtl::OUString& rName, const Sfx } SvMemoryStream aDestStrm( 65535, 65535 ); ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False ); - uno::Sequence<sal_Int8> aSeq((sal_Int8*)aDestStrm.GetData(), aDestStrm.GetSize()); + const uno::Sequence<sal_Int8> aSeq( + static_cast< const sal_Int8* >(aDestStrm.GetData()), + aDestStrm.GetEndOfData()); rValue <<= aSeq; } } diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 296018d80ed9..d68eb053ede1 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -98,6 +98,7 @@ #include "unomaster.hxx" #include <editeng/outlobj.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <vector> @@ -700,7 +701,9 @@ uno::Any SvxShape::GetBitmap( sal_Bool bMetaFile /* = sal_False */ ) const throw { SvMemoryStream aDestStrm( 65535, 65535 ); ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False ); - uno::Sequence<sal_Int8> aSeq((sal_Int8*)aDestStrm.GetData(), aDestStrm.GetSize()); + const uno::Sequence<sal_Int8> aSeq( + static_cast< const sal_Int8* >(aDestStrm.GetData()), + aDestStrm.GetEndOfData()); aAny.setValue( &aSeq, ::getCppuType((const uno::Sequence< sal_Int8 >*)0) ); } else @@ -2536,10 +2539,7 @@ bool SvxShape::setPropertyValueImpl( const ::rtl::OUString&, const SfxItemProper if( mpModel->IsWriter() ) { Point aPoint( mpObj->GetAnchorPos() ); - - basegfx::B2DHomMatrix aMatrix; - aMatrix.translate( aPoint.X(), aPoint.Y() ); - aNewPolyPolygon.transform( aMatrix ); + aNewPolyPolygon.transform(basegfx::tools::createTranslateB2DHomMatrix(aPoint.X(), aPoint.Y())); } pEdgeObj->SetEdgeTrackPath( aNewPolyPolygon ); return true; @@ -2972,10 +2972,7 @@ bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemProper if( mpModel->IsWriter() ) { Point aPoint( mpObj->GetAnchorPos() ); - - basegfx::B2DHomMatrix aMatrix; - aMatrix.translate( -aPoint.X(), -aPoint.Y() ); - aPolyPoly.transform( aMatrix ); + aPolyPoly.transform(basegfx::tools::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y())); } drawing::PolyPolygonBezierCoords aRetval; SvxConvertB2DPolyPolygonToPolyPolygonBezier( aPolyPoly, aRetval); @@ -3147,7 +3144,9 @@ bool SvxShape::getPropertyValueImpl( const ::rtl::OUString&, const SfxItemProper } SvMemoryStream aDestStrm( 65535, 65535 ); ConvertGDIMetaFileToWMF( aMtf, aDestStrm, NULL, sal_False ); - uno::Sequence<sal_Int8> aSeq((sal_Int8*)aDestStrm.GetData(), aDestStrm.GetSize()); + const uno::Sequence<sal_Int8> aSeq( + static_cast< const sal_Int8* >(aDestStrm.GetData()), + aDestStrm.GetEndOfData()); rValue <<= aSeq; } } diff --git a/svx/util/makefile.mk b/svx/util/makefile.mk index e22781a096d5..210c8caa368b 100644 --- a/svx/util/makefile.mk +++ b/svx/util/makefile.mk @@ -40,10 +40,6 @@ GEN_HID_OTHER=TRUE .INCLUDE : settings.mk -.IF "$(OS)"=="IRIX" -LINKFLAGS+=-Wl,-LD_LAYOUT:lgot_buffer=30 -.ENDIF - RSCLOCINC+=-I$(PRJ)$/source$/svdraw HELPIDFILES= ..$/inc$/helpid.hrc diff --git a/sysui/desktop/debian/makefile.mk b/sysui/desktop/debian/makefile.mk index 1e0761198c14..cb4369763070 100644 --- a/sysui/desktop/debian/makefile.mk +++ b/sysui/desktop/debian/makefile.mk @@ -49,7 +49,7 @@ TARGET=debian .IF "$(PKGFORMAT)"!="$(PKGFORMAT:s/deb//)" -DEBFILES=$(foreach,i,{$(PRODUCTLIST)} $(PKGDIR)$/$i3.2-$(TARGET)-menus_$(PKGVERSION.$i)-$(PKGREV)_all.deb) +DEBFILES=$(foreach,i,{$(PRODUCTLIST)} $(PKGDIR)$/$i3.3-$(TARGET)-menus_$(PKGVERSION.$i)-$(PKGREV)_all.deb) .ENDIF @@ -64,22 +64,22 @@ ALLTAR : $(DEBFILES) %/DEBIAN/control : $$(@:f) @$(MKDIRHIER) $(@:d) $*$/etc $*$/usr/share/applnk/Office $*$/usr/lib/menu - ln -sf /opt/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.2//)) $*$/etc$/ - /bin/sh -c -x "cd $(COMMONMISC)$/$(*:f:s/-/ /:1:s/3.2//) && DESTDIR=$(shell @cd $*; pwd) ICON_PREFIX=$(ICONPREFIX) KDEMAINDIR=/usr GNOMEDIR=/usr create_tree.sh" - @cat openoffice.org-debian-menus | sed -e 's/%PRODUCTNAME/$(PRODUCTNAME.$(*:f:s/-/ /:1:s/3.2//)) $(PRODUCTVERSION.$(*:f:s/-/ /:1:s/3.2//))/' -e 's/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.2//))/' -e 's/%ICONPREFIX/$(ICONPREFIX.$(*:f:s/-/ /:1:s/3.2//))/' > $*$/usr/lib/menu/$(*:f:s/_/ /:1:s/3.2//) - echo "Package: $(*:f:s/_/ /:1:s/3.2//)" > $@ - cat $(@:f) | tr -d "\015" | sed "s/%productname/$(PRODUCTNAME.$(*:f:s/-/ /:1:s/3.2//))/" >> $@ - echo "Version: $(PKGVERSION.$(*:f:s/-/ /:1:s/3.2//))-$(PKGREV)" >> $@ + ln -sf /opt/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.3//)) $*$/etc$/ + /bin/sh -c -x "cd $(COMMONMISC)$/$(*:f:s/-/ /:1:s/3.3//) && DESTDIR=$(shell @cd $*; pwd) ICON_PREFIX=$(ICONPREFIX) KDEMAINDIR=/usr GNOMEDIR=/usr create_tree.sh" + @cat openoffice.org-debian-menus | sed -e 's/%PRODUCTNAME/$(PRODUCTNAME.$(*:f:s/-/ /:1:s/3.3//)) $(PRODUCTVERSION.$(*:f:s/-/ /:1:s/3.3//))/' -e 's/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.3//))/' -e 's/%ICONPREFIX/$(ICONPREFIX.$(*:f:s/-/ /:1:s/3.3//))/' > $*$/usr/lib/menu/$(*:f:s/_/ /:1:s/3.3//) + echo "Package: $(*:f:s/_/ /:1:s/3.3//)" > $@ + cat $(@:f) | tr -d "\015" | sed "s/%productname/$(PRODUCTNAME.$(*:f:s/-/ /:1:s/3.3//))/" >> $@ + echo "Version: $(PKGVERSION.$(*:f:s/-/ /:1:s/3.3//))-$(PKGREV)" >> $@ @du -k -s $* | awk -F ' ' '{ printf "Installed-Size: %s\n", $$1 ; }' >> $@ %/DEBIAN/postinst : $$(@:f) - @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.2//))/g" > $@ + @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.3//))/g" > $@ %/DEBIAN/postrm : $$(@:f) - @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.2//))/g" > $@ + @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.3//))/g" > $@ %/DEBIAN/prerm : $$(@:f) - @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.2//))/g" > $@ + @cat $< | tr -d "\015" | sed -e "s/%PREFIX/$(UNIXFILENAME.$(*:f:s/-/ /:1:s/3.3//))/g" > $@ # --- packaging --------------------------------------------------- diff --git a/sysui/desktop/productversion.mk b/sysui/desktop/productversion.mk index 7d2467d32e7e..4bb67bc50b35 100644 --- a/sysui/desktop/productversion.mk +++ b/sysui/desktop/productversion.mk @@ -50,7 +50,7 @@ PKGDIR=$(BIN) PRODUCTLIST = openoffice.org broffice.org # default values to minimize maintainance effort -PRODUCTVERSION = 3.2 +PRODUCTVERSION = 3.3 PRODUCTVERSIONSHORT = 3 PKGVERSION = $(PRODUCTVERSION) # gnome-vfs treats everything behind the last '.' as an icon extension, diff --git a/sysui/desktop/slackware/makefile.mk b/sysui/desktop/slackware/makefile.mk index ae08a3772838..8d8fc071d250 100644 --- a/sysui/desktop/slackware/makefile.mk +++ b/sysui/desktop/slackware/makefile.mk @@ -44,7 +44,7 @@ TARGET=slackware # --- Files -------------------------------------------------------- -MENUFILES=$(PKGDIR)$/{$(PRODUCTLIST)}3.2-$(TARGET)-menus-$(PKGVERSION)-noarch-$(PKGREV).tgz +MENUFILES=$(PKGDIR)$/{$(PRODUCTLIST)}3.3-$(TARGET)-menus-$(PKGVERSION)-noarch-$(PKGREV).tgz .IF "$(USE_SHELL)"=="bash" ECHOPARAM=-e @@ -67,26 +67,26 @@ $(MISC)/$(TARGET)/usr/share/applications/ : # FIXME: removal of *-extension.* only to create identical packages to OOF680 %/usr/share/applications : @$(MKDIRHIER) $@ - /bin/sh -c "cd $(COMMONMISC)$/$(*:b:s/-/ /:1:s/3.2//); DESTDIR=$(shell @cd $*; pwd) GNOMEDIR="" ICON_PREFIX=$(ICONPREFIX.$(*:b:s/-/ /:1:s/3.2//)) KDEMAINDIR=/opt/kde .$/create_tree.sh" + /bin/sh -c "cd $(COMMONMISC)$/$(*:b:s/-/ /:1:s/3.3//); DESTDIR=$(shell @cd $*; pwd) GNOMEDIR="" ICON_PREFIX=$(ICONPREFIX.$(*:b:s/-/ /:1:s/3.3//)) KDEMAINDIR=/opt/kde .$/create_tree.sh" $(RM) $*$/opt$/kde$/share$/icons$/*$/*$/*$/*-extension.png $(RM) $*$/opt$/kde$/share$/mimelnk$/application$/*-extension.desktop $(RM) $*$/usr$/share$/applications$/*.desktop $(RM) $*$/usr$/bin$/soffice %$/install$/doinst.sh : update-script - @echo "( cd etc ; rm -rf $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.2//)) )" > $@ - @echo "( cd etc ; ln -snf /opt/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.2//):s/-//) $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.2//)) )" >> $@ + @echo "( cd etc ; rm -rf $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//)) )" > $@ + @echo "( cd etc ; ln -snf /opt/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//):s/-//) $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//)) )" >> $@ @echo "( cd usr/bin ; rm -rf soffice )" >> $@ - @echo "( cd usr/bin ; ln -sf /etc/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.2//))/program/soffice soffice )" >> $@ - @echo $(ECHOPARAM) $(foreach,i,$(shell @cat $(COMMONMISC)$/$(*:b:s/-/ /:1:s/3.2//)/launcherlist) "\n( cd usr/share/applications ; rm -rf $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.2//))-$i )\n( cd usr/share/applications ; ln -sf /etc/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.2//))/share/xdg/$i $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.2//))-$i )") >> $@ + @echo "( cd usr/bin ; ln -sf /etc/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//))/program/soffice soffice )" >> $@ + @echo $(ECHOPARAM) $(foreach,i,$(shell @cat $(COMMONMISC)$/$(*:b:s/-/ /:1:s/3.3//)/launcherlist) "\n( cd usr/share/applications ; rm -rf $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//))-$i )\n( cd usr/share/applications ; ln -sf /etc/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//))/share/xdg/$i $(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//))-$i )") >> $@ @cat $< >> $@ %$/install$/slack-desc : slack-desc @$(MKDIRHIER) $(@:d) - @sed -e "s/PKGNAME/$(*:b:s/-/ /:1:s/3.2//)-$(TARGET)-menus/g" -e "s/PKGVERSION/$(PKGVERSION.$(*:b:s/-/ /:1:s/3.2//))/g" \ - -e "s/LONGPRODUCTNAME/$(PRODUCTNAME.$(*:b:s/-/ /:1:s/3.2//)) $(PRODUCTVERSION.$(*:b:s/-/ /:1:s/3.2//))/g" \ - -e "s/PRODUCTNAME/$(PRODUCTNAME.$(*:b:s/-/ /:1:s/3.2//))/g" \ - -e "s/UNIXFILENAME/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.2//))/g" $< > $@ + @sed -e "s/PKGNAME/$(*:b:s/-/ /:1:s/3.3//)-$(TARGET)-menus/g" -e "s/PKGVERSION/$(PKGVERSION.$(*:b:s/-/ /:1:s/3.3//))/g" \ + -e "s/LONGPRODUCTNAME/$(PRODUCTNAME.$(*:b:s/-/ /:1:s/3.3//)) $(PRODUCTVERSION.$(*:b:s/-/ /:1:s/3.3//))/g" \ + -e "s/PRODUCTNAME/$(PRODUCTNAME.$(*:b:s/-/ /:1:s/3.3//))/g" \ + -e "s/UNIXFILENAME/$(UNIXFILENAME.$(*:b:s/-/ /:1:s/3.3//))/g" $< > $@ # needed to satisfy the slackware package tools - they need # the entries like this diff --git a/ucb/source/ucp/webdav/NeonSession.cxx b/ucb/source/ucp/webdav/NeonSession.cxx index 5d1ba2d6927c..25126f619540 100644 --- a/ucb/source/ucp/webdav/NeonSession.cxx +++ b/ucb/source/ucp/webdav/NeonSession.cxx @@ -329,8 +329,8 @@ extern "C" int NeonSession_NeonAuth( void * inUserData, #ifdef NE_FEATURE_SSPI bCanUseSystemCreds = (attempt == 0) && // avoid endless loops ne_has_support( NE_FEATURE_SSPI ) && // Windows-only feature. - ( ne_strcasecmp( inAuthProtocol, "NTLM" ) == 0 ) || - ( ne_strcasecmp( inAuthProtocol, "Negotiate" ) == 0 ); + ( ( ne_strcasecmp( inAuthProtocol, "NTLM" ) == 0 ) || + ( ne_strcasecmp( inAuthProtocol, "Negotiate" ) == 0 ) ); #endif // #i97003# (tkr): Ask XMasterPasswordHandling if we should store the diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 7817fa7c4c19..af20bfbb23dc 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -1568,15 +1568,7 @@ void XMLTextImportHelper::AddOutlineStyleCandidate( const sal_Int8 nOutlineLevel { if( !mpOutlineStylesCandidates ) { -#ifdef IRIX - /* GCC 2 bug when member function is called as part of an array - * initialiser - */ - sal_Int8 count = xChapterNumbering->getCount(); - mpOutlineStylesCandidates = new ::std::vector<OUString>[count]; -#else mpOutlineStylesCandidates = new ::std::vector<OUString>[xChapterNumbering->getCount()]; -#endif } mpOutlineStylesCandidates[nOutlineLevel-1].push_back( rStyleName ); } |