Kaydet (Commit) 5e69b361 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:flatten in toolkit..writerfilter

Change-Id: I4da2a768b6b55869c3a3d6f8a8d50dc018709acd
Reviewed-on: https://gerrit.libreoffice.org/44865Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 1d097883
...@@ -179,24 +179,25 @@ void SAL_CALL VCLXTabPageContainer::elementInserted( const css::container::Conta ...@@ -179,24 +179,25 @@ void SAL_CALL VCLXTabPageContainer::elementInserted( const css::container::Conta
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
VclPtr<TabControl> pTabCtrl = GetAs<TabControl>(); VclPtr<TabControl> pTabCtrl = GetAs<TabControl>();
Reference< css::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY); Reference< css::awt::tab::XTabPage > xTabPage(Event.Element,uno::UNO_QUERY);
if ( pTabCtrl && xTabPage.is() ) if ( !pTabCtrl || !xTabPage.is() )
{ return;
Reference< awt::XControl > xControl(xTabPage,UNO_QUERY );
Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY ); Reference< awt::XControl > xControl(xTabPage,UNO_QUERY );
sal_Int16 nPageID = xP->getTabPageID(); Reference< awt::tab::XTabPageModel > xP( xControl->getModel(), UNO_QUERY );
sal_Int16 nPageID = xP->getTabPageID();
VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xControl->getPeer());
TabPage* pPage = static_cast<TabPage*>(pWindow.get()); VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xControl->getPeer());
pTabCtrl->InsertPage(nPageID,pPage->GetText()); TabPage* pPage = static_cast<TabPage*>(pWindow.get());
pTabCtrl->InsertPage(nPageID,pPage->GetText());
pPage->Hide();
pTabCtrl->SetTabPage(nPageID,pPage); pPage->Hide();
pTabCtrl->SetHelpText(nPageID,xP->getToolTip()); pTabCtrl->SetTabPage(nPageID,pPage);
pTabCtrl->SetPageImage(nPageID,TkResMgr::getImageFromURL(xP->getImageURL())); pTabCtrl->SetHelpText(nPageID,xP->getToolTip());
pTabCtrl->SelectTabPage(nPageID); pTabCtrl->SetPageImage(nPageID,TkResMgr::getImageFromURL(xP->getImageURL()));
pTabCtrl->EnablePage(nPageID,xP->getEnabled()); pTabCtrl->SelectTabPage(nPageID);
m_aTabPages.push_back(xTabPage); pTabCtrl->EnablePage(nPageID,xP->getEnabled());
} m_aTabPages.push_back(xTabPage);
} }
void SAL_CALL VCLXTabPageContainer::elementRemoved( const css::container::ContainerEvent& Event ) void SAL_CALL VCLXTabPageContainer::elementRemoved( const css::container::ContainerEvent& Event )
{ {
......
...@@ -488,65 +488,67 @@ void SAL_CALL UnoDialogControl::windowResized( const css::awt::WindowEvent& e ) ...@@ -488,65 +488,67 @@ void SAL_CALL UnoDialogControl::windowResized( const css::awt::WindowEvent& e )
{ {
OutputDevice*pOutDev = Application::GetDefaultDevice(); OutputDevice*pOutDev = Application::GetDefaultDevice();
DBG_ASSERT( pOutDev, "Missing Default Device!" ); DBG_ASSERT( pOutDev, "Missing Default Device!" );
if ( pOutDev && !mbSizeModified ) if ( !pOutDev || mbSizeModified )
{ return;
// Currentley we are simply using MapUnit::MapAppFont
::Size aAppFontSize( e.Width, e.Height );
Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW ); // Currentley we are simply using MapUnit::MapAppFont
Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY ); ::Size aAppFontSize( e.Width, e.Height );
OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" );
// #i87592 In design mode the drawing layer works with sizes with decoration. Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW );
// Therefore we have to subtract them before writing back to the properties (model). Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY );
if ( xDialogDevice.is() && mbDesignMode ) OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" );
{
DeviceInfo aDeviceInfo( xDialogDevice->getInfo() );
aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
}
aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize ); // #i87592 In design mode the drawing layer works with sizes with decoration.
// Therefore we have to subtract them before writing back to the properties (model).
// Remember that changes have been done by listener. No need to if ( xDialogDevice.is() && mbDesignMode )
// update the position because of property change event. {
mbSizeModified = true; DeviceInfo aDeviceInfo( xDialogDevice->getInfo() );
Sequence< OUString > aProps( 2 ); aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
Sequence< Any > aValues( 2 ); aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
// Properties in a sequence must be sorted!
aProps[0] = "Height";
aProps[1] = "Width";
aValues[0] <<= aAppFontSize.Height();
aValues[1] <<= aAppFontSize.Width();
ImplSetPropertyValues( aProps, aValues, true );
mbSizeModified = false;
} }
aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize );
// Remember that changes have been done by listener. No need to
// update the position because of property change event.
mbSizeModified = true;
Sequence< OUString > aProps( 2 );
Sequence< Any > aValues( 2 );
// Properties in a sequence must be sorted!
aProps[0] = "Height";
aProps[1] = "Width";
aValues[0] <<= aAppFontSize.Height();
aValues[1] <<= aAppFontSize.Width();
ImplSetPropertyValues( aProps, aValues, true );
mbSizeModified = false;
} }
void SAL_CALL UnoDialogControl::windowMoved( const css::awt::WindowEvent& e ) void SAL_CALL UnoDialogControl::windowMoved( const css::awt::WindowEvent& e )
{ {
OutputDevice*pOutDev = Application::GetDefaultDevice(); OutputDevice*pOutDev = Application::GetDefaultDevice();
DBG_ASSERT( pOutDev, "Missing Default Device!" ); DBG_ASSERT( pOutDev, "Missing Default Device!" );
if ( pOutDev && !mbPosModified ) if ( !pOutDev || mbPosModified )
{ return;
// Currentley we are simply using MapUnit::MapAppFont
::Size aTmp( e.X, e.Y ); // Currentley we are simply using MapUnit::MapAppFont
aTmp = ImplMapPixelToAppFont( pOutDev, aTmp ); ::Size aTmp( e.X, e.Y );
aTmp = ImplMapPixelToAppFont( pOutDev, aTmp );
// Remember that changes have been done by listener. No need to
// update the position because of property change event. // Remember that changes have been done by listener. No need to
mbPosModified = true; // update the position because of property change event.
Sequence< OUString > aProps( 2 ); mbPosModified = true;
Sequence< Any > aValues( 2 ); Sequence< OUString > aProps( 2 );
aProps[0] = "PositionX"; Sequence< Any > aValues( 2 );
aProps[1] = "PositionY"; aProps[0] = "PositionX";
aValues[0] <<= aTmp.Width(); aProps[1] = "PositionY";
aValues[1] <<= aTmp.Height(); aValues[0] <<= aTmp.Width();
aValues[1] <<= aTmp.Height();
ImplSetPropertyValues( aProps, aValues, true );
mbPosModified = false; ImplSetPropertyValues( aProps, aValues, true );
} mbPosModified = false;
} }
void SAL_CALL UnoDialogControl::windowShown( const EventObject& ) {} void SAL_CALL UnoDialogControl::windowShown( const EventObject& ) {}
......
...@@ -235,62 +235,64 @@ void SAL_CALL UnoControlTabPage::windowResized( const css::awt::WindowEvent& e ) ...@@ -235,62 +235,64 @@ void SAL_CALL UnoControlTabPage::windowResized( const css::awt::WindowEvent& e )
{ {
OutputDevice*pOutDev = Application::GetDefaultDevice(); OutputDevice*pOutDev = Application::GetDefaultDevice();
DBG_ASSERT( pOutDev, "Missing Default Device!" ); DBG_ASSERT( pOutDev, "Missing Default Device!" );
if ( pOutDev && !mbSizeModified ) if ( !pOutDev || mbSizeModified )
{ return;
// Currentley we are simply using MapUnit::MapAppFont
::Size aAppFontSize( e.Width, e.Height );
Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW ); // Currentley we are simply using MapUnit::MapAppFont
Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY ); ::Size aAppFontSize( e.Width, e.Height );
OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" );
if ( xDialogDevice.is() )
{
DeviceInfo aDeviceInfo( xDialogDevice->getInfo() );
aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
}
aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize ); Reference< XControl > xDialogControl( *this, UNO_QUERY_THROW );
Reference< XDevice > xDialogDevice( xDialogControl->getPeer(), UNO_QUERY );
// Remember that changes have been done by listener. No need to OSL_ENSURE( xDialogDevice.is(), "UnoDialogControl::windowResized: no peer, but a windowResized event?" );
// update the position because of property change event. if ( xDialogDevice.is() )
mbSizeModified = true; {
Sequence< OUString > aProps( 2 ); DeviceInfo aDeviceInfo( xDialogDevice->getInfo() );
Sequence< Any > aValues( 2 ); aAppFontSize.Width() -= aDeviceInfo.LeftInset + aDeviceInfo.RightInset;
// Properties in a sequence must be sorted! aAppFontSize.Height() -= aDeviceInfo.TopInset + aDeviceInfo.BottomInset;
aProps[0] = "Height";
aProps[1] = "Width";
aValues[0] <<= aAppFontSize.Height();
aValues[1] <<= aAppFontSize.Width();
ImplSetPropertyValues( aProps, aValues, true );
mbSizeModified = false;
} }
aAppFontSize = ImplMapPixelToAppFont( pOutDev, aAppFontSize );
// Remember that changes have been done by listener. No need to
// update the position because of property change event.
mbSizeModified = true;
Sequence< OUString > aProps( 2 );
Sequence< Any > aValues( 2 );
// Properties in a sequence must be sorted!
aProps[0] = "Height";
aProps[1] = "Width";
aValues[0] <<= aAppFontSize.Height();
aValues[1] <<= aAppFontSize.Width();
ImplSetPropertyValues( aProps, aValues, true );
mbSizeModified = false;
} }
void SAL_CALL UnoControlTabPage::windowMoved( const css::awt::WindowEvent& e ) void SAL_CALL UnoControlTabPage::windowMoved( const css::awt::WindowEvent& e )
{ {
OutputDevice*pOutDev = Application::GetDefaultDevice(); OutputDevice*pOutDev = Application::GetDefaultDevice();
DBG_ASSERT( pOutDev, "Missing Default Device!" ); DBG_ASSERT( pOutDev, "Missing Default Device!" );
if ( pOutDev && !mbPosModified ) if ( !pOutDev || mbPosModified )
{ return;
// Currentley we are simply using MapUnit::MapAppFont
::Size aTmp( e.X, e.Y ); // Currentley we are simply using MapUnit::MapAppFont
aTmp = ImplMapPixelToAppFont( pOutDev, aTmp ); ::Size aTmp( e.X, e.Y );
aTmp = ImplMapPixelToAppFont( pOutDev, aTmp );
// Remember that changes have been done by listener. No need to
// update the position because of property change event. // Remember that changes have been done by listener. No need to
mbPosModified = true; // update the position because of property change event.
Sequence< OUString > aProps( 2 ); mbPosModified = true;
Sequence< Any > aValues( 2 ); Sequence< OUString > aProps( 2 );
aProps[0] = "PositionX"; Sequence< Any > aValues( 2 );
aProps[1] = "PositionY"; aProps[0] = "PositionX";
aValues[0] <<= aTmp.Width(); aProps[1] = "PositionY";
aValues[1] <<= aTmp.Height(); aValues[0] <<= aTmp.Width();
aValues[1] <<= aTmp.Height();
ImplSetPropertyValues( aProps, aValues, true );
mbPosModified = false; ImplSetPropertyValues( aProps, aValues, true );
} mbPosModified = false;
} }
void SAL_CALL UnoControlTabPage::windowShown( const css::lang::EventObject& ) {} void SAL_CALL UnoControlTabPage::windowShown( const css::lang::EventObject& ) {}
......
...@@ -38,83 +38,84 @@ using namespace tdoc_ucp; ...@@ -38,83 +38,84 @@ using namespace tdoc_ucp;
void Uri::init() const void Uri::init() const
{ {
// Already inited? // Already inited?
if ( m_eState == UNKNOWN ) if ( m_eState != UNKNOWN )
return;
m_eState = INVALID;
// Check for proper length: must be at least length of <sheme>:/
if ( m_aUri.getLength() < TDOC_URL_SCHEME_LENGTH + 2 )
{
// Invalid length (to short).
return;
}
// Check for proper scheme. (Scheme is case insensitive.)
OUString aScheme
= m_aUri.copy( 0, TDOC_URL_SCHEME_LENGTH ).toAsciiLowerCase();
if ( aScheme != TDOC_URL_SCHEME )
{
// Invalid scheme.
return;
}
// Remember normalized scheme string.
m_aUri = m_aUri.replaceAt( 0, aScheme.getLength(), aScheme );
if ( m_aUri[ TDOC_URL_SCHEME_LENGTH ] != ':' )
{ {
m_eState = INVALID; // Invalid (no ':' after <scheme>).
return;
// Check for proper length: must be at least length of <sheme>:/
if ( m_aUri.getLength() < TDOC_URL_SCHEME_LENGTH + 2 )
{
// Invalid length (to short).
return;
}
// Check for proper scheme. (Scheme is case insensitive.)
OUString aScheme
= m_aUri.copy( 0, TDOC_URL_SCHEME_LENGTH ).toAsciiLowerCase();
if ( aScheme != TDOC_URL_SCHEME )
{
// Invalid scheme.
return;
}
// Remember normalized scheme string.
m_aUri = m_aUri.replaceAt( 0, aScheme.getLength(), aScheme );
if ( m_aUri[ TDOC_URL_SCHEME_LENGTH ] != ':' )
{
// Invalid (no ':' after <scheme>).
return;
}
if ( m_aUri[ TDOC_URL_SCHEME_LENGTH + 1 ] != '/' )
{
// Invalid (no '/' after <scheme>:).
return;
}
m_aPath = m_aUri.copy( TDOC_URL_SCHEME_LENGTH + 1 );
// Note: There must be at least one slash; see above.
sal_Int32 nLastSlash = m_aUri.lastIndexOf( '/' );
bool bTrailingSlash = false;
if ( nLastSlash == m_aUri.getLength() - 1 )
{
// ignore trailing slash
bTrailingSlash = true;
nLastSlash = m_aUri.lastIndexOf( '/', nLastSlash );
}
if ( nLastSlash != -1 ) // -1 is valid for the root folder
{
m_aParentUri = m_aUri.copy( 0, nLastSlash + 1 );
if ( bTrailingSlash )
m_aName = m_aUri.copy( nLastSlash + 1,
m_aUri.getLength() - nLastSlash - 2 );
else
m_aName = m_aUri.copy( nLastSlash + 1 );
m_aDecodedName = ::ucb_impl::urihelper::decodeSegment( m_aName );
sal_Int32 nSlash = m_aPath.indexOf( '/', 1 );
if ( nSlash == -1 )
m_aDocId = m_aPath.copy( 1 );
else
m_aDocId = m_aPath.copy( 1, nSlash - 1 );
}
if ( !m_aDocId.isEmpty() )
{
sal_Int32 nSlash = m_aPath.indexOf( '/', 1 );
if ( nSlash != - 1 )
m_aInternalPath = m_aPath.copy( nSlash );
else
m_aInternalPath = "/";
}
m_eState = VALID;
} }
if ( m_aUri[ TDOC_URL_SCHEME_LENGTH + 1 ] != '/' )
{
// Invalid (no '/' after <scheme>:).
return;
}
m_aPath = m_aUri.copy( TDOC_URL_SCHEME_LENGTH + 1 );
// Note: There must be at least one slash; see above.
sal_Int32 nLastSlash = m_aUri.lastIndexOf( '/' );
bool bTrailingSlash = false;
if ( nLastSlash == m_aUri.getLength() - 1 )
{
// ignore trailing slash
bTrailingSlash = true;
nLastSlash = m_aUri.lastIndexOf( '/', nLastSlash );
}
if ( nLastSlash != -1 ) // -1 is valid for the root folder
{
m_aParentUri = m_aUri.copy( 0, nLastSlash + 1 );
if ( bTrailingSlash )
m_aName = m_aUri.copy( nLastSlash + 1,
m_aUri.getLength() - nLastSlash - 2 );
else
m_aName = m_aUri.copy( nLastSlash + 1 );
m_aDecodedName = ::ucb_impl::urihelper::decodeSegment( m_aName );
sal_Int32 nSlash = m_aPath.indexOf( '/', 1 );
if ( nSlash == -1 )
m_aDocId = m_aPath.copy( 1 );
else
m_aDocId = m_aPath.copy( 1, nSlash - 1 );
}
if ( !m_aDocId.isEmpty() )
{
sal_Int32 nSlash = m_aPath.indexOf( '/', 1 );
if ( nSlash != - 1 )
m_aInternalPath = m_aPath.copy( nSlash );
else
m_aInternalPath = "/";
}
m_eState = VALID;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -82,30 +82,31 @@ namespace DOM ...@@ -82,30 +82,31 @@ namespace DOM
{ {
::osl::ClearableMutexGuard guard(m_rMutex); ::osl::ClearableMutexGuard guard(m_rMutex);
if (m_aNodePtr != nullptr) if (m_aNodePtr == nullptr)
{ return;
// get current data
std::shared_ptr<xmlChar const> const pContent( // get current data
xmlNodeGetContent(m_aNodePtr), xmlFree); std::shared_ptr<xmlChar const> const pContent(
OString aData(reinterpret_cast<sal_Char const*>(pContent.get())); xmlNodeGetContent(m_aNodePtr), xmlFree);
OUString tmp(OStringToOUString(aData, RTL_TEXTENCODING_UTF8)); OString aData(reinterpret_cast<sal_Char const*>(pContent.get()));
if (offset > tmp.getLength() || offset < 0 || count < 0) { OUString tmp(OStringToOUString(aData, RTL_TEXTENCODING_UTF8));
DOMException e; if (offset > tmp.getLength() || offset < 0 || count < 0) {
e.Code = DOMExceptionType_INDEX_SIZE_ERR; DOMException e;
throw e; e.Code = DOMExceptionType_INDEX_SIZE_ERR;
} throw e;
if ((offset+count) > tmp.getLength()) }
count = tmp.getLength() - offset; if ((offset+count) > tmp.getLength())
count = tmp.getLength() - offset;
OUString tmp2 = tmp.copy(0, offset); OUString tmp2 = tmp.copy(0, offset);
tmp2 += tmp.copy(offset+count); tmp2 += tmp.copy(offset+count);
OUString oldValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); OUString oldValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8);
xmlNodeSetContent(m_aNodePtr, reinterpret_cast<const xmlChar*>(OUStringToOString(tmp2, RTL_TEXTENCODING_UTF8).getStr())); xmlNodeSetContent(m_aNodePtr, reinterpret_cast<const xmlChar*>(OUStringToOString(tmp2, RTL_TEXTENCODING_UTF8).getStr()));
OUString newValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); OUString newValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8);
guard.clear(); // release mutex before calling event handlers
dispatchEvent_Impl(oldValue, newValue);
guard.clear(); // release mutex before calling event handlers
dispatchEvent_Impl(oldValue, newValue);
}
} }
...@@ -152,29 +153,30 @@ namespace DOM ...@@ -152,29 +153,30 @@ namespace DOM
{ {
::osl::ClearableMutexGuard guard(m_rMutex); ::osl::ClearableMutexGuard guard(m_rMutex);
if (m_aNodePtr != nullptr) if (m_aNodePtr == nullptr)
{ return;
// get current data
std::shared_ptr<xmlChar const> const pContent( // get current data
xmlNodeGetContent(m_aNodePtr), xmlFree); std::shared_ptr<xmlChar const> const pContent(
OString aData(reinterpret_cast<sal_Char const*>(pContent.get())); xmlNodeGetContent(m_aNodePtr), xmlFree);
OUString tmp(OStringToOUString(aData, RTL_TEXTENCODING_UTF8)); OString aData(reinterpret_cast<sal_Char const*>(pContent.get()));
if (offset > tmp.getLength() || offset < 0) { OUString tmp(OStringToOUString(aData, RTL_TEXTENCODING_UTF8));
DOMException e; if (offset > tmp.getLength() || offset < 0) {
e.Code = DOMExceptionType_INDEX_SIZE_ERR; DOMException e;
throw e; e.Code = DOMExceptionType_INDEX_SIZE_ERR;
} throw e;
}
OUString tmp2 = tmp.copy(0, offset); OUString tmp2 = tmp.copy(0, offset);
tmp2 += arg; tmp2 += arg;
tmp2 += tmp.copy(offset); tmp2 += tmp.copy(offset);
OUString oldValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); OUString oldValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8);
xmlNodeSetContent(m_aNodePtr, reinterpret_cast<const xmlChar*>(OUStringToOString(tmp2, RTL_TEXTENCODING_UTF8).getStr())); xmlNodeSetContent(m_aNodePtr, reinterpret_cast<const xmlChar*>(OUStringToOString(tmp2, RTL_TEXTENCODING_UTF8).getStr()));
OUString newValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); OUString newValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8);
guard.clear(); // release mutex before calling event handlers
dispatchEvent_Impl(oldValue, newValue);
guard.clear(); // release mutex before calling event handlers
dispatchEvent_Impl(oldValue, newValue);
}
} }
...@@ -186,31 +188,32 @@ namespace DOM ...@@ -186,31 +188,32 @@ namespace DOM
{ {
::osl::ClearableMutexGuard guard(m_rMutex); ::osl::ClearableMutexGuard guard(m_rMutex);
if (m_aNodePtr != nullptr) if (m_aNodePtr == nullptr)
{ return;
// get current data
std::shared_ptr<xmlChar const> const pContent( // get current data
xmlNodeGetContent(m_aNodePtr), xmlFree); std::shared_ptr<xmlChar const> const pContent(
OString aData(reinterpret_cast<sal_Char const*>(pContent.get())); xmlNodeGetContent(m_aNodePtr), xmlFree);
OUString tmp(OStringToOUString(aData, RTL_TEXTENCODING_UTF8)); OString aData(reinterpret_cast<sal_Char const*>(pContent.get()));
if (offset > tmp.getLength() || offset < 0 || count < 0){ OUString tmp(OStringToOUString(aData, RTL_TEXTENCODING_UTF8));
DOMException e; if (offset > tmp.getLength() || offset < 0 || count < 0){
e.Code = DOMExceptionType_INDEX_SIZE_ERR; DOMException e;
throw e; e.Code = DOMExceptionType_INDEX_SIZE_ERR;
} throw e;
if ((offset+count) > tmp.getLength()) }
count = tmp.getLength() - offset; if ((offset+count) > tmp.getLength())
count = tmp.getLength() - offset;
OUString tmp2 = tmp.copy(0, offset); OUString tmp2 = tmp.copy(0, offset);
tmp2 += arg; tmp2 += arg;
tmp2 += tmp.copy(offset+count); tmp2 += tmp.copy(offset+count);
OUString oldValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); OUString oldValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8);
xmlNodeSetContent(m_aNodePtr, reinterpret_cast<const xmlChar*>(OUStringToOString(tmp2, RTL_TEXTENCODING_UTF8).getStr())); xmlNodeSetContent(m_aNodePtr, reinterpret_cast<const xmlChar*>(OUStringToOString(tmp2, RTL_TEXTENCODING_UTF8).getStr()));
OUString newValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8); OUString newValue(reinterpret_cast<char*>(m_aNodePtr->content), strlen(reinterpret_cast<char*>(m_aNodePtr->content)), RTL_TEXTENCODING_UTF8);
guard.clear(); // release mutex before calling event handlers
dispatchEvent_Impl(oldValue, newValue);
guard.clear(); // release mutex before calling event handlers
dispatchEvent_Impl(oldValue, newValue);
}
} }
/** /**
......
...@@ -362,49 +362,49 @@ void PrintOutHelper( SfxViewShell const * pViewShell, const uno::Any& From, cons ...@@ -362,49 +362,49 @@ void PrintOutHelper( SfxViewShell const * pViewShell, const uno::Any& From, cons
SfxViewFrame* pViewFrame = nullptr; SfxViewFrame* pViewFrame = nullptr;
if ( pViewShell ) if ( pViewShell )
pViewFrame = pViewShell->GetViewFrame(); pViewFrame = pViewShell->GetViewFrame();
if ( pViewFrame ) if ( !pViewFrame )
{ return;
SfxAllItemSet aArgs( SfxGetpApp()->GetPool() );
SfxBoolItem sfxCollate( SID_PRINT_COLLATE, bCollate ); SfxAllItemSet aArgs( SfxGetpApp()->GetPool() );
aArgs.Put( sfxCollate, sfxCollate.Which() );
SfxInt16Item sfxCopies( SID_PRINT_COPIES, nCopies );
aArgs.Put( sfxCopies, sfxCopies.Which() );
if ( !sFileName.isEmpty() )
{
SfxStringItem sfxFileName( SID_FILE_NAME, sFileName);
aArgs.Put( sfxFileName, sfxFileName.Which() );
} SfxBoolItem sfxCollate( SID_PRINT_COLLATE, bCollate );
if ( !sRange.isEmpty() ) aArgs.Put( sfxCollate, sfxCollate.Which() );
{ SfxInt16Item sfxCopies( SID_PRINT_COPIES, nCopies );
SfxStringItem sfxRange( SID_PRINT_PAGES, sRange ); aArgs.Put( sfxCopies, sfxCopies.Which() );
aArgs.Put( sfxRange, sfxRange.Which() ); if ( !sFileName.isEmpty() )
} {
SfxBoolItem sfxSelection( SID_SELECTION, bSelection ); SfxStringItem sfxFileName( SID_FILE_NAME, sFileName);
aArgs.Put( sfxSelection, sfxSelection.Which() ); aArgs.Put( sfxFileName, sfxFileName.Which() );
SfxBoolItem sfxAsync( SID_ASYNCHRON, false );
aArgs.Put( sfxAsync, sfxAsync.Which() );
SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
if ( pDispatcher ) }
if ( !sRange.isEmpty() )
{
SfxStringItem sfxRange( SID_PRINT_PAGES, sRange );
aArgs.Put( sfxRange, sfxRange.Which() );
}
SfxBoolItem sfxSelection( SID_SELECTION, bSelection );
aArgs.Put( sfxSelection, sfxSelection.Which() );
SfxBoolItem sfxAsync( SID_ASYNCHRON, false );
aArgs.Put( sfxAsync, sfxAsync.Which() );
SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
if ( pDispatcher )
{
if ( bPreview )
{ {
if ( bPreview ) if ( !pViewFrame->GetFrame().IsInPlace() )
{ {
if ( !pViewFrame->GetFrame().IsInPlace() ) // #TODO is this necessary ( calc specific )
{
// #TODO is this necessary ( calc specific )
// SC_MOD()->InputEnterHandler(); // SC_MOD()->InputEnterHandler();
pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SfxCallMode::SYNCHRON ); pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SfxCallMode::SYNCHRON );
WaitUntilPreviewIsClosed( pViewFrame ); WaitUntilPreviewIsClosed( pViewFrame );
}
} }
else
pDispatcher->Execute( (sal_uInt16)SID_PRINTDOC, SfxCallMode::SYNCHRON, aArgs );
} }
else
pDispatcher->Execute( (sal_uInt16)SID_PRINTDOC, SfxCallMode::SYNCHRON, aArgs );
} }
// #FIXME #TODO // #FIXME #TODO
// 1 ActivePrinter ( how/can we switch a printer via API? ) // 1 ActivePrinter ( how/can we switch a printer via API? )
// 2 PrintToFile ( ms behaviour if this option is specified but no // 2 PrintToFile ( ms behaviour if this option is specified but no
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment