diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-03-25 10:57:30 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-03-25 10:57:30 +0100 |
commit | 361c48ac8ee7b60e12a13345e04d9148de5b05d3 (patch) | |
tree | ad4370336257b8aa9bf676ff9d2e63b2ce6b9b31 /sfx2 | |
parent | 9f2ff67ac41abedb1ec04eb6927fa82b160355d0 (diff) | |
parent | 9823cbf7faac2ef54b29e453a8fd03bb7d987c6b (diff) |
gridfixes: pulled and merged DEV300:m104
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/inc/sfx2/module.hxx | 12 | ||||
-rw-r--r-- | sfx2/qa/cppunit/makefile.mk | 86 | ||||
-rw-r--r-- | sfx2/qa/unoapi/makefile.mk | 48 | ||||
-rw-r--r-- | sfx2/source/appl/module.cxx | 34 | ||||
-rw-r--r-- | sfx2/source/config/evntconf.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 46 | ||||
-rw-r--r-- | sfx2/source/doc/objxtor.cxx | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | sfx2/source/view/viewprn.cxx | 83 |
10 files changed, 286 insertions, 34 deletions
diff --git a/sfx2/inc/sfx2/module.hxx b/sfx2/inc/sfx2/module.hxx index f944b29c18da..5551df850ff2 100644 --- a/sfx2/inc/sfx2/module.hxx +++ b/sfx2/inc/sfx2/module.hxx @@ -34,6 +34,7 @@ #include <sfx2/imgdef.hxx> #include <sal/types.h> #include <tools/fldunit.hxx> +#include <com/sun/star/uno/Reference.hxx> class ImageList; @@ -56,6 +57,9 @@ class SfxStbCtrlFactArr_Impl; class SfxTabPage; class Window; +namespace com { namespace sun { namespace star { namespace frame { + class XFrame; +} } } } //==================================================================== class SFX2_DLLPUBLIC SfxModule : public SfxShell @@ -97,6 +101,14 @@ public: static SfxModule* GetActiveModule( SfxViewFrame* pFrame=NULL ); static FieldUnit GetCurrentFieldUnit(); + /** retrieves the field unit of the module belonging to the document displayed in the given frame + + Effectively, this method looks up the SfxViewFrame belonging to the given XFrame, then the SfxModule belonging to + the document in this frame, then this module's field unit. + + Failures in any of those steps are reported as assertion in non-product builds, and then FUNIT_100TH_MM is returned. + */ + static FieldUnit GetModuleFieldUnit( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > const & i_frame ); FieldUnit GetFieldUnit() const; //#if 0 // _SOLAR__PRIVATE diff --git a/sfx2/qa/cppunit/makefile.mk b/sfx2/qa/cppunit/makefile.mk new file mode 100644 index 000000000000..b53a04ec43f9 --- /dev/null +++ b/sfx2/qa/cppunit/makefile.mk @@ -0,0 +1,86 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# 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. +# +#************************************************************************* + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ=../.. +PRJNAME=sfx2 +TARGET=qa_cppunit + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +#building with stlport, but cppunit was not built with stlport +.IF "$(USE_SYSTEM_STL)"!="YES" +.IF "$(SYSTEM_CPPUNIT)"=="YES" +CFLAGSCXX+=-DADAPT_EXT_STL +.ENDIF +.ENDIF + +CFLAGSCXX += $(CPPUNIT_CFLAGS) +DLLPRE = # no leading "lib" on .so files + +# --- Libs --------------------------------------------------------- + +SHL1OBJS= \ + $(SLO)/test_metadatable.obj \ + + +SHL1STDLIBS= \ + $(CPPUNITLIB) \ + $(SALLIB) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(VCLLIB) \ + $(SFXLIB) \ + + +SHL1TARGET= test_metadatable +SHL1RPATH = NONE +SHL1IMPLIB= i$(SHL1TARGET) +# SHL1DEF= $(MISC)/$(SHL1TARGET).def +DEF1NAME=$(SHL1TARGET) +# DEF1EXPORTFILE= export.exp +SHL1VERSIONMAP= version.map + +# --- All object files --------------------------------------------- + +SLOFILES= \ + $(SHL1OBJS) \ + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : _cppunit.mk + +.END diff --git a/sfx2/qa/unoapi/makefile.mk b/sfx2/qa/unoapi/makefile.mk new file mode 100644 index 000000000000..ea91ba4d1c44 --- /dev/null +++ b/sfx2/qa/unoapi/makefile.mk @@ -0,0 +1,48 @@ +#************************************************************************* +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# 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. +#***********************************************************************/ + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ../.. +PRJNAME = sfx2 +TARGET = qa_unoapi + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = org/openoffice/sfx2/qa/unoapi +JAVATESTFILES = Test.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END + +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk + +ALLTAR : javatest + +.END diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx index 90b93cc3748e..87953e134292 100644 --- a/sfx2/source/appl/module.cxx +++ b/sfx2/source/appl/module.cxx @@ -51,6 +51,7 @@ #include <svl/intitem.hxx> #include "sfx2/taskpane.hxx" #include <tools/diagnose_ex.h> +#include <rtl/strbuf.hxx> #define SfxModule #include "sfxslots.hxx" @@ -423,6 +424,39 @@ SfxModule* SfxModule::GetActiveModule( SfxViewFrame* pFrame ) return pSh ? pSh->GetModule() : 0; } +FieldUnit SfxModule::GetModuleFieldUnit( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > const & i_frame ) +{ + ENSURE_OR_RETURN( i_frame.is(), "SfxModule::GetModuleFieldUnit: invalid frame!", FUNIT_100TH_MM ); + + // find SfxViewFrame for the given XFrame + SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst(); + while ( pViewFrame != NULL ) + { + if ( pViewFrame->GetFrame().GetFrameInterface() == i_frame ) + break; + pViewFrame = SfxViewFrame::GetNext( *pViewFrame ); + } + ENSURE_OR_RETURN( pViewFrame != NULL, "SfxModule::GetModuleFieldUnit: unable to find an SfxViewFrame for the given XFrame", FUNIT_100TH_MM ); + + // find the module + SfxModule const * pModule = GetActiveModule( pViewFrame ); + ENSURE_OR_RETURN( pModule != NULL, "SfxModule::GetModuleFieldUnit: no SfxModule for the given frame!", FUNIT_100TH_MM ); + + SfxPoolItem const * pItem = pModule->GetItem( SID_ATTR_METRIC ); + if ( pItem == NULL ) + { +#if OSL_DEBUG_LEVEL > 0 + ::rtl::OStringBuffer message; + message.append( "SfxModule::GetFieldUnit: no metric item in the module implemented by '" ); + message.append( typeid( *pModule ).name() ); + message.append( "'!" ); + OSL_ENSURE( false, message.makeStringAndClear().getStr() ); +#endif + return FUNIT_100TH_MM; + } + return (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue(); +} + FieldUnit SfxModule::GetCurrentFieldUnit() { FieldUnit eUnit = FUNIT_INCH; diff --git a/sfx2/source/config/evntconf.cxx b/sfx2/source/config/evntconf.cxx index 59d3107532a4..31f9105c28aa 100644 --- a/sfx2/source/config/evntconf.cxx +++ b/sfx2/source/config/evntconf.cxx @@ -59,7 +59,7 @@ // ----------------------------------------------------------------------- TYPEINIT1(SfxEventHint, SfxHint); TYPEINIT1(SfxEventNamesItem, SfxPoolItem); -TYPEINIT1(SfxViewEventHint, SfxHint); +TYPEINIT1(SfxViewEventHint, SfxEventHint); using namespace com::sun::star; diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 2a54e5b1c638..0bde76cb44b1 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -131,7 +131,7 @@ void SfxUnoControllerItem::UnBind() void SAL_CALL SfxUnoControllerItem::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvent) throw ( ::com::sun::star::uno::RuntimeException ) { ::vos::OGuard aGuard( Application::GetSolarMutex() ); - DBG_ASSERT( pCtrlItem, "Dispatch hat den StatusListener nicht entfern!" ); + DBG_ASSERT( pCtrlItem, "dispatch implementation didn't respect our previous removeStatusListener call!" ); if ( rEvent.Requery ) { diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 0f3b35648061..eb6373b5b998 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -1566,7 +1566,7 @@ ErrCode FileDialogHelper_Impl::execute( SvStringsDtor*& rpURLList, // the item should remain only if it was set by the dialog rpSet->ClearItem( SID_SELECTION ); - if( mbExport ) + if( mbExport && mbHasSelectionBox ) { try { diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index f18e903eb6e4..41b969fc1e59 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -1142,7 +1142,6 @@ void SAL_CALL SfxDocumentMetaData::init( m_isInitialized = false; m_xDoc = i_xDoc; - m_xDoc->normalize(); // select nodes for standard meta data stuff xPath->registerNS(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("xlink")), @@ -1171,26 +1170,49 @@ void SAL_CALL SfxDocumentMetaData::init( if (!m_xParent.is()) { // all this create/append stuff may throw DOMException try { - css::uno::Reference<css::xml::dom::XElement> xRElem( - i_xDoc->createElementNS( + css::uno::Reference<css::xml::dom::XElement> xRElem; + css::uno::Reference<css::xml::dom::XNode> xNode( + i_xDoc->getFirstChild()); + while (xNode.is()) { + if (css::xml::dom::NodeType_ELEMENT_NODE ==xNode->getNodeType()) + { + if (xNode->getNamespaceURI().equalsAscii(s_nsODF) && + xNode->getLocalName().equalsAscii("document-meta")) + { + xRElem.set(xNode, css::uno::UNO_QUERY_THROW); + break; + } + else + { + OSL_TRACE("SfxDocumentMetaData::init(): " + "deleting unexpected root element: %s", + ::rtl::OUStringToOString(xNode->getLocalName(), + RTL_TEXTENCODING_UTF8).getStr()); + i_xDoc->removeChild(xNode); + xNode = i_xDoc->getFirstChild(); // start over + } + } else { + xNode = xNode->getNextSibling(); + } + } + if (!xRElem.is()) { + xRElem = i_xDoc->createElementNS( ::rtl::OUString::createFromAscii(s_nsODF), - ::rtl::OUString::createFromAscii("office:document-meta"))); - css::uno::Reference<css::xml::dom::XNode> xRNode(xRElem, - css::uno::UNO_QUERY_THROW); - // NB: the following is a _bad_idea_ with our DOM implementation - // do _not_ create attributes with xmlns prefix! -// xRElem->setAttribute(::rtl::OUString::createFromAscii("xmlns:office"), -// ::rtl::OUString::createFromAscii(s_nsODF)); + ::rtl::OUString::createFromAscii("office:document-meta")); + css::uno::Reference<css::xml::dom::XNode> xRNode(xRElem, + css::uno::UNO_QUERY_THROW); + i_xDoc->appendChild(xRNode); + } xRElem->setAttributeNS(::rtl::OUString::createFromAscii(s_nsODF), ::rtl::OUString::createFromAscii("office:version"), ::rtl::OUString::createFromAscii("1.0")); - i_xDoc->appendChild(xRNode); + // does not exist, otherwise m_xParent would not be null css::uno::Reference<css::xml::dom::XNode> xParent ( i_xDoc->createElementNS( ::rtl::OUString::createFromAscii(s_nsODF), ::rtl::OUString::createFromAscii("office:meta")), css::uno::UNO_QUERY_THROW); - xRNode->appendChild(xParent); + xRElem->appendChild(xParent); m_xParent = xParent; } catch (css::xml::dom::DOMException & e) { css::uno::Any a(e); diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 4255e9bd2939..3da1f374af1c 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -921,11 +921,6 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp s_xCurrentComponent = _rxComponent; if ( pAppMgr ) pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxComponent ) ); - -#if OSL_DEBUG_LEVEL > 0 - const char* pComponentImplName = _rxComponent.get() ? typeid( *_rxComponent.get() ).name() : "void"; - OSL_TRACE( "current component is a %s\n", pComponentImplName ); -#endif } Reference< XInterface > SfxObjectShell::GetCurrentComponent() diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 515149c5a2d3..b91e8b4848ba 100644..100755 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -80,13 +80,15 @@ class SfxPrinterController : public vcl::PrinterController, public SfxListener sal_Bool m_bOrigStatus; sal_Bool m_bNeedsChange; sal_Bool m_bApi; + sal_Bool m_bTempPrinter; util::DateTime m_aLastPrinted; ::rtl::OUString m_aLastPrintedBy; Sequence< beans::PropertyValue > getMergedOptions() const; const Any& getSelectionObject() const; public: - SfxPrinterController( const Any& i_rComplete, + SfxPrinterController( const boost::shared_ptr<Printer>& i_rPrinter, + const Any& i_rComplete, const Any& i_rSelection, const Any& i_rViewProp, const Reference< view::XRenderable >& i_xRender, @@ -105,7 +107,8 @@ public: virtual void jobFinished( com::sun::star::view::PrintableState ); }; -SfxPrinterController::SfxPrinterController( const Any& i_rComplete, +SfxPrinterController::SfxPrinterController( const boost::shared_ptr<Printer>& i_rPrinter, + const Any& i_rComplete, const Any& i_rSelection, const Any& i_rViewProp, const Reference< view::XRenderable >& i_xRender, @@ -113,7 +116,8 @@ SfxPrinterController::SfxPrinterController( const Any& i_rComplete, SfxViewShell* pView, const uno::Sequence< beans::PropertyValue >& rProps ) - : maCompleteSelection( i_rComplete ) + : PrinterController( i_rPrinter) + , maCompleteSelection( i_rComplete ) , maSelection( i_rSelection ) , mxRenderable( i_xRender ) , mpLastPrinter( NULL ) @@ -122,6 +126,7 @@ SfxPrinterController::SfxPrinterController( const Any& i_rComplete, , m_bOrigStatus( sal_False ) , m_bNeedsChange( sal_False ) , m_bApi(i_bApi) + , m_bTempPrinter( i_rPrinter.get() != NULL ) { if ( mpViewShell ) { @@ -191,15 +196,19 @@ SfxPrinterController::~SfxPrinterController() const Any& SfxPrinterController::getSelectionObject() const { + const beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelectionOnly" ) ) ); + if( pVal ) + { + sal_Bool bSel = sal_False; + pVal->Value >>= bSel; + return bSel ? maSelection : maCompleteSelection; + } + sal_Int32 nChoice = 0; - sal_Bool bSel = sal_False; - const beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ) ); + 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; + return (nChoice > 1) ? maSelection : maCompleteSelection; } Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const @@ -307,6 +316,7 @@ void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nSt { if ( mpObjectShell ) { + bool bCopyJobSetup = false; mpObjectShell->Broadcast( SfxPrintingHint( nState ) ); switch ( nState ) { @@ -334,6 +344,7 @@ void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nSt rBind.Invalidate( SID_PRINTDOC ); rBind.Invalidate( SID_PRINTDOCDIRECT ); rBind.Invalidate( SID_SETUPPRINTER ); + bCopyJobSetup = ! m_bTempPrinter; break; } @@ -341,6 +352,27 @@ void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nSt break; } + if( bCopyJobSetup && mpViewShell ) + { + // #i114306# + // Note: this possibly creates a printer that gets immediately replaced + // by a new one. The reason for this is that otherwise we would not get + // the printer's SfxItemSet here to copy. Awkward, but at the moment there is no + // other way here to get the item set. + SfxPrinter* pDocPrt = mpViewShell->GetPrinter(sal_True); + if( pDocPrt ) + { + if( pDocPrt->GetName() == getPrinter()->GetName() ) + pDocPrt->SetJobSetup( getPrinter()->GetJobSetup() ); + else + { + SfxPrinter* pNewPrt = new SfxPrinter( pDocPrt->GetOptions().Clone(), getPrinter()->GetName() ); + pNewPrt->SetJobSetup( getPrinter()->GetJobSetup() ); + mpViewShell->SetPrinter( pNewPrt, SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP ); + } + } + } + if ( m_bNeedsChange ) mpObjectShell->EnableSetModified( m_bOrigStatus ); @@ -586,8 +618,23 @@ void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rPro aSelection <<= GetObjectShell()->GetModel(); Any aComplete( makeAny( GetObjectShell()->GetModel() ) ); Any aViewProp( makeAny( xController ) ); + boost::shared_ptr<Printer> aPrt; - boost::shared_ptr<vcl::PrinterController> pController( new SfxPrinterController( aComplete, + const beans::PropertyValue* pVal = rProps.getConstArray(); + for( sal_Int32 i = 0; i < rProps.getLength(); i++ ) + { + if( pVal[i].Name.equalsAscii( "PrinterName" ) ) + { + rtl::OUString aPrinterName; + pVal[i].Value >>= aPrinterName; + aPrt.reset( new Printer( aPrinterName ) ); + break; + } + } + + boost::shared_ptr<vcl::PrinterController> pController( new SfxPrinterController( + aPrt, + aComplete, aSelection, aViewProp, GetRenderable(), @@ -704,10 +751,18 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) } } } - sal_Int32 nLen = aProps.getLength(); - aProps.realloc( nLen + 1 ); - aProps[nLen].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelectionOnly" ) ); - aProps[nLen].Value = makeAny( bSelection ); + // HACK: writer sets the SID_SELECTION item when printing directly and expects + // to get only the selection document in that case (see getSelectionObject) + // however it also reacts to the PrintContent property. We need this distinction here, too, + // else one of the combinations print / print direct and selection / all will not work. + // it would be better if writer handled this internally + if( nId == SID_PRINTDOCDIRECT ) + { + 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) ); |