User: kz      
Date: 05/01/21 09:04:32

Modified:
 /dba/dbaccess/source/core/dataaccess/
  documentdefinition.cxx

Log:
 INTEGRATION: CWS dba22 (1.15.2); FILE MERGED
 2005/01/11 07:26:32 oj 1.15.2.4: #i39123# commit embedded storage
 2005/01/07 07:50:14 oj 1.15.2.3: RESYNC: (1.15-1.18); FILE MERGED
 2004/12/13 12:52:34 oj 1.15.2.2: #i38903# show grid when in design mode
 2004/12/10 08:54:51 oj 1.15.2.1: #i33930# #i30178# set document title

File Changes:

Directory: /dba/dbaccess/source/core/dataaccess/
================================================

File [changed]: documentdefinition.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.cxx?r1=1.18&r2=1.19
Delta lines:  +86 -85
---------------------
--- documentdefinition.cxx      5 Jan 2005 12:28:50 -0000       1.18
+++ documentdefinition.cxx      21 Jan 2005 17:04:28 -0000      1.19
@@ -77,6 +77,9 @@
 #ifndef _COMPHELPER_SEQUENCE_HXX_
 #include <comphelper/sequence.hxx>
 #endif
+#ifndef _COMPHELPER_MEDIADESCRIPTOR_HXX_
+#include <comphelper/mediadescriptor.hxx>
+#endif
 #ifndef _SO_CLSIDS_HXX
 #include <so3/clsids.hxx>
 #endif
@@ -258,13 +261,13 @@
                class OEmbedObjectHolder :       public 
::comphelper::OBaseMutex 
                                                                        ,public 
TEmbedObjectHolder
                {
-                       Reference< XStateChangeBroadcaster > m_xBroadCaster;
+                       Reference< XEmbeddedObject > m_xBroadCaster;
                        ODocumentDefinition*                             
m_pDefinition;
                        sal_Bool                                                
         m_bInStateChange;
                protected:
                        virtual void SAL_CALL disposing();
                public:
-                       OEmbedObjectHolder(const Reference< 
XStateChangeBroadcaster >& _xBroadCaster,ODocumentDefinition* _pDefinition) 
+                       OEmbedObjectHolder(const Reference< XEmbeddedObject >& 
_xBroadCaster,ODocumentDefinition* _pDefinition) 
                                : TEmbedObjectHolder(m_aMutex)
                                ,m_xBroadCaster(_xBroadCaster)
                                ,m_pDefinition(_pDefinition)
@@ -468,6 +471,7 @@
        ,m_pInterceptor(NULL)
        ,m_pClientHelper(NULL)
        ,m_bForm(_bForm)
+       ,m_bOpenInDesign(sal_False)
 {
        DBG_CTOR(ODocumentDefinition, NULL);
        registerProperties();
@@ -568,7 +572,8 @@
        Any aRet;
        ::osl::MutexGuard aGuard(m_aMutex);
        sal_Bool bOpenInDesign = aCommand.Name.equalsAscii("openDesign");
-       if ( aCommand.Name.compareToAscii( "open" ) == 0 || (bOpenInDesign) ) 
+       sal_Bool bOpenForMail = aCommand.Name.equalsAscii("openForMail");
+       if ( aCommand.Name.compareToAscii( "open" ) == 0 || bOpenInDesign || 
bOpenForMail ) 
        {
                
//////////////////////////////////////////////////////////////////
                // open command for a folder content
@@ -641,9 +646,18 @@
                        Reference<XModel> xModel;
                        if ( m_pImpl->m_aProps.sPersistentName.getLength() )
                        {
+                               m_bOpenInDesign = bOpenInDesign;
                                loadEmbeddedObject(Sequence< sal_Int8 
>(),xConnection,!bOpenInDesign);
                                if ( m_xEmbeddedObject.is() )
                                {
+                                       if ( bOpenForMail )
+                                       {
+                                               
xModel.set(getComponent(),UNO_QUERY);
+                                               fillReportData(!bOpenInDesign);
+                                               aRet <<= xModel;
+                                       }
+                                       else
+                                       {
                                        
m_xEmbeddedObject->changeState(EmbedStates::ACTIVE);
                                
                                        // object is new, so we an interceptor 
for save
@@ -678,6 +692,9 @@
                                                                }
                                                        }
 
+                                                               //      
Reference<XStateChangeBroadcaster> xBrd(m_xEmbeddedObject,UNO_QUERY);
+                                                               m_xListener = 
new OEmbedObjectHolder(m_xEmbeddedObject,this);
+                                                       }
                                                        if ( bOpenInDesign && 
m_bForm )
                                                        {
                                                                
Reference<XViewSettingsSupplier> 
xViewSup(xModel->getCurrentController(),UNO_QUERY);
@@ -703,8 +720,6 @@
                                                                        }
                                                                }
                                                        }
-                                                       
Reference<XStateChangeBroadcaster> xBrd(m_xEmbeddedObject,UNO_QUERY);
-                                                       m_xListener = new 
OEmbedObjectHolder(xBrd,this);
                                                }
                                                fillReportData(!bOpenInDesign);
                                                aRet <<= xModel;
@@ -914,6 +929,8 @@
                                        m_pImpl->m_aProps.aTitle = 
pDocuSave->getName();
                                        Reference< XContent> xContent = this;
                                        
xNC->insertByName(pDocuSave->getName(),makeAny(xContent));
+
+                                       updateDocumentTitle();
                                }
                        }
                }
@@ -956,9 +973,6 @@
        _rArgs[nLen].Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode"));
        _rArgs[nLen++].Value <<= MacroExecMode::USE_CONFIG;
 
-       _rArgs[nLen].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"));
-       _rArgs[nLen++].Value <<= 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/swriter"));
-
        if ( m_pImpl->m_aProps.aTitle.getLength() )
        {
                _rArgs.realloc(nLen+1);
@@ -1060,40 +1074,23 @@
        if ( xModel.is() )
        {
                Sequence<PropertyValue> aArgs = xModel->getArgs();
+               ::comphelper::MediaDescriptor aHelper(aArgs);
+               static const ::rtl::OUString 
s_sReadOnly(RTL_CONSTASCII_USTRINGPARAM("ReadOnly"));
+               if ( ! aHelper.createItemIfMissing(s_sReadOnly,_bReadOnly) )
+                       aHelper[s_sReadOnly] <<= _bReadOnly;
 
-               sal_Bool bAddReadOnly = sal_True;
-               sal_Bool bMacroExecutionMode = sal_True;
-               PropertyValue* pIter = aArgs.getArray();
-               PropertyValue* pEnd      = pIter + aArgs.getLength();
-               for(;pIter != pEnd;++pIter)
-               {
-                       if ( pIter->Name.equalsAscii("ReadOnly") )
-                       {
-                               pIter->Value <<= _bReadOnly;
-                               bAddReadOnly = sal_False;
-                       }
-                       else if ( pIter->Name.equalsAscii("MacroExecutionMode") 
)
+               if ( m_pImpl->m_aProps.aTitle.getLength() )
                        {
-                               pIter->Value <<= MacroExecMode::USE_CONFIG;
-                               bMacroExecutionMode = sal_False;
-                       }
+                       static const ::rtl::OUString 
s_sDocumentTitle(RTL_CONSTASCII_USTRINGPARAM("DocumentTitle"));
+                       if ( ! 
aHelper.createItemIfMissing(s_sDocumentTitle,m_pImpl->m_aProps.aTitle) )
+                               aHelper[s_sDocumentTitle] <<= 
m_pImpl->m_aProps.aTitle;
                }
 
-               if ( bAddReadOnly )
-               {
-                       sal_Int32 nLen = aArgs.getLength();
-                       aArgs.realloc(nLen+1);
-                       aArgs[nLen].Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly"));
-                       aArgs[nLen].Value <<= _bReadOnly;
-               }
+               static const ::rtl::OUString 
s_sMacroExecutionMode(RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode"));
+               if ( ! 
aHelper.createItemIfMissing(s_sMacroExecutionMode,MacroExecMode::USE_CONFIG) )
+                       aHelper[s_sMacroExecutionMode] <<= 
MacroExecMode::USE_CONFIG;
 
-               if ( bMacroExecutionMode )
-               {
-                       sal_Int32 nLen = aArgs.getLength();
-                       aArgs.realloc(nLen+1);
-                       aArgs[nLen].Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode"));
-                       aArgs[nLen].Value <<= MacroExecMode::USE_CONFIG;
-               }
+               aHelper >> aArgs;
 
                xModel->attachResource(xModel->getURL(),aArgs);
        }
@@ -1209,6 +1206,9 @@
                fire(&nHandle, &aNew, &aOld, 1, sal_True );
                m_pImpl->m_aProps.aTitle = newName;
                fire(&nHandle, &aNew, &aOld, 1, sal_False );
+
+               if ( m_xEmbeddedObject.is() && 
m_xEmbeddedObject->getCurrentState() == EmbedStates::ACTIVE )
+                       updateDocumentTitle();
        }
        catch(const PropertyVetoException&)
        {
@@ -1241,35 +1241,19 @@
        if ( xModel.is() )
        {
                Sequence<PropertyValue> aArgs = xModel->getArgs();
+               ::comphelper::MediaDescriptor aHelper(aArgs);
+               static const ::rtl::OUString 
s_sReadOnly(RTL_CONSTASCII_USTRINGPARAM("ReadOnly"));
+               if ( ! aHelper.createItemIfMissing(s_sReadOnly,_bReadOnly) )
+                       aHelper[s_sReadOnly] <<= _bReadOnly;
 
-               sal_Bool bAddReadOnly = sal_True;
-               sal_Bool bMacroExecutionMode = sal_True;
-               PropertyValue* pIter = aArgs.getArray();
-               PropertyValue* pEnd      = pIter + aArgs.getLength();
-               for(;pIter != pEnd;++pIter)
-               {
-                       if ( pIter->Name.equalsAscii("ReadOnly") )
-                       {
-                               pIter->Value <<= _bReadOnly;
-                               bAddReadOnly = sal_False;
-                       }
-               }
-
-               if ( bAddReadOnly )
-               {
-                       sal_Int32 nLen = aArgs.getLength();
-                       aArgs.realloc(nLen+1);
-                       aArgs[nLen].Name = 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly"));
-                       aArgs[nLen].Value <<= _bReadOnly;
-               }
-
+               aHelper >> aArgs;
                xModel->attachResource(xModel->getURL(),aArgs);
        }
 }
 // 
-----------------------------------------------------------------------------
 void ODocumentDefinition::fillReportData(sal_Bool _bFill)
 {
-       if ( !m_bForm && _bFill && m_pImpl->m_aProps.bAsTemplate ) // open a 
report in alive mode, so we need to fill it
+       if ( !m_bForm && _bFill && m_pImpl->m_aProps.bAsTemplate && 
!m_bOpenInDesign ) // open a report in alive mode, so we need to fill it
        {
                setModelReadOnly(sal_False);
                Sequence<Any> aArgs(1);
@@ -1284,6 +1268,23 @@
        }
 }
 // 
-----------------------------------------------------------------------------
+void ODocumentDefinition::updateDocumentTitle()
+{
+       if ( m_pImpl->m_aProps.aTitle.getLength() )
+       {
+               Reference<XModel> xModel(getComponent(),UNO_QUERY);
+               if ( xModel.is() )
+               {
+                       Sequence<PropertyValue> aArgs = xModel->getArgs();
+                       ::comphelper::MediaDescriptor aHelper(aArgs);
+                       static const ::rtl::OUString 
s_sDocumentTitle(RTL_CONSTASCII_USTRINGPARAM("DocumentTitle"));
+                       if ( ! 
aHelper.createItemIfMissing(s_sDocumentTitle,m_pImpl->m_aProps.aTitle) )
+                               aHelper[s_sDocumentTitle] <<= 
m_pImpl->m_aProps.aTitle;
+                       aHelper >> aArgs;
+                       xModel->attachResource(xModel->getURL(),aArgs);
+               }
+       }
+}
 //........................................................................
 }      // namespace dbaccess
 //........................................................................




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to